java.lang.reflect.Modifier#ABSTRACT源码实例Demo

下面列出了java.lang.reflect.Modifier#ABSTRACT 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: kalang   文件: ModifierUtil.java
private static int parseSingleModfier(String s) throws InvalidModifierException {
    switch (s) {
        case "public":
            return Modifier.PUBLIC;
        case "protected":
            return Modifier.PROTECTED;
        case "private":
            return Modifier.PRIVATE;
        case "static":
            return Modifier.STATIC;
        case "final":
            return Modifier.FINAL;
        case "abstract":
            return Modifier.ABSTRACT;
        case "native":
            return Modifier.NATIVE;
        case "synchronized":
            return Modifier.SYNCHRONIZED;
        case "transient":
            return Modifier.TRANSIENT;
        case "volatile":
            return Modifier.VOLATILE;
        default:
            throw new InvalidModifierException("unrecognized modifier:" + s);
    }
}
 
源代码2 项目: jdk8u-dev-jdk   文件: ObjectStreamClass.java
/**
 * Returns non-static, non-abstract method with given signature provided it
 * is defined by or accessible (via inheritance) by the given class, or
 * null if no match found.  Access checks are disabled on the returned
 * method (if any).
 */
private static Method getInheritableMethod(Class<?> cl, String name,
                                           Class<?>[] argTypes,
                                           Class<?> returnType)
{
    Method meth = null;
    Class<?> defCl = cl;
    while (defCl != null) {
        try {
            meth = defCl.getDeclaredMethod(name, argTypes);
            break;
        } catch (NoSuchMethodException ex) {
            defCl = defCl.getSuperclass();
        }
    }

    if ((meth == null) || (meth.getReturnType() != returnType)) {
        return null;
    }
    meth.setAccessible(true);
    int mods = meth.getModifiers();
    if ((mods & (Modifier.STATIC | Modifier.ABSTRACT)) != 0) {
        return null;
    } else if ((mods & (Modifier.PUBLIC | Modifier.PROTECTED)) != 0) {
        return meth;
    } else if ((mods & Modifier.PRIVATE) != 0) {
        return (cl == defCl) ? meth : null;
    } else {
        return packageEquals(cl, defCl) ? meth : null;
    }
}
 
源代码3 项目: consulo   文件: TestRunnerUtil.java
@TestOnly
public static boolean isJUnit4TestClass(final Class aClass) {
  final int modifiers = aClass.getModifiers();
  if ((modifiers & Modifier.ABSTRACT) != 0) return false;
  if ((modifiers & Modifier.PUBLIC) == 0) return false;
  if (aClass.getAnnotation(RunWith.class) != null) return true;
  for (Method method : aClass.getMethods()) {
    if (method.getAnnotation(Test.class) != null) return true;
  }
  return false;
}
 
源代码4 项目: javastruct   文件: StructUtils.java
/**
 * is object accessible?
 *
 * @param obj Object
 * @throws StructException 
 */
public static void isAccessible(Object obj) throws StructException{
    int modifiers = obj.getClass().getModifiers();
    if ((modifiers & Modifier.PUBLIC) == 0)
        throw new StructException("Struct operations are only accessible for public classes. Class: " + obj.getClass().getName());
    if ((modifiers & (Modifier.INTERFACE | Modifier.ABSTRACT)) != 0)
        throw new StructException("Struct operations are not accessible for abstract classes and interfaces. Class: " + obj.getClass().getName());
}
 
源代码5 项目: kalang   文件: Ast2Class.java
private void createInterfaceBridgeMethodIfNeed(MethodNode interfaceMethod,MethodNode implementMethod) {
    String desc = getMethodDescriptor(interfaceMethod);
    String implementDesc = getMethodDescriptor(implementMethod);
    if (desc.equals(implementDesc)) {
        return;
    }
    int access = interfaceMethod.getModifier() & ~Modifier.ABSTRACT;
    String name = interfaceMethod.getName();
    MethodVisitor methodVisitor = classWriter.visitMethod(access, name, desc, methodSignature(interfaceMethod), null);
    ParameterNode[] params = interfaceMethod.getParameters();
    for(ParameterNode p : params) {
        methodVisitor.visitParameter(p.getName(), p.getModifier());
    }
    ParameterNode[] implementedParams = implementMethod.getParameters();
    methodVisitor.visitVarInsn(ALOAD,0);
    int varIdx = 1;
    for(int i=0;i<params.length;i++) {
        Type implementedParamType = implementedParams[i].getType();
        Type interfaceParamType = params[i].getType();
        org.objectweb.asm.Type interfaceParamAsmType = asmType(interfaceParamType);
        methodVisitor.visitVarInsn(interfaceParamAsmType.getOpcode(ILOAD),varIdx);
        if (!implementedParamType.isAssignableFrom(interfaceParamType)) {
            methodVisitor.visitTypeInsn(CHECKCAST,internalName(implementedParamType));
        }
        varIdx += interfaceParamAsmType.getSize();
    }
    String owner = internalName(implementMethod.getClassNode());
    methodVisitor.visitMethodInsn(INVOKEVIRTUAL,owner,implementMethod.getName(),implementDesc,false);
    Type returnType = interfaceMethod.getType();
    if (VOID_TYPE.equals(returnType)) {
        methodVisitor.visitInsn(RETURN);
    } else {
        methodVisitor.visitInsn(asmType(returnType).getOpcode(IRETURN));
    }
    methodVisitor.visitMaxs(0,0);
    methodVisitor.visitEnd();
}
 
源代码6 项目: gemfirexd-oss   文件: AutoSerializableManager.java
/**
 * Returns true if a non-static, non-abstract method with given signature provided it
 * is defined by or accessible (via inheritance) by the given class, or
 * false if no match found.
 */
private static boolean getInheritableMethod(Class cl, String name,
                                           Class[] argTypes,
                                           Class returnType)
{
    Method meth = null;
    Class defCl = cl;
    while (defCl != null) {
        try {
            meth = defCl.getDeclaredMethod(name, argTypes);
            break;
        } catch (NoSuchMethodException ex) {
            defCl = defCl.getSuperclass();
        }
    }

    if ((meth == null) || (meth.getReturnType() != returnType)) {
        return false;
    }
    int mods = meth.getModifiers();
    if ((mods & (Modifier.STATIC | Modifier.ABSTRACT)) != 0) {
        return false;
    } else if ((mods & (Modifier.PUBLIC | Modifier.PROTECTED)) != 0) {
        return true;
    } else if ((mods & Modifier.PRIVATE) != 0) {
        return (cl == defCl);
    } else {
        return packageEquals(cl, defCl);
    }
}
 
源代码7 项目: Java8CN   文件: ObjectStreamClass.java
/**
 * Returns non-static, non-abstract method with given signature provided it
 * is defined by or accessible (via inheritance) by the given class, or
 * null if no match found.  Access checks are disabled on the returned
 * method (if any).
 */
private static Method getInheritableMethod(Class<?> cl, String name,
                                           Class<?>[] argTypes,
                                           Class<?> returnType)
{
    Method meth = null;
    Class<?> defCl = cl;
    while (defCl != null) {
        try {
            meth = defCl.getDeclaredMethod(name, argTypes);
            break;
        } catch (NoSuchMethodException ex) {
            defCl = defCl.getSuperclass();
        }
    }

    if ((meth == null) || (meth.getReturnType() != returnType)) {
        return null;
    }
    meth.setAccessible(true);
    int mods = meth.getModifiers();
    if ((mods & (Modifier.STATIC | Modifier.ABSTRACT)) != 0) {
        return null;
    } else if ((mods & (Modifier.PUBLIC | Modifier.PROTECTED)) != 0) {
        return meth;
    } else if ((mods & Modifier.PRIVATE) != 0) {
        return (cl == defCl) ? meth : null;
    } else {
        return packageEquals(cl, defCl) ? meth : null;
    }
}
 
源代码8 项目: openjdk-8-source   文件: ObjectStreamClass.java
/**
 * Returns non-static, non-abstract method with given signature provided it
 * is defined by or accessible (via inheritance) by the given class, or
 * null if no match found.  Access checks are disabled on the returned
 * method (if any).
 *
 * Copied from the Merlin java.io.ObjectStreamClass.
 */
private static Method getInheritableMethod(Class cl, String name,
                                           Class[] argTypes,
                                           Class returnType)
{
    Method meth = null;
    Class defCl = cl;
    while (defCl != null) {
        try {
            meth = defCl.getDeclaredMethod(name, argTypes);
            break;
        } catch (NoSuchMethodException ex) {
            defCl = defCl.getSuperclass();
        }
    }

    if ((meth == null) || (meth.getReturnType() != returnType)) {
        return null;
    }
    meth.setAccessible(true);
    int mods = meth.getModifiers();
    if ((mods & (Modifier.STATIC | Modifier.ABSTRACT)) != 0) {
        return null;
    } else if ((mods & (Modifier.PUBLIC | Modifier.PROTECTED)) != 0) {
        return meth;
    } else if ((mods & Modifier.PRIVATE) != 0) {
        return (cl == defCl) ? meth : null;
    } else {
        return packageEquals(cl, defCl) ? meth : null;
    }
}
 
源代码9 项目: JDKSourceCode1.8   文件: ObjectStreamClass.java
/**
 * Returns non-static, non-abstract method with given signature provided it
 * is defined by or accessible (via inheritance) by the given class, or
 * null if no match found.  Access checks are disabled on the returned
 * method (if any).
 *
 * Copied from the Merlin java.io.ObjectStreamClass.
 */
private static Method getInheritableMethod(Class<?> cl, String name,
                                           Class<?>[] argTypes,
                                           Class<?> returnType)
{
    Method meth = null;
    Class<?> defCl = cl;
    while (defCl != null) {
        try {
            meth = defCl.getDeclaredMethod(name, argTypes);
            break;
        } catch (NoSuchMethodException ex) {
            defCl = defCl.getSuperclass();
        }
    }

    if ((meth == null) || (meth.getReturnType() != returnType)) {
        return null;
    }
    meth.setAccessible(true);
    int mods = meth.getModifiers();
    if ((mods & (Modifier.STATIC | Modifier.ABSTRACT)) != 0) {
        return null;
    } else if ((mods & (Modifier.PUBLIC | Modifier.PROTECTED)) != 0) {
        return meth;
    } else if ((mods & Modifier.PRIVATE) != 0) {
        return (cl == defCl) ? meth : null;
    } else {
        return packageEquals(cl, defCl) ? meth : null;
    }
}
 
源代码10 项目: yGuard   文件: InnerClassesInfo.java
public int getModifiers(){
  int mods = 0;
  if ((u2innerClassAccessFlags & 0x0001) == 0x0001) mods |= Modifier.PUBLIC;
  if ((u2innerClassAccessFlags & 0x0002) == 0x0002) mods |= Modifier.PRIVATE;
  if ((u2innerClassAccessFlags & 0x0004) == 0x0004) mods |= Modifier.PROTECTED;
  if ((u2innerClassAccessFlags & 0x0008) == 0x0008) mods |= Modifier.STATIC;
  if ((u2innerClassAccessFlags & 0x0010) == 0x0010) mods |= Modifier.FINAL;
  if ((u2innerClassAccessFlags & 0x0200) == 0x0200) mods |= Modifier.INTERFACE;
  if ((u2innerClassAccessFlags & 0x0400) == 0x0400) mods |= Modifier.ABSTRACT;
  return mods;
}
 
源代码11 项目: jdk8u-jdk   文件: ObjectStreamClass.java
/**
 * Returns non-static, non-abstract method with given signature provided it
 * is defined by or accessible (via inheritance) by the given class, or
 * null if no match found.  Access checks are disabled on the returned
 * method (if any).
 */
private static Method getInheritableMethod(Class<?> cl, String name,
                                           Class<?>[] argTypes,
                                           Class<?> returnType)
{
    Method meth = null;
    Class<?> defCl = cl;
    while (defCl != null) {
        try {
            meth = defCl.getDeclaredMethod(name, argTypes);
            break;
        } catch (NoSuchMethodException ex) {
            defCl = defCl.getSuperclass();
        }
    }

    if ((meth == null) || (meth.getReturnType() != returnType)) {
        return null;
    }
    meth.setAccessible(true);
    int mods = meth.getModifiers();
    if ((mods & (Modifier.STATIC | Modifier.ABSTRACT)) != 0) {
        return null;
    } else if ((mods & (Modifier.PUBLIC | Modifier.PROTECTED)) != 0) {
        return meth;
    } else if ((mods & Modifier.PRIVATE) != 0) {
        return (cl == defCl) ? meth : null;
    } else {
        return packageEquals(cl, defCl) ? meth : null;
    }
}
 
源代码12 项目: openjdk-8-source   文件: ObjectStreamClass.java
/**
 * Returns non-static, non-abstract method with given signature provided it
 * is defined by or accessible (via inheritance) by the given class, or
 * null if no match found.  Access checks are disabled on the returned
 * method (if any).
 */
private static Method getInheritableMethod(Class<?> cl, String name,
                                           Class<?>[] argTypes,
                                           Class<?> returnType)
{
    Method meth = null;
    Class<?> defCl = cl;
    while (defCl != null) {
        try {
            meth = defCl.getDeclaredMethod(name, argTypes);
            break;
        } catch (NoSuchMethodException ex) {
            defCl = defCl.getSuperclass();
        }
    }

    if ((meth == null) || (meth.getReturnType() != returnType)) {
        return null;
    }
    meth.setAccessible(true);
    int mods = meth.getModifiers();
    if ((mods & (Modifier.STATIC | Modifier.ABSTRACT)) != 0) {
        return null;
    } else if ((mods & (Modifier.PUBLIC | Modifier.PROTECTED)) != 0) {
        return meth;
    } else if ((mods & Modifier.PRIVATE) != 0) {
        return (cl == defCl) ? meth : null;
    } else {
        return packageEquals(cl, defCl) ? meth : null;
    }
}
 
源代码13 项目: astor   文件: SerializableMethod.java
public SerializableMethod(Method method) {
    declaringClass = method.getDeclaringClass();
    methodName = method.getName();
    parameterTypes = method.getParameterTypes();
    returnType = method.getReturnType();
    exceptionTypes = method.getExceptionTypes();
    isVarArgs = method.isVarArgs();
    isAbstract = (method.getModifiers() & Modifier.ABSTRACT) != 0;
}
 
源代码14 项目: openjdk-jdk8u   文件: ObjectStreamClass.java
/**
 * Returns non-static, non-abstract method with given signature provided it
 * is defined by or accessible (via inheritance) by the given class, or
 * null if no match found.  Access checks are disabled on the returned
 * method (if any).
 */
private static Method getInheritableMethod(Class<?> cl, String name,
                                           Class<?>[] argTypes,
                                           Class<?> returnType)
{
    Method meth = null;
    Class<?> defCl = cl;
    while (defCl != null) {
        try {
            meth = defCl.getDeclaredMethod(name, argTypes);
            break;
        } catch (NoSuchMethodException ex) {
            defCl = defCl.getSuperclass();
        }
    }

    if ((meth == null) || (meth.getReturnType() != returnType)) {
        return null;
    }
    meth.setAccessible(true);
    int mods = meth.getModifiers();
    if ((mods & (Modifier.STATIC | Modifier.ABSTRACT)) != 0) {
        return null;
    } else if ((mods & (Modifier.PUBLIC | Modifier.PROTECTED)) != 0) {
        return meth;
    } else if ((mods & Modifier.PRIVATE) != 0) {
        return (cl == defCl) ? meth : null;
    } else {
        return packageEquals(cl, defCl) ? meth : null;
    }
}
 
源代码15 项目: openjdk-jdk9   文件: ObjectStreamClass.java
/**
 * Returns non-static, non-abstract method with given signature provided it
 * is defined by or accessible (via inheritance) by the given class, or
 * null if no match found.  Access checks are disabled on the returned
 * method (if any).
 *
 * Copied from the Merlin java.io.ObjectStreamClass.
 */
private static Method getInheritableMethod(Class<?> cl, String name,
                                           Class<?>[] argTypes,
                                           Class<?> returnType)
{
    Method meth = null;
    Class<?> defCl = cl;
    while (defCl != null) {
        try {
            meth = defCl.getDeclaredMethod(name, argTypes);
            break;
        } catch (NoSuchMethodException ex) {
            defCl = defCl.getSuperclass();
        }
    }

    if ((meth == null) || (meth.getReturnType() != returnType)) {
        return null;
    }
    int mods = meth.getModifiers();
    if ((mods & (Modifier.STATIC | Modifier.ABSTRACT)) != 0) {
        return null;
    } else if ((mods & (Modifier.PUBLIC | Modifier.PROTECTED)) != 0) {
        return meth;
    } else if ((mods & Modifier.PRIVATE) != 0) {
        return (cl == defCl) ? meth : null;
    } else {
        return packageEquals(cl, defCl) ? meth : null;
    }
}
 
源代码16 项目: openjdk-jdk8u   文件: Code.java
static boolean flagsRequireCode(int flags) {
    // A method's flags force it to have a Code attribute,
    // if the flags are neither native nor abstract.
    return (flags & (Modifier.NATIVE | Modifier.ABSTRACT)) == 0;
}
 
源代码17 项目: hottub   文件: Code.java
static boolean flagsRequireCode(int flags) {
    // A method's flags force it to have a Code attribute,
    // if the flags are neither native nor abstract.
    return (flags & (Modifier.NATIVE | Modifier.ABSTRACT)) == 0;
}
 
源代码18 项目: jdk8u-jdk   文件: Code.java
static boolean flagsRequireCode(int flags) {
    // A method's flags force it to have a Code attribute,
    // if the flags are neither native nor abstract.
    return (flags & (Modifier.NATIVE | Modifier.ABSTRACT)) == 0;
}
 
源代码19 项目: AndroidComponentPlugin   文件: Class.java
/**
 * Returns the Java language modifiers for this class or interface, encoded
 * in an integer. The modifiers consist of the Java Virtual Machine's
 * constants for {@code public}, {@code protected},
 * {@code private}, {@code final}, {@code static},
 * {@code abstract} and {@code interface}; they should be decoded
 * using the methods of class {@code Modifier}.
 *
 * <p> If the underlying class is an array class, then its
 * {@code public}, {@code private} and {@code protected}
 * modifiers are the same as those of its component type.  If this
 * {@code Class} represents a primitive type or void, its
 * {@code public} modifier is always {@code true}, and its
 * {@code protected} and {@code private} modifiers are always
 * {@code false}. If this object represents an array class, a
 * primitive type or void, then its {@code final} modifier is always
 * {@code true} and its interface modifier is always
 * {@code false}. The values of its other modifiers are not determined
 * by this specification.
 *
 * <p> The modifier encodings are defined in <em>The Java Virtual Machine
 * Specification</em>, table 4.1.
 *
 * @return the {@code int} representing the modifiers for this class
 * @see     java.lang.reflect.Modifier
 * @since JDK1.1
 */
public int getModifiers() {
    // Array classes inherit modifiers from their component types, but in the case of arrays
    // of an inner class, the class file may contain "fake" access flags because it's not valid
    // for a top-level class to private, say. The real access flags are stored in the InnerClass
    // attribute, so we need to make sure we drill down to the inner class: the accessFlags
    // field is not the value we want to return, and the synthesized array class does not itself
    // have an InnerClass attribute. https://code.google.com/p/android/issues/detail?id=56267
    if (isArray()) {
        int componentModifiers = getComponentType().getModifiers();
        if ((componentModifiers & Modifier.INTERFACE) != 0) {
            componentModifiers &= ~(Modifier.INTERFACE | Modifier.STATIC);
        }
        return Modifier.ABSTRACT | Modifier.FINAL | componentModifiers;
    }
    int JAVA_FLAGS_MASK = 0xffff;
    int modifiers = this.getInnerClassFlags(accessFlags & JAVA_FLAGS_MASK);
    return modifiers & JAVA_FLAGS_MASK;
}
 
源代码20 项目: dragonwell8_jdk   文件: Code.java
static boolean flagsRequireCode(int flags) {
    // A method's flags force it to have a Code attribute,
    // if the flags are neither native nor abstract.
    return (flags & (Modifier.NATIVE | Modifier.ABSTRACT)) == 0;
}