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.
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.