Java - 如何找出哪个类文件有损坏的常量池?
是否有某种工具或 javac 的一些更好的输出来找出哪个类文件具有损坏的常量池..因为我无法编译一些现有的 java 文件,因为某些预编译的文件有一个损坏的常量池..
这是损坏的常量池堆栈打印输出的样子
An exception has occurred in the compiler (1.6.0_26). Please file a bug at the J
ava Developer Connection (http://java.sun.com/webapps/bugreport) after checking
the Bug Parade for duplicates. Include your program and the following diagnosti
c in your report. Thank you.
java.lang.ArrayIndexOutOfBoundsException: 8047705
at com.sun.tools.javac.jvm.ClassReader.nextInt(ClassReader.java:277)
at com.sun.tools.javac.jvm.ClassReader.skipMember(ClassReader.java:1504)
at com.sun.tools.javac.jvm.ClassReader.readClass(ClassReader.java:1559)
at com.sun.tools.javac.jvm.ClassReader.readClassFile(ClassReader.java:16
58)
at com.sun.tools.javac.jvm.ClassReader.fillIn(ClassReader.java:1845)
at com.sun.tools.javac.jvm.ClassReader.complete(ClassReader.java:1777)
at com.sun.tools.javac.code.Symbol.complete(Symbol.java:386)
at com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:763)
at com.sun.tools.javac.jvm.ClassReader.loadClass(ClassReader.java:1951)
at com.sun.tools.javac.comp.Resolve.loadClass(Resolve.java:842)
at com.sun.tools.javac.comp.Resolve.findIdentInPackage(Resolve.java:1011
)
at com.sun.tools.javac.comp.Attr.selectSym(Attr.java:1921)
at com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:1835)
at com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:1522
)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:360)
at com.sun.tools.javac.comp.Attr.attribType(Attr.java:390)
at com.sun.tools.javac.comp.MemberEnter.attribImportType(MemberEnter.jav
a:681)
at com.sun.tools.javac.comp.MemberEnter.visitImport(MemberEnter.java:545
)
at com.sun.tools.javac.tree.JCTree$JCImport.accept(JCTree.java:495)
at com.sun.tools.javac.comp.MemberEnter.memberEnter(MemberEnter.java:387
)
at com.sun.tools.javac.comp.MemberEnter.memberEnter(MemberEnter.java:399
)
at com.sun.tools.javac.comp.MemberEnter.visitTopLevel(MemberEnter.java:5
12)
at com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:
446)
at com.sun.tools.javac.comp.MemberEnter.memberEnter(MemberEnter.java:387
)
at com.sun.tools.javac.comp.MemberEnter.complete(MemberEnter.java:819)
at com.sun.tools.javac.code.Symbol.complete(Symbol.java:386)
at com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:763)
at com.sun.tools.javac.comp.Enter.complete(Enter.java:464)
at com.sun.tools.javac.main.JavaCompiler.complete(JavaCompiler.java:659)
at com.sun.tools.javac.jvm.ClassReader.fillIn(ClassReader.java:1869)
at com.sun.tools.javac.jvm.ClassReader.complete(ClassReader.java:1777)
at com.sun.tools.javac.code.Symbol.complete(Symbol.java:386)
at com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:763)
at com.sun.tools.javac.jvm.ClassReader.loadClass(ClassReader.java:1951)
at com.sun.tools.javac.comp.Resolve.loadClass(Resolve.java:842)
at com.sun.tools.javac.comp.Resolve.findGlobalType(Resolve.java:901)
at com.sun.tools.javac.comp.Resolve.findType(Resolve.java:957)
at com.sun.tools.javac.comp.Resolve.findIdent(Resolve.java:986)
at com.sun.tools.javac.comp.Resolve.resolveIdent(Resolve.java:1162)
at com.sun.tools.javac.comp.Attr.visitIdent(Attr.java:1714)
at com.sun.tools.javac.tree.JCTree$JCIdent.accept(JCTree.java:1547)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:360)
at com.sun.tools.javac.comp.Attr.attribType(Attr.java:390)
at com.sun.tools.javac.comp.MemberEnter.signature(MemberEnter.java:355)
at com.sun.tools.javac.comp.MemberEnter.visitMethodDef(MemberEnter.java:
560)
at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:639)
at com.sun.tools.javac.comp.MemberEnter.memberEnter(MemberEnter.java:387
)
at com.sun.tools.javac.comp.MemberEnter.memberEnter(MemberEnter.java:399
)
at com.sun.tools.javac.comp.MemberEnter.finishClass(MemberEnter.java:410
)
at com.sun.tools.javac.comp.MemberEnter.finish(MemberEnter.java:1000)
at com.sun.tools.javac.comp.MemberEnter.complete(MemberEnter.java:967)
at com.sun.tools.javac.code.Symbol.complete(Symbol.java:386)
at com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:763)
at com.sun.tools.javac.comp.Enter.complete(Enter.java:464)
at com.sun.tools.javac.comp.Enter.main(Enter.java:442)
at com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:81
9)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:727)
at com.sun.tools.javac.main.Main.compile(Main.java:353)
at com.sun.tools.javac.main.Main.compile(Main.java:279)
at com.sun.tools.javac.main.Main.compile(Main.java:270)
at com.sun.tools.javac.Main.compile(Main.java:69)
at com.sun.tools.javac.Main.main(Main.java:54)
Is there some kind of a tool or some better output from javac
to figure out which class file has a corrupt constant pool.. as I cannot compile some existing java files due to some pre-compiled file has a corrupt constant pool..
Here is how a corrupt constant pool stack print out looks like
An exception has occurred in the compiler (1.6.0_26). Please file a bug at the J
ava Developer Connection (http://java.sun.com/webapps/bugreport) after checking
the Bug Parade for duplicates. Include your program and the following diagnosti
c in your report. Thank you.
java.lang.ArrayIndexOutOfBoundsException: 8047705
at com.sun.tools.javac.jvm.ClassReader.nextInt(ClassReader.java:277)
at com.sun.tools.javac.jvm.ClassReader.skipMember(ClassReader.java:1504)
at com.sun.tools.javac.jvm.ClassReader.readClass(ClassReader.java:1559)
at com.sun.tools.javac.jvm.ClassReader.readClassFile(ClassReader.java:16
58)
at com.sun.tools.javac.jvm.ClassReader.fillIn(ClassReader.java:1845)
at com.sun.tools.javac.jvm.ClassReader.complete(ClassReader.java:1777)
at com.sun.tools.javac.code.Symbol.complete(Symbol.java:386)
at com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:763)
at com.sun.tools.javac.jvm.ClassReader.loadClass(ClassReader.java:1951)
at com.sun.tools.javac.comp.Resolve.loadClass(Resolve.java:842)
at com.sun.tools.javac.comp.Resolve.findIdentInPackage(Resolve.java:1011
)
at com.sun.tools.javac.comp.Attr.selectSym(Attr.java:1921)
at com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:1835)
at com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:1522
)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:360)
at com.sun.tools.javac.comp.Attr.attribType(Attr.java:390)
at com.sun.tools.javac.comp.MemberEnter.attribImportType(MemberEnter.jav
a:681)
at com.sun.tools.javac.comp.MemberEnter.visitImport(MemberEnter.java:545
)
at com.sun.tools.javac.tree.JCTree$JCImport.accept(JCTree.java:495)
at com.sun.tools.javac.comp.MemberEnter.memberEnter(MemberEnter.java:387
)
at com.sun.tools.javac.comp.MemberEnter.memberEnter(MemberEnter.java:399
)
at com.sun.tools.javac.comp.MemberEnter.visitTopLevel(MemberEnter.java:5
12)
at com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:
446)
at com.sun.tools.javac.comp.MemberEnter.memberEnter(MemberEnter.java:387
)
at com.sun.tools.javac.comp.MemberEnter.complete(MemberEnter.java:819)
at com.sun.tools.javac.code.Symbol.complete(Symbol.java:386)
at com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:763)
at com.sun.tools.javac.comp.Enter.complete(Enter.java:464)
at com.sun.tools.javac.main.JavaCompiler.complete(JavaCompiler.java:659)
at com.sun.tools.javac.jvm.ClassReader.fillIn(ClassReader.java:1869)
at com.sun.tools.javac.jvm.ClassReader.complete(ClassReader.java:1777)
at com.sun.tools.javac.code.Symbol.complete(Symbol.java:386)
at com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:763)
at com.sun.tools.javac.jvm.ClassReader.loadClass(ClassReader.java:1951)
at com.sun.tools.javac.comp.Resolve.loadClass(Resolve.java:842)
at com.sun.tools.javac.comp.Resolve.findGlobalType(Resolve.java:901)
at com.sun.tools.javac.comp.Resolve.findType(Resolve.java:957)
at com.sun.tools.javac.comp.Resolve.findIdent(Resolve.java:986)
at com.sun.tools.javac.comp.Resolve.resolveIdent(Resolve.java:1162)
at com.sun.tools.javac.comp.Attr.visitIdent(Attr.java:1714)
at com.sun.tools.javac.tree.JCTree$JCIdent.accept(JCTree.java:1547)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:360)
at com.sun.tools.javac.comp.Attr.attribType(Attr.java:390)
at com.sun.tools.javac.comp.MemberEnter.signature(MemberEnter.java:355)
at com.sun.tools.javac.comp.MemberEnter.visitMethodDef(MemberEnter.java:
560)
at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:639)
at com.sun.tools.javac.comp.MemberEnter.memberEnter(MemberEnter.java:387
)
at com.sun.tools.javac.comp.MemberEnter.memberEnter(MemberEnter.java:399
)
at com.sun.tools.javac.comp.MemberEnter.finishClass(MemberEnter.java:410
)
at com.sun.tools.javac.comp.MemberEnter.finish(MemberEnter.java:1000)
at com.sun.tools.javac.comp.MemberEnter.complete(MemberEnter.java:967)
at com.sun.tools.javac.code.Symbol.complete(Symbol.java:386)
at com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:763)
at com.sun.tools.javac.comp.Enter.complete(Enter.java:464)
at com.sun.tools.javac.comp.Enter.main(Enter.java:442)
at com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:81
9)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:727)
at com.sun.tools.javac.main.Main.compile(Main.java:353)
at com.sun.tools.javac.main.Main.compile(Main.java:279)
at com.sun.tools.javac.main.Main.compile(Main.java:270)
at com.sun.tools.javac.Main.compile(Main.java:69)
at com.sun.tools.javac.Main.main(Main.java:54)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有点固定,找到了一个很好的快速修复..只需将
-verbose
添加到您的javac
参数中,您就会看到类似的内容。Kinda fixed, found out a good quickfix.. just add
-verbose
to yourjavac
parameters and you'll see like..我建议您使用aspectj 来检测编译器。您只需要捕获精确的堆栈签名并转储传递给每个方法的参数即可。你的班级名称将在那个转储中。
编辑:
例如
com.sun.tools.javac.jvm.ClassReader.readClassFile
I suggest you instrument the compiler with aspectj. You just need to trap that precise stack signatures and dump the params passed to each method. Your class name is gonna be in that dump.
edit:
e.g.
com.sun.tools.javac.jvm.ClassReader.readClassFile