ClassWriter.writeClassAttributes() can throw NPE

XMLWordPrintable

    • Type: Bug
    • Resolution: Unresolved
    • Priority: P4
    • tbd
    • Affects Version/s: 26
    • Component/s: hotspot
    • None

      The method ConstantPool.getBootstrapMethodAt(int) can return null:

      public short[] getBootstrapMethodAt(int bsmIndex) {
          U4Array offs = getOffsets();
          U2Array bsms = getBootstrapMethods();
          if (offs == null || bsms == null) return null; // safety first
          ...
      }

      However, ClassWriter.writeClassAttributes() calls this method without checking for null:

      for (int index = 0; index < bsmCount; index++) {
          short[] value = cpool.getBootstrapMethodAt(index);
          for (int i = 0; i < value.length; i++) {
              ...
      To prevent possible NPE, getBootstrapMethodAt() should return an empty array instead of null.

            Assignee:
            Unassigned
            Reporter:
            Fernando Guallini
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: