Java 类com.sun.tools.classfile.AccessFlags 实例源码

项目:OpenJSharp    文件:Options.java   
/**
 * Checks access of class, field or method.
 */
public boolean checkAccess(AccessFlags flags){

    boolean isPublic = flags.is(AccessFlags.ACC_PUBLIC);
    boolean isProtected = flags.is(AccessFlags.ACC_PROTECTED);
    boolean isPrivate = flags.is(AccessFlags.ACC_PRIVATE);
    boolean isPackage = !(isPublic || isProtected || isPrivate);

    if ((showAccess == AccessFlags.ACC_PUBLIC) && (isProtected || isPrivate || isPackage))
        return false;
    else if ((showAccess == AccessFlags.ACC_PROTECTED) && (isPrivate || isPackage))
        return false;
    else if ((showAccess == 0) && (isPrivate))
        return false;
    else
        return true;
}
项目:jdk8u-jdk    文件:ClassReader.java   
private void readClass(ClassFile c) throws IOException,
                                           ConstantPoolException,
                                           InvalidDescriptor {
    klass = new Element("Class");
    cfile.add(klass);
    String thisk = c.getName();

    klass.setAttr("name", thisk);

    AccessFlags af = new AccessFlags(c.access_flags.flags);
    klass.setAttr("flags", flagString(af, klass));
    if (!"java/lang/Object".equals(thisk)) {
        klass.setAttr("super", c.getSuperclassName());
    }
    for (int i : c.interfaces) {
        klass.add(new Element("Interface", "name", getCpString(i)));
    }
    readFields(c, klass);
    readMethods(c, klass);
    readAttributesFor(c, c.attributes, klass);
    klass.trimToSize();
}
项目:jdk8u-jdk    文件:ClassReader.java   
protected String flagString(AccessFlags af, String kind) {
    Set<String> mods = null;
    switch (kind) {
        case "Class":
            mods = af.getClassFlags();
            break;
        case "InnerClass":
            mods = af.getInnerClassFlags();
            break;
        case "Field":
            mods = af.getFieldFlags();
            break;
        case "Method":
            mods = af.getMethodFlags();
            break;
        default:
            throw new RuntimeException("should not reach here");
    }
    StringBuilder sb = new StringBuilder();
    for (String x : mods) {
        sb.append(x.substring(x.indexOf('_') + 1).toLowerCase()).append(" ");
    }
    return sb.toString().trim();
}
项目:openjdk-jdk10    文件:Options.java   
/**
 * Checks access of class, field or method.
 */
public boolean checkAccess(AccessFlags flags){

    boolean isPublic = flags.is(AccessFlags.ACC_PUBLIC);
    boolean isProtected = flags.is(AccessFlags.ACC_PROTECTED);
    boolean isPrivate = flags.is(AccessFlags.ACC_PRIVATE);
    boolean isPackage = !(isPublic || isProtected || isPrivate);

    if ((showAccess == AccessFlags.ACC_PUBLIC) && (isProtected || isPrivate || isPackage))
        return false;
    else if ((showAccess == AccessFlags.ACC_PROTECTED) && (isPrivate || isPackage))
        return false;
    else if ((showAccess == 0) && (isPrivate))
        return false;
    else
        return true;
}
项目:openjdk-jdk10    文件:ModuleFlagTest.java   
public static void main(String[] args) throws IOException, ConstantPoolException {
    Path outdir = Paths.get(".");
    ToolBox tb = new ToolBox();
    final Path moduleInfo = Paths.get("module-info.java");
    tb.writeFile(moduleInfo, "module test_module{}");
    new JavacTask(tb)
            .outdir(outdir)
            .files(moduleInfo)
            .run();

    AccessFlags accessFlags = ClassFile.read(outdir.resolve("module-info.class"))
            .access_flags;
    if (!accessFlags.is(AccessFlags.ACC_MODULE)) {
        throw new RuntimeException("Classfile doesn't have module access flag");
    }
}
项目:openjdk-jdk10    文件:ClassReader.java   
private void readClass(ClassFile c) throws IOException,
                                           ConstantPoolException,
                                           InvalidDescriptor {
    klass = new Element("Class");
    cfile.add(klass);
    String thisk = c.getName();

    klass.setAttr("name", thisk);

    AccessFlags af = new AccessFlags(c.access_flags.flags);
    klass.setAttr("flags", flagString(af, klass));
    if (!"java/lang/Object".equals(thisk)) {
        if (c.super_class != 0) {
            klass.setAttr("super", c.getSuperclassName());
        }
    }
    for (int i : c.interfaces) {
        klass.add(new Element("Interface", "name", getCpString(i)));
    }
    readFields(c, klass);
    readMethods(c, klass);
    readAttributesFor(c, c.attributes, klass);
    klass.trimToSize();
}
项目:openjdk-jdk10    文件:ClassReader.java   
protected String flagString(AccessFlags af, String kind) {
    Set<String> mods = null;
    switch (kind) {
        case "Class":
            mods = af.getClassFlags();
            break;
        case "InnerClass":
            mods = af.getInnerClassFlags();
            break;
        case "Field":
            mods = af.getFieldFlags();
            break;
        case "Method":
            mods = af.getMethodFlags();
            break;
        default:
            throw new RuntimeException("should not reach here");
    }
    StringBuilder sb = new StringBuilder();
    for (String x : mods) {
        sb.append(x.substring(x.indexOf('_') + 1).toLowerCase()).append(" ");
    }
    return sb.toString().trim();
}
项目:openjdk9    文件:Options.java   
/**
 * Checks access of class, field or method.
 */
public boolean checkAccess(AccessFlags flags){

    boolean isPublic = flags.is(AccessFlags.ACC_PUBLIC);
    boolean isProtected = flags.is(AccessFlags.ACC_PROTECTED);
    boolean isPrivate = flags.is(AccessFlags.ACC_PRIVATE);
    boolean isPackage = !(isPublic || isProtected || isPrivate);

    if ((showAccess == AccessFlags.ACC_PUBLIC) && (isProtected || isPrivate || isPackage))
        return false;
    else if ((showAccess == AccessFlags.ACC_PROTECTED) && (isPrivate || isPackage))
        return false;
    else if ((showAccess == 0) && (isPrivate))
        return false;
    else
        return true;
}
项目:openjdk9    文件:ModuleFlagTest.java   
public static void main(String[] args) throws IOException, ConstantPoolException {
    Path outdir = Paths.get(".");
    ToolBox tb = new ToolBox();
    final Path moduleInfo = Paths.get("module-info.java");
    tb.writeFile(moduleInfo, "module test_module{}");
    new JavacTask(tb)
            .outdir(outdir)
            .files(moduleInfo)
            .run();

    AccessFlags accessFlags = ClassFile.read(outdir.resolve("module-info.class"))
            .access_flags;
    if (!accessFlags.is(AccessFlags.ACC_MODULE)) {
        throw new RuntimeException("Classfile doesn't have module access flag");
    }
}
项目:openjdk9    文件:ClassReader.java   
private void readClass(ClassFile c) throws IOException,
                                           ConstantPoolException,
                                           InvalidDescriptor {
    klass = new Element("Class");
    cfile.add(klass);
    String thisk = c.getName();

    klass.setAttr("name", thisk);

    AccessFlags af = new AccessFlags(c.access_flags.flags);
    klass.setAttr("flags", flagString(af, klass));
    if (!"java/lang/Object".equals(thisk)) {
        if (c.super_class != 0) {
            klass.setAttr("super", c.getSuperclassName());
        }
    }
    for (int i : c.interfaces) {
        klass.add(new Element("Interface", "name", getCpString(i)));
    }
    readFields(c, klass);
    readMethods(c, klass);
    readAttributesFor(c, c.attributes, klass);
    klass.trimToSize();
}
项目:openjdk9    文件:ClassReader.java   
protected String flagString(AccessFlags af, String kind) {
    Set<String> mods = null;
    switch (kind) {
        case "Class":
            mods = af.getClassFlags();
            break;
        case "InnerClass":
            mods = af.getInnerClassFlags();
            break;
        case "Field":
            mods = af.getFieldFlags();
            break;
        case "Method":
            mods = af.getMethodFlags();
            break;
        default:
            throw new RuntimeException("should not reach here");
    }
    StringBuilder sb = new StringBuilder();
    for (String x : mods) {
        sb.append(x.substring(x.indexOf('_') + 1).toLowerCase()).append(" ");
    }
    return sb.toString().trim();
}
项目:jdk8u_jdk    文件:ClassReader.java   
private void readClass(ClassFile c) throws IOException,
                                           ConstantPoolException,
                                           InvalidDescriptor {
    klass = new Element("Class");
    cfile.add(klass);
    String thisk = c.getName();

    klass.setAttr("name", thisk);

    AccessFlags af = new AccessFlags(c.access_flags.flags);
    klass.setAttr("flags", flagString(af, klass));
    if (!"java/lang/Object".equals(thisk)) {
        klass.setAttr("super", c.getSuperclassName());
    }
    for (int i : c.interfaces) {
        klass.add(new Element("Interface", "name", getCpString(i)));
    }
    readFields(c, klass);
    readMethods(c, klass);
    readAttributesFor(c, c.attributes, klass);
    klass.trimToSize();
}
项目:jdk8u_jdk    文件:ClassReader.java   
protected String flagString(AccessFlags af, String kind) {
    Set<String> mods = null;
    switch (kind) {
        case "Class":
            mods = af.getClassFlags();
            break;
        case "InnerClass":
            mods = af.getInnerClassFlags();
            break;
        case "Field":
            mods = af.getFieldFlags();
            break;
        case "Method":
            mods = af.getMethodFlags();
            break;
        default:
            throw new RuntimeException("should not reach here");
    }
    StringBuilder sb = new StringBuilder();
    for (String x : mods) {
        sb.append(x.substring(x.indexOf('_') + 1).toLowerCase()).append(" ");
    }
    return sb.toString().trim();
}
项目:lookaside_java-1.8.0-openjdk    文件:Options.java   
/**
 * Checks access of class, field or method.
 */
public boolean checkAccess(AccessFlags flags){

    boolean isPublic = flags.is(AccessFlags.ACC_PUBLIC);
    boolean isProtected = flags.is(AccessFlags.ACC_PROTECTED);
    boolean isPrivate = flags.is(AccessFlags.ACC_PRIVATE);
    boolean isPackage = !(isPublic || isProtected || isPrivate);

    if ((showAccess == AccessFlags.ACC_PUBLIC) && (isProtected || isPrivate || isPackage))
        return false;
    else if ((showAccess == AccessFlags.ACC_PROTECTED) && (isPrivate || isPackage))
        return false;
    else if ((showAccess == 0) && (isPrivate))
        return false;
    else
        return true;
}
项目:lookaside_java-1.8.0-openjdk    文件:CompareTest.java   
boolean isNativeClass(JarFile jar, JarEntry entry) throws IOException, ConstantPoolException {
    String name = entry.getName();
    if (name.startsWith("META-INF") || !name.endsWith(".class"))
        return false;
    //String className = name.substring(0, name.length() - 6).replace("/", ".");
    //System.err.println("check " + className);
    InputStream in = jar.getInputStream(entry);
    ClassFile cf = ClassFile.read(in);
    for (int i = 0; i < cf.methods.length; i++) {
        Method m = cf.methods[i];
        if (m.access_flags.is(AccessFlags.ACC_NATIVE)) {
            // System.err.println(className);
            return true;
        }
    }
    return false;
}
项目:lookaside_java-1.8.0-openjdk    文件:FindNativeFiles.java   
boolean isNativeClass(JarFile jar, JarEntry entry) throws IOException, ConstantPoolException {
    String name = entry.getName();
    if (name.startsWith("META-INF") || !name.endsWith(".class"))
        return false;
    //String className = name.substring(0, name.length() - 6).replace("/", ".");
    //System.err.println("check " + className);
    InputStream in = jar.getInputStream(entry);
    ClassFile cf = ClassFile.read(in);
    in.close();
    for (int i = 0; i < cf.methods.length; i++) {
        Method m = cf.methods[i];
        if (m.access_flags.is(AccessFlags.ACC_NATIVE)) {
            // System.err.println(className);
            return true;
        }
    }
    return false;
}
项目:lookaside_java-1.8.0-openjdk    文件:ClassReader.java   
private void readClass(ClassFile c) throws IOException,
                                           ConstantPoolException,
                                           InvalidDescriptor {
    klass = new Element("Class");
    cfile.add(klass);
    String thisk = c.getName();

    klass.setAttr("name", thisk);

    AccessFlags af = new AccessFlags(c.access_flags.flags);
    klass.setAttr("flags", flagString(af, klass));
    if (!"java/lang/Object".equals(thisk)) {
        klass.setAttr("super", c.getSuperclassName());
    }
    for (int i : c.interfaces) {
        klass.add(new Element("Interface", "name", getCpString(i)));
    }
    readFields(c, klass);
    readMethods(c, klass);
    readAttributesFor(c, c.attributes, klass);
    klass.trimToSize();
}
项目:lookaside_java-1.8.0-openjdk    文件:ClassReader.java   
protected String flagString(AccessFlags af, String kind) {
    Set<String> mods = null;
    switch (kind) {
        case "Class":
            mods = af.getClassFlags();
            break;
        case "InnerClass":
            mods = af.getInnerClassFlags();
            break;
        case "Field":
            mods = af.getFieldFlags();
            break;
        case "Method":
            mods = af.getMethodFlags();
            break;
        default:
            throw new RuntimeException("should not reach here");
    }
    StringBuilder sb = new StringBuilder();
    for (String x : mods) {
        sb.append(x.substring(x.indexOf('_') + 1).toLowerCase()).append(" ");
    }
    return sb.toString().trim();
}
项目:jsr308-langtools    文件:Options.java   
/**
 * Checks access of class, field or method.
 */
public boolean checkAccess(AccessFlags flags){

    boolean isPublic = flags.is(AccessFlags.ACC_PUBLIC);
    boolean isProtected = flags.is(AccessFlags.ACC_PROTECTED);
    boolean isPrivate = flags.is(AccessFlags.ACC_PRIVATE);
    boolean isPackage = !(isPublic || isProtected || isPrivate);

    if ((showAccess == AccessFlags.ACC_PUBLIC) && (isProtected || isPrivate || isPackage))
        return false;
    else if ((showAccess == AccessFlags.ACC_PROTECTED) && (isPrivate || isPackage))
        return false;
    else if ((showAccess == 0) && (isPrivate))
        return false;
    else
        return true;
}
项目:jsr308-langtools    文件:CompareTest.java   
boolean isNativeClass(JarFile jar, JarEntry entry) throws IOException, ConstantPoolException {
    String name = entry.getName();
    if (name.startsWith("META-INF") || !name.endsWith(".class"))
        return false;
    //String className = name.substring(0, name.length() - 6).replace("/", ".");
    //System.err.println("check " + className);
    InputStream in = jar.getInputStream(entry);
    ClassFile cf = ClassFile.read(in);
    for (int i = 0; i < cf.methods.length; i++) {
        Method m = cf.methods[i];
        if (m.access_flags.is(AccessFlags.ACC_NATIVE)) {
            // System.err.println(className);
            return true;
        }
    }
    return false;
}
项目:jsr308-langtools    文件:FindNativeFiles.java   
boolean isNativeClass(JarFile jar, JarEntry entry) throws IOException, ConstantPoolException {
    String name = entry.getName();
    if (name.startsWith("META-INF") || !name.endsWith(".class"))
        return false;
    //String className = name.substring(0, name.length() - 6).replace("/", ".");
    //System.err.println("check " + className);
    InputStream in = jar.getInputStream(entry);
    ClassFile cf = ClassFile.read(in);
    in.close();
    for (int i = 0; i < cf.methods.length; i++) {
        Method m = cf.methods[i];
        if (m.access_flags.is(AccessFlags.ACC_NATIVE)) {
            // System.err.println(className);
            return true;
        }
    }
    return false;
}
项目:infobip-open-jdk-8    文件:Options.java   
/**
 * Checks access of class, field or method.
 */
public boolean checkAccess(AccessFlags flags){

    boolean isPublic = flags.is(AccessFlags.ACC_PUBLIC);
    boolean isProtected = flags.is(AccessFlags.ACC_PROTECTED);
    boolean isPrivate = flags.is(AccessFlags.ACC_PRIVATE);
    boolean isPackage = !(isPublic || isProtected || isPrivate);

    if ((showAccess == AccessFlags.ACC_PUBLIC) && (isProtected || isPrivate || isPackage))
        return false;
    else if ((showAccess == AccessFlags.ACC_PROTECTED) && (isPrivate || isPackage))
        return false;
    else if ((showAccess == 0) && (isPrivate))
        return false;
    else
        return true;
}
项目:infobip-open-jdk-8    文件:CompareTest.java   
boolean isNativeClass(JarFile jar, JarEntry entry) throws IOException, ConstantPoolException {
    String name = entry.getName();
    if (name.startsWith("META-INF") || !name.endsWith(".class"))
        return false;
    //String className = name.substring(0, name.length() - 6).replace("/", ".");
    //System.err.println("check " + className);
    InputStream in = jar.getInputStream(entry);
    ClassFile cf = ClassFile.read(in);
    for (int i = 0; i < cf.methods.length; i++) {
        Method m = cf.methods[i];
        if (m.access_flags.is(AccessFlags.ACC_NATIVE)) {
            // System.err.println(className);
            return true;
        }
    }
    return false;
}
项目:infobip-open-jdk-8    文件:FindNativeFiles.java   
boolean isNativeClass(JarFile jar, JarEntry entry) throws IOException, ConstantPoolException {
    String name = entry.getName();
    if (name.startsWith("META-INF") || !name.endsWith(".class"))
        return false;
    //String className = name.substring(0, name.length() - 6).replace("/", ".");
    //System.err.println("check " + className);
    InputStream in = jar.getInputStream(entry);
    ClassFile cf = ClassFile.read(in);
    in.close();
    for (int i = 0; i < cf.methods.length; i++) {
        Method m = cf.methods[i];
        if (m.access_flags.is(AccessFlags.ACC_NATIVE)) {
            // System.err.println(className);
            return true;
        }
    }
    return false;
}
项目:infobip-open-jdk-8    文件:ClassReader.java   
private void readClass(ClassFile c) throws IOException,
                                           ConstantPoolException,
                                           InvalidDescriptor {
    klass = new Element("Class");
    cfile.add(klass);
    String thisk = c.getName();

    klass.setAttr("name", thisk);

    AccessFlags af = new AccessFlags(c.access_flags.flags);
    klass.setAttr("flags", flagString(af, klass));
    if (!"java/lang/Object".equals(thisk)) {
        klass.setAttr("super", c.getSuperclassName());
    }
    for (int i : c.interfaces) {
        klass.add(new Element("Interface", "name", getCpString(i)));
    }
    readFields(c, klass);
    readMethods(c, klass);
    readAttributesFor(c, c.attributes, klass);
    klass.trimToSize();
}
项目:infobip-open-jdk-8    文件:ClassReader.java   
protected String flagString(AccessFlags af, String kind) {
    Set<String> mods = null;
    switch (kind) {
        case "Class":
            mods = af.getClassFlags();
            break;
        case "InnerClass":
            mods = af.getInnerClassFlags();
            break;
        case "Field":
            mods = af.getFieldFlags();
            break;
        case "Method":
            mods = af.getMethodFlags();
            break;
        default:
            throw new RuntimeException("should not reach here");
    }
    StringBuilder sb = new StringBuilder();
    for (String x : mods) {
        sb.append(x.substring(x.indexOf('_') + 1).toLowerCase()).append(" ");
    }
    return sb.toString().trim();
}
项目:jdk8u-dev-jdk    文件:ClassReader.java   
private void readClass(ClassFile c) throws IOException,
                                           ConstantPoolException,
                                           InvalidDescriptor {
    klass = new Element("Class");
    cfile.add(klass);
    String thisk = c.getName();

    klass.setAttr("name", thisk);

    AccessFlags af = new AccessFlags(c.access_flags.flags);
    klass.setAttr("flags", flagString(af, klass));
    if (!"java/lang/Object".equals(thisk)) {
        klass.setAttr("super", c.getSuperclassName());
    }
    for (int i : c.interfaces) {
        klass.add(new Element("Interface", "name", getCpString(i)));
    }
    readFields(c, klass);
    readMethods(c, klass);
    readAttributesFor(c, c.attributes, klass);
    klass.trimToSize();
}
项目:jdk8u-dev-jdk    文件:ClassReader.java   
protected String flagString(AccessFlags af, String kind) {
    Set<String> mods = null;
    switch (kind) {
        case "Class":
            mods = af.getClassFlags();
            break;
        case "InnerClass":
            mods = af.getInnerClassFlags();
            break;
        case "Field":
            mods = af.getFieldFlags();
            break;
        case "Method":
            mods = af.getMethodFlags();
            break;
        default:
            throw new RuntimeException("should not reach here");
    }
    StringBuilder sb = new StringBuilder();
    for (String x : mods) {
        sb.append(x.substring(x.indexOf('_') + 1).toLowerCase()).append(" ");
    }
    return sb.toString().trim();
}
项目:openjdk-source-code-learn    文件:Options.java   
/**
 * Checks access of class, field or method.
 */
public boolean checkAccess(AccessFlags flags){

    boolean isPublic = flags.is(AccessFlags.ACC_PUBLIC);
    boolean isProtected = flags.is(AccessFlags.ACC_PROTECTED);
    boolean isPrivate = flags.is(AccessFlags.ACC_PRIVATE);
    boolean isPackage = !(isPublic || isProtected || isPrivate);

    if ((showAccess == AccessFlags.ACC_PUBLIC) && (isProtected || isPrivate || isPackage))
        return false;
    else if ((showAccess == AccessFlags.ACC_PROTECTED) && (isPrivate || isPackage))
        return false;
    else if ((showAccess == 0) && (isPrivate))
        return false;
    else
        return true;
}
项目:openjdk-source-code-learn    文件:CompareTest.java   
boolean isNativeClass(JarFile jar, JarEntry entry) throws IOException, ConstantPoolException {
    String name = entry.getName();
    if (name.startsWith("META-INF") || !name.endsWith(".class"))
        return false;
    //String className = name.substring(0, name.length() - 6).replace("/", ".");
    //System.err.println("check " + className);
    InputStream in = jar.getInputStream(entry);
    ClassFile cf = ClassFile.read(in);
    for (int i = 0; i < cf.methods.length; i++) {
        Method m = cf.methods[i];
        if (m.access_flags.is(AccessFlags.ACC_NATIVE)) {
            // System.err.println(className);
            return true;
        }
    }
    return false;
}
项目:openjdk-source-code-learn    文件:FindNativeFiles.java   
boolean isNativeClass(JarFile jar, JarEntry entry) throws IOException, ConstantPoolException {
    String name = entry.getName();
    if (name.startsWith("META-INF") || !name.endsWith(".class"))
        return false;
    //String className = name.substring(0, name.length() - 6).replace("/", ".");
    //System.err.println("check " + className);
    InputStream in = jar.getInputStream(entry);
    ClassFile cf = ClassFile.read(in);
    in.close();
    for (int i = 0; i < cf.methods.length; i++) {
        Method m = cf.methods[i];
        if (m.access_flags.is(AccessFlags.ACC_NATIVE)) {
            // System.err.println(className);
            return true;
        }
    }
    return false;
}
项目:OLD-OpenJDK8    文件:Options.java   
/**
 * Checks access of class, field or method.
 */
public boolean checkAccess(AccessFlags flags){

    boolean isPublic = flags.is(AccessFlags.ACC_PUBLIC);
    boolean isProtected = flags.is(AccessFlags.ACC_PROTECTED);
    boolean isPrivate = flags.is(AccessFlags.ACC_PRIVATE);
    boolean isPackage = !(isPublic || isProtected || isPrivate);

    if ((showAccess == AccessFlags.ACC_PUBLIC) && (isProtected || isPrivate || isPackage))
        return false;
    else if ((showAccess == AccessFlags.ACC_PROTECTED) && (isPrivate || isPackage))
        return false;
    else if ((showAccess == 0) && (isPrivate))
        return false;
    else
        return true;
}
项目:OLD-OpenJDK8    文件:CompareTest.java   
boolean isNativeClass(JarFile jar, JarEntry entry) throws IOException, ConstantPoolException {
    String name = entry.getName();
    if (name.startsWith("META-INF") || !name.endsWith(".class"))
        return false;
    //String className = name.substring(0, name.length() - 6).replace("/", ".");
    //System.err.println("check " + className);
    InputStream in = jar.getInputStream(entry);
    ClassFile cf = ClassFile.read(in);
    for (int i = 0; i < cf.methods.length; i++) {
        Method m = cf.methods[i];
        if (m.access_flags.is(AccessFlags.ACC_NATIVE)) {
            // System.err.println(className);
            return true;
        }
    }
    return false;
}
项目:OLD-OpenJDK8    文件:FindNativeFiles.java   
boolean isNativeClass(JarFile jar, JarEntry entry) throws IOException, ConstantPoolException {
    String name = entry.getName();
    if (name.startsWith("META-INF") || !name.endsWith(".class"))
        return false;
    //String className = name.substring(0, name.length() - 6).replace("/", ".");
    //System.err.println("check " + className);
    InputStream in = jar.getInputStream(entry);
    ClassFile cf = ClassFile.read(in);
    in.close();
    for (int i = 0; i < cf.methods.length; i++) {
        Method m = cf.methods[i];
        if (m.access_flags.is(AccessFlags.ACC_NATIVE)) {
            // System.err.println(className);
            return true;
        }
    }
    return false;
}
项目:OLD-OpenJDK8    文件:ClassReader.java   
private void readClass(ClassFile c) throws IOException,
                                           ConstantPoolException,
                                           InvalidDescriptor {
    klass = new Element("Class");
    cfile.add(klass);
    String thisk = c.getName();

    klass.setAttr("name", thisk);

    AccessFlags af = new AccessFlags(c.access_flags.flags);
    klass.setAttr("flags", flagString(af, klass));
    if (!"java/lang/Object".equals(thisk)) {
        klass.setAttr("super", c.getSuperclassName());
    }
    for (int i : c.interfaces) {
        klass.add(new Element("Interface", "name", getCpString(i)));
    }
    readFields(c, klass);
    readMethods(c, klass);
    readAttributesFor(c, c.attributes, klass);
    klass.trimToSize();
}
项目:OLD-OpenJDK8    文件:ClassReader.java   
protected String flagString(AccessFlags af, String kind) {
    Set<String> mods = null;
    switch (kind) {
        case "Class":
            mods = af.getClassFlags();
            break;
        case "InnerClass":
            mods = af.getInnerClassFlags();
            break;
        case "Field":
            mods = af.getFieldFlags();
            break;
        case "Method":
            mods = af.getMethodFlags();
            break;
        default:
            throw new RuntimeException("should not reach here");
    }
    StringBuilder sb = new StringBuilder();
    for (String x : mods) {
        sb.append(x.substring(x.indexOf('_') + 1).toLowerCase()).append(" ");
    }
    return sb.toString().trim();
}
项目:s4j    文件:Options.java   
/**
 * Checks access of class, field or method.
 */
public boolean checkAccess(AccessFlags flags){

    boolean isPublic = flags.is(AccessFlags.ACC_PUBLIC);
    boolean isProtected = flags.is(AccessFlags.ACC_PROTECTED);
    boolean isPrivate = flags.is(AccessFlags.ACC_PRIVATE);
    boolean isPackage = !(isPublic || isProtected || isPrivate);

    if ((showAccess == AccessFlags.ACC_PUBLIC) && (isProtected || isPrivate || isPackage))
        return false;
    else if ((showAccess == AccessFlags.ACC_PROTECTED) && (isPrivate || isPackage))
        return false;
    else if ((showAccess == 0) && (isPrivate))
        return false;
    else
        return true;
}
项目:s4j    文件:CompareTest.java   
boolean isNativeClass(JarFile jar, JarEntry entry) throws IOException, ConstantPoolException {
    String name = entry.getName();
    if (name.startsWith("META-INF") || !name.endsWith(".class"))
        return false;
    //String className = name.substring(0, name.length() - 6).replace("/", ".");
    //System.err.println("check " + className);
    InputStream in = jar.getInputStream(entry);
    ClassFile cf = ClassFile.read(in);
    for (int i = 0; i < cf.methods.length; i++) {
        Method m = cf.methods[i];
        if (m.access_flags.is(AccessFlags.ACC_NATIVE)) {
            // System.err.println(className);
            return true;
        }
    }
    return false;
}
项目:s4j    文件:FindNativeFiles.java   
boolean isNativeClass(JarFile jar, JarEntry entry) throws IOException, ConstantPoolException {
    String name = entry.getName();
    if (name.startsWith("META-INF") || !name.endsWith(".class"))
        return false;
    //String className = name.substring(0, name.length() - 6).replace("/", ".");
    //System.err.println("check " + className);
    InputStream in = jar.getInputStream(entry);
    ClassFile cf = ClassFile.read(in);
    in.close();
    for (int i = 0; i < cf.methods.length; i++) {
        Method m = cf.methods[i];
        if (m.access_flags.is(AccessFlags.ACC_NATIVE)) {
            // System.err.println(className);
            return true;
        }
    }
    return false;
}
项目:jdk7-langtools    文件:Options.java   
/**
 * Checks access of class, field or method.
 */
public boolean checkAccess(AccessFlags flags){

    boolean isPublic = flags.is(AccessFlags.ACC_PUBLIC);
    boolean isProtected = flags.is(AccessFlags.ACC_PROTECTED);
    boolean isPrivate = flags.is(AccessFlags.ACC_PRIVATE);
    boolean isPackage = !(isPublic || isProtected || isPrivate);

    if ((showAccess == AccessFlags.ACC_PUBLIC) && (isProtected || isPrivate || isPackage))
        return false;
    else if ((showAccess == AccessFlags.ACC_PROTECTED) && (isPrivate || isPackage))
        return false;
    else if ((showAccess == 0) && (isPrivate))
        return false;
    else
        return true;
}