本文整理汇总了Java中java.lang.reflect.Modifier.isInterface方法的典型用法代码示例。如果您正苦于以下问题:Java Modifier.isInterface方法的具体用法?Java Modifier.isInterface怎么用?Java Modifier.isInterface使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.lang.reflect.Modifier
的用法示例。
在下文中一共展示了Modifier.isInterface方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: emitSuperCall
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
private void emitSuperCall(final InstructionAdapter mv, final Class<?> owner, final String name, final String methodDesc) {
mv.visitVarInsn(ALOAD, 0);
int nextParam = 1;
final Type methodType = Type.getMethodType(methodDesc);
for(final Type t: methodType.getArgumentTypes()) {
mv.load(nextParam, t);
nextParam += t.getSize();
}
// default method - non-abstract, interface method
if (Modifier.isInterface(owner.getModifiers())) {
mv.invokespecial(Type.getInternalName(owner), name, methodDesc, false);
} else {
mv.invokespecial(superClassName, name, methodDesc, false);
}
mv.areturn(methodType.getReturnType());
}
示例2: emitSuperCall
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
private int emitSuperCall(final InstructionAdapter mv, final Class<?> owner, final String name, final String methodDesc, final boolean constructor) {
mv.visitVarInsn(ALOAD, 0);
int nextParam = 1;
final Type methodType = Type.getMethodType(methodDesc);
for(final Type t: methodType.getArgumentTypes()) {
mv.load(nextParam, t);
nextParam += t.getSize();
}
// default method - non-abstract, interface method
if (!constructor && Modifier.isInterface(owner.getModifiers())) {
// we should call default method on the immediate "super" type - not on (possibly)
// the indirectly inherited interface class!
final Class<?> superType = findInvokespecialOwnerFor(owner);
mv.visitMethodInsn(INVOKESPECIAL, Type.getInternalName(superType), name, methodDesc,
Modifier.isInterface(superType.getModifiers()));
} else {
mv.invokespecial(superClassName, name, methodDesc, false);
}
return nextParam;
}
示例3: RuleScriptGenerator
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
public RuleScriptGenerator(List<String> helpers) {
for (String helper : helpers) {
try {
Class<?> clazz = Class.forName(helper);
int modifiers = clazz.getModifiers();
if (Modifier.isAbstract(modifiers) || Modifier.isInterface(modifiers)) {
continue;
}
if (!AbstractRuleSet.class.isAssignableFrom(clazz)) {
System.err.println("Not a RuleSet: " + clazz);
continue;
}
AbstractRuleSet ruleSet = (AbstractRuleSet) clazz.newInstance();
ruleSets.add(ruleSet);
} catch (ClassNotFoundException | IllegalAccessException | InstantiationException e) {
System.err.println(e);
}
}
}
示例4: findScriptCodeMap
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
/**
* 查找可实例化的脚本
*
* @param scriptClazzs
* @return
* @throws InstantiationException
* @throws IllegalAccessException
*/
protected Map<Integer, Class<? extends T>> findScriptCodeMap(Set<Class<? extends T>> scriptClazzs)
throws InstantiationException, IllegalAccessException {
Map<Integer, Class<? extends T>> codeMap = new ConcurrentHashMap<Integer, Class<? extends T>>();
for (Class<? extends T> scriptClazz : scriptClazzs) {
boolean isAbstractOrInterface = Modifier.isAbstract(scriptClazz.getModifiers())
|| Modifier.isInterface(scriptClazz.getModifiers());// 是否是抽象类
if (!isAbstractOrInterface) {// 可实例化脚本
IScript script = scriptClazz.newInstance();
int code = script.getMessageCode();
if (codeMap.containsKey(script.getMessageCode())) {// 重复脚本code定义
_log.error("find Repeat CodeScriptClass,code="+code+",addingScript:" + script.getClass() + ",existScript:"
+ codeMap.get(code));
} else {
codeMap.put(code, scriptClazz);
_log.info("loaded CodeScriptClass:code="+code+",class=" + scriptClazz);
}
}
}
return codeMap;
}
示例5: registStaticScript
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
/**
* 注册静态脚本
* @param scriptClass
*/
protected final void registStaticScript(Class<? extends T> scriptClass)
{
try {
boolean isAbstractOrInterface = Modifier.isAbstract(scriptClass.getModifiers())
|| Modifier.isInterface(scriptClass.getModifiers());// 是否是抽象类
if(isAbstractOrInterface)
{
throw new UnsupportedOperationException(scriptClass +"can not newInstance");
}
T script = scriptClass.newInstance();
int code=script.getMessageCode();
Class<? extends T> old=staticCodeMap.get(code);
staticCodeMap.put(code,scriptClass);
if(old==null)
{
_log.info("regist Static codeScript,code="+code+"(0x"+Integer.toHexString(code)+"),class="+scriptClass);
}else
{
_log.info("regist Static codeScript,code="+code+"(0x"+Integer.toHexString(code)+"),class="+scriptClass+",Override script="+old);
}
} catch (Exception e) {
_log.error(e.getMessage(),e);
}
}
示例6: registStaticScript
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
/**
* 注册静态脚本
* @param scriptClass
*/
protected final void registStaticScript(Class<? extends T> scriptClass)
{
try {
boolean isAbstractOrInterface = Modifier.isAbstract(scriptClass.getModifiers())
|| Modifier.isInterface(scriptClass.getModifiers());// 是否是抽象类
if(isAbstractOrInterface)
{
throw new UnsupportedOperationException(scriptClass +"can not newInstance");
}
T script = scriptClass.newInstance();
K key=script.getScriptKey();
Class<? extends T> old=staticCodeMap.get(key);
staticCodeMap.put(key,scriptClass);
if(old==null)
{
_log.info("regist Static Script,key="+key+",class="+scriptClass);
}else
{
_log.info("regist Static Script,key="+key+",class="+scriptClass+",Override script="+old);
}
} catch (Exception e) {
_log.error(e.getMessage(),e);
}
}
示例7: BytecoderUnitTestRunner
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
public BytecoderUnitTestRunner(Class aClass) throws InitializationError {
super(aClass);
testClass = new TestClass(aClass);
testMethods = new ArrayList<>();
Method[] classMethods = aClass.getDeclaredMethods();
for (Method classMethod : classMethods) {
Class retClass = classMethod.getReturnType();
int length = classMethod.getParameterTypes().length;
int modifiers = classMethod.getModifiers();
if (retClass == null || length != 0 || Modifier.isStatic(modifiers)
|| !Modifier.isPublic(modifiers) || Modifier.isInterface(modifiers)
|| Modifier.isAbstract(modifiers)) {
continue;
}
String methodName = classMethod.getName();
if (methodName.toUpperCase().startsWith("TEST")
|| classMethod.getAnnotation(Test.class) != null) {
testMethods.add(new FrameworkMethod(classMethod));
}
if (classMethod.getAnnotation(Ignore.class) != null) {
testMethods.remove(classMethod);
}
}
}
示例8: validateClass
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
private void validateClass(Class<?> source, RuleSourceValidationProblemCollector problems) {
int modifiers = source.getModifiers();
if (Modifier.isInterface(modifiers)) {
problems.add("Must be a class, not an interface");
}
if (source.getEnclosingClass() != null) {
if (Modifier.isStatic(modifiers)) {
if (Modifier.isPrivate(modifiers)) {
problems.add("Class cannot be private");
}
} else {
problems.add("Enclosed classes must be static and non private");
}
}
Constructor<?>[] constructors = source.getDeclaredConstructors();
for (Constructor<?> constructor : constructors) {
if (constructor.getParameterTypes().length > 0) {
problems.add("Cannot declare a constructor that takes arguments");
break;
}
}
Field[] fields = source.getDeclaredFields();
for (Field field : fields) {
int fieldModifiers = field.getModifiers();
if (!field.isSynthetic() && !(Modifier.isStatic(fieldModifiers) && Modifier.isFinal(fieldModifiers))) {
problems.add(field, "Fields must be static final.");
}
}
}
示例9: testCreation
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
/**
* Basic method for testing that a MBean of a given class can be
* instantiated by the MBean server.<p>
* This method checks that:
* <ul><li>The given class is a concrete class.</li>
* <li>The given class exposes at least one public constructor.</li>
* </ul>
* If these conditions are not met, throws a NotCompliantMBeanException.
* @param c The class of the MBean we want to create.
* @exception NotCompliantMBeanException if the MBean class makes it
* impossible to instantiate the MBean from within the
* MBeanServer.
*
**/
public static void testCreation(Class<?> c)
throws NotCompliantMBeanException {
// Check if the class is a concrete class
final int mods = c.getModifiers();
if (Modifier.isAbstract(mods) || Modifier.isInterface(mods)) {
throw new NotCompliantMBeanException("MBean class must be concrete");
}
// Check if the MBean has a public constructor
final Constructor<?>[] consList = c.getConstructors();
if (consList.length == 0) {
throw new NotCompliantMBeanException("MBean class must have public constructor");
}
}
示例10: keepPublicConcreteClasses
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
private static void keepPublicConcreteClasses(final Collection<Class> classes) {
if (null != classes) {
final Iterator<Class> itr = classes.iterator();
for (Class clazz = null; itr.hasNext(); clazz = itr.next()) {
if (null != clazz) {
final int modifiers = clazz.getModifiers();
if (Modifier.isAbstract(modifiers) || Modifier.isInterface(modifiers) || Modifier.isPrivate(modifiers) || Modifier.isProtected(modifiers)) {
itr.remove();
}
}
}
}
}
示例11: findInstanceAbleScript
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
/**
* 查找可实例化的脚本
* @param scriptClazzs
* @return
* @throws InstantiationException
* @throws IllegalAccessException
*/
private Map<Integer, Class<? extends T>> findInstanceAbleScript(Set<Class<? extends T>> scriptClazzs)
throws InstantiationException, IllegalAccessException {
Map<Integer, Class<? extends T>> codeMap = new ConcurrentHashMap<Integer, Class<? extends T>>();
for (Class<? extends T> scriptClazz : scriptClazzs)
{
boolean isAbstractOrInterface = Modifier.isAbstract(scriptClazz.getModifiers())|| Modifier.isInterface(scriptClazz.getModifiers());// 是否是抽象类
if (!isAbstractOrInterface) {// 可实例化脚本
T script = null;
try {
script=scriptClazz.newInstance();
} catch (Exception e) {
_log.error("can't newInstance ScriptClass:" + scriptClazz);
continue;
}
int code = script.getMessageCode();
if (codeMap.containsKey(script.getMessageCode())) {// 重复脚本code定义
_log.error("find Repeat ScriptClass,code="+code+",addingScript:" + script.getClass() + ",existScript:"
+ codeMap.get(code));
} else {
codeMap.put(code, scriptClazz);
_log.info("regist ScriptClass:code="+code+",class=" + scriptClazz);
}
}
}
return codeMap;
}
示例12: isPublicConcrete
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
/**
* @param clazz the class to test
* @return true if the class is public, not abstract and not an interface.
*/
public static boolean isPublicConcrete(final Class clazz) {
final int modifiers = clazz.getModifiers();
return Modifier.isPublic(modifiers)
&& !Modifier.isAbstract(modifiers)
&& !Modifier.isInterface(modifiers);
}
示例13: isInterface
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
public boolean isInterface() {
return Modifier.isInterface(accessFlags);
}
示例14: isConcrete
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
public static boolean isConcrete(Class<?> klass) {
int mod = klass.getModifiers();
return !Modifier.isAbstract(mod) && !Modifier.isInterface(mod);
}
示例15: isAllModifiersContainSpecificModifier
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
public static boolean isAllModifiersContainSpecificModifier(int allModifiers, int specificModifier) {
if (Modifier.isAbstract(allModifiers) && Modifier.isAbstract(specificModifier))
return true;
if (Modifier.isFinal(allModifiers) && Modifier.isFinal(specificModifier))
return true;
if (Modifier.isInterface(allModifiers) && Modifier.isInterface(specificModifier))
return true;
if (Modifier.isNative(allModifiers) && Modifier.isNative(specificModifier))
return true;
if (Modifier.isPrivate(allModifiers) && Modifier.isPrivate(specificModifier))
return true;
if (Modifier.isProtected(allModifiers) && Modifier.isProtected(specificModifier))
return true;
if (Modifier.isPublic(allModifiers) && Modifier.isPublic(specificModifier))
return true;
if (Modifier.isStatic(allModifiers) && Modifier.isStatic(specificModifier))
return true;
if (Modifier.isStrict(allModifiers) && Modifier.isStrict(specificModifier))
return true;
if (Modifier.isSynchronized(allModifiers) && Modifier.isSynchronized(specificModifier))
return true;
if (Modifier.isTransient(allModifiers) && Modifier.isTransient(specificModifier))
return true;
if (Modifier.isVolatile(allModifiers) && Modifier.isVolatile(specificModifier))
return true;
if (Modifier.isVolatile(allModifiers) && Modifier.isVolatile(specificModifier))
return true;
return false;
}