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:23 UTC
[commons-bcel] 03/03: [BCEL-330] Remove unnecessary references to
Constants.
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;
}
}