Java 类com.sun.tools.classfile.Descriptor.InvalidDescriptor 实例源码

项目:jdk8u-jdk    文件:ClassReader.java   
public Element readFrom(InputStream in) throws IOException {
    try {
        this.in = in;
        ClassFile c = ClassFile.read(in);
        // read the file header
        if (c.magic != 0xCAFEBABE) {
            throw new RuntimeException("bad magic number " +
                    Integer.toHexString(c.magic));
        }
        cfile.setAttr("magic", "" + c.magic);
        int minver = c.minor_version;
        int majver = c.major_version;
        cfile.setAttr("minver", "" + minver);
        cfile.setAttr("majver", "" + majver);
        readCP(c);
        readClass(c);
        return result();
    } catch (InvalidDescriptor | ConstantPoolException ex) {
        throw new IOException("Fatal error", ex);
    }
}
项目: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();
}
项目:openjdk-jdk10    文件:LVTHarness.java   
void checkClassFile(File file)
        throws IOException, ConstantPoolException, InvalidDescriptor {
    ClassFile classFile = ClassFile.read(file);
    ConstantPool constantPool = classFile.constant_pool;

    //lets get all the methods in the class file.
    for (Method method : classFile.methods) {
        for (ElementKey elementKey: aliveRangeMap.keySet()) {
            String methodDesc = method.getName(constantPool) +
                    method.descriptor.getParameterTypes(constantPool).replace(" ", "");
            if (methodDesc.equals(elementKey.elem.toString())) {
                checkMethod(constantPool, method, aliveRangeMap.get(elementKey));
                seenAliveRanges.add(elementKey);
            }
        }
    }
}
项目:openjdk-jdk10    文件:CheckACC_STRICTFlagOnclinitTest.java   
void check(String dir, String... fileNames)
    throws
        IOException,
        ConstantPoolException,
        Descriptor.InvalidDescriptor {
    for (String fileName : fileNames) {
        ClassFile classFileToCheck = ClassFile.read(new File(dir, fileName));

        for (Method method : classFileToCheck.methods) {
            if ((method.access_flags.flags & ACC_STRICT) == 0) {
                errors.add(String.format(offendingMethodErrorMessage,
                        method.getName(classFileToCheck.constant_pool),
                        classFileToCheck.getName()));
            }
        }
    }
}
项目:openjdk-jdk10    文件:DetectMutableStaticFields.java   
private void run()
    throws
        IOException,
        ConstantPoolException,
        InvalidDescriptor,
        URISyntaxException {

    JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
    try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
        for (String module: modules) {
            analyzeModule(fm, module);
        }
    }

    if (errors.size() > 0) {
        for (String error: errors) {
            System.err.println(error);
        }
        throw new AssertionError("There are mutable fields, "
            + "please check output");
    }
}
项目:openjdk-jdk10    文件:DetectMutableStaticFields.java   
void analyzeModule(StandardJavaFileManager fm, String moduleName)
    throws
        IOException,
        ConstantPoolException,
        InvalidDescriptor {
    JavaFileManager.Location location =
            fm.getLocationForModule(StandardLocation.SYSTEM_MODULES, moduleName);
    if (location == null)
        throw new AssertionError("can't find module " + moduleName);

    for (JavaFileObject file : fm.list(location, "", EnumSet.of(CLASS), true)) {
        String className = fm.inferBinaryName(location, file);
        int index = className.lastIndexOf('.');
        String pckName = index == -1 ? "" : className.substring(0, index);
        if (shouldAnalyzePackage(pckName)) {
            analyzeClassFile(ClassFile.read(file.openInputStream()));
        }
    }
}
项目:openjdk-jdk10    文件:CheckACC_STRICTFlagOnDefaultMethodTest.java   
void check(String dir, String... fileNames)
    throws
        IOException,
        ConstantPoolException,
        Descriptor.InvalidDescriptor {
    for (String fileName : fileNames) {
        ClassFile classFileToCheck = ClassFile.read(new File(dir, fileName));

        for (Method method : classFileToCheck.methods) {
            if ((method.access_flags.flags & ACC_STRICT) == 0) {
                errors.add(String.format(offendingMethodErrorMessage,
                        method.getName(classFileToCheck.constant_pool),
                        classFileToCheck.getName()));
            }
        }
    }
}
项目:openjdk-jdk10    文件:ClassReader.java   
public Element readFrom(InputStream in) throws IOException {
    try {
        this.in = in;
        ClassFile c = ClassFile.read(in);
        // read the file header
        if (c.magic != 0xCAFEBABE) {
            throw new RuntimeException("bad magic number " +
                    Integer.toHexString(c.magic));
        }
        cfile.setAttr("magic", "" + c.magic);
        int minver = c.minor_version;
        int majver = c.major_version;
        cfile.setAttr("minver", "" + minver);
        cfile.setAttr("majver", "" + majver);
        readCP(c);
        readClass(c);
        return result();
    } catch (InvalidDescriptor | ConstantPoolException ex) {
        throw new IOException("Fatal error", ex);
    }
}
项目: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();
}
项目:openjdk9    文件:LVTHarness.java   
void checkClassFile(File file)
        throws IOException, ConstantPoolException, InvalidDescriptor {
    ClassFile classFile = ClassFile.read(file);
    ConstantPool constantPool = classFile.constant_pool;

    //lets get all the methods in the class file.
    for (Method method : classFile.methods) {
        for (ElementKey elementKey: aliveRangeMap.keySet()) {
            String methodDesc = method.getName(constantPool) +
                    method.descriptor.getParameterTypes(constantPool).replace(" ", "");
            if (methodDesc.equals(elementKey.elem.toString())) {
                checkMethod(constantPool, method, aliveRangeMap.get(elementKey));
                seenAliveRanges.add(elementKey);
            }
        }
    }
}
项目:openjdk9    文件:CheckACC_STRICTFlagOnclinitTest.java   
void check(String dir, String... fileNames)
    throws
        IOException,
        ConstantPoolException,
        Descriptor.InvalidDescriptor {
    for (String fileName : fileNames) {
        ClassFile classFileToCheck = ClassFile.read(new File(dir, fileName));

        for (Method method : classFileToCheck.methods) {
            if ((method.access_flags.flags & ACC_STRICT) == 0) {
                errors.add(String.format(offendingMethodErrorMessage,
                        method.getName(classFileToCheck.constant_pool),
                        classFileToCheck.getName()));
            }
        }
    }
}
项目:openjdk9    文件:DetectMutableStaticFields.java   
private void run()
    throws
        IOException,
        ConstantPoolException,
        InvalidDescriptor,
        URISyntaxException {

    JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
    try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
        for (String module: modules) {
            analyzeModule(fm, module);
        }
    }

    if (errors.size() > 0) {
        for (String error: errors) {
            System.err.println(error);
        }
        throw new AssertionError("There are mutable fields, "
            + "please check output");
    }
}
项目:openjdk9    文件:DetectMutableStaticFields.java   
void analyzeModule(StandardJavaFileManager fm, String moduleName)
    throws
        IOException,
        ConstantPoolException,
        InvalidDescriptor {
    JavaFileManager.Location location =
            fm.getModuleLocation(StandardLocation.SYSTEM_MODULES, moduleName);
    if (location == null)
        throw new AssertionError("can't find module " + moduleName);

    for (JavaFileObject file : fm.list(location, "", EnumSet.of(CLASS), true)) {
        String className = fm.inferBinaryName(location, file);
        int index = className.lastIndexOf('.');
        String pckName = index == -1 ? "" : className.substring(0, index);
        if (shouldAnalyzePackage(pckName)) {
            analyzeClassFile(ClassFile.read(file.openInputStream()));
        }
    }
}
项目:openjdk9    文件:CheckACC_STRICTFlagOnDefaultMethodTest.java   
void check(String dir, String... fileNames)
    throws
        IOException,
        ConstantPoolException,
        Descriptor.InvalidDescriptor {
    for (String fileName : fileNames) {
        ClassFile classFileToCheck = ClassFile.read(new File(dir, fileName));

        for (Method method : classFileToCheck.methods) {
            if ((method.access_flags.flags & ACC_STRICT) == 0) {
                errors.add(String.format(offendingMethodErrorMessage,
                        method.getName(classFileToCheck.constant_pool),
                        classFileToCheck.getName()));
            }
        }
    }
}
项目:openjdk9    文件:ClassReader.java   
public Element readFrom(InputStream in) throws IOException {
    try {
        this.in = in;
        ClassFile c = ClassFile.read(in);
        // read the file header
        if (c.magic != 0xCAFEBABE) {
            throw new RuntimeException("bad magic number " +
                    Integer.toHexString(c.magic));
        }
        cfile.setAttr("magic", "" + c.magic);
        int minver = c.minor_version;
        int majver = c.major_version;
        cfile.setAttr("minver", "" + minver);
        cfile.setAttr("majver", "" + majver);
        readCP(c);
        readClass(c);
        return result();
    } catch (InvalidDescriptor | ConstantPoolException ex) {
        throw new IOException("Fatal error", ex);
    }
}
项目: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();
}
项目:jdk8u_jdk    文件:ClassReader.java   
public Element readFrom(InputStream in) throws IOException {
    try {
        this.in = in;
        ClassFile c = ClassFile.read(in);
        // read the file header
        if (c.magic != 0xCAFEBABE) {
            throw new RuntimeException("bad magic number " +
                    Integer.toHexString(c.magic));
        }
        cfile.setAttr("magic", "" + c.magic);
        int minver = c.minor_version;
        int majver = c.major_version;
        cfile.setAttr("minver", "" + minver);
        cfile.setAttr("majver", "" + majver);
        readCP(c);
        readClass(c);
        return result();
    } catch (InvalidDescriptor | ConstantPoolException ex) {
        throw new IOException("Fatal error", ex);
    }
}
项目: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();
}
项目:lookaside_java-1.8.0-openjdk    文件:LVTHarness.java   
void checkClassFile(File file)
        throws IOException, ConstantPoolException, InvalidDescriptor {
    ClassFile classFile = ClassFile.read(file);
    ConstantPool constantPool = classFile.constant_pool;

    //lets get all the methods in the class file.
    for (Method method : classFile.methods) {
        for (ElementKey elementKey: aliveRangeMap.keySet()) {
            String methodDesc = method.getName(constantPool) +
                    method.descriptor.getParameterTypes(constantPool).replace(" ", "");
            if (methodDesc.equals(elementKey.elem.toString())) {
                checkMethod(constantPool, method, aliveRangeMap.get(elementKey));
                seenAliveRanges.add(elementKey);
            }
        }
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:CheckACC_STRICTFlagOnclinitTest.java   
void check(String dir, String... fileNames)
    throws
        IOException,
        ConstantPoolException,
        Descriptor.InvalidDescriptor {
    for (String fileName : fileNames) {
        ClassFile classFileToCheck = ClassFile.read(new File(dir, fileName));

        for (Method method : classFileToCheck.methods) {
            if ((method.access_flags.flags & ACC_STRICT) == 0) {
                errors.add(String.format(offendingMethodErrorMessage,
                        method.getName(classFileToCheck.constant_pool),
                        classFileToCheck.getName()));
            }
        }
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:DetectMutableStaticFields.java   
private void run()
    throws
        IOException,
        ConstantPoolException,
        InvalidDescriptor,
        URISyntaxException {

    URI resource = findResource(keyResource);
    if (resource == null) {
        throw new AssertionError("Resource " + keyResource +
            "not found in the class path");
    }
    analyzeResource(resource);

    if (errors.size() > 0) {
        for (String error: errors) {
            System.err.println(error);
        }
        throw new AssertionError("There are mutable fields, "
            + "please check output");
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:DetectMutableStaticFields.java   
void analyzeResource(URI resource)
    throws
        IOException,
        ConstantPoolException,
        InvalidDescriptor {
    JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
    StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
    JavaFileManager.Location location =
            StandardLocation.locationFor(resource.getPath());
    fm.setLocation(location, com.sun.tools.javac.util.List.of(
            new File(resource.getPath())));

    for (JavaFileObject file : fm.list(location, "", EnumSet.of(CLASS), true)) {
        String className = fm.inferBinaryName(location, file);
        int index = className.lastIndexOf('.');
        String pckName = index == -1 ? "" : className.substring(0, index);
        if (shouldAnalyzePackage(pckName)) {
            analyzeClassFile(ClassFile.read(file.openInputStream()));
        }
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:CheckACC_STRICTFlagOnDefaultMethodTest.java   
void check(String dir, String... fileNames)
    throws
        IOException,
        ConstantPoolException,
        Descriptor.InvalidDescriptor {
    for (String fileName : fileNames) {
        ClassFile classFileToCheck = ClassFile.read(new File(dir, fileName));

        for (Method method : classFileToCheck.methods) {
            if ((method.access_flags.flags & ACC_STRICT) == 0) {
                errors.add(String.format(offendingMethodErrorMessage,
                        method.getName(classFileToCheck.constant_pool),
                        classFileToCheck.getName()));
            }
        }
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:ClassReader.java   
public Element readFrom(InputStream in) throws IOException {
    try {
        this.in = in;
        ClassFile c = ClassFile.read(in);
        // read the file header
        if (c.magic != 0xCAFEBABE) {
            throw new RuntimeException("bad magic number " +
                    Integer.toHexString(c.magic));
        }
        cfile.setAttr("magic", "" + c.magic);
        int minver = c.minor_version;
        int majver = c.major_version;
        cfile.setAttr("minver", "" + minver);
        cfile.setAttr("majver", "" + majver);
        readCP(c);
        readClass(c);
        return result();
    } catch (InvalidDescriptor | ConstantPoolException ex) {
        throw new IOException("Fatal error", ex);
    }
}
项目: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();
}
项目:jsr308-langtools    文件:LVTHarness.java   
void checkClassFile(File file)
        throws IOException, ConstantPoolException, InvalidDescriptor {
    ClassFile classFile = ClassFile.read(file);
    ConstantPool constantPool = classFile.constant_pool;

    //lets get all the methods in the class file.
    for (Method method : classFile.methods) {
        for (ElementKey elementKey: aliveRangeMap.keySet()) {
            String methodDesc = method.getName(constantPool) +
                    method.descriptor.getParameterTypes(constantPool).replace(" ", "");
            if (methodDesc.equals(elementKey.elem.toString())) {
                checkMethod(constantPool, method, aliveRangeMap.get(elementKey));
                seenAliveRanges.add(elementKey);
            }
        }
    }
}
项目:jsr308-langtools    文件:CheckACC_STRICTFlagOnclinitTest.java   
void check(String dir, String... fileNames)
    throws
        IOException,
        ConstantPoolException,
        Descriptor.InvalidDescriptor {
    for (String fileName : fileNames) {
        ClassFile classFileToCheck = ClassFile.read(new File(dir, fileName));

        for (Method method : classFileToCheck.methods) {
            if ((method.access_flags.flags & ACC_STRICT) == 0) {
                errors.add(String.format(offendingMethodErrorMessage,
                        method.getName(classFileToCheck.constant_pool),
                        classFileToCheck.getName()));
            }
        }
    }
}
项目:jsr308-langtools    文件:DetectMutableStaticFields.java   
private void run()
    throws
        IOException,
        ConstantPoolException,
        InvalidDescriptor,
        URISyntaxException {

    URI resource = findResource(keyResource);
    if (resource == null) {
        throw new AssertionError("Resource " + keyResource +
            "not found in the class path");
    }
    analyzeResource(resource);

    if (errors.size() > 0) {
        for (String error: errors) {
            System.err.println(error);
        }
        throw new AssertionError("There are mutable fields, "
            + "please check output");
    }
}
项目:jsr308-langtools    文件:DetectMutableStaticFields.java   
void analyzeResource(URI resource)
    throws
        IOException,
        ConstantPoolException,
        InvalidDescriptor {
    JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
    StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
    JavaFileManager.Location location =
            StandardLocation.locationFor(resource.getPath());
    fm.setLocation(location, com.sun.tools.javac.util.List.of(
            new File(resource.getPath())));

    for (JavaFileObject file : fm.list(location, "", EnumSet.of(CLASS), true)) {
        String className = fm.inferBinaryName(location, file);
        int index = className.lastIndexOf('.');
        String pckName = index == -1 ? "" : className.substring(0, index);
        if (shouldAnalyzePackage(pckName)) {
            analyzeClassFile(ClassFile.read(file.openInputStream()));
        }
    }
}
项目:jsr308-langtools    文件:CheckACC_STRICTFlagOnDefaultMethodTest.java   
void check(String dir, String... fileNames)
    throws
        IOException,
        ConstantPoolException,
        Descriptor.InvalidDescriptor {
    for (String fileName : fileNames) {
        ClassFile classFileToCheck = ClassFile.read(new File(dir, fileName));

        for (Method method : classFileToCheck.methods) {
            if ((method.access_flags.flags & ACC_STRICT) == 0) {
                errors.add(String.format(offendingMethodErrorMessage,
                        method.getName(classFileToCheck.constant_pool),
                        classFileToCheck.getName()));
            }
        }
    }
}
项目:infobip-open-jdk-8    文件:LVTHarness.java   
void checkClassFile(File file)
        throws IOException, ConstantPoolException, InvalidDescriptor {
    ClassFile classFile = ClassFile.read(file);
    ConstantPool constantPool = classFile.constant_pool;

    //lets get all the methods in the class file.
    for (Method method : classFile.methods) {
        for (ElementKey elementKey: aliveRangeMap.keySet()) {
            String methodDesc = method.getName(constantPool) +
                    method.descriptor.getParameterTypes(constantPool).replace(" ", "");
            if (methodDesc.equals(elementKey.elem.toString())) {
                checkMethod(constantPool, method, aliveRangeMap.get(elementKey));
                seenAliveRanges.add(elementKey);
            }
        }
    }
}
项目:infobip-open-jdk-8    文件:CheckACC_STRICTFlagOnclinitTest.java   
void check(String dir, String... fileNames)
    throws
        IOException,
        ConstantPoolException,
        Descriptor.InvalidDescriptor {
    for (String fileName : fileNames) {
        ClassFile classFileToCheck = ClassFile.read(new File(dir, fileName));

        for (Method method : classFileToCheck.methods) {
            if ((method.access_flags.flags & ACC_STRICT) == 0) {
                errors.add(String.format(offendingMethodErrorMessage,
                        method.getName(classFileToCheck.constant_pool),
                        classFileToCheck.getName()));
            }
        }
    }
}
项目:infobip-open-jdk-8    文件:DetectMutableStaticFields.java   
private void run()
    throws
        IOException,
        ConstantPoolException,
        InvalidDescriptor,
        URISyntaxException {

    URI resource = findResource(keyResource);
    if (resource == null) {
        throw new AssertionError("Resource " + keyResource +
            "not found in the class path");
    }
    analyzeResource(resource);

    if (errors.size() > 0) {
        for (String error: errors) {
            System.err.println(error);
        }
        throw new AssertionError("There are mutable fields, "
            + "please check output");
    }
}
项目:infobip-open-jdk-8    文件:DetectMutableStaticFields.java   
void analyzeResource(URI resource)
    throws
        IOException,
        ConstantPoolException,
        InvalidDescriptor {
    JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
    StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
    JavaFileManager.Location location =
            StandardLocation.locationFor(resource.getPath());
    fm.setLocation(location, com.sun.tools.javac.util.List.of(
            new File(resource.getPath())));

    for (JavaFileObject file : fm.list(location, "", EnumSet.of(CLASS), true)) {
        String className = fm.inferBinaryName(location, file);
        int index = className.lastIndexOf('.');
        String pckName = index == -1 ? "" : className.substring(0, index);
        if (shouldAnalyzePackage(pckName)) {
            analyzeClassFile(ClassFile.read(file.openInputStream()));
        }
    }
}
项目:infobip-open-jdk-8    文件:CheckACC_STRICTFlagOnDefaultMethodTest.java   
void check(String dir, String... fileNames)
    throws
        IOException,
        ConstantPoolException,
        Descriptor.InvalidDescriptor {
    for (String fileName : fileNames) {
        ClassFile classFileToCheck = ClassFile.read(new File(dir, fileName));

        for (Method method : classFileToCheck.methods) {
            if ((method.access_flags.flags & ACC_STRICT) == 0) {
                errors.add(String.format(offendingMethodErrorMessage,
                        method.getName(classFileToCheck.constant_pool),
                        classFileToCheck.getName()));
            }
        }
    }
}
项目:infobip-open-jdk-8    文件:ClassReader.java   
public Element readFrom(InputStream in) throws IOException {
    try {
        this.in = in;
        ClassFile c = ClassFile.read(in);
        // read the file header
        if (c.magic != 0xCAFEBABE) {
            throw new RuntimeException("bad magic number " +
                    Integer.toHexString(c.magic));
        }
        cfile.setAttr("magic", "" + c.magic);
        int minver = c.minor_version;
        int majver = c.major_version;
        cfile.setAttr("minver", "" + minver);
        cfile.setAttr("majver", "" + majver);
        readCP(c);
        readClass(c);
        return result();
    } catch (InvalidDescriptor | ConstantPoolException ex) {
        throw new IOException("Fatal error", ex);
    }
}
项目: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();
}
项目:jdk8u-dev-jdk    文件:ClassReader.java   
public Element readFrom(InputStream in) throws IOException {
    try {
        this.in = in;
        ClassFile c = ClassFile.read(in);
        // read the file header
        if (c.magic != 0xCAFEBABE) {
            throw new RuntimeException("bad magic number " +
                    Integer.toHexString(c.magic));
        }
        cfile.setAttr("magic", "" + c.magic);
        int minver = c.minor_version;
        int majver = c.major_version;
        cfile.setAttr("minver", "" + minver);
        cfile.setAttr("majver", "" + majver);
        readCP(c);
        readClass(c);
        return result();
    } catch (InvalidDescriptor | ConstantPoolException ex) {
        throw new IOException("Fatal error", ex);
    }
}
项目: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();
}
项目:openjdk-source-code-learn    文件:OverrideBridge.java   
static void check(Map<ClassFile, List<Method>> refMembers, Map<ClassFile, List<Method>> membersToCheck) throws ConstantPoolException, InvalidDescriptor {
    for (Map.Entry<ClassFile, List<Method>> ref : refMembers.entrySet()) {
        ClassFile cRef = ref.getKey();
        for (Method mRef : ref.getValue()) {
            boolean ok = false;
            for (Map.Entry<ClassFile, List<Method>> toCheck : membersToCheck.entrySet()) {
                ClassFile cToCheck = toCheck.getKey();
                for (Method mToCheck : toCheck.getValue()) {
                    if (cRef.getName().equals(cToCheck.getName()) &&
                            mRef.descriptor.getReturnType(cRef.constant_pool).equals(
                            mToCheck.descriptor.getReturnType(cToCheck.constant_pool)) &&
                            mRef.descriptor.getParameterTypes(cRef.constant_pool).equals(
                            mToCheck.descriptor.getParameterTypes(cToCheck.constant_pool))) {
                        ok = true;
                    }
                }
            }
            if (!ok) {
                throw new AssertionError("Matching method descriptor for " + mRef.descriptor.getParameterTypes(cRef.constant_pool) + "not found");
            }
        }
    }
}