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 2022/11/22 14:40:47 UTC

[commons-bcel] branch master updated (35f3d786 -> 7acacff7)

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 35f3d786 Replace magic number with Const.MAX_ARRAY_DIMENSIONS
     new 31eebe37 Javadoc
     new 7acacff7 Fix exception message

The 2 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:
 .../apache/bcel/classfile/AnnotationDefault.java   |  2 +-
 .../org/apache/bcel/classfile/ElementValue.java    | 45 ++++++++++++++++++++--
 2 files changed, 42 insertions(+), 5 deletions(-)


[commons-bcel] 01/02: Javadoc

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 31eebe37611056411d4bb75e6fd450cae3102ef1
Author: Gary David Gregory (Code signing key) <gg...@apache.org>
AuthorDate: Tue Nov 22 08:05:36 2022 -0500

    Javadoc
---
 src/main/java/org/apache/bcel/classfile/AnnotationDefault.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/bcel/classfile/AnnotationDefault.java b/src/main/java/org/apache/bcel/classfile/AnnotationDefault.java
index afc9a373..1c818ba1 100644
--- a/src/main/java/org/apache/bcel/classfile/AnnotationDefault.java
+++ b/src/main/java/org/apache/bcel/classfile/AnnotationDefault.java
@@ -24,7 +24,7 @@ import java.io.IOException;
 import org.apache.bcel.Const;
 
 /**
- * Represents the default value of a annotation for a method info
+ * Represents the default value of a annotation for a method info.
  *
  * @since 6.0
  */


[commons-bcel] 02/02: Fix exception message

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 7acacff738cff413e951da59cf8f4d1218b700a3
Author: Gary David Gregory (Code signing key) <gg...@apache.org>
AuthorDate: Tue Nov 22 09:40:43 2022 -0500

    Fix exception message
    
    Better internal name
    Javadoc
---
 .../org/apache/bcel/classfile/ElementValue.java    | 45 ++++++++++++++++++++--
 1 file changed, 41 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/apache/bcel/classfile/ElementValue.java b/src/main/java/org/apache/bcel/classfile/ElementValue.java
index 41a302c4..7bcd73bd 100644
--- a/src/main/java/org/apache/bcel/classfile/ElementValue.java
+++ b/src/main/java/org/apache/bcel/classfile/ElementValue.java
@@ -24,6 +24,28 @@ import java.io.IOException;
 import org.apache.bcel.Const;
 
 /**
+ * The element_value structure is documented at https://docs.oracle.com/javase/specs/jvms/se11/html/jvms-4.html#jvms-4.7.16.1
+ *
+ * <pre>
+ * element_value {
+ *    u1 tag;
+ *    union {
+ *        u2 const_value_index;
+ *
+ *        {   u2 type_name_index;
+ *            u2 const_name_index;
+ *        } enum_const_value;
+ *
+ *        u2 class_info_index;
+ *
+ *        annotation annotation_value;
+ *
+ *        {   u2            num_values;
+ *            element_value values[num_values];
+ *        } array_value;
+ *    } value;
+ *}
+ *</pre>
  * @since 6.0
  */
 public abstract class ElementValue {
@@ -42,17 +64,32 @@ public abstract class ElementValue {
     public static final byte PRIMITIVE_SHORT = 'S';
     public static final byte PRIMITIVE_BOOLEAN = 'Z';
 
+    /**
+     * Reads an {@code element_value} as an {@code ElementValue}.
+     *
+     * @param input Raw data input.
+     * @param cpool Constant pool.
+     * @return a new ElementValue.
+     * @throws IOException if an I/O error occurs.
+     */
     public static ElementValue readElementValue(final DataInput input, final ConstantPool cpool) throws IOException {
         return readElementValue(input, cpool, 0);
     }
 
     /**
+     * Reads an {@code element_value} as an {@code ElementValue}.
+     *
+     * @param input Raw data input.
+     * @param cpool Constant pool.
+     * @param arrayNesting level of current array nesting.
+     * @return a new ElementValue.
+     * @throws IOException if an I/O error occurs.
      * @since 6.7.0
      */
     public static ElementValue readElementValue(final DataInput input, final ConstantPool cpool, int arrayNesting)
             throws IOException {
-        final byte type = input.readByte();
-        switch (type) {
+        final byte tag = input.readByte();
+        switch (tag) {
         case PRIMITIVE_BYTE:
         case PRIMITIVE_CHAR:
         case PRIMITIVE_DOUBLE:
@@ -62,7 +99,7 @@ public abstract class ElementValue {
         case PRIMITIVE_SHORT:
         case PRIMITIVE_BOOLEAN:
         case STRING:
-            return new SimpleElementValue(type, input.readUnsignedShort(), cpool);
+            return new SimpleElementValue(tag, input.readUnsignedShort(), cpool);
 
         case ENUM_CONSTANT:
             return new EnumElementValue(ENUM_CONSTANT, input.readUnsignedShort(), input.readUnsignedShort(), cpool);
@@ -88,7 +125,7 @@ public abstract class ElementValue {
             return new ArrayElementValue(ARRAY, evalues, cpool);
 
         default:
-            throw new ClassFormatException("Unexpected element value kind in annotation: " + type);
+            throw new ClassFormatException("Unexpected element value tag in annotation: " + tag);
         }
     }