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
The following commit(s) were added to refs/heads/master by this push:
new 35f3d786 Replace magic number with Const.MAX_ARRAY_DIMENSIONS
35f3d786 is described below
commit 35f3d7860e5ce7fd6882e67f5778f9bdc2e036f2
Author: Gary David Gregory (Code signing key) <[email protected]>
AuthorDate: Tue Nov 22 07:59:05 2022 -0500
Replace magic number with Const.MAX_ARRAY_DIMENSIONS
---
src/main/java/org/apache/bcel/classfile/ElementValue.java | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/main/java/org/apache/bcel/classfile/ElementValue.java
b/src/main/java/org/apache/bcel/classfile/ElementValue.java
index 91c4c159..41a302c4 100644
--- a/src/main/java/org/apache/bcel/classfile/ElementValue.java
+++ b/src/main/java/org/apache/bcel/classfile/ElementValue.java
@@ -21,6 +21,8 @@ import java.io.DataInput;
import java.io.DataOutputStream;
import java.io.IOException;
+import org.apache.bcel.Const;
+
/**
* @since 6.0
*/
@@ -44,6 +46,9 @@ public abstract class ElementValue {
return readElementValue(input, cpool, 0);
}
+ /**
+ * @since 6.7.0
+ */
public static ElementValue readElementValue(final DataInput input, final
ConstantPool cpool, int arrayNesting)
throws IOException {
final byte type = input.readByte();
@@ -71,9 +76,9 @@ public abstract class ElementValue {
case ARRAY:
arrayNesting++;
- if (arrayNesting > 255) {
+ if (arrayNesting > Const.MAX_ARRAY_DIMENSIONS) {
// JVM spec 4.4.1
- throw new ClassFormatException("Arrays are only valid if they
represent 255 or fewer dimensions.");
+ throw new ClassFormatException(String.format("Arrays are only
valid if they represent %,d or fewer dimensions.", Const.MAX_ARRAY_DIMENSIONS));
}
final int numArrayVals = input.readUnsignedShort();
final ElementValue[] evalues = new ElementValue[numArrayVals];