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

Loading class from jar file yields InvalidJarIndexException

    XMLWordPrintable

Details

    Description

      ADDITIONAL SYSTEM INFORMATION :
      O.S. Windows 10:
      java version "1.8.0_202"
      Java(TM) SE Runtime Environment (build 1.8.0_202-b08)
      Java HotSpot(TM) 64-Bit Server VM (build 25.202-b08, mixed mode)


      On Red Hat Linux:
      java version "1.8.0_202"
      Java(TM) SE Runtime Environment (build 1.8.0_202-b08)
      Java HotSpot(TM) 64-Bit Server VM (build 25.202-b08, mixed mode)

      A DESCRIPTION OF THE PROBLEM :
      When loading the class "" a InvalidJarIndexException exception is thrown but a ClassNotFoundException should be thrown.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create a class with the following line:

              Class clazz = Class.forName("com.dovetailsys$routing$preference$RoutingPayment");

      And execute it having a jar file in the classpath containing the following INDEX.LIST file (without the quotes):

      "
      JarIndex-Version: 1.0

      mysql-connector-java-commercial-5.1.22-bin.jar
      com
      com/mysql
      com/mysql/jdbc
      com/mysql/jdbc/authentication
      com/mysql/jdbc/configs
      com/mysql/jdbc/exceptions
      com/mysql/jdbc/exceptions/jdbc4
      com/mysql/jdbc/integration
      com/mysql/jdbc/integration/c3p0
      com/mysql/jdbc/integration/jboss
      com/mysql/jdbc/interceptors
      com/mysql/jdbc/jdbc2
      com/mysql/jdbc/jdbc2/optional
      com/mysql/jdbc/jmx
      com/mysql/jdbc/log
      com/mysql/jdbc/profiler
      com/mysql/jdbc/util
      org
      org/gjt
      org/gjt/mm
      org/gjt/mm/mysql
      "


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      A java.lang.ClassNotFoundException exception to be thrown.
      ACTUAL -
      An sun.misc.InvalidJarIndexException exception is thrown.

      ---------- BEGIN SOURCE ----------
      public class ClassLoadTest {

          public static void main(String[]args) throws ClassNotFoundException{

              // The following line throws a InvalidIndexException. But if the first dollar sign is replaced by a dot a ClassNotFoundException is throw
              Class clazz = Class.forName("com.dovetailsys$routing$preference$RoutingPayment");
          }
          
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Remove INDEX.LIST file from the META-INF directory of the jar file in the classpath

      FREQUENCY : always


      Attachments

        Activity

          People

            bchristi Brent Christian
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: