/** Check the SourceFileAttribute is the simple name of the original source file. */ void verifySourceFileAttribute(File f) { System.err.println("verify: " + f); try { ClassFile cf = ClassFile.read(f); SourceFile_attribute sfa = (SourceFile_attribute) cf.getAttribute(Attribute.SourceFile); String found = sfa.getSourceFile(cf.constant_pool); String expect = f.getName().replaceAll("([$.].*)?\\.class", ".java"); if (!expect.equals(found)) { error("bad value found: " + found + ", expected: " + expect); } } catch (Exception e) { error("error reading " + f + ": " + e); } }
String getSourceFile(SourceFile_attribute attr) { try { return attr.getSourceFile(constant_pool); } catch (ConstantPoolException e) { return report(e); } }