Defining hidden class with no room in constant pool crashes the VM

XMLWordPrintable

    • master
    • generic
    • generic

      A DESCRIPTION OF THE PROBLEM :
      If class has 65535 entries in the constant pool, VM will reserve one more entry for hidden class name, resulting in a crash.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the program.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      VM throws some exception.
      ACTUAL -
      VM crashes.

      ---------- BEGIN SOURCE ----------
      import org.objectweb.asm.ClassWriter;

      import java.lang.invoke.MethodHandles;

      import static org.objectweb.asm.Opcodes.ACC_PUBLIC;
      import static org.objectweb.asm.Opcodes.V17;

      public class HiddenClassesTest {

      public static void main(String[] args) throws Exception {
      var cw = new ClassWriter(0);
      cw.visit(V17, ACC_PUBLIC, "Hidden", null, "java/lang/Object", null);
      for (int i = 0; i < 65530; i++) {
      cw.newUTF8(Integer.toString(i));
      }
      MethodHandles.lookup().defineHiddenClass(cw.toByteArray(), false);
      }
      }

      ---------- END SOURCE ----------

            Assignee:
            Coleen Phillimore
            Reporter:
            Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: