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

Hotspot 8 and 11 throw different exceptions when Constant pool at index 0 is nul

XMLWordPrintable

    • x86_64
    • linux

      ADDITIONAL SYSTEM INFORMATION :
      openjdk version "1.8.0_432"
      OpenJDK Runtime Environment (Temurin)(build 1.8.0_432-b06)
      OpenJDK 64-Bit Server VM (Temurin)(build 25.432-b06, mixed mode)

      openjdk version "11.0.25" 2024-10-15
      OpenJDK Runtime Environment Temurin-11.0.25+9 (build 11.0.25+9)
      OpenJDK 64-Bit Server VM Temurin-11.0.25+9 (build 11.0.25+9, mixed mode)

      A DESCRIPTION OF THE PROBLEM :
      Attempting to create a com.sun.org.apache.bcel.internal.classfile.JavaClass object with a ConstantPool(new Constant[3]) in the parameters causes the report Constant pool at index 0 is null
      Although the final report content is the same, the Exception thrown by Hotspot8 and 11 are different.
      Where Hotspot-8 reports:
      com.sun.org.apache.bcel.internal.classfile.ClassFormatException: constant pool at index 0 is null.
              at com.sun.org.apache.bcel.internal.classfile.ConstantPool.getConstant(ConstantPool.java:241)
              at com.sun.org.apache.bcel.internal.classfile.ConstantPool.getConstantString(ConstantPool.java:274)
              at com.sun.org.apache.bcel.internal.classfile.JavaClass.<init>(JavaClass.java:145)
              at test.main(test.java:6)
      Hotspot-11 Report:
      Exception in thread “main” java.lang.NullPointerException
              at java.xml/com.sun.org.apache.bcel.internal.classfile.ConstantPool.getConstantString(ConstantPool.java:369)
              at java.xml/com.sun.org.apache.bcel.internal.classfile.JavaClass.<init>(JavaClass.java:214)
              at test.main(test.java:6)

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      java.lang.NullPointerException
      ACTUAL -
      com.sun.org.apache.bcel.internal.classfile.ClassFormatException

      ---------- BEGIN SOURCE ----------

      import com.sun.org.apache.bcel.internal.classfile.*;
      public class test {
          public static void main(String[] var0) {
              new JavaClass(0, 100, "", 3, 3, 3, new ConstantPool(new Constant[3]), new int[3], new Field[3], new Method[1], new Attribute[3], (byte)1);
          }
      }
      ---------- END SOURCE ----------

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: