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 2019/10/11 19:07:22 UTC
[commons-bcel] 02/03: Revert "BCEL-330 (#35)"
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 6618b2566557e25d276da0a43f7372e74a64b98d
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Oct 11 14:56:42 2019 -0400
Revert "BCEL-330 (#35)"
This reverts commit b2dcf8ed70ae66b8702dd0ce60a815d004490ca0.
---
.../org/apache/bcel/classfile/CodeException.java | 3 +-
.../org/apache/bcel/classfile/LocalVariable.java | 3 +-
.../java/org/apache/bcel/generic/MethodGen.java | 40 +++++++++-------------
src/main/java/org/apache/bcel/util/Class2HTML.java | 3 +-
.../bcel/verifier/statics/Pass2Verifier.java | 3 +-
.../structurals/UninitializedObjectType.java | 3 +-
6 files changed, 26 insertions(+), 29 deletions(-)
diff --git a/src/main/java/org/apache/bcel/classfile/CodeException.java b/src/main/java/org/apache/bcel/classfile/CodeException.java
index f51cde1..c79cc9b 100644
--- a/src/main/java/org/apache/bcel/classfile/CodeException.java
+++ b/src/main/java/org/apache/bcel/classfile/CodeException.java
@@ -22,6 +22,7 @@ import java.io.DataOutputStream;
import java.io.IOException;
import org.apache.bcel.Const;
+import org.apache.bcel.Constants;
/**
* This class represents an entry in the exception table of the <em>Code</em>
@@ -30,7 +31,7 @@ import org.apache.bcel.Const;
*
* @see Code
*/
-public final class CodeException implements Cloneable, Node {
+public final class CodeException implements Cloneable, Node, Constants {
private int start_pc; // Range in the code the exception handler is
private int end_pc; // active. start_pc is inclusive, end_pc exclusive
diff --git a/src/main/java/org/apache/bcel/classfile/LocalVariable.java b/src/main/java/org/apache/bcel/classfile/LocalVariable.java
index e8c6315..7ad67e4 100644
--- a/src/main/java/org/apache/bcel/classfile/LocalVariable.java
+++ b/src/main/java/org/apache/bcel/classfile/LocalVariable.java
@@ -22,6 +22,7 @@ import java.io.DataOutputStream;
import java.io.IOException;
import org.apache.bcel.Const;
+import org.apache.bcel.Constants;
/**
* This class represents a local variable within a method. It contains its
@@ -36,7 +37,7 @@ import org.apache.bcel.Const;
* @see LocalVariableTable
* @see LocalVariableTypeTable
*/
-public final class LocalVariable implements Cloneable, Node {
+public final class LocalVariable implements Cloneable, Node, Constants {
private int start_pc; // Range in which the variable is valid
private int length;
diff --git a/src/main/java/org/apache/bcel/generic/MethodGen.java b/src/main/java/org/apache/bcel/generic/MethodGen.java
index 958e28d..b0743e3 100644
--- a/src/main/java/org/apache/bcel/generic/MethodGen.java
+++ b/src/main/java/org/apache/bcel/generic/MethodGen.java
@@ -599,33 +599,27 @@ public class MethodGen extends FieldGenOrMethodGen {
/**
* @since 6.0
*/
- public Attribute[] addAnnotationsAsAttribute(final ConstantPoolGen cp) {
- final Attribute[] attrs = AnnotationEntryGen.getAnnotationAttributes(cp, super.getAnnotationEntries());
+ public void addAnnotationsAsAttribute(final ConstantPoolGen cp) {
+ final Attribute[] attrs = AnnotationEntryGen.getAnnotationAttributes(cp, super.getAnnotationEntries());
for (final Attribute attr : attrs) {
addAttribute(attr);
}
- return attrs;
- }
+ }
/**
* @since 6.0
*/
- public Attribute[] addParameterAnnotationsAsAttribute(final ConstantPoolGen cp) {
- if (!hasParameterAnnotations) {
- return new Attribute[0];
- }
- final Attribute[] attrs = AnnotationEntryGen.getParameterAnnotationAttributes(cp, param_annotations);
- for (final Attribute attr : attrs) {
- addAttribute(attr);
- }
- return attrs;
- }
-
- private void removeAttributes(Attribute[] attrs) {
- for (final Attribute attr : attrs) {
- removeAttribute(attr);
- }
- }
+ public void addParameterAnnotationsAsAttribute(final ConstantPoolGen cp) {
+ if (!hasParameterAnnotations) {
+ return;
+ }
+ final Attribute[] attrs = AnnotationEntryGen.getParameterAnnotationAttributes(cp,param_annotations);
+ if (attrs != null) {
+ for (final Attribute attr : attrs) {
+ addAttribute(attr);
+ }
+ }
+ }
/**
@@ -687,8 +681,8 @@ public class MethodGen extends FieldGenOrMethodGen {
max_stack, max_locals, byte_code, c_exc, code_attrs, _cp.getConstantPool());
addAttribute(code);
}
- Attribute[] annotations = addAnnotationsAsAttribute(_cp);
- Attribute[] parameterAnnotations = addParameterAnnotationsAsAttribute(_cp);
+ addAnnotationsAsAttribute(_cp);
+ addParameterAnnotationsAsAttribute(_cp);
ExceptionTable et = null;
if (throws_vec.size() > 0) {
addAttribute(et = getExceptionTable(_cp));
@@ -712,8 +706,6 @@ public class MethodGen extends FieldGenOrMethodGen {
if (et != null) {
removeAttribute(et);
}
- removeAttributes(annotations);
- removeAttributes(parameterAnnotations);
return m;
}
diff --git a/src/main/java/org/apache/bcel/util/Class2HTML.java b/src/main/java/org/apache/bcel/util/Class2HTML.java
index e652665..1a34723 100644
--- a/src/main/java/org/apache/bcel/util/Class2HTML.java
+++ b/src/main/java/org/apache/bcel/util/Class2HTML.java
@@ -25,6 +25,7 @@ import java.util.HashSet;
import java.util.Set;
import org.apache.bcel.Const;
+import org.apache.bcel.Constants;
import org.apache.bcel.classfile.Attribute;
import org.apache.bcel.classfile.ClassParser;
import org.apache.bcel.classfile.ConstantPool;
@@ -52,7 +53,7 @@ import org.apache.bcel.classfile.Utility;
* the Code frame.
*
*/
-public class Class2HTML {
+public class Class2HTML implements Constants {
private final JavaClass java_class; // current class object
private final String dir;
diff --git a/src/main/java/org/apache/bcel/verifier/statics/Pass2Verifier.java b/src/main/java/org/apache/bcel/verifier/statics/Pass2Verifier.java
index e350657..fe79b22 100644
--- a/src/main/java/org/apache/bcel/verifier/statics/Pass2Verifier.java
+++ b/src/main/java/org/apache/bcel/verifier/statics/Pass2Verifier.java
@@ -25,6 +25,7 @@ import java.util.Map;
import java.util.Set;
import org.apache.bcel.Const;
+import org.apache.bcel.Constants;
import org.apache.bcel.Repository;
import org.apache.bcel.classfile.Attribute;
import org.apache.bcel.classfile.ClassFormatException;
@@ -81,7 +82,7 @@ import org.apache.bcel.verifier.exc.LocalVariableInfoInconsistentException;
*
* @see #do_verify()
*/
-public final class Pass2Verifier extends PassVerifier {
+public final class Pass2Verifier extends PassVerifier implements Constants {
/**
* The LocalVariableInfo instances used by Pass3bVerifier.
diff --git a/src/main/java/org/apache/bcel/verifier/structurals/UninitializedObjectType.java b/src/main/java/org/apache/bcel/verifier/structurals/UninitializedObjectType.java
index 4b8f637..78fe4cc 100644
--- a/src/main/java/org/apache/bcel/verifier/structurals/UninitializedObjectType.java
+++ b/src/main/java/org/apache/bcel/verifier/structurals/UninitializedObjectType.java
@@ -19,6 +19,7 @@ package org.apache.bcel.verifier.structurals;
import org.apache.bcel.Const;
+import org.apache.bcel.Constants;
import org.apache.bcel.generic.ObjectType;
import org.apache.bcel.generic.ReferenceType;
@@ -28,7 +29,7 @@ import org.apache.bcel.generic.ReferenceType;
* more details.
*
*/
-public class UninitializedObjectType extends ReferenceType {
+public class UninitializedObjectType extends ReferenceType implements Constants {
/** The "initialized" version. */
private final ObjectType initialized;