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:20 UTC

[commons-bcel] branch master updated (c5329a6 -> cf60dc6)

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 c5329a6  Update properties for next release.
     new 53e5fb4  Revert "[BCEL-330] Remove unnecessary references to Constants."
     new 6618b25  Revert "BCEL-330 (#35)"
     new cf60dc6  [BCEL-330] Remove unnecessary references to Constants.

The 3 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:
 src/changes/changes.xml                            |  3 --
 .../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 +-
 .../bcel/classfile/CodeExceptionTestCase.java}     | 17 +++++----
 .../bcel/classfile/LocalVariableTestCase.java}     | 17 +++++----
 .../org/apache/bcel/util/Class2HTMLTestCase.java   | 11 ++++++
 .../statics/Pass2VerifierTestCase.java}            | 24 ++++++-------
 .../UninitializedObjectTypeTestCase.java}          | 24 ++++++-------
 12 files changed, 81 insertions(+), 70 deletions(-)
 copy src/{main/java/org/apache/bcel/classfile/Node.java => test/java/org/apache/bcel/classfile/CodeExceptionTestCase.java} (73%)
 copy src/{main/java/org/apache/bcel/classfile/Node.java => test/java/org/apache/bcel/classfile/LocalVariableTestCase.java} (73%)
 copy src/test/java/org/apache/bcel/{data/AttributeTestClassEM01.java => verifier/statics/Pass2VerifierTestCase.java} (73%)
 copy src/test/java/org/apache/bcel/{data/AttributeTestClassEM01.java => verifier/structurals/UninitializedObjectTypeTestCase.java} (72%)


[commons-bcel] 03/03: [BCEL-330] Remove unnecessary references to Constants.

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 cf60dc62b269a44ad5fcd43bd77ba4431de49e0c
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Oct 11 15:07:16 2019 -0400

    [BCEL-330] Remove unnecessary references to Constants.
    
    Add tests to enforce binary compatibilty. If this PR was merged, we
    would no longer compile to run.
---
 .../bcel/classfile/CodeExceptionTestCase.java      | 32 ++++++++++++++++++++++
 .../bcel/classfile/LocalVariableTestCase.java      | 32 ++++++++++++++++++++++
 .../org/apache/bcel/util/Class2HTMLTestCase.java   | 11 ++++++++
 .../statics/Pass2VerifierTestCase.java}            | 31 +++++++--------------
 .../UninitializedObjectTypeTestCase.java}          | 31 +++++++--------------
 5 files changed, 95 insertions(+), 42 deletions(-)

diff --git a/src/test/java/org/apache/bcel/classfile/CodeExceptionTestCase.java b/src/test/java/org/apache/bcel/classfile/CodeExceptionTestCase.java
new file mode 100644
index 0000000..141cc06
--- /dev/null
+++ b/src/test/java/org/apache/bcel/classfile/CodeExceptionTestCase.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.bcel.classfile;
+
+import org.junit.Test;
+
+public class CodeExceptionTestCase {
+
+    /**
+     * Tests that we do not break binary compatibility with BCEL-330.
+     */
+    @Test
+    public void testReferenceToConstant() {
+        @SuppressWarnings("unused")
+        short referenceToConstant = CodeException.AALOAD;
+    }
+}
diff --git a/src/test/java/org/apache/bcel/classfile/LocalVariableTestCase.java b/src/test/java/org/apache/bcel/classfile/LocalVariableTestCase.java
new file mode 100644
index 0000000..ac03a44
--- /dev/null
+++ b/src/test/java/org/apache/bcel/classfile/LocalVariableTestCase.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.bcel.classfile;
+
+import org.junit.Test;
+
+public class LocalVariableTestCase {
+
+    /**
+     * Tests that we do not break binary compatibility with BCEL-330.
+     */
+    @Test
+    public void testReferenceToConstant() {
+        @SuppressWarnings("unused")
+        short referenceToConstant = LocalVariable.AALOAD;
+    }
+}
diff --git a/src/test/java/org/apache/bcel/util/Class2HTMLTestCase.java b/src/test/java/org/apache/bcel/util/Class2HTMLTestCase.java
index ca455b1..02d3eb7 100644
--- a/src/test/java/org/apache/bcel/util/Class2HTMLTestCase.java
+++ b/src/test/java/org/apache/bcel/util/Class2HTMLTestCase.java
@@ -22,6 +22,7 @@ import java.io.FileInputStream;
 
 import org.apache.bcel.classfile.ClassParser;
 import org.junit.Assert;
+import org.junit.Test;
 
 import junit.framework.TestCase;
 
@@ -40,4 +41,14 @@ public class Class2HTMLTestCase extends TestCase {
             new Class2HTML(parser.parse(), outputDir.getAbsolutePath() + "/");
         }
     }
+    
+    /**
+     * Tests that we do not break binary compatibility with BCEL-330.
+     */
+    @Test
+    public void testReferenceToConstant() {
+        @SuppressWarnings("unused")
+        short referenceToConstant = Class2HTML.AALOAD;
+    }
+
 }
diff --git a/src/test/java/org/apache/bcel/util/Class2HTMLTestCase.java b/src/test/java/org/apache/bcel/verifier/statics/Pass2VerifierTestCase.java
similarity index 50%
copy from src/test/java/org/apache/bcel/util/Class2HTMLTestCase.java
copy to src/test/java/org/apache/bcel/verifier/statics/Pass2VerifierTestCase.java
index ca455b1..e336a73 100644
--- a/src/test/java/org/apache/bcel/util/Class2HTMLTestCase.java
+++ b/src/test/java/org/apache/bcel/verifier/statics/Pass2VerifierTestCase.java
@@ -15,29 +15,18 @@
  * limitations under the License.
  */
 
-package org.apache.bcel.util;
+package org.apache.bcel.verifier.statics;
 
-import java.io.File;
-import java.io.FileInputStream;
+import org.junit.Test;
 
-import org.apache.bcel.classfile.ClassParser;
-import org.junit.Assert;
+public class Pass2VerifierTestCase {
 
-import junit.framework.TestCase;
-
-public class Class2HTMLTestCase extends TestCase {
-
-    public void testConvertJavaUtil() throws Exception {
-        final File outputDir = new File("target/test-output/html");
-        if (!outputDir.mkdirs()) { // either was not created or already existed
-            Assert.assertTrue(outputDir.isDirectory()); // fail if missing
-        }
-
-        try (FileInputStream file = new FileInputStream("target/test-classes/Java8Example.class")) {
-
-            final ClassParser parser = new ClassParser(file, "Java8Example.class");
-
-            new Class2HTML(parser.parse(), outputDir.getAbsolutePath() + "/");
-        }
+    /**
+     * Tests that we do not break binary compatibility with BCEL-330.
+     */
+    @Test
+    public void testReferenceToConstant() {
+        @SuppressWarnings("unused")
+        short referenceToConstant = Pass2Verifier.AALOAD;
     }
 }
diff --git a/src/test/java/org/apache/bcel/util/Class2HTMLTestCase.java b/src/test/java/org/apache/bcel/verifier/structurals/UninitializedObjectTypeTestCase.java
similarity index 50%
copy from src/test/java/org/apache/bcel/util/Class2HTMLTestCase.java
copy to src/test/java/org/apache/bcel/verifier/structurals/UninitializedObjectTypeTestCase.java
index ca455b1..43028ca 100644
--- a/src/test/java/org/apache/bcel/util/Class2HTMLTestCase.java
+++ b/src/test/java/org/apache/bcel/verifier/structurals/UninitializedObjectTypeTestCase.java
@@ -15,29 +15,18 @@
  * limitations under the License.
  */
 
-package org.apache.bcel.util;
+package org.apache.bcel.verifier.structurals;
 
-import java.io.File;
-import java.io.FileInputStream;
+import org.junit.Test;
 
-import org.apache.bcel.classfile.ClassParser;
-import org.junit.Assert;
+public class UninitializedObjectTypeTestCase {
 
-import junit.framework.TestCase;
-
-public class Class2HTMLTestCase extends TestCase {
-
-    public void testConvertJavaUtil() throws Exception {
-        final File outputDir = new File("target/test-output/html");
-        if (!outputDir.mkdirs()) { // either was not created or already existed
-            Assert.assertTrue(outputDir.isDirectory()); // fail if missing
-        }
-
-        try (FileInputStream file = new FileInputStream("target/test-classes/Java8Example.class")) {
-
-            final ClassParser parser = new ClassParser(file, "Java8Example.class");
-
-            new Class2HTML(parser.parse(), outputDir.getAbsolutePath() + "/");
-        }
+    /**
+     * Tests that we do not break binary compatibility with BCEL-330.
+     */
+    @Test
+    public void testReferenceToConstant() {
+        @SuppressWarnings("unused")
+        short referenceToConstant = UninitializedObjectType.AALOAD;
     }
 }


[commons-bcel] 01/03: Revert "[BCEL-330] Remove unnecessary references to Constants."

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 53e5fb4296c3c7c5ad9dceaf5e860a57e7e31da5
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Oct 11 14:56:25 2019 -0400

    Revert "[BCEL-330] Remove unnecessary references to Constants."
    
    This reverts commit c7be397b2964267281c10466e75835c682b52e45.
---
 src/changes/changes.xml | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index de89ed4..ca5cb29 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -62,9 +62,6 @@ The <action> type attribute can be add,update,fix,remove.
    -->
 
   <body>
-    <release version="6.4.2" date="2019-MM-DD" description="Bug fix release.">
-      <action issue="BCEL-330" type="update" dev="ggregory" due-to="Mark Roberts">Remove unnecessary references to Constants.</action>
-    </release>  
     <release version="6.4.1" date="2019-09-26" description="Bug fix release.">
       <action issue="BCEL-328" type="fix" dev="ggregory" due-to="Gary Gregory, Mark Roberts">java.util.EmptyStackException at org.apache.bcel.classfile.DescendingVisitor.visitModule (DescendingVisitor.java:592).</action>
       <action                  type="update" dev="ggregory" due-to="Gary Gregory">Update build from Checkstyle Maven Plugin 3.0.0 to 3.1.0.</action>


[commons-bcel] 02/03: Revert "BCEL-330 (#35)"

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 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;