JDK-6232676 : javac crashes with ArrayIndexOutOfBoundsException on ZIP merged jar files.
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 1.4.2,1.4.2_07
  • Priority: P3
  • Status: Closed
  • Resolution: Cannot Reproduce
  • OS: solaris_8,windows_xp
  • CPU: x86,sparc
  • Submitted: 2005-02-24
  • Updated: 2010-05-10
  • Resolved: 2005-02-24
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.4.2_07Resolved
Related Reports
Relates :  
Relates :  
Description
A dynamically create Jar -File contains the same class twice (fully qualified class name is identical). This is allowed by the zip format and the error causing zip file is the result of a merge process of different jar files.

The runtime does not have a problem, but the compiler fails -> this seems to be a bug.

Test Case:
Class A and Class B uses Class A

jar File x.jar containing twice Class A (in different size)

javac -cp x.jar B.java

[build] An exception has occurred in the compiler (1.4.2_05). Please file a bug at the Java Developer Connection (http://java.sun.com/cgi-bin/bugreport.cgi) after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report. Thank you.
[build] java.lang.ArrayIndexOutOfBoundsException: 1932486510
[build] at com.sun.tools.javac.v8.code.ClassReader.nextInt(ClassReader.java:335)
[build] at com.sun.tools.javac.v8.code.ClassReader.skipMember(ClassReader.java:820)
[build] at com.sun.tools.javac.v8.code.ClassReader.readClass(ClassReader.java:861)
[build] at com.sun.tools.javac.v8.code.ClassReader.readClassFile(ClassReader.java:936)
[build] at com.sun.tools.javac.v8.code.ClassReader.fillIn(ClassReader.java:1091)
[build] at com.sun.tools.javac.v8.code.ClassReader.complete(ClassReader.java:1049)
[build] at com.sun.tools.javac.v8.code.Symbol.complete(Symbol.java:372)
[build] at com.sun.tools.javac.v8.code.Symbol$ClassSymbol.complete(Symbol.java:691)
[build] at com.sun.tools.javac.v8.code.ClassReader.loadClass(ClassReader.java:1130)
[build] at com.sun.tools.javac.v8.comp.Resolve.loadClass(Resolve.java:471)
[build] at com.sun.tools.javac.v8.comp.Resolve.findIdentInPackage(Resolve.java:644)
[build] at com.sun.tools.javac.v8.comp.Attr.selectSym(Attr.java:1127)
[build] at com.sun.tools.javac.v8.comp.Attr.visitSelect(Attr.java:1076)
[build] at com.sun.tools.javac.v8.tree.Tree$Select.accept(Tree.java:1091)
[build] at com.sun.tools.javac.v8.comp.Attr.attribTree(Attr.java:198)
[build] at com.sun.tools.javac.v8.comp.Attr.attribType(Attr.java:228)
[build] at com.sun.tools.javac.v8.comp.Enter$MemberEnter.visitImport(Enter.java:763)
[build] at com.sun.tools.javac.v8.tree.Tree$Import.accept(Tree.java:407)
[build] at com.sun.tools.javac.v8.comp.Enter$MemberEnter.memberEnter(Enter.java:715)
[build] at com.sun.tools.javac.v8.comp.Enter$MemberEnter.memberEnter(Enter.java:727)
[build] at com.sun.tools.javac.v8.comp.Enter$MemberEnter.visitTopLevel(Enter.java:746)
[build] at com.sun.tools.javac.v8.tree.Tree$TopLevel.accept(Tree.java:390)
[build] at com.sun.tools.javac.v8.comp.Enter$MemberEnter.memberEnter(Enter.java:715)
[build] at com.sun.tools.javac.v8.comp.Enter$CompleteEnter.complete(Enter.java:848)
[build] at com.sun.tools.javac.v8.code.Symbol.complete(Symbol.java:372)
[build] at com.sun.tools.javac.v8.code.Symbol$ClassSymbol.complete(Symbol.java:691)
[build] at com.sun.tools.javac.v8.comp.Enter.complete(Enter.java:601)
[build] at com.sun.tools.javac.v8.comp.Enter.main(Enter.java:582)
[build] at com.sun.tools.javac.v8.JavaCompiler.compile(JavaCompiler.java:331)
[build] at com.sun.tools.javac.v8.Main.compile(Main.java:569)
[build] at com.sun.tools.javac.Main.compile(Main.java:36) 

This occurs because the developer has merged a.jar with b.jar both are containing the class a.b.AB 
After the merge the ab.jar will contain twice the class a.b.AB.

The merge is done with Ant's zip functions, *not* with jar.
###@###.### 2005-2-24 14:52:45 GMT

Comments
EVALUATION I can't reproduce this problem as I have no way to create a jar file with the described characteristics. Furthermore, scanning Jar files is a very time critical operation in javac so I'm reluctant to change the diagnostics just to catch a bug in Ant. Furthermore, I expect that when 6225605 is integrated, javac should not be affectd by this problem. ###@###.### 2005-2-24 17:56:01 GMT
24-02-2005

WORK AROUND Don't use Zip to build merged jar files. ###@###.### 2005-2-24 14:52:45 GMT
24-02-2005