Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4358512

Classes loaded through reflection produces InvalidJarIndexException errors

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 1.3.0
    • Fix Version/s: 1.3.0_03
    • Component/s: tools
    • Labels:
    • Subcomponent:
      jar
    • Resolved In Build:
      03
    • CPU:
      x86
    • OS:
      generic
    • Verification:
      Verified

      Backports

        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


          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  busersunw Btplusnull User (Inactive)
                  Reporter:
                  mchansunw Mei Chan (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  0 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: