com.sun.tools.classfile.Method Java Examples
The following examples show how to use
com.sun.tools.classfile.Method.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LambdaAsm.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
static int checkMethod(ClassFile cf, String mthd) throws Exception { if (cf.major_version < 52) { throw new RuntimeException("unexpected class file version, in " + cf.getName() + "expected 52, got " + cf.major_version); } int count = 0; for (Method m : cf.methods) { String mname = m.getName(cf.constant_pool); if (mname.equals(mthd)) { for (Attribute a : m.attributes) { if ("Code".equals(a.getName(cf.constant_pool))) { count++; checkMethod(cf.getName(), mname, cf.constant_pool, (Code_attribute) a); } } } } return count; }
Example #2
Source File: TestDirectSuperInterfaceInvoke.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
void verifyDefaultBody(String classFile) { String workDir = System.getProperty("test.classes"); File file = new File(workDir, classFile); try { final ClassFile cf = ClassFile.read(file); for (Method m : cf.methods) { Code_attribute codeAttr = (Code_attribute)m.attributes.get(Attribute.Code); for (Instruction instr : codeAttr.getInstructions()) { if (instr.getOpcode() == Opcode.INVOKESPECIAL) { int pc_index = instr.getShort(1); CPRefInfo ref = (CPRefInfo)cf.constant_pool.get(pc_index); String className = ref.getClassName(); if (className.equals("BaseInterface")) throw new IllegalStateException("Must not directly refer to TestedInterface"); } } } } catch (Exception e) { e.printStackTrace(); throw new Error("error reading " + file +": " + e); } }
Example #3
Source File: LVTHarness.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
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); } } } }
Example #4
Source File: DebugPointerAtBadPositionTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
void checkClassFile(final File cfile, String methodToFind) throws Exception { ClassFile classFile = ClassFile.read(cfile); boolean methodFound = false; for (Method method : classFile.methods) { if (method.getName(classFile.constant_pool).equals(methodToFind)) { methodFound = true; Code_attribute code = (Code_attribute) method.attributes.get("Code"); LineNumberTable_attribute lnt = (LineNumberTable_attribute) code.attributes.get("LineNumberTable"); Assert.check(lnt.line_number_table_length == expectedLNT.length, foundLNTLengthDifferentThanExpMsg); int i = 0; for (LineNumberTable_attribute.Entry entry: lnt.line_number_table) { Assert.check(entry.line_number == expectedLNT[i][0] && entry.start_pc == expectedLNT[i][1], "LNT entry at pos " + i + " differ from expected." + "Found " + entry.line_number + ":" + entry.start_pc + ". Expected " + expectedLNT[i][0] + ":" + expectedLNT[i][1]); i++; } } } Assert.check(methodFound, seekMethodNotFoundMsg); }
Example #5
Source File: DeadCodeGeneratedForEmptyTryTest.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
void checkClassFile(final Path path) throws Exception { ClassFile classFile = ClassFile.read( new BufferedInputStream(Files.newInputStream(path))); constantPool = classFile.constant_pool; utf8Index = constantPool.getUTF8Index("STR_TO_LOOK_FOR"); for (Method method: classFile.methods) { if (method.getName(constantPool).equals("methodToLookFor")) { Code_attribute codeAtt = (Code_attribute)method.attributes.get(Attribute.Code); for (Instruction inst: codeAtt.getInstructions()) { inst.accept(codeVisitor, null); } } } Assert.check(numberOfRefToStr == 1, "There should only be one reference to a CONSTANT_String_info structure in the generated code"); }
Example #6
Source File: ReferenceInfoUtil.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
private static void findAnnotations(ClassFile cf, Method m, String name, List<TypeAnnotation> annos) { int index = m.attributes.getIndex(cf.constant_pool, name); if (index != -1) { Attribute attr = m.attributes.get(index); assert attr instanceof RuntimeTypeAnnotations_attribute; RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr; annos.addAll(Arrays.asList(tAttr.annotations)); } int cindex = m.attributes.getIndex(cf.constant_pool, Attribute.Code); if (cindex != -1) { Attribute cattr = m.attributes.get(cindex); assert cattr instanceof Code_attribute; Code_attribute cAttr = (Code_attribute)cattr; index = cAttr.attributes.getIndex(cf.constant_pool, name); if (index != -1) { Attribute attr = cAttr.attributes.get(index); assert attr instanceof RuntimeTypeAnnotations_attribute; RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr; annos.addAll(Arrays.asList(tAttr.annotations)); } } }
Example #7
Source File: FindNativeFiles.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
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; }
Example #8
Source File: CompareTest.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
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; }
Example #9
Source File: LambdaAsm.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
static int checkMethod(ClassFile cf, String mthd) throws Exception { if (cf.major_version < 52) { throw new RuntimeException("unexpected class file version, in " + cf.getName() + "expected 52, got " + cf.major_version); } int count = 0; for (Method m : cf.methods) { String mname = m.getName(cf.constant_pool); if (mname.equals(mthd)) { for (Attribute a : m.attributes) { if ("Code".equals(a.getName(cf.constant_pool))) { count++; checkMethod(cf.getName(), mname, cf.constant_pool, (Code_attribute) a); } } } } return count; }
Example #10
Source File: ReferenceInfoUtil.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
private static void findAnnotations(ClassFile cf, Method m, String name, List<TypeAnnotation> annos) { int index = m.attributes.getIndex(cf.constant_pool, name); if (index != -1) { Attribute attr = m.attributes.get(index); assert attr instanceof RuntimeTypeAnnotations_attribute; RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr; annos.addAll(Arrays.asList(tAttr.annotations)); } int cindex = m.attributes.getIndex(cf.constant_pool, Attribute.Code); if (cindex != -1) { Attribute cattr = m.attributes.get(cindex); assert cattr instanceof Code_attribute; Code_attribute cAttr = (Code_attribute)cattr; index = cAttr.attributes.getIndex(cf.constant_pool, name); if (index != -1) { Attribute attr = cAttr.attributes.get(index); assert attr instanceof RuntimeTypeAnnotations_attribute; RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr; annos.addAll(Arrays.asList(tAttr.annotations)); } } }
Example #11
Source File: LambdaAsm.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
static int checkMethod(ClassFile cf, String mthd) throws Exception { if (cf.major_version < 52) { throw new RuntimeException("unexpected class file version, in " + cf.getName() + "expected 52, got " + cf.major_version); } int count = 0; for (Method m : cf.methods) { String mname = m.getName(cf.constant_pool); if (mname.equals(mthd)) { for (Attribute a : m.attributes) { if ("Code".equals(a.getName(cf.constant_pool))) { count++; checkMethod(cf.getName(), mname, cf.constant_pool, (Code_attribute) a); } } } } return count; }
Example #12
Source File: LVTHarness.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
void checkMethod(ConstantPool constantPool, Method method, AliveRanges ranges) throws InvalidIndex, UnexpectedEntry, ConstantPoolException { Code_attribute code = (Code_attribute) method.attributes.get(Attribute.Code); LocalVariableTable_attribute lvt = (LocalVariableTable_attribute) (code.attributes.get(Attribute.LocalVariableTable)); List<String> infoFromRanges = convertToStringList(ranges); List<String> infoFromLVT = convertToStringList(constantPool, lvt); // infoFromRanges most be contained in infoFromLVT int i = 0; int j = 0; while (i < infoFromRanges.size() && j < infoFromLVT.size()) { int comparison = infoFromRanges.get(i).compareTo(infoFromLVT.get(j)); if (comparison == 0) { i++; j++; } else if (comparison > 0) { j++; } else { break; } } if (i < infoFromRanges.size()) { error(infoFromLVT, infoFromRanges, method.getName(constantPool).toString()); } }
Example #13
Source File: InlinedFinallyConfuseDebuggersTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
void checkClassFile(final File cfile, String methodToFind) throws Exception { ClassFile classFile = ClassFile.read(cfile); boolean methodFound = false; for (Method method : classFile.methods) { if (method.getName(classFile.constant_pool).equals(methodToFind)) { methodFound = true; Code_attribute code = (Code_attribute) method.attributes.get("Code"); LineNumberTable_attribute lnt = (LineNumberTable_attribute) code.attributes.get("LineNumberTable"); Assert.check(lnt.line_number_table_length == expectedLNT.length, "The LineNumberTable found has a length different to the expected one"); int i = 0; for (LineNumberTable_attribute.Entry entry: lnt.line_number_table) { Assert.check(entry.line_number == expectedLNT[i][0] && entry.start_pc == expectedLNT[i][1], "LNT entry at pos " + i + " differ from expected." + "Found " + entry.line_number + ":" + entry.start_pc + ". Expected " + expectedLNT[i][0] + ":" + expectedLNT[i][1]); i++; } } } Assert.check(methodFound, "The seek method was not found"); }
Example #14
Source File: LVTHarness.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
void checkMethod(ConstantPool constantPool, Method method, AliveRanges ranges) throws InvalidIndex, UnexpectedEntry, ConstantPoolException { Code_attribute code = (Code_attribute) method.attributes.get(Attribute.Code); LocalVariableTable_attribute lvt = (LocalVariableTable_attribute) (code.attributes.get(Attribute.LocalVariableTable)); List<String> infoFromRanges = convertToStringList(ranges); List<String> infoFromLVT = convertToStringList(constantPool, lvt); // infoFromRanges most be contained in infoFromLVT int i = 0; int j = 0; while (i < infoFromRanges.size() && j < infoFromLVT.size()) { int comparison = infoFromRanges.get(i).compareTo(infoFromLVT.get(j)); if (comparison == 0) { i++; j++; } else if (comparison > 0) { j++; } else { break; } } if (i < infoFromRanges.size()) { error(infoFromLVT, infoFromRanges, method.getName(constantPool).toString()); } }
Example #15
Source File: WrongLNTForLambdaTest.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
void checkClassFile(final File cfile, String methodToFind, int[][] expectedLNT) throws Exception { ClassFile classFile = ClassFile.read(cfile); boolean methodFound = false; for (Method method : classFile.methods) { if (method.getName(classFile.constant_pool).equals(methodToFind)) { methodFound = true; Code_attribute code = (Code_attribute) method.attributes.get("Code"); LineNumberTable_attribute lnt = (LineNumberTable_attribute) code.attributes.get("LineNumberTable"); Assert.check(lnt.line_number_table_length == expectedLNT.length, "The LineNumberTable found has a length different to the expected one"); int i = 0; for (LineNumberTable_attribute.Entry entry: lnt.line_number_table) { Assert.check(entry.line_number == expectedLNT[i][0] && entry.start_pc == expectedLNT[i][1], "LNT entry at pos " + i + " differ from expected." + "Found " + entry.line_number + ":" + entry.start_pc + ". Expected " + expectedLNT[i][0] + ":" + expectedLNT[i][1]); i++; } } } Assert.check(methodFound, "The seek method was not found"); }
Example #16
Source File: InlinedFinallyConfuseDebuggersTest.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
void checkClassFile(final File cfile, String methodToFind) throws Exception { ClassFile classFile = ClassFile.read(cfile); boolean methodFound = false; for (Method method : classFile.methods) { if (method.getName(classFile.constant_pool).equals(methodToFind)) { methodFound = true; Code_attribute code = (Code_attribute) method.attributes.get("Code"); LineNumberTable_attribute lnt = (LineNumberTable_attribute) code.attributes.get("LineNumberTable"); Assert.check(lnt.line_number_table_length == expectedLNT.length, "The LineNumberTable found has a length different to the expected one"); int i = 0; for (LineNumberTable_attribute.Entry entry: lnt.line_number_table) { Assert.check(entry.line_number == expectedLNT[i][0] && entry.start_pc == expectedLNT[i][1], "LNT entry at pos " + i + " differ from expected." + "Found " + entry.line_number + ":" + entry.start_pc + ". Expected " + expectedLNT[i][0] + ":" + expectedLNT[i][1]); i++; } } } Assert.check(methodFound, "The seek method was not found"); }
Example #17
Source File: DeadCodeGeneratedForEmptyTryTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
void checkClassFile(final Path path) throws Exception { ClassFile classFile = ClassFile.read( new BufferedInputStream(Files.newInputStream(path))); constantPool = classFile.constant_pool; utf8Index = constantPool.getUTF8Index("STR_TO_LOOK_FOR"); for (Method method: classFile.methods) { if (method.getName(constantPool).equals("methodToLookFor")) { Code_attribute codeAtt = (Code_attribute)method.attributes.get(Attribute.Code); for (Instruction inst: codeAtt.getInstructions()) { inst.accept(codeVisitor, null); } } } Assert.check(numberOfRefToStr == 1, "There should only be one reference to a CONSTANT_String_info structure in the generated code"); }
Example #18
Source File: CheckACC_STRICTFlagOnclinitTest.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
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())); } } } }
Example #19
Source File: DebugPointerAtBadPositionTest.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
void checkClassFile(final File cfile, String methodToFind) throws Exception { ClassFile classFile = ClassFile.read(cfile); boolean methodFound = false; for (Method method : classFile.methods) { if (method.getName(classFile.constant_pool).equals(methodToFind)) { methodFound = true; Code_attribute code = (Code_attribute) method.attributes.get("Code"); LineNumberTable_attribute lnt = (LineNumberTable_attribute) code.attributes.get("LineNumberTable"); Assert.check(lnt.line_number_table_length == expectedLNT.length, foundLNTLengthDifferentThanExpMsg); int i = 0; for (LineNumberTable_attribute.Entry entry: lnt.line_number_table) { Assert.check(entry.line_number == expectedLNT[i][0] && entry.start_pc == expectedLNT[i][1], "LNT entry at pos " + i + " differ from expected." + "Found " + entry.line_number + ":" + entry.start_pc + ". Expected " + expectedLNT[i][0] + ":" + expectedLNT[i][1]); i++; } } } Assert.check(methodFound, seekMethodNotFoundMsg); }
Example #20
Source File: DeadCodeGeneratedForEmptyTryTest.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
void checkClassFile(final Path path) throws Exception { ClassFile classFile = ClassFile.read( new BufferedInputStream(Files.newInputStream(path))); constantPool = classFile.constant_pool; utf8Index = constantPool.getUTF8Index("STR_TO_LOOK_FOR"); for (Method method: classFile.methods) { if (method.getName(constantPool).equals("methodToLookFor")) { Code_attribute codeAtt = (Code_attribute)method.attributes.get(Attribute.Code); for (Instruction inst: codeAtt.getInstructions()) { inst.accept(codeVisitor, null); } } } Assert.check(numberOfRefToStr == 1, "There should only be one reference to a CONSTANT_String_info structure in the generated code"); }
Example #21
Source File: FindNativeFiles.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
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; }
Example #22
Source File: LambdaAsm.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
static int checkMethod(ClassFile cf, String mthd) throws Exception { if (cf.major_version < 52) { throw new RuntimeException("unexpected class file version, in " + cf.getName() + "expected 52, got " + cf.major_version); } int count = 0; for (Method m : cf.methods) { String mname = m.getName(cf.constant_pool); if (mname.equals(mthd)) { for (Attribute a : m.attributes) { if ("Code".equals(a.getName(cf.constant_pool))) { count++; checkMethod(cf.getName(), mname, cf.constant_pool, (Code_attribute) a); } } } } return count; }
Example #23
Source File: TypeAnnotationPropagationTest.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public void run() throws Exception { ClassFile cf = getClassFile("TypeAnnotationPropagationTest$Test.class"); Method f = null; for (Method m : cf.methods) { if (m.getName(cf.constant_pool).contains("f")) { f = m; break; } } int idx = f.attributes.getIndex(cf.constant_pool, Attribute.Code); Code_attribute cattr = (Code_attribute) f.attributes.get(idx); idx = cattr.attributes.getIndex(cf.constant_pool, Attribute.RuntimeVisibleTypeAnnotations); RuntimeVisibleTypeAnnotations_attribute attr = (RuntimeVisibleTypeAnnotations_attribute) cattr.attributes.get(idx); TypeAnnotation anno = attr.annotations[0]; assertEquals(anno.position.lvarOffset, new int[] {3}, "start_pc"); assertEquals(anno.position.lvarLength, new int[] {8}, "length"); assertEquals(anno.position.lvarIndex, new int[] {1}, "index"); }
Example #24
Source File: CheckACC_STRICTFlagOnDefaultMethodTest.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
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())); } } } }
Example #25
Source File: NoDeadCodeGenerationOnTrySmtTest.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
void checkClassFile(final File cfile, String[] methodsToFind) throws Exception { ClassFile classFile = ClassFile.read(cfile); int numberOfmethodsFound = 0; for (String methodToFind : methodsToFind) { for (Method method : classFile.methods) { if (method.getName(classFile.constant_pool).equals(methodToFind)) { numberOfmethodsFound++; Code_attribute code = (Code_attribute) method.attributes.get("Code"); Assert.check(code.exception_table_length == expectedExceptionTable.length, "The ExceptionTable found has a length different to the expected one"); int i = 0; for (Exception_data entry: code.exception_table) { Assert.check(entry.start_pc == expectedExceptionTable[i][0] && entry.end_pc == expectedExceptionTable[i][1] && entry.handler_pc == expectedExceptionTable[i][2] && entry.catch_type == expectedExceptionTable[i][3], "Exception table entry at pos " + i + " differ from expected."); i++; } } } } Assert.check(numberOfmethodsFound == 2, "Some seek methods were not found"); }
Example #26
Source File: CheckACC_STRICTFlagOnDefaultMethodTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
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())); } } } }
Example #27
Source File: CheckACC_STRICTFlagOnDefaultMethodTest.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
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())); } } } }
Example #28
Source File: CompareTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
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; }
Example #29
Source File: CheckACC_STRICTFlagOnclinitTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
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())); } } } }
Example #30
Source File: ConstDebugTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public static void main(String args[]) throws Exception { ClassFile classFile = ClassFile.read(Paths.get(System.getProperty("test.classes"), ConstDebugTest.class.getSimpleName() + ".class")); for (Method method: classFile.methods) { if (method.getName(classFile.constant_pool).equals("<clinit>")) { throw new AssertionError( "javac should not create a <clinit> method for ConstDebugTest class"); } } }