Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6232676
Votes 0
Synopsis javac crashes with ArrayIndexOutOfBoundsException on ZIP merged jar files.
Category java:compiler
Reported Against 1.4.2_07
Release Fixed
State 11-Closed, Not Reproducible, bug
Priority: 3-Medium
Related Bugs 4376065 , 6225605
Submit Date 24-FEB-2005
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.
  xxxxx@xxxxx   2005-2-24 14:52:45 GMT
Work Around
Don't use Zip to build merged jar files.
  xxxxx@xxxxx   2005-2-24 14:52:45 GMT
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.

  xxxxx@xxxxx   2005-2-24 17:56:01 GMT
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang