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 e1f40f8ff8af240d7930de270876e793d9631f01 Author: Gary David Gregory (Code signing key) <ggreg...@apache.org> AuthorDate: Fri Oct 7 10:50:45 2022 -0400 Throw IllegalStateException wrapping a CloneNotSupportedException instead of a plain NullPointerException --- .../java/org/apache/bcel/classfile/FieldOrMethod.java | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/apache/bcel/classfile/FieldOrMethod.java b/src/main/java/org/apache/bcel/classfile/FieldOrMethod.java index 9ab4f04d..dc5373be 100644 --- a/src/main/java/org/apache/bcel/classfile/FieldOrMethod.java +++ b/src/main/java/org/apache/bcel/classfile/FieldOrMethod.java @@ -124,20 +124,16 @@ public abstract class FieldOrMethod extends AccessFlags implements Cloneable, No * @return deep copy of this field */ protected FieldOrMethod copy_(final ConstantPool constantPool) { - FieldOrMethod c = null; - try { - c = (FieldOrMethod) clone(); + final FieldOrMethod c = (FieldOrMethod) clone(); + c.constant_pool = constant_pool; + c.attributes = new Attribute[attributes.length]; + c.attributes_count = attributes_count; // init deprecated field + Arrays.setAll(c.attributes, i -> attributes[i].copy(constant_pool)); + return c; } catch (final CloneNotSupportedException e) { - // ignored, but will cause NPE ... + throw new IllegalStateException(e); } - - c.constant_pool = constant_pool; - c.attributes = new Attribute[attributes.length]; - c.attributes_count = attributes_count; // init deprecated field - - Arrays.setAll(c.attributes, i -> attributes[i].copy(constant_pool)); - return c; } /**