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 2020/10/15 22:14:41 UTC
[commons-bcel] branch master updated: minor improvements to
comments and toString() methods (#71)
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 3f281e4 minor improvements to comments and toString() methods (#71)
3f281e4 is described below
commit 3f281e465b404f0a5dd81cc887b2251c82b8ab38
Author: Mark Roberts <ma...@users.noreply.github.com>
AuthorDate: Thu Oct 15 15:14:31 2020 -0700
minor improvements to comments and toString() methods (#71)
---
.../org/apache/bcel/classfile/AnnotationEntry.java | 3 +++
.../java/org/apache/bcel/classfile/Annotations.java | 21 +++++++++++++++++++++
.../java/org/apache/bcel/classfile/Deprecated.java | 2 +-
.../java/org/apache/bcel/generic/INVOKEDYNAMIC.java | 4 ++++
4 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/src/main/java/org/apache/bcel/classfile/AnnotationEntry.java b/src/main/java/org/apache/bcel/classfile/AnnotationEntry.java
index 6540e2d..16d8439 100644
--- a/src/main/java/org/apache/bcel/classfile/AnnotationEntry.java
+++ b/src/main/java/org/apache/bcel/classfile/AnnotationEntry.java
@@ -142,7 +142,10 @@ public class AnnotationEntry implements Node {
result.append("(");
for (final ElementValuePair element : evPairs) {
result.append(element.toShortString());
+ result.append(", ");
}
+ // remove last ", "
+ result.setLength(result.length() - 2);
result.append(")");
}
return result.toString();
diff --git a/src/main/java/org/apache/bcel/classfile/Annotations.java b/src/main/java/org/apache/bcel/classfile/Annotations.java
index 584cc5f..0aeac31 100644
--- a/src/main/java/org/apache/bcel/classfile/Annotations.java
+++ b/src/main/java/org/apache/bcel/classfile/Annotations.java
@@ -21,6 +21,8 @@ import java.io.DataInput;
import java.io.DataOutputStream;
import java.io.IOException;
+import org.apache.bcel.Const;
+
/**
* base class for annotations
*
@@ -37,6 +39,7 @@ public abstract class Annotations extends Attribute {
* @param length Content length in bytes
* @param input Input stream
* @param constant_pool Array of constants
+ * @param isRuntimeVisible is Annotation visible at runtime?
*/
Annotations(final byte annotation_type, final int name_index, final int length, final DataInput input,
final ConstantPool constant_pool, final boolean isRuntimeVisible) throws IOException {
@@ -54,6 +57,7 @@ public abstract class Annotations extends Attribute {
* @param length Content length in bytes
* @param annotationTable the actual annotations
* @param constantPool Array of constants
+ * @param isRuntimeVisible is Annotation visible at runtime?
*/
public Annotations(final byte annotationType, final int nameIndex, final int length, final AnnotationEntry[] annotationTable,
final ConstantPool constantPool, final boolean isRuntimeVisible) {
@@ -110,4 +114,21 @@ public abstract class Annotations extends Attribute {
element.dump(dos);
}
}
+
+ /**
+ * @return String representation
+ */
+ @Override
+ public final String toString() {
+ final StringBuilder buf = new StringBuilder(Const.getAttributeName(getTag()));
+ buf.append(":\n");
+ for (int i = 0; i < annotationTable.length; i++) {
+ buf.append(" ").append(annotationTable[i]);
+ if (i < annotationTable.length - 1) {
+ buf.append('\n');
+ }
+ }
+ return buf.toString();
+ }
+
}
diff --git a/src/main/java/org/apache/bcel/classfile/Deprecated.java b/src/main/java/org/apache/bcel/classfile/Deprecated.java
index 0b67e86..e7c6184 100644
--- a/src/main/java/org/apache/bcel/classfile/Deprecated.java
+++ b/src/main/java/org/apache/bcel/classfile/Deprecated.java
@@ -125,7 +125,7 @@ public final class Deprecated extends Attribute {
*/
@Override
public String toString() {
- return Const.getAttributeName(Const.ATTR_DEPRECATED);
+ return Const.getAttributeName(Const.ATTR_DEPRECATED) + ": true";
}
diff --git a/src/main/java/org/apache/bcel/generic/INVOKEDYNAMIC.java b/src/main/java/org/apache/bcel/generic/INVOKEDYNAMIC.java
index ae31a0c..e740e5b 100644
--- a/src/main/java/org/apache/bcel/generic/INVOKEDYNAMIC.java
+++ b/src/main/java/org/apache/bcel/generic/INVOKEDYNAMIC.java
@@ -119,6 +119,10 @@ public class INVOKEDYNAMIC extends InvokeInstruction {
/**
* Override the parent method because our classname is held elsewhere.
+ *
+ * Note: Contrary to this method's name it does not return the classname of the
+ * invoke target; rather it returns the name of the method that will be used to
+ * invoke the Lambda method generated by this invoke dynamic instruction.
*/
@Override
public String getClassName( final ConstantPoolGen cpg ) {