United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4358512 : Classes loaded through reflection produces InvalidJarIndexException errors

Details
Type:
Bug
Submit Date:
2000-08-02
Status:
Closed
Updated Date:
2001-10-19
Project Name:
JDK
Resolved Date:
2000-08-18
Component:
tools
OS:
generic
Sub-Component:
jar
CPU:
x86
Priority:
P3
Resolution:
Fixed
Affected Versions:
1.3.0
Fixed Versions:
1.3.0_03 (03)

Related Reports
Backport:
Backport:
Relates:

Sub Tasks

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
EVALUATION

Definitely a bug. See the comments for more information.

naveen.sanjeeva@eng 2000-08-02
                                     
2000-08-02
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


                                     
2004-06-14



Hardware and Software, Engineered to Work Together