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 2023/04/08 15:49:06 UTC
[commons-bcel] branch master updated: verifier tests on various opcodes (#180)
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 d8c6a228 verifier tests on various opcodes (#180)
d8c6a228 is described below
commit d8c6a228ea9c76fbc8cbeba04d2ba17bab9634c0
Author: nbauma109 <nb...@users.noreply.github.com>
AuthorDate: Sat Apr 8 17:49:00 2023 +0200
verifier tests on various opcodes (#180)
* verifier tests on various opcodes
- fixed typo testCommonsLang1->2
- test of various opcodes
* Added javadoc links to opcodes
---------
Co-authored-by: nbauma109 <nb...@github.com>
---
.../org/apache/bcel/verifier/VerifierTestCase.java | 7 +-
.../org/apache/bcel/verifier/tests/JvmOpCodes.java | 172 +++++++++++++++++++++
2 files changed, 178 insertions(+), 1 deletion(-)
diff --git a/src/test/java/org/apache/bcel/verifier/VerifierTestCase.java b/src/test/java/org/apache/bcel/verifier/VerifierTestCase.java
index 739d0a11..ec04b9ec 100644
--- a/src/test/java/org/apache/bcel/verifier/VerifierTestCase.java
+++ b/src/test/java/org/apache/bcel/verifier/VerifierTestCase.java
@@ -117,7 +117,7 @@ public class VerifierTestCase {
}
@Test
- public void testCommonsLang1() throws IOException, URISyntaxException, ClassNotFoundException {
+ public void testCommonsLang2() throws IOException, URISyntaxException, ClassNotFoundException {
testJarFile(getJarFile(org.apache.commons.lang.StringUtils.class), "ArrayUtils", "SerializationUtils");
}
@@ -126,6 +126,11 @@ public class VerifierTestCase {
testNestHostWithJavaVersion("com.ibm.wsdl.DefinitionImpl");
}
+ @Test
+ public void testJvmOpCodes() throws ClassNotFoundException {
+ testDefaultMethodValidation("org.apache.bcel.verifier.tests.JvmOpCodes");
+ }
+
@Test
public void testWSDL() throws IOException, URISyntaxException, ClassNotFoundException {
testJarFile(getJarFile(javax.wsdl.Port.class), "WSDLReaderImpl", "DefinitionImpl");
diff --git a/src/test/java/org/apache/bcel/verifier/tests/JvmOpCodes.java b/src/test/java/org/apache/bcel/verifier/tests/JvmOpCodes.java
new file mode 100644
index 00000000..0653796a
--- /dev/null
+++ b/src/test/java/org/apache/bcel/verifier/tests/JvmOpCodes.java
@@ -0,0 +1,172 @@
+/*
+ * 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.verifier.tests;
+
+import org.apache.bcel.generic.DNEG;
+import org.apache.bcel.generic.DREM;
+import org.apache.bcel.generic.DUP2;
+import org.apache.bcel.generic.DUP2_X1;
+import org.apache.bcel.generic.DUP2_X2;
+import org.apache.bcel.generic.DUP_X2;
+import org.apache.bcel.generic.FADD;
+import org.apache.bcel.generic.FNEG;
+import org.apache.bcel.generic.FREM;
+import org.apache.bcel.generic.FSUB;
+import org.apache.bcel.generic.IUSHR;
+import org.apache.bcel.generic.LAND;
+import org.apache.bcel.generic.LNEG;
+import org.apache.bcel.generic.LOR;
+import org.apache.bcel.generic.LSHL;
+import org.apache.bcel.generic.LUSHR;
+import org.apache.bcel.generic.POP;
+import org.apache.bcel.generic.POP2;
+
+/*
+ * A selection of JVM opcodes, each one in a minimal method.
+ */
+public class JvmOpCodes {
+
+ long l1, l2;
+
+ /**
+ * Tests {@link DUP2_X1}.
+ */
+ void dup2x1(String[] s) {
+ s[0] += "s"; // Form 1
+ l2 = l1 = 1; // Form 2
+ }
+
+ /**
+ * Tests {@link DUP2}.
+ */
+ long dup2(long a) {
+ return a = a + 1;
+ }
+
+ /**
+ * Tests {@link DUP2_X2}.
+ */
+ long dup2x2(long[] array, int i, long l) {
+ return array[i] = l;
+ }
+
+ /**
+ * Tests {@link DUP_X2}.
+ */
+ int dupx2(int[] array, int i, int l) {
+ return array[i] = l;
+ }
+
+ /**
+ * Tests {@link LNEG}.
+ */
+ long lneg(long a) {
+ return -a;
+ }
+
+ /**
+ * Tests {@link LOR}.
+ */
+ long lor(long a, long b) {
+ return a | b;
+ }
+
+ /**
+ * Tests {@link LAND}.
+ */
+ long land(long a, long b) {
+ return a & b;
+ }
+
+ /**
+ * Tests {@link LUSHR}.
+ */
+ long lushr(long a, long b) {
+ return a >>> b;
+ }
+
+ /**
+ * Tests {@link IUSHR}.
+ */
+ int iushr(int a, int b) {
+ return a >>> b;
+ }
+
+ /**
+ * Tests {@link LSHL}.
+ */
+ long lshl(long a, long b) {
+ return a << b;
+ }
+
+ /**
+ * Tests {@link FSUB}.
+ */
+ float fsub(float a, float b) {
+ return a - b;
+ }
+
+ /**
+ * Tests {@link FADD}.
+ */
+ float fadd(float a, float b) {
+ return a + b;
+ }
+
+ /**
+ * Tests {@link FREM}.
+ */
+ float frem(float a, float b) {
+ return a % b;
+ }
+
+ /**
+ * Tests {@link FNEG}.
+ */
+ float fneg(float a) {
+ return -a;
+ }
+
+ /**
+ * Tests {@link DREM}.
+ */
+ double drem(double a, double b) {
+ return a % b;
+ }
+
+ /**
+ * Tests {@link DNEG}.
+ */
+ double dneg(double a) {
+ return -a;
+ }
+
+ /**
+ * Tests {@link POP}.
+ */
+ void pop() {
+ Math.round(0.5f);
+ }
+
+ /**
+ * Tests {@link POP2}.
+ */
+ void pop2() {
+ Math.round(0.5d);
+ }
+}