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

NPE: Cannot invoke "java.lang.constant.ClassDesc.isArray()" because "this.sym" is null

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • 22
    • 22
    • core-libs

    Description

      ClassFileAPI related.
      Parsing a particular class file to build a ClassModel throws an NPE. Following is the code snippet:
       
              ClassModel cm = ClassFile.of().parse(bytes);
              byte[] newBytes = ClassFile.of().build(cm.thisClass().asSymbol(),
                      classBuilder -> {
                          for (ClassElement ce : cm) {
                              if (ce instanceof ClassFileVersion) {
                                  classBuilder.with(ClassFileVersion.of(66, 0));
                              } else {
                                  classBuilder.with(ce);
                              }
                          }
                      });
      The file is a valid and verifiable (JVM) file. The stack trace is:
      java.lang.NullPointerException: Cannot invoke "java.lang.constant.ClassDesc.isArray()" because "this.sym" is null
                    at java.base/jdk.internal.classfile.impl.StackMapGenerator$Type.getComponent(StackMapGenerator.java:1391)
                    at java.base/jdk.internal.classfile.impl.StackMapGenerator.processBlock(StackMapGenerator.java:503)
                    at java.base/jdk.internal.classfile.impl.StackMapGenerator.processMethod(StackMapGenerator.java:440)
                    at java.base/jdk.internal.classfile.impl.StackMapGenerator.generate(StackMapGenerator.java:317)
                    at java.base/jdk.internal.classfile.impl.StackMapGenerator.<init>(StackMapGenerator.java:243)
                    at java.base/jdk.internal.classfile.impl.StackMapGenerator.of(StackMapGenerator.java:156)
                    at java.base/jdk.internal.classfile.impl.DirectCodeBuilder$4.generateStackMaps(DirectCodeBuilder.java:331)
                    at java.base/jdk.internal.classfile.impl.DirectCodeBuilder$4.tryGenerateStackMaps(DirectCodeBuilder.java:340)
                    at java.base/jdk.internal.classfile.impl.DirectCodeBuilder$4.writeBody(DirectCodeBuilder.java:382)
                    at java.base/jdk.internal.classfile.impl.UnboundAttribute$AdHocAttribute.writeTo(UnboundAttribute.java:914)
                    at java.base/jdk.internal.classfile.impl.CodeImpl.writeTo(CodeImpl.java:157)
                    at java.base/jdk.internal.classfile.impl.AttributeHolder.writeTo(AttributeHolder.java:56)
                    at java.base/jdk.internal.classfile.impl.DirectMethodBuilder.writeTo(DirectMethodBuilder.java:156)
                    at java.base/jdk.internal.classfile.impl.BufWriterImpl.writeList(BufWriterImpl.java:207)
                    at java.base/jdk.internal.classfile.impl.DirectClassBuilder.build(DirectClassBuilder.java:181)
                    at java.base/jdk.internal.classfile.impl.ClassFileImpl.build(ClassFileImpl.java:113)
                    at java.base/java.lang.classfile.ClassFile.build(ClassFile.java:329)
       

      Attachments

        Issue Links

          Activity

            People

              asotona Adam Sotona
              pchinnasamy Prabushankar Chinnasamy
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: