JDK-4358512 : Classes loaded through reflection produces InvalidJarIndexException errors
  • Type: Bug
  • Component: tools
  • Sub-Component: jar
  • Affected Version: 1.3.0
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: x86
  • Submitted: 2000-08-02
  • Updated: 2001-10-19
  • Resolved: 2000-08-18
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 Other Other
1.3.0_03 03Fixed 1.3.1Fixed 1.4.0Fixed
Related Reports
Relates :  
Description
If you create a jar index file that contains classes loaded
through reflection, you will get InvalidJarIndexException errors.

Here is a test case and reproducible steps using JDK 1.3.0-C build.
The jar works fine with JRE 1.2.2.
With JRE 1.3, you will get the following errors:

Class B
Exception in thread "main" sun.misc.InvalidJarIndexException: Invalid index!
        at sun.misc.URLClassPath$JarLoader.getResource(Unknown Source)
        at sun.misc.URLClassPath.getResource(Unknown Source)
        at java.net.URLClassLoader$2.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findResource(Unknown Source)
        at java.lang.ClassLoader.getResource(Unknown Source)
        at java.lang.ClassLoader.getSystemResource(Unknown Source)
        at java.lang.ClassLoader.getSystemResourceAsStream(Unknown Source)
        at c.B$1.run(B.java:13)
        at java.security.AccessController.doPrivileged(Native Method)
        at c.B.<init>(B.java:10)
        at A.<init>(A.java:13)
        at A.main(A.java:7)

The platform is Windows NT 4.0, sp6
JDK/JRE =
	java version "1.3.0"
	java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
	Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)

Steps to reproduce:
-------------------
set classpath=.;b.jar
javac -d . B.java

del b.jar
jar cfm b.jar manifest.mf -C . c\B.class
jar -i b.jar
del c\B.class

javac A.java

java A


A.java
------
public class A
{
    public static void main( String args[] )
    {
        A a = new A();
    }

    public A()
    {
        new c.B();
    }
}


B.java
------
package c;

import java.io.*;

public class B
{
    public B()
    {
        System.out.println( "Class B" );
        InputStream stream = (InputStream)java.security.AccessController.doPrivileged
         (new java.security.PrivilegedAction() {
          public Object run() {
         /* ****************************************************************/
                    // The following line is the one that causes the problem.
              return ClassLoader.getSystemResourceAsStream( "c/b.properties" );
          }
         });
        System.out.println( "stream = " + stream );
    }
}


manifest.mf
-----------
Specification-Title: A B test
Specification-Vendor: A B test
Specification-Version: 1.0.0
Implementation-Vendor: A B test
Implementation-Version: 1.0.0
Implementation-Title: A B test

Name: c\B.class
Java-Bean: True



Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: 1.3.0_03 ladybird merlin-beta FIXED IN: 1.3.0_03 ladybird merlin-beta INTEGRATED IN: 1.3.0_03 1.3.1 ladybird-rc1 merlin-beta VERIFIED IN: 1.3.0_03 1.3.1_01a
14-06-2004

EVALUATION Definitely a bug. See the comments for more information. naveen.sanjeeva@eng 2000-08-02
02-08-2000