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 17:47:26 UTC
(commons-bcel) branch master updated (fb85ced5 -> 1dbef18b)
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 fb85ced5 Add null guard for InstructionFactory.createInvoke() #289
new 511a7787 Avoid NullPointerException calling org.apache.bcel.generic.InstructionList.redirectLocalVariables(LocalVariableGen[], InstructionHandle, InstructionHandle) with null
new 95552fea Avoid NullPointerException calling org.apache.bcel.generic.InstructionList.redirectExceptionHandlers(CodeExceptionGen[], InstructionHandle, InstructionHandle) with null
new ca1add6d Avoid NullPointerException calling org.apache.bcel.generic.InstructionList.findHandle(InstructionHandle[], int[], int, int) with null
new 87eac0ab Fix typo in comment
new 0aebd69e Avoid NullPointerException calling org.apache.bcel.generic.MethodGen.setArgumentTypes(Type[]) with null
new c032ef5d Avoid NullPointerException calling org.apache.bcel.generic.MethodGen.setArgumentNames(String[]) with null
new 0e4e0d69 Avoid NullPointerException calling org.apache.bcel.generic.MethodGen.removeRuntimeAttributes(Attribute[]) with null
new 1dbef18b Avoid NullPointerException calling org.apache.bcel.generic.MethodGen.makeMutableVersion(AnnotationEntry[]) with null
The 8 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 | 7 +++
.../org/apache/bcel/generic/InstructionList.java | 51 +++++++++++-----------
.../java/org/apache/bcel/generic/MethodGen.java | 24 ++++------
src/main/java/org/apache/bcel/generic/Select.java | 2 +-
4 files changed, 43 insertions(+), 41 deletions(-)
(commons-bcel) 06/08: Avoid NullPointerException calling org.apache.bcel.generic.MethodGen.setArgumentNames(String[]) with null
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 c032ef5d7db20640d8cd4847df4d46081842f338
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Apr 1 11:30:20 2024 -0400
Avoid NullPointerException calling
org.apache.bcel.generic.MethodGen.setArgumentNames(String[]) with null
---
src/changes/changes.xml | 1 +
src/main/java/org/apache/bcel/generic/MethodGen.java | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 7004873e..28970421 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -93,6 +93,7 @@ The <action> type attribute can be add,update,fix,remove.
<action type="update" dev="ggregory" due-to="Gary Gregory">Avoid NullPointerException calling org.apache.bcel.generic.InstructionList.redirectExceptionHandlers(CodeExceptionGen[], InstructionHandle, InstructionHandle) with null.</action>
<action type="update" dev="ggregory" due-to="Gary Gregory">Avoid NullPointerException calling org.apache.bcel.generic.InstructionList.findHandle(InstructionHandle[], int[], int, int) with null.</action>
<action type="update" dev="ggregory" due-to="Gary Gregory">Avoid NullPointerException calling org.apache.bcel.generic.MethodGen.setArgumentTypes(Type[]) with null.</action>
+ <action type="update" dev="ggregory" due-to="Gary Gregory">Avoid NullPointerException calling org.apache.bcel.generic.MethodGen.setArgumentNames(String[]) 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/generic/MethodGen.java b/src/main/java/org/apache/bcel/generic/MethodGen.java
index 37e21679..b93400f8 100644
--- a/src/main/java/org/apache/bcel/generic/MethodGen.java
+++ b/src/main/java/org/apache/bcel/generic/MethodGen.java
@@ -1034,7 +1034,7 @@ public class MethodGen extends FieldGenOrMethodGen {
}
public void setArgumentNames(final String[] argNames) {
- this.argNames = argNames;
+ this.argNames = ArrayUtils.nullToEmpty(argNames);
}
public void setArgumentType(final int i, final Type type) {
(commons-bcel) 05/08: Avoid NullPointerException calling org.apache.bcel.generic.MethodGen.setArgumentTypes(Type[]) with null
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 0aebd69e9fa517a044c491d23fcf2bc22bbe5d09
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Apr 1 11:28:46 2024 -0400
Avoid NullPointerException calling
org.apache.bcel.generic.MethodGen.setArgumentTypes(Type[]) with null
---
src/changes/changes.xml | 1 +
src/main/java/org/apache/bcel/generic/MethodGen.java | 8 +++-----
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 4d0d81a0..7004873e 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -92,6 +92,7 @@ The <action> type attribute can be add,update,fix,remove.
<action type="update" dev="ggregory" due-to="Gary Gregory">Avoid NullPointerException calling org.apache.bcel.generic.InstructionList.redirectLocalVariables(LocalVariableGen[], InstructionHandle, InstructionHandle) with null.</action>
<action type="update" dev="ggregory" due-to="Gary Gregory">Avoid NullPointerException calling org.apache.bcel.generic.InstructionList.redirectExceptionHandlers(CodeExceptionGen[], InstructionHandle, InstructionHandle) with null.</action>
<action type="update" dev="ggregory" due-to="Gary Gregory">Avoid NullPointerException calling org.apache.bcel.generic.InstructionList.findHandle(InstructionHandle[], int[], int, int) with null.</action>
+ <action type="update" dev="ggregory" due-to="Gary Gregory">Avoid NullPointerException calling org.apache.bcel.generic.MethodGen.setArgumentTypes(Type[]) 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/generic/MethodGen.java b/src/main/java/org/apache/bcel/generic/MethodGen.java
index 1cccda44..37e21679 100644
--- a/src/main/java/org/apache/bcel/generic/MethodGen.java
+++ b/src/main/java/org/apache/bcel/generic/MethodGen.java
@@ -1042,7 +1042,7 @@ public class MethodGen extends FieldGenOrMethodGen {
}
public void setArgumentTypes(final Type[] argTypes) {
- this.argTypes = argTypes;
+ this.argTypes = argTypes != null ? argTypes : Type.NO_ARGS;
}
public void setClassName(final String className) { // TODO could be package-protected?
@@ -1059,10 +1059,8 @@ public class MethodGen extends FieldGenOrMethodGen {
public void setMaxLocals() { // TODO could be package-protected? (some tests would need repackaging)
if (il != null) {
int max = isStatic() ? 0 : 1;
- if (argTypes != null) {
- for (final Type argType : argTypes) {
- max += argType.getSize();
- }
+ for (final Type argType : argTypes) {
+ max += argType.getSize();
}
for (InstructionHandle ih = il.getStart(); ih != null; ih = ih.getNext()) {
final Instruction ins = ih.getInstruction();
(commons-bcel) 02/08: Avoid NullPointerException calling org.apache.bcel.generic.InstructionList.redirectExceptionHandlers(CodeExceptionGen[], InstructionHandle, InstructionHandle) with null
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 95552fea8528697b0679f2b0a03e4426304f580d
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Apr 1 11:22:43 2024 -0400
Avoid NullPointerException calling
org.apache.bcel.generic.InstructionList.redirectExceptionHandlers(CodeExceptionGen[],
InstructionHandle, InstructionHandle) with null
---
src/changes/changes.xml | 1 +
src/main/java/org/apache/bcel/generic/InstructionList.java | 4 ++--
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index bbf421d3..1ee1e74f 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -90,6 +90,7 @@ 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.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>
<action type="update" dev="ggregory" due-to="Gary Gregory">Avoid NullPointerException calling org.apache.bcel.generic.InstructionList.redirectLocalVariables(LocalVariableGen[], InstructionHandle, InstructionHandle) with null.</action>
+ <action type="update" dev="ggregory" due-to="Gary Gregory">Avoid NullPointerException calling org.apache.bcel.generic.InstructionList.redirectExceptionHandlers(CodeExceptionGen[], InstructionHandle, InstructionHandle) 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/generic/InstructionList.java b/src/main/java/org/apache/bcel/generic/InstructionList.java
index 2f8c11aa..c840a7e7 100644
--- a/src/main/java/org/apache/bcel/generic/InstructionList.java
+++ b/src/main/java/org/apache/bcel/generic/InstructionList.java
@@ -957,7 +957,7 @@ public class InstructionList implements Iterable<InstructionHandle> {
* @see MethodGen
*/
public void redirectExceptionHandlers(final CodeExceptionGen[] exceptions, final InstructionHandle oldTarget, final InstructionHandle newTarget) {
- for (final CodeExceptionGen exception : exceptions) {
+ Streams.of(exceptions).forEach(exception -> {
if (exception.getStartPC() == oldTarget) {
exception.setStartPC(newTarget);
}
@@ -967,7 +967,7 @@ public class InstructionList implements Iterable<InstructionHandle> {
if (exception.getHandlerPC() == oldTarget) {
exception.setHandlerPC(newTarget);
}
- }
+ });
}
/**
(commons-bcel) 01/08: Avoid NullPointerException calling org.apache.bcel.generic.InstructionList.redirectLocalVariables(LocalVariableGen[], InstructionHandle, InstructionHandle) with null
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 511a7787d4298082872ef1b36995f7247d0fea4d
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Apr 1 11:21:26 2024 -0400
Avoid NullPointerException calling
org.apache.bcel.generic.InstructionList.redirectLocalVariables(LocalVariableGen[],
InstructionHandle, InstructionHandle) with null
---
src/changes/changes.xml | 1 +
src/main/java/org/apache/bcel/generic/InstructionList.java | 11 +++++------
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index e6541f74..bbf421d3 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -89,6 +89,7 @@ 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.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>
+ <action type="update" dev="ggregory" due-to="Gary Gregory">Avoid NullPointerException calling org.apache.bcel.generic.InstructionList.redirectLocalVariables(LocalVariableGen[], InstructionHandle, InstructionHandle) 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/generic/InstructionList.java b/src/main/java/org/apache/bcel/generic/InstructionList.java
index ca053e44..2f8c11aa 100644
--- a/src/main/java/org/apache/bcel/generic/InstructionList.java
+++ b/src/main/java/org/apache/bcel/generic/InstructionList.java
@@ -31,6 +31,7 @@ import org.apache.bcel.Const;
import org.apache.bcel.classfile.Constant;
import org.apache.bcel.util.ByteSequence;
import org.apache.commons.lang3.ArrayUtils;
+import org.apache.commons.lang3.stream.Streams;
/**
* This class is a container for a list of <a href="Instruction.html">Instruction</a> objects. Instructions can be
@@ -978,16 +979,14 @@ public class InstructionList implements Iterable<InstructionHandle> {
* @see MethodGen
*/
public void redirectLocalVariables(final LocalVariableGen[] lg, final InstructionHandle oldTarget, final InstructionHandle newTarget) {
- for (final LocalVariableGen element : lg) {
- final InstructionHandle start = element.getStart();
- final InstructionHandle end = element.getEnd();
- if (start == oldTarget) {
+ Streams.of(lg).forEach(element -> {
+ if (element.getStart() == oldTarget) {
element.setStart(newTarget);
}
- if (end == oldTarget) {
+ if (element.getEnd() == oldTarget) {
element.setEnd(newTarget);
}
- }
+ });
}
/**
(commons-bcel) 04/08: Fix typo in comment
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 87eac0ab55adfdb043017016d73ff101747093c5
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Apr 1 11:25:11 2024 -0400
Fix typo in comment
---
src/main/java/org/apache/bcel/generic/Select.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/java/org/apache/bcel/generic/Select.java b/src/main/java/org/apache/bcel/generic/Select.java
index ce1efc3b..b08e5596 100644
--- a/src/main/java/org/apache/bcel/generic/Select.java
+++ b/src/main/java/org/apache/bcel/generic/Select.java
@@ -83,7 +83,7 @@ public abstract class Select extends BranchInstruction implements VariableLength
* @param defaultTarget default instruction target
*/
Select(final short opcode, final int[] match, final InstructionHandle[] targets, final InstructionHandle defaultTarget) {
- // don't set default target before instuction is built
+ // don't set default target before instruction is built
super(opcode, null);
this.match = match;
this.targets = targets;
(commons-bcel) 03/08: Avoid NullPointerException calling org.apache.bcel.generic.InstructionList.findHandle(InstructionHandle[], int[], int, int) with null
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 ca1add6d481319fb80ac2930c8500484b2e000e3
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Apr 1 11:24:05 2024 -0400
Avoid NullPointerException calling
org.apache.bcel.generic.InstructionList.findHandle(InstructionHandle[],
int[], int, int) with null
---
src/changes/changes.xml | 1 +
.../org/apache/bcel/generic/InstructionList.java | 36 ++++++++++++----------
2 files changed, 20 insertions(+), 17 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 1ee1e74f..4d0d81a0 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -91,6 +91,7 @@ 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.BootstrapMethods.setBootstrapMethods(BootstrapMethod[]) with null.</action>
<action type="update" dev="ggregory" due-to="Gary Gregory">Avoid NullPointerException calling org.apache.bcel.generic.InstructionList.redirectLocalVariables(LocalVariableGen[], InstructionHandle, InstructionHandle) with null.</action>
<action type="update" dev="ggregory" due-to="Gary Gregory">Avoid NullPointerException calling org.apache.bcel.generic.InstructionList.redirectExceptionHandlers(CodeExceptionGen[], InstructionHandle, InstructionHandle) with null.</action>
+ <action type="update" dev="ggregory" due-to="Gary Gregory">Avoid NullPointerException calling org.apache.bcel.generic.InstructionList.findHandle(InstructionHandle[], int[], int, int) 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/generic/InstructionList.java b/src/main/java/org/apache/bcel/generic/InstructionList.java
index c840a7e7..0f4340b7 100644
--- a/src/main/java/org/apache/bcel/generic/InstructionList.java
+++ b/src/main/java/org/apache/bcel/generic/InstructionList.java
@@ -58,23 +58,25 @@ public class InstructionList implements Iterable<InstructionHandle> {
* @return target position's instruction handle if available
*/
public static InstructionHandle findHandle(final InstructionHandle[] ihs, final int[] pos, final int count, final int target) {
- int l = 0;
- int r = count - 1;
- /*
- * Do a binary search since the pos array is orderd.
- */
- do {
- final int i = l + r >>> 1;
- final int j = pos[i];
- if (j == target) {
- return ihs[i];
- }
- if (target < j) {
- r = i - 1;
- } else {
- l = i + 1;
- }
- } while (l <= r);
+ if (ihs != null && pos != null) {
+ int l = 0;
+ int r = count - 1;
+ /*
+ * Do a binary search since the pos array is orderd.
+ */
+ do {
+ final int i = l + r >>> 1;
+ final int j = pos[i];
+ if (j == target) {
+ return ihs[i];
+ }
+ if (target < j) {
+ r = i - 1;
+ } else {
+ l = i + 1;
+ }
+ } while (l <= r);
+ }
return null;
}
(commons-bcel) 07/08: Avoid NullPointerException calling org.apache.bcel.generic.MethodGen.removeRuntimeAttributes(Attribute[]) with null
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 0e4e0d69df4cfc062e18891953bee085c9f79dfa
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Apr 1 11:31:52 2024 -0400
Avoid NullPointerException calling
org.apache.bcel.generic.MethodGen.removeRuntimeAttributes(Attribute[])
with null
---
src/changes/changes.xml | 1 +
src/main/java/org/apache/bcel/generic/MethodGen.java | 7 +++----
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 28970421..c4d1f379 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -94,6 +94,7 @@ The <action> type attribute can be add,update,fix,remove.
<action type="update" dev="ggregory" due-to="Gary Gregory">Avoid NullPointerException calling org.apache.bcel.generic.InstructionList.findHandle(InstructionHandle[], int[], int, int) with null.</action>
<action type="update" dev="ggregory" due-to="Gary Gregory">Avoid NullPointerException calling org.apache.bcel.generic.MethodGen.setArgumentTypes(Type[]) with null.</action>
<action type="update" dev="ggregory" due-to="Gary Gregory">Avoid NullPointerException calling org.apache.bcel.generic.MethodGen.setArgumentNames(String[]) with null.</action>
+ <action type="update" dev="ggregory" due-to="Gary Gregory">Avoid NullPointerException calling org.apache.bcel.generic.MethodGen.removeRuntimeAttributes(Attribute[]) 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/generic/MethodGen.java b/src/main/java/org/apache/bcel/generic/MethodGen.java
index b93400f8..9167a15f 100644
--- a/src/main/java/org/apache/bcel/generic/MethodGen.java
+++ b/src/main/java/org/apache/bcel/generic/MethodGen.java
@@ -44,6 +44,7 @@ import org.apache.bcel.classfile.RuntimeVisibleParameterAnnotations;
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 method. This is done by defining exception handlers, adding thrown exceptions, local
@@ -1023,10 +1024,8 @@ public class MethodGen extends FieldGenOrMethodGen {
*
* @since 6.5.0
*/
- public void removeRuntimeAttributes(final Attribute[] attrs) {
- for (final Attribute attr : attrs) {
- removeAttribute(attr);
- }
+ public void removeRuntimeAttributes(final Attribute[] attributes) {
+ Streams.of(attributes).forEach(this::removeAttribute);
}
public void setArgumentName(final int i, final String name) {
(commons-bcel) 08/08: Avoid NullPointerException calling org.apache.bcel.generic.MethodGen.makeMutableVersion(AnnotationEntry[]) with null
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 1dbef18b2f548174b439a72febf5de78399856ee
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Apr 1 11:35:07 2024 -0400
Avoid NullPointerException calling
org.apache.bcel.generic.MethodGen.makeMutableVersion(AnnotationEntry[])
with null
---
src/changes/changes.xml | 1 +
src/main/java/org/apache/bcel/generic/MethodGen.java | 7 ++-----
2 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index c4d1f379..0325b739 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -95,6 +95,7 @@ The <action> type attribute can be add,update,fix,remove.
<action type="update" dev="ggregory" due-to="Gary Gregory">Avoid NullPointerException calling org.apache.bcel.generic.MethodGen.setArgumentTypes(Type[]) with null.</action>
<action type="update" dev="ggregory" due-to="Gary Gregory">Avoid NullPointerException calling org.apache.bcel.generic.MethodGen.setArgumentNames(String[]) with null.</action>
<action type="update" dev="ggregory" due-to="Gary Gregory">Avoid NullPointerException calling org.apache.bcel.generic.MethodGen.removeRuntimeAttributes(Attribute[]) with null.</action>
+ <action type="update" dev="ggregory" due-to="Gary Gregory">Avoid NullPointerException calling org.apache.bcel.generic.MethodGen.makeMutableVersion(AnnotationEntry[]) 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/generic/MethodGen.java b/src/main/java/org/apache/bcel/generic/MethodGen.java
index 9167a15f..0f3cc8c9 100644
--- a/src/main/java/org/apache/bcel/generic/MethodGen.java
+++ b/src/main/java/org/apache/bcel/generic/MethodGen.java
@@ -24,6 +24,7 @@ import java.util.Hashtable;
import java.util.List;
import java.util.Objects;
import java.util.Stack;
+import java.util.stream.Collectors;
import org.apache.bcel.Const;
import org.apache.bcel.classfile.AnnotationEntry;
@@ -894,11 +895,7 @@ public class MethodGen extends FieldGenOrMethodGen {
}
private List<AnnotationEntryGen> makeMutableVersion(final AnnotationEntry[] mutableArray) {
- final List<AnnotationEntryGen> result = new ArrayList<>();
- for (final AnnotationEntry element : mutableArray) {
- result.add(new AnnotationEntryGen(element, getConstantPool(), false));
- }
- return result;
+ return Streams.of(mutableArray).map(ae -> new AnnotationEntryGen(ae, getConstantPool(), false)).collect(Collectors.toList());
}
/**