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 1079f38522f00608f70a8c3362f1e208d5d7666e
Author: Gary David Gregory (Code signing key) <ggreg...@apache.org>
AuthorDate: Tue Nov 15 13:19:51 2022 -0500

    Normalize exception messages
---
 src/main/java/org/apache/bcel/classfile/Attribute.java     | 2 +-
 src/main/java/org/apache/bcel/classfile/Code.java          | 2 +-
 src/main/java/org/apache/bcel/classfile/ConstantValue.java | 2 +-
 src/main/java/org/apache/bcel/classfile/Deprecated.java    | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/apache/bcel/classfile/Attribute.java 
b/src/main/java/org/apache/bcel/classfile/Attribute.java
index d4a66312..edd4ce1a 100644
--- a/src/main/java/org/apache/bcel/classfile/Attribute.java
+++ b/src/main/java/org/apache/bcel/classfile/Attribute.java
@@ -240,7 +240,7 @@ public abstract class Attribute implements Cloneable, Node {
 
     protected Attribute(final byte tag, final int nameIndex, final int length, 
final ConstantPool constantPool) {
         this.tag = tag;
-        this.name_index = Args.requireU2(nameIndex, 0, 
constantPool.getLength(), "Invalid name index");
+        this.name_index = Args.requireU2(nameIndex, 0, 
constantPool.getLength(), getClass().getSimpleName() + " name index");
         this.length = length;
         this.constant_pool = constantPool;
     }
diff --git a/src/main/java/org/apache/bcel/classfile/Code.java 
b/src/main/java/org/apache/bcel/classfile/Code.java
index 0ec8f6f4..c29fcd39 100644
--- a/src/main/java/org/apache/bcel/classfile/Code.java
+++ b/src/main/java/org/apache/bcel/classfile/Code.java
@@ -66,7 +66,7 @@ public final class Code extends Attribute {
     Code(final int nameIndex, final int length, final DataInput file, final 
ConstantPool constantPool) throws IOException {
         // Initialize with some default values which will be overwritten later
         this(nameIndex, length, file.readUnsignedShort(), 
file.readUnsignedShort(), (byte[]) null, (CodeException[]) null, (Attribute[]) 
null, constantPool);
-        final int codeLength = Args.requireU2(file.readInt(), 1, "Invalid 
length for Code attribute");
+        final int codeLength = Args.requireU2(file.readInt(), 1, "Code length 
attribute");
         code = new byte[codeLength]; // Read byte code
         file.readFully(code);
         /*
diff --git a/src/main/java/org/apache/bcel/classfile/ConstantValue.java 
b/src/main/java/org/apache/bcel/classfile/ConstantValue.java
index 50058ba5..580d26c7 100644
--- a/src/main/java/org/apache/bcel/classfile/ConstantValue.java
+++ b/src/main/java/org/apache/bcel/classfile/ConstantValue.java
@@ -61,7 +61,7 @@ public final class ConstantValue extends Attribute {
      * @param constantPool Array of constants
      */
     public ConstantValue(final int nameIndex, final int length, final int 
constantValueIndex, final ConstantPool constantPool) {
-        super(Const.ATTR_CONSTANT_VALUE, nameIndex, Args.require(2, length, 
"Invalid constant value attribute length"), constantPool);
+        super(Const.ATTR_CONSTANT_VALUE, nameIndex, Args.require(2, length, 
"ConstantValue attribute length"), constantPool);
         this.constantValueIndex = constantValueIndex;
     }
 
diff --git a/src/main/java/org/apache/bcel/classfile/Deprecated.java 
b/src/main/java/org/apache/bcel/classfile/Deprecated.java
index 45f4f721..2c90eb57 100644
--- a/src/main/java/org/apache/bcel/classfile/Deprecated.java
+++ b/src/main/java/org/apache/bcel/classfile/Deprecated.java
@@ -48,7 +48,7 @@ public final class Deprecated extends Attribute {
      * @param constantPool Array of constants
      */
     public Deprecated(final int nameIndex, final int length, final byte[] 
bytes, final ConstantPool constantPool) {
-        super(Const.ATTR_DEPRECATED, nameIndex, Args.require0(length, "Invalid 
Deprecated attribute length"), constantPool);
+        super(Const.ATTR_DEPRECATED, nameIndex, Args.require0(length, 
"Deprecated attribute length"), constantPool);
         this.bytes = bytes;
     }
 

Reply via email to