This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-bcel.git

commit dc9b61b30fc364b4f610a8a5469ff65fe2000536
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Mon Apr 1 11:11:02 2024 -0400

    Avoid NullPointerException after calling
    org.apache.bcel.classfile.BootstrapMethods.BootstrapMethods(int, int,
    BootstrapMethod[], ConstantPool) with null
    
    Avoid NullPointerException after calling
    
org.apache.bcel.classfile.BootstrapMethods.setBootstrapMethods(BootstrapMethod[])
    with null.
---
 src/changes/changes.xml                                       | 2 ++
 src/main/java/org/apache/bcel/classfile/BootstrapMethod.java  | 2 ++
 src/main/java/org/apache/bcel/classfile/BootstrapMethods.java | 4 ++--
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 98fbda75..0df97860 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -86,6 +86,8 @@ The <action> type attribute can be add,update,fix,remove.
       <action                  type="update" dev="ggregory" due-to="Gary 
Gregory">Avoid NullPointerException after calling 
org.apache.bcel.classfile.ArrayElementValue.ArrayElementValue(int, 
ElementValue[], ConstantPool) with null.</action>
       <action                  type="update" dev="ggregory" due-to="Gary 
Gregory">Avoid NullPointerException after calling 
org.apache.bcel.classfile.BootstrapMethod.BootstrapMethod(int, int[]) with 
null.</action>
       <action                  type="update" dev="ggregory" due-to="Gary 
Gregory">Avoid NullPointerException after calling 
org.apache.bcel.classfile.BootstrapMethod.setBootstrapArguments(int[]) with 
null.</action>
+      <action                  type="update" dev="ggregory" due-to="Gary 
Gregory">Avoid NullPointerException after calling 
org.apache.bcel.classfile.BootstrapMethods.BootstrapMethods(int, int, 
BootstrapMethod[], ConstantPool) with null.</action>
+      <action                  type="update" dev="ggregory" due-to="Gary 
Gregory">Avoid NullPointerException after calling 
org.apache.bcel.classfile.BootstrapMethods.setBootstrapMethods(BootstrapMethod[])
 with null.</action>
       <!-- UPDATE -->
       <action                  type="update" dev="ggregory" 
due-to="Dependabot">Bump org.apache.commons:commons-parent from 66 to 67 
#283.</action>
       <action                  type="update" dev="ggregory" 
due-to="Dependabot">Bump org.jetbrains.kotlin:kotlin-stdlib from 1.9.22 to 
1.9.23 #284.</action>
diff --git a/src/main/java/org/apache/bcel/classfile/BootstrapMethod.java 
b/src/main/java/org/apache/bcel/classfile/BootstrapMethod.java
index ad88aa1e..ff4b93b0 100644
--- a/src/main/java/org/apache/bcel/classfile/BootstrapMethod.java
+++ b/src/main/java/org/apache/bcel/classfile/BootstrapMethod.java
@@ -35,6 +35,8 @@ import org.apache.commons.lang3.ArrayUtils;
  */
 public class BootstrapMethod implements Cloneable {
 
+    static final BootstrapMethod[] EMPTY_ARRAY = {};
+
     /** Index of the CONSTANT_MethodHandle_info structure in the constant_pool 
table */
     private int bootstrapMethodRef;
 
diff --git a/src/main/java/org/apache/bcel/classfile/BootstrapMethods.java 
b/src/main/java/org/apache/bcel/classfile/BootstrapMethods.java
index d44a1afa..42af84ee 100644
--- a/src/main/java/org/apache/bcel/classfile/BootstrapMethods.java
+++ b/src/main/java/org/apache/bcel/classfile/BootstrapMethods.java
@@ -54,7 +54,7 @@ public class BootstrapMethods extends Attribute implements 
Iterable<BootstrapMet
      */
     public BootstrapMethods(final int nameIndex, final int length, final 
BootstrapMethod[] bootstrapMethods, final ConstantPool constantPool) {
         super(Const.ATTR_BOOTSTRAP_METHODS, nameIndex, length, constantPool);
-        this.bootstrapMethods = bootstrapMethods;
+        setBootstrapMethods(bootstrapMethods);
     }
 
     /**
@@ -131,7 +131,7 @@ public class BootstrapMethods extends Attribute implements 
Iterable<BootstrapMet
      * @param bootstrapMethods the array of bootstrap methods
      */
     public final void setBootstrapMethods(final BootstrapMethod[] 
bootstrapMethods) {
-        this.bootstrapMethods = bootstrapMethods;
+        this.bootstrapMethods = bootstrapMethods != null ? bootstrapMethods : 
BootstrapMethod.EMPTY_ARRAY;
     }
 
     /**

Reply via email to