You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2024/04/01 13:45:49 UTC

(commons-bcel) branch master updated (3ba8aa0c -> e8357416)

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

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


    from 3ba8aa0c Avoid possible NullPointerException in org.apache.bcel.generic.ClassGen.setMethods(Method[])
     new 35cc0cc3 Javadoc
     new 7baa87ac Javadoc
     new 52358332 Better local name
     new 490800ac Javadoc
     new a7016253 Avoid possible NullPointerException in org.apache.bcel.generic.ClassGen.unpackAnnotations(Attribute[])
     new 1e4e630f Avoid possible NullPointerException in org.apache.bcel.classfile.ParameterAnnotationEntry.createParameterAnnotationEntries(Attribute[])
     new c7082c09 Avoid possible NullPointerException in org.apache.bcel.generic.ClassGen.ClassGen(JavaClass)
     new f4208899 Avoid possible NullPointerException in org.apache.bcel.generic.FieldGenOrMethodGen.addAll(Attribute[])
     new e8357416 Remove trainling whitespace

The 9 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/changes/changes.xml                            |  4 ++
 .../bcel/classfile/ParameterAnnotationEntry.java   |  5 ++-
 .../bcel/classfile/ParameterAnnotations.java       |  4 ++
 .../classfile/RuntimeInvisibleAnnotations.java     |  8 +++-
 .../RuntimeInvisibleParameterAnnotations.java      |  2 +
 .../bcel/classfile/RuntimeVisibleAnnotations.java  |  8 +++-
 .../RuntimeVisibleParameterAnnotations.java        |  2 +
 .../java/org/apache/bcel/generic/ClassGen.java     | 45 ++++++++++++++--------
 .../apache/bcel/generic/FieldGenOrMethodGen.java   |  6 ++-
 9 files changed, 61 insertions(+), 23 deletions(-)


(commons-bcel) 05/09: Avoid possible NullPointerException in org.apache.bcel.generic.ClassGen.unpackAnnotations(Attribute[])

Posted by gg...@apache.org.
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 a7016253948e2b8faa6b14575199ef9f402888d5
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Apr 1 09:27:09 2024 -0400

    Avoid possible NullPointerException in
    org.apache.bcel.generic.ClassGen.unpackAnnotations(Attribute[])
---
 src/changes/changes.xml                             |  1 +
 src/main/java/org/apache/bcel/generic/ClassGen.java | 16 +++++++++-------
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 919ec56d..1e26e2fe 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -65,6 +65,7 @@ The <action> type attribute can be add,update,fix,remove.
       <action                  type="update" dev="ggregory" due-to="Gary Gregory">Avoid possible NullPointerException in AnnotationEntryGen.copyValues(ElementValuePair[], ConstantPoolGen, boolean).</action>
       <action                  type="update" dev="ggregory" due-to="Gary Gregory">Avoid possible NullPointerException in ArrayElementValueGen.ArrayElementValueGen(int, ElementValue[], ConstantPoolGen).</action>
       <action                  type="update" dev="ggregory" due-to="Gary Gregory">Avoid possible NullPointerException in org.apache.bcel.generic.ClassGen.setMethods(Method[]).</action>
+      <action                  type="update" dev="ggregory" due-to="Gary Gregory">Avoid possible NullPointerException in org.apache.bcel.generic.ClassGen.unpackAnnotations(Attribute[]).</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/generic/ClassGen.java b/src/main/java/org/apache/bcel/generic/ClassGen.java
index 9ed5c42c..aa9de68e 100644
--- a/src/main/java/org/apache/bcel/generic/ClassGen.java
+++ b/src/main/java/org/apache/bcel/generic/ClassGen.java
@@ -515,13 +515,15 @@ public class ClassGen extends AccessFlags implements Cloneable {
      */
     private AnnotationEntryGen[] unpackAnnotations(final Attribute[] attributes) {
         final List<AnnotationEntryGen> annotationGenObjs = new ArrayList<>();
-        for (final Attribute attr : attributes) {
-            if (attr instanceof RuntimeVisibleAnnotations) {
-                final RuntimeVisibleAnnotations rva = (RuntimeVisibleAnnotations) attr;
-                rva.forEach(a -> annotationGenObjs.add(new AnnotationEntryGen(a, getConstantPool(), false)));
-            } else if (attr instanceof RuntimeInvisibleAnnotations) {
-                final RuntimeInvisibleAnnotations ria = (RuntimeInvisibleAnnotations) attr;
-                ria.forEach(a -> annotationGenObjs.add(new AnnotationEntryGen(a, getConstantPool(), false)));
+        if (attributes != null) {
+            for (final Attribute attr : attributes) {
+                if (attr instanceof RuntimeVisibleAnnotations) {
+                    final RuntimeVisibleAnnotations rva = (RuntimeVisibleAnnotations) attr;
+                    rva.forEach(a -> annotationGenObjs.add(new AnnotationEntryGen(a, getConstantPool(), false)));
+                } else if (attr instanceof RuntimeInvisibleAnnotations) {
+                    final RuntimeInvisibleAnnotations ria = (RuntimeInvisibleAnnotations) attr;
+                    ria.forEach(a -> annotationGenObjs.add(new AnnotationEntryGen(a, getConstantPool(), false)));
+                }
             }
         }
         return annotationGenObjs.toArray(AnnotationEntryGen.EMPTY_ARRAY);


(commons-bcel) 07/09: Avoid possible NullPointerException in org.apache.bcel.generic.ClassGen.ClassGen(JavaClass)

Posted by gg...@apache.org.
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 c7082c0975590fc052ce10d777789bdd295df86f
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Apr 1 09:36:44 2024 -0400

    Avoid possible NullPointerException in
    org.apache.bcel.generic.ClassGen.ClassGen(JavaClass)
---
 src/changes/changes.xml                            |  1 +
 .../java/org/apache/bcel/generic/ClassGen.java     | 26 +++++++++++++++-------
 2 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 4f84d3a2..9ac6575a 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -67,6 +67,7 @@ The <action> type attribute can be add,update,fix,remove.
       <action                  type="update" dev="ggregory" due-to="Gary Gregory">Avoid possible NullPointerException in org.apache.bcel.generic.ClassGen.setMethods(Method[]).</action>
       <action                  type="update" dev="ggregory" due-to="Gary Gregory">Avoid possible NullPointerException in org.apache.bcel.generic.ClassGen.unpackAnnotations(Attribute[]).</action>
       <action                  type="update" dev="ggregory" due-to="Gary Gregory">Avoid possible NullPointerException in org.apache.bcel.classfile.ParameterAnnotationEntry.createParameterAnnotationEntries(Attribute[]).</action>
+      <action                  type="update" dev="ggregory" due-to="Gary Gregory">Avoid possible NullPointerException in org.apache.bcel.generic.ClassGen.ClassGen(JavaClass).</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/generic/ClassGen.java b/src/main/java/org/apache/bcel/generic/ClassGen.java
index aa9de68e..12cb3bf4 100644
--- a/src/main/java/org/apache/bcel/generic/ClassGen.java
+++ b/src/main/java/org/apache/bcel/generic/ClassGen.java
@@ -95,7 +95,7 @@ public class ClassGen extends AccessFlags implements Cloneable {
     private List<ClassObserver> observers;
 
     /**
-     * Initialize with existing class.
+     * Constructs a new instance from an existing class.
      *
      * @param clazz JavaClass object (e.g. read from file)
      */
@@ -112,16 +112,26 @@ public class ClassGen extends AccessFlags implements Cloneable {
         final Attribute[] attributes = clazz.getAttributes();
         // J5TODO: Could make unpacking lazy, done on first reference
         final AnnotationEntryGen[] annotations = unpackAnnotations(attributes);
-        Collections.addAll(interfaceList, clazz.getInterfaceNames());
-        for (final Attribute attribute : attributes) {
-            if (!(attribute instanceof Annotations)) {
-                addAttribute(attribute);
+        final String[] interfaceNames = clazz.getInterfaceNames();
+        if (interfaceNames != null) {
+            Collections.addAll(interfaceList, interfaceNames);
+        }
+        if (attributes != null) {
+            for (final Attribute attribute : attributes) {
+                if (!(attribute instanceof Annotations)) {
+                    addAttribute(attribute);
+                }
             }
         }
         Collections.addAll(annotationList, annotations);
-        Collections.addAll(methodList, clazz.getMethods());
-        Collections.addAll(fieldList, clazz.getFields());
-    }
+        final Method[] methods = clazz.getMethods();
+        if (methods != null) {
+            Collections.addAll(methodList, methods);
+        }
+        final Field[] fields = clazz.getFields();
+        if (fields != null) {
+            Collections.addAll(fieldList, fields);
+        }}
 
     /**
      * Convenience constructor to set up some important values initially.


(commons-bcel) 09/09: Remove trainling whitespace

Posted by gg...@apache.org.
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 e8357416743dc009e630d2d47121653e3b6e841e
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Apr 1 09:45:44 2024 -0400

    Remove trainling whitespace
    
    Fix Checkstyle formatting issue
---
 .../java/org/apache/bcel/classfile/RuntimeInvisibleAnnotations.java    | 2 +-
 src/main/java/org/apache/bcel/generic/ClassGen.java                    | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/bcel/classfile/RuntimeInvisibleAnnotations.java b/src/main/java/org/apache/bcel/classfile/RuntimeInvisibleAnnotations.java
index 410c1876..1c087ed1 100644
--- a/src/main/java/org/apache/bcel/classfile/RuntimeInvisibleAnnotations.java
+++ b/src/main/java/org/apache/bcel/classfile/RuntimeInvisibleAnnotations.java
@@ -44,7 +44,7 @@ public class RuntimeInvisibleAnnotations extends Annotations {
 
     /**
      * Creates a deep copy of this attribute.
-     * 
+     *
      * @return deep copy of this attribute.
      */
     @Override
diff --git a/src/main/java/org/apache/bcel/generic/ClassGen.java b/src/main/java/org/apache/bcel/generic/ClassGen.java
index 12cb3bf4..e961cbcb 100644
--- a/src/main/java/org/apache/bcel/generic/ClassGen.java
+++ b/src/main/java/org/apache/bcel/generic/ClassGen.java
@@ -131,7 +131,8 @@ public class ClassGen extends AccessFlags implements Cloneable {
         final Field[] fields = clazz.getFields();
         if (fields != null) {
             Collections.addAll(fieldList, fields);
-        }}
+        }
+    }
 
     /**
      * Convenience constructor to set up some important values initially.


(commons-bcel) 06/09: Avoid possible NullPointerException in org.apache.bcel.classfile.ParameterAnnotationEntry.createParameterAnnotationEntries(Attribute[])

Posted by gg...@apache.org.
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 1e4e630f4367d486694b68b759ea0371bb965bef
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Apr 1 09:31:31 2024 -0400

    Avoid possible NullPointerException in
    org.apache.bcel.classfile.ParameterAnnotationEntry.createParameterAnnotationEntries(Attribute[])
---
 src/changes/changes.xml                                              | 1 +
 .../java/org/apache/bcel/classfile/ParameterAnnotationEntry.java     | 5 ++++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 1e26e2fe..4f84d3a2 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -66,6 +66,7 @@ The <action> type attribute can be add,update,fix,remove.
       <action                  type="update" dev="ggregory" due-to="Gary Gregory">Avoid possible NullPointerException in ArrayElementValueGen.ArrayElementValueGen(int, ElementValue[], ConstantPoolGen).</action>
       <action                  type="update" dev="ggregory" due-to="Gary Gregory">Avoid possible NullPointerException in org.apache.bcel.generic.ClassGen.setMethods(Method[]).</action>
       <action                  type="update" dev="ggregory" due-to="Gary Gregory">Avoid possible NullPointerException in org.apache.bcel.generic.ClassGen.unpackAnnotations(Attribute[]).</action>
+      <action                  type="update" dev="ggregory" due-to="Gary Gregory">Avoid possible NullPointerException in org.apache.bcel.classfile.ParameterAnnotationEntry.createParameterAnnotationEntries(Attribute[]).</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/ParameterAnnotationEntry.java b/src/main/java/org/apache/bcel/classfile/ParameterAnnotationEntry.java
index 563ff6b0..f6aa2d27 100644
--- a/src/main/java/org/apache/bcel/classfile/ParameterAnnotationEntry.java
+++ b/src/main/java/org/apache/bcel/classfile/ParameterAnnotationEntry.java
@@ -38,7 +38,10 @@ public class ParameterAnnotationEntry implements Node {
         for (final Attribute attribute : attrs) {
             if (attribute instanceof ParameterAnnotations) {
                 final ParameterAnnotations runtimeAnnotations = (ParameterAnnotations) attribute;
-                Collections.addAll(accumulatedAnnotations, runtimeAnnotations.getParameterAnnotationEntries());
+                final ParameterAnnotationEntry[] parameterAnnotationEntries = runtimeAnnotations.getParameterAnnotationEntries();
+                if (parameterAnnotationEntries != null) {
+                    Collections.addAll(accumulatedAnnotations, parameterAnnotationEntries);
+                }
             }
         }
         return accumulatedAnnotations.toArray(ParameterAnnotationEntry.EMPTY_ARRAY);


(commons-bcel) 01/09: Javadoc

Posted by gg...@apache.org.
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 35cc0cc33f3c6df685a2f7f04b955e9925a24798
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Apr 1 09:21:12 2024 -0400

    Javadoc
---
 .../org/apache/bcel/classfile/RuntimeInvisibleAnnotations.java    | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/bcel/classfile/RuntimeInvisibleAnnotations.java b/src/main/java/org/apache/bcel/classfile/RuntimeInvisibleAnnotations.java
index 0cdfa5fd..410c1876 100644
--- a/src/main/java/org/apache/bcel/classfile/RuntimeInvisibleAnnotations.java
+++ b/src/main/java/org/apache/bcel/classfile/RuntimeInvisibleAnnotations.java
@@ -23,13 +23,15 @@ import java.io.IOException;
 import org.apache.bcel.Const;
 
 /**
- * represents an annotation that is represented in the class file but is not provided to the JVM.
+ * An annotation that is represented in the class file but is not provided to the JVM.
  *
  * @since 6.0
  */
 public class RuntimeInvisibleAnnotations extends Annotations {
 
     /**
+     * Constructs a new instance.
+     *
      * @param nameIndex Index pointing to the name <em>Code</em>
      * @param length Content length in bytes
      * @param input Input stream
@@ -41,7 +43,9 @@ public class RuntimeInvisibleAnnotations extends Annotations {
     }
 
     /**
-     * @return deep copy of this attribute
+     * Creates a deep copy of this attribute.
+     * 
+     * @return deep copy of this attribute.
      */
     @Override
     public Attribute copy(final ConstantPool constantPool) {


(commons-bcel) 04/09: Javadoc

Posted by gg...@apache.org.
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 490800accbf9df8264e94ecde75b9ca1a25fc9d6
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Apr 1 09:25:40 2024 -0400

    Javadoc
---
 src/main/java/org/apache/bcel/classfile/ParameterAnnotations.java | 4 ++++
 .../bcel/classfile/RuntimeInvisibleParameterAnnotations.java      | 2 ++
 .../java/org/apache/bcel/classfile/RuntimeVisibleAnnotations.java | 8 ++++++--
 .../apache/bcel/classfile/RuntimeVisibleParameterAnnotations.java | 2 ++
 src/main/java/org/apache/bcel/generic/ClassGen.java               | 3 +--
 5 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/apache/bcel/classfile/ParameterAnnotations.java b/src/main/java/org/apache/bcel/classfile/ParameterAnnotations.java
index d7a9a20d..390d0391 100644
--- a/src/main/java/org/apache/bcel/classfile/ParameterAnnotations.java
+++ b/src/main/java/org/apache/bcel/classfile/ParameterAnnotations.java
@@ -33,6 +33,8 @@ public abstract class ParameterAnnotations extends Attribute implements Iterable
     private ParameterAnnotationEntry[] parameterAnnotationTable;
 
     /**
+     * Constructs a new instance.
+     *
      * @param parameterAnnotationType the subclass type of the parameter annotation
      * @param nameIndex Index pointing to the name <em>Code</em>
      * @param length Content length in bytes
@@ -50,6 +52,8 @@ public abstract class ParameterAnnotations extends Attribute implements Iterable
     }
 
     /**
+     * Constructs a new instance.
+     *
      * @param parameterAnnotationType the subclass type of the parameter annotation
      * @param nameIndex Index pointing to the name <em>Code</em>
      * @param length Content length in bytes
diff --git a/src/main/java/org/apache/bcel/classfile/RuntimeInvisibleParameterAnnotations.java b/src/main/java/org/apache/bcel/classfile/RuntimeInvisibleParameterAnnotations.java
index 9fb84b96..44ff1bed 100644
--- a/src/main/java/org/apache/bcel/classfile/RuntimeInvisibleParameterAnnotations.java
+++ b/src/main/java/org/apache/bcel/classfile/RuntimeInvisibleParameterAnnotations.java
@@ -29,6 +29,8 @@ import org.apache.bcel.Const;
 public class RuntimeInvisibleParameterAnnotations extends ParameterAnnotations {
 
     /**
+     * Constructs a new instance.
+     *
      * @param nameIndex Index pointing to the name <em>Code</em>
      * @param length Content length in bytes
      * @param input Input stream
diff --git a/src/main/java/org/apache/bcel/classfile/RuntimeVisibleAnnotations.java b/src/main/java/org/apache/bcel/classfile/RuntimeVisibleAnnotations.java
index f17dd8e9..071e2865 100644
--- a/src/main/java/org/apache/bcel/classfile/RuntimeVisibleAnnotations.java
+++ b/src/main/java/org/apache/bcel/classfile/RuntimeVisibleAnnotations.java
@@ -23,13 +23,15 @@ import java.io.IOException;
 import org.apache.bcel.Const;
 
 /**
- * represents an annotation that is represented in the class file and is provided to the JVM.
+ * An annotation that is represented in the class file and is provided to the JVM.
  *
  * @since 6.0
  */
 public class RuntimeVisibleAnnotations extends Annotations {
 
     /**
+     * Constructs a new instance.
+     *
      * @param nameIndex Index pointing to the name <em>Code</em>
      * @param length Content length in bytes
      * @param input Input stream
@@ -41,7 +43,9 @@ public class RuntimeVisibleAnnotations extends Annotations {
     }
 
     /**
-     * @return deep copy of this attribute
+     * Creates a deep copy of this attribute.
+     *
+     * @return deep copy of this attribute.
      */
     @Override
     public Attribute copy(final ConstantPool constantPool) {
diff --git a/src/main/java/org/apache/bcel/classfile/RuntimeVisibleParameterAnnotations.java b/src/main/java/org/apache/bcel/classfile/RuntimeVisibleParameterAnnotations.java
index 299627bc..ad9d6625 100644
--- a/src/main/java/org/apache/bcel/classfile/RuntimeVisibleParameterAnnotations.java
+++ b/src/main/java/org/apache/bcel/classfile/RuntimeVisibleParameterAnnotations.java
@@ -29,6 +29,8 @@ import org.apache.bcel.Const;
 public class RuntimeVisibleParameterAnnotations extends ParameterAnnotations {
 
     /**
+     * Constructs a new instance.
+     *
      * @param nameIndex Index pointing to the name <em>Code</em>
      * @param length Content length in bytes
      * @param input Input stream
diff --git a/src/main/java/org/apache/bcel/generic/ClassGen.java b/src/main/java/org/apache/bcel/generic/ClassGen.java
index 9526bb14..9ed5c42c 100644
--- a/src/main/java/org/apache/bcel/generic/ClassGen.java
+++ b/src/main/java/org/apache/bcel/generic/ClassGen.java
@@ -21,7 +21,6 @@ import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 import java.util.Objects;
-import java.util.stream.Collectors;
 
 import org.apache.bcel.Const;
 import org.apache.bcel.classfile.AccessFlags;
@@ -31,12 +30,12 @@ import org.apache.bcel.classfile.ConstantPool;
 import org.apache.bcel.classfile.Field;
 import org.apache.bcel.classfile.JavaClass;
 import org.apache.bcel.classfile.Method;
+import org.apache.bcel.classfile.RuntimeInvisibleAnnotations;
 import org.apache.bcel.classfile.RuntimeVisibleAnnotations;
 import org.apache.bcel.classfile.SourceFile;
 import org.apache.bcel.classfile.Utility;
 import org.apache.bcel.util.BCELComparator;
 import org.apache.commons.lang3.ArrayUtils;
-import org.apache.commons.lang3.stream.Streams;
 
 /**
  * Template class for building up a java class. May be initialized with an existing Java class (file).


(commons-bcel) 02/09: Javadoc

Posted by gg...@apache.org.
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 7baa87ac608e28a888ca87d3814b4c563d91d2fa
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Apr 1 09:21:54 2024 -0400

    Javadoc
---
 src/main/java/org/apache/bcel/generic/ClassGen.java | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/bcel/generic/ClassGen.java b/src/main/java/org/apache/bcel/generic/ClassGen.java
index 7799b14f..a579c851 100644
--- a/src/main/java/org/apache/bcel/generic/ClassGen.java
+++ b/src/main/java/org/apache/bcel/generic/ClassGen.java
@@ -21,6 +21,7 @@ import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 import java.util.Objects;
+import java.util.stream.Collectors;
 
 import org.apache.bcel.Const;
 import org.apache.bcel.classfile.AccessFlags;
@@ -30,12 +31,12 @@ import org.apache.bcel.classfile.ConstantPool;
 import org.apache.bcel.classfile.Field;
 import org.apache.bcel.classfile.JavaClass;
 import org.apache.bcel.classfile.Method;
-import org.apache.bcel.classfile.RuntimeInvisibleAnnotations;
 import org.apache.bcel.classfile.RuntimeVisibleAnnotations;
 import org.apache.bcel.classfile.SourceFile;
 import org.apache.bcel.classfile.Utility;
 import org.apache.bcel.util.BCELComparator;
 import org.apache.commons.lang3.ArrayUtils;
+import org.apache.commons.lang3.stream.Streams;
 
 /**
  * Template class for building up a java class. May be initialized with an existing Java class (file).
@@ -511,7 +512,7 @@ public class ClassGen extends AccessFlags implements Cloneable {
     }
 
     /**
-     * Look for attributes representing annotations and unpack them.
+     * Unpacks attributes representing annotations.
      */
     private AnnotationEntryGen[] unpackAnnotations(final Attribute[] attrs) {
         final List<AnnotationEntryGen> annotationGenObjs = new ArrayList<>();


(commons-bcel) 08/09: Avoid possible NullPointerException in org.apache.bcel.generic.FieldGenOrMethodGen.addAll(Attribute[])

Posted by gg...@apache.org.
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 f420889909d2920cb45eb006a860e4b04b43a999
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Apr 1 09:37:53 2024 -0400

    Avoid possible NullPointerException in
    org.apache.bcel.generic.FieldGenOrMethodGen.addAll(Attribute[])
---
 src/changes/changes.xml                                        | 1 +
 src/main/java/org/apache/bcel/generic/FieldGenOrMethodGen.java | 6 ++++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 9ac6575a..5246fd3f 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -68,6 +68,7 @@ The <action> type attribute can be add,update,fix,remove.
       <action                  type="update" dev="ggregory" due-to="Gary Gregory">Avoid possible NullPointerException in org.apache.bcel.generic.ClassGen.unpackAnnotations(Attribute[]).</action>
       <action                  type="update" dev="ggregory" due-to="Gary Gregory">Avoid possible NullPointerException in org.apache.bcel.classfile.ParameterAnnotationEntry.createParameterAnnotationEntries(Attribute[]).</action>
       <action                  type="update" dev="ggregory" due-to="Gary Gregory">Avoid possible NullPointerException in org.apache.bcel.generic.ClassGen.ClassGen(JavaClass).</action>
+      <action                  type="update" dev="ggregory" due-to="Gary Gregory">Avoid possible NullPointerException in org.apache.bcel.generic.FieldGenOrMethodGen.addAll(Attribute[]).</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/generic/FieldGenOrMethodGen.java b/src/main/java/org/apache/bcel/generic/FieldGenOrMethodGen.java
index 9f6c5b2d..9b6fbabe 100644
--- a/src/main/java/org/apache/bcel/generic/FieldGenOrMethodGen.java
+++ b/src/main/java/org/apache/bcel/generic/FieldGenOrMethodGen.java
@@ -62,8 +62,10 @@ public abstract class FieldGenOrMethodGen extends AccessFlags implements NamedAn
         super(accessFlags);
     }
 
-    protected void addAll(final Attribute[] attrs) {
-        Collections.addAll(attributeList, attrs);
+    protected void addAll(final Attribute[] attributes) {
+        if (attributes != null) {
+            Collections.addAll(attributeList, attributes);
+        }
     }
 
     /**


(commons-bcel) 03/09: Better local name

Posted by gg...@apache.org.
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 5235833264a5778843d24de54c0188818473e72d
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Apr 1 09:22:37 2024 -0400

    Better local name
---
 src/main/java/org/apache/bcel/generic/ClassGen.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/bcel/generic/ClassGen.java b/src/main/java/org/apache/bcel/generic/ClassGen.java
index a579c851..9526bb14 100644
--- a/src/main/java/org/apache/bcel/generic/ClassGen.java
+++ b/src/main/java/org/apache/bcel/generic/ClassGen.java
@@ -514,9 +514,9 @@ public class ClassGen extends AccessFlags implements Cloneable {
     /**
      * Unpacks attributes representing annotations.
      */
-    private AnnotationEntryGen[] unpackAnnotations(final Attribute[] attrs) {
+    private AnnotationEntryGen[] unpackAnnotations(final Attribute[] attributes) {
         final List<AnnotationEntryGen> annotationGenObjs = new ArrayList<>();
-        for (final Attribute attr : attrs) {
+        for (final Attribute attr : attributes) {
             if (attr instanceof RuntimeVisibleAnnotations) {
                 final RuntimeVisibleAnnotations rva = (RuntimeVisibleAnnotations) attr;
                 rva.forEach(a -> annotationGenObjs.add(new AnnotationEntryGen(a, getConstantPool(), false)));