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 6c0452a853a6820a4c885d79637a01e25b80dfde Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Mon Apr 1 10:43:16 2024 -0400 Avoid NullPointerException after calling org.apache.bcel.classfile.LineNumberTable.setLineNumberTable(LineNumber[]) Update constant ref --- src/changes/changes.xml | 1 + .../org/apache/bcel/classfile/LineNumberTable.java | 21 +++++++++++---------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index b36badaa..1505feb5 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -74,6 +74,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.ParameterAnnotations.setParameterAnnotationTable(ParameterAnnotationEntry[]) with null.</action> <action type="update" dev="ggregory" due-to="Gary Gregory">Avoid NullPointerException after calling org.apache.bcel.classfile.LocalVariableTypeTable.setLocalVariableTable(LocalVariable[]) with null.</action> <action type="update" dev="ggregory" due-to="Gary Gregory">Avoid NullPointerException after calling org.apache.bcel.classfile.LocalVariableTable.setLocalVariableTable(LocalVariable[]) with null.</action> + <action type="update" dev="ggregory" due-to="Gary Gregory">Avoid NullPointerException after calling org.apache.bcel.classfile.LineNumberTable.setLineNumberTable(LineNumber[]).</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/LineNumberTable.java b/src/main/java/org/apache/bcel/classfile/LineNumberTable.java index 929b5f18..55f58239 100644 --- a/src/main/java/org/apache/bcel/classfile/LineNumberTable.java +++ b/src/main/java/org/apache/bcel/classfile/LineNumberTable.java @@ -39,7 +39,7 @@ public final class LineNumberTable extends Attribute implements Iterable<LineNum private LineNumber[] lineNumberTable; // Table of line/numbers pairs /** - * Constructs object from input stream. + * Constructs a new instance from a data input stream. * * @param nameIndex Index of name * @param length Content length in bytes @@ -56,13 +56,12 @@ public final class LineNumberTable extends Attribute implements Iterable<LineNum } } - /* - * @param nameIndex Index of name + /** + * Constructs a new instance. * + * @param nameIndex Index of name * @param length Content length in bytes - * * @param lineNumberTable Table of line/numbers pairs - * * @param constantPool Array of constants */ public LineNumberTable(final int nameIndex, final int length, final LineNumber[] lineNumberTable, final ConstantPool constantPool) { @@ -71,9 +70,11 @@ public final class LineNumberTable extends Attribute implements Iterable<LineNum Args.requireU2(this.lineNumberTable.length, "lineNumberTable.length"); } - /* - * Initialize from another object. Note that both objects use the same references (shallow copy). Use copy() for a - * physical copy. + /** + * Constructs a new instance from another. + * <p> + * Note that both objects use the same references (shallow copy). Use copy() for a physical copy. + * </p> */ public LineNumberTable(final LineNumberTable c) { this(c.getNameIndex(), c.getLength(), c.getLineNumberTable(), c.getConstantPool()); @@ -173,7 +174,7 @@ public final class LineNumberTable extends Attribute implements Iterable<LineNum } public int getTableLength() { - return lineNumberTable == null ? 0 : lineNumberTable.length; + return lineNumberTable.length; } @Override @@ -185,7 +186,7 @@ public final class LineNumberTable extends Attribute implements Iterable<LineNum * @param lineNumberTable the line number entries for this table */ public void setLineNumberTable(final LineNumber[] lineNumberTable) { - this.lineNumberTable = lineNumberTable; + this.lineNumberTable = lineNumberTable != null ? lineNumberTable : EMPTY_ARRAY; } /**