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

ClassFile.verify(byte[] bytes) throws unexpected ConstantPoolException, IAE

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 23
    • 22, 23
    • core-libs
    • b27
    • b24
    • Not verified

      The expected behavior doesn't allow for raising any exceptions.
      List<VerifyError> veList = ClassFile.of().verify(getBytes(resourceName));
      ---
      class jcod/negative/BadCPReference {
        0xCAFEBABE;
        0; // minor version
        66; // version
        [] { // Constant Pool
          ; // first element is empty
          Method #2 #3; // #1
          class #100; // #2 #4 -> #100 Refers out of CP
          NameAndType #5 #6; // #3
          Utf8 "java/lang/Object"; // #4
          Utf8 "<init>"; // #5
          Utf8 "()V"; // #6
          class #8; // #7
          Utf8 "jcod/negative/BadCPReference"; // #8
          Utf8 "Code"; // #9
          Utf8 "SourceFile"; // #10
          Utf8 "BadCPReference.jasm"; // #11
        }
      ---
      1) Also the class file should not cause the IllegalArgumentException exception when it has a bad magic number. (BadMagicNumber.jcod)
      2) BadCPTag.jcod - java.lang.classfile.constantpool.ConstantPoolException: Bad tag (254) at index (12) position (175)
      3) BadConstantPoolCount.jcod - java.lang.ArrayIndexOutOfBoundsException: Index 49915 out of bounds for length 188
      4) BrokenCode.jcod - java.lang.classfile.constantpool.ConstantPoolException: Bad CP UTF8 index: 1536

            asotona Adam Sotona
            lkuskov Leonid Kuskov
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: