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

ClassFile.verify() can throw exceptions instead of returning VerifyErrors

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P4
    • 24
    • 23
    • core-libs
    • None

    Description

      The ClassFile API verify method is supposed to return an array of VerifyError instances in case of verification failures. However with certain class files exceptions are thrown instead:

      jshell> java.lang.classfile.ClassFile.of().verify(new FileInputStream("CCE_CodeImpl_vs_MethodImpl.class").readAllBytes())
      | Exception java.lang.ClassCastException: class jdk.internal.classfile.impl.MethodImpl cannot be cast to class jdk.internal.classfile.impl.CodeImpl (jdk.internal.classfile.impl.MethodImpl and jdk.internal.classfile.impl.CodeImpl are in module java.base of loader 'bootstrap')
      | at BoundAttribute$BoundLocalVariableTypeTableAttribute.<init> (BoundAttribute.java:315)
      | at AbstractAttributeMapper$LocalVariableTypeTableMapper.readAttribute (AbstractAttributeMapper.java:344)
      | at AbstractAttributeMapper$LocalVariableTypeTableMapper.readAttribute (AbstractAttributeMapper.java:335)
      | at BoundAttribute.readAttributes (BoundAttribute.java:150)
      | at MethodImpl.attributes (MethodImpl.java:98)
      | at AttributedElement.findAttribute (AttributedElement.java:60)
      | at MethodImpl.code (MethodImpl.java:121)
      | at VerificationWrapper$MethodWrapper.<init> (VerificationWrapper.java:89)
      | at VerificationWrapper.lambda$methods$0 (VerificationWrapper.java:71)
      | at ReferencePipeline$3$1.accept (ReferencePipeline.java:215)
      | at AbstractList$RandomAccessSpliterator.forEachRemaining (AbstractList.java:722)
      | at AbstractPipeline.copyInto (AbstractPipeline.java:570)
      | at AbstractPipeline.wrapAndCopyInto (AbstractPipeline.java:560)
      | at AbstractPipeline.evaluate (AbstractPipeline.java:636)
      | at AbstractPipeline.evaluateToArrayNode (AbstractPipeline.java:291)
      | at ReferencePipeline.toArray (ReferencePipeline.java:656)
      | at ReferencePipeline.toArray (ReferencePipeline.java:662)
      | at ReferencePipeline.toList (ReferencePipeline.java:667)
      | at VerificationWrapper.methods (VerificationWrapper.java:71)
      | at VerifierImpl.verify_class (VerifierImpl.java:245)
      | at VerifierImpl.verify (VerifierImpl.java:119)
      | at ClassFileImpl.verify (ClassFileImpl.java:135)
      | at ClassFileImpl.verify (ClassFileImpl.java:141)
      | at (#1:1)

      jshell> java.lang.classfile.ClassFile.of().verify(new FileInputStream("AbstractPoolEntry_CpException_malformed_input.class").readAllBytes())
      | Exception jdk.internal.classfile.impl.AbstractPoolEntry$CpException: malformed input around byte 122
      | at AbstractPoolEntry$Utf8EntryImpl.inflate (AbstractPoolEntry.java:290)
      | at AbstractPoolEntry$Utf8EntryImpl.toString (AbstractPoolEntry.java:320)
      | at AbstractPoolEntry$Utf8EntryImpl.stringValue (AbstractPoolEntry.java:332)
      | at AbstractPoolEntry$AbstractNamedEntry.asInternalName (AbstractPoolEntry.java:539)
      | at AbstractPoolEntry$ClassEntryImpl.asInternalName (AbstractPoolEntry.java:552)
      | at VerificationWrapper.thisClassName (VerificationWrapper.java:55)
      | at VerifierImpl.is_eligible_for_verification (VerifierImpl.java:135)
      | at VerifierImpl.verify (VerifierImpl.java:113)
      | at ClassFileImpl.verify (ClassFileImpl.java:135)
      | at ClassFileImpl.verify (ClassFileImpl.java:141)
      | at (#2:1)

      Attachments

        Activity

          People

            asotona Adam Sotona
            mschoene Marc Schönefeld
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: