summaryrefslogtreecommitdiff
path: root/asm4/test/conform/org
diff options
context:
space:
mode:
Diffstat (limited to 'asm4/test/conform/org')
-rw-r--r--asm4/test/conform/org/objectweb/asm/AbstractTest.java260
-rw-r--r--asm4/test/conform/org/objectweb/asm/AnnotationsTest.java150
-rw-r--r--asm4/test/conform/org/objectweb/asm/AttributeUnitTest.java44
-rw-r--r--asm4/test/conform/org/objectweb/asm/ClassAdapterTest.java129
-rw-r--r--asm4/test/conform/org/objectweb/asm/ClassReaderTest.java107
-rw-r--r--asm4/test/conform/org/objectweb/asm/ClassReaderUnitTest.java94
-rw-r--r--asm4/test/conform/org/objectweb/asm/ClassWriterComputeFramesDeadCodeTest.java242
-rw-r--r--asm4/test/conform/org/objectweb/asm/ClassWriterComputeFramesTest.java269
-rw-r--r--asm4/test/conform/org/objectweb/asm/ClassWriterComputeMaxsTest.java53
-rw-r--r--asm4/test/conform/org/objectweb/asm/ClassWriterComputeMaxsUnitTest.java963
-rw-r--r--asm4/test/conform/org/objectweb/asm/ClassWriterCopyPoolTest.java72
-rw-r--r--asm4/test/conform/org/objectweb/asm/ClassWriterResizeInsnsTest.java142
-rw-r--r--asm4/test/conform/org/objectweb/asm/ClassWriterTest.java56
-rw-r--r--asm4/test/conform/org/objectweb/asm/ClassWriterUnitTest.java68
-rw-r--r--asm4/test/conform/org/objectweb/asm/LabelUnitTest.java62
-rw-r--r--asm4/test/conform/org/objectweb/asm/TypeUnitTest.java113
-rw-r--r--asm4/test/conform/org/objectweb/asm/attrs/CodeComment.java92
-rw-r--r--asm4/test/conform/org/objectweb/asm/attrs/Comment.java81
-rw-r--r--asm4/test/conform/org/objectweb/asm/commons/AdviceAdapterTest.java127
-rw-r--r--asm4/test/conform/org/objectweb/asm/commons/AdviceAdapterUnitTest.java226
-rw-r--r--asm4/test/conform/org/objectweb/asm/commons/AnalyzerAdapterTest.java96
-rw-r--r--asm4/test/conform/org/objectweb/asm/commons/CodeSizeEvaluatorTest.java74
-rw-r--r--asm4/test/conform/org/objectweb/asm/commons/GASMifier.java927
-rw-r--r--asm4/test/conform/org/objectweb/asm/commons/GASMifierTest.java187
-rw-r--r--asm4/test/conform/org/objectweb/asm/commons/JSRInlinerAdapterTest.java87
-rw-r--r--asm4/test/conform/org/objectweb/asm/commons/JSRInlinerAdapterUnitTest.java1874
-rw-r--r--asm4/test/conform/org/objectweb/asm/commons/LocalVariablesSorterTest.java84
-rw-r--r--asm4/test/conform/org/objectweb/asm/commons/LocalVariablesSorterTest2.java124
-rw-r--r--asm4/test/conform/org/objectweb/asm/commons/RemappingClassAdapterTest.java250
-rw-r--r--asm4/test/conform/org/objectweb/asm/commons/RemappingClassAdapterTest2.java62
-rw-r--r--asm4/test/conform/org/objectweb/asm/commons/SerialVersionUIDAdderTest.java53
-rw-r--r--asm4/test/conform/org/objectweb/asm/commons/SerialVersionUIDAdderUnitTest.java77
-rw-r--r--asm4/test/conform/org/objectweb/asm/commons/StaticInitMergerTest.java83
-rw-r--r--asm4/test/conform/org/objectweb/asm/signature/SignatureUnitTest.java83
-rw-r--r--asm4/test/conform/org/objectweb/asm/signature/SignatureWriterTest.java93
-rw-r--r--asm4/test/conform/org/objectweb/asm/test/cases/Annotation.java313
-rw-r--r--asm4/test/conform/org/objectweb/asm/test/cases/Attribute.java96
-rw-r--r--asm4/test/conform/org/objectweb/asm/test/cases/Debug.java90
-rw-r--r--asm4/test/conform/org/objectweb/asm/test/cases/Enum.java158
-rw-r--r--asm4/test/conform/org/objectweb/asm/test/cases/Frames.java732
-rw-r--r--asm4/test/conform/org/objectweb/asm/test/cases/Generator.java70
-rw-r--r--asm4/test/conform/org/objectweb/asm/test/cases/Insns.java750
-rw-r--r--asm4/test/conform/org/objectweb/asm/test/cases/Interface.java66
-rw-r--r--asm4/test/conform/org/objectweb/asm/test/cases/Invalid.java80
-rw-r--r--asm4/test/conform/org/objectweb/asm/test/cases/InvokeDynamic.java79
-rw-r--r--asm4/test/conform/org/objectweb/asm/test/cases/JSR.java170
-rw-r--r--asm4/test/conform/org/objectweb/asm/test/cases/Outer.java187
-rw-r--r--asm4/test/conform/org/objectweb/asm/test/cases/Wide.java112
-rw-r--r--asm4/test/conform/org/objectweb/asm/tree/ClassNodeTest.java95
-rw-r--r--asm4/test/conform/org/objectweb/asm/tree/ClassNodeUnitTest.java156
-rw-r--r--asm4/test/conform/org/objectweb/asm/tree/InsnListUnitTest.java780
-rw-r--r--asm4/test/conform/org/objectweb/asm/tree/analysis/AnalyzerUnitTest.java108
-rw-r--r--asm4/test/conform/org/objectweb/asm/tree/analysis/BasicInterpreterTest.java65
-rw-r--r--asm4/test/conform/org/objectweb/asm/tree/analysis/BasicVerifierTest.java64
-rw-r--r--asm4/test/conform/org/objectweb/asm/tree/analysis/SimpleVerifierTest.java64
-rw-r--r--asm4/test/conform/org/objectweb/asm/tree/analysis/SimpleVerifierUnitTest.java451
-rw-r--r--asm4/test/conform/org/objectweb/asm/tree/analysis/SmallSetUnitTest.java64
-rw-r--r--asm4/test/conform/org/objectweb/asm/tree/analysis/SourceInterpreterTest.java64
-rw-r--r--asm4/test/conform/org/objectweb/asm/tree/analysis/ValueUnitTest.java53
-rw-r--r--asm4/test/conform/org/objectweb/asm/util/ASMifierTest.java122
-rw-r--r--asm4/test/conform/org/objectweb/asm/util/ASMifierUnitTest.java49
-rw-r--r--asm4/test/conform/org/objectweb/asm/util/CheckClassAdapterTest.java56
-rw-r--r--asm4/test/conform/org/objectweb/asm/util/CheckClassAdapterUnitTest.java887
-rw-r--r--asm4/test/conform/org/objectweb/asm/util/CheckSignatureAdapterTest.java98
-rw-r--r--asm4/test/conform/org/objectweb/asm/util/CheckSignatureAdapterUnitTest.java269
-rw-r--r--asm4/test/conform/org/objectweb/asm/util/TraceClassAdapterTest.java65
-rw-r--r--asm4/test/conform/org/objectweb/asm/util/TraceClassAdapterUnitTest.java49
-rw-r--r--asm4/test/conform/org/objectweb/asm/util/TraceSignatureVisitorUnitTest.java184
-rw-r--r--asm4/test/conform/org/objectweb/asm/util/VerifyClassTest.java68
-rw-r--r--asm4/test/conform/org/objectweb/asm/xml/ASMContentHandlerUnitTest.java171
-rw-r--r--asm4/test/conform/org/objectweb/asm/xml/SAXAdapterTest.java94
-rw-r--r--asm4/test/conform/org/objectweb/asm/xml/SAXAdapterUnitTest.java108
72 files changed, 0 insertions, 14591 deletions
diff --git a/asm4/test/conform/org/objectweb/asm/AbstractTest.java b/asm4/test/conform/org/objectweb/asm/AbstractTest.java
deleted file mode 100644
index ba32aee..0000000
--- a/asm4/test/conform/org/objectweb/asm/AbstractTest.java
+++ /dev/null
@@ -1,260 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.Arrays;
-import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.ListIterator;
-import java.util.Set;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.objectweb.asm.tree.AbstractInsnNode;
-import org.objectweb.asm.tree.LabelNode;
-import org.objectweb.asm.tree.MethodNode;
-import org.objectweb.asm.util.TraceClassVisitor;
-
-/**
- * Super class for test suites based on a jar file.
- *
- * @author Eugene Kuleshov
- * @author Eric Bruneton
- */
-public abstract class AbstractTest extends TestCase {
-
- protected String n;
-
- protected InputStream is;
-
- public AbstractTest() {
- super("test");
- }
-
- protected void init(final String n, final InputStream is) {
- this.n = n;
- this.is = is;
- }
-
- protected TestSuite getSuite() throws Exception {
- TestSuite suite = new TestSuite(getClass().getName());
- String files = System.getProperty("asm.test") + ",";
- String clazz = System.getProperty("asm.test.class");
- String partcount = System.getProperty("parts");
- String partid = System.getProperty("part");
- int parts = partcount == null ? 1 : Integer.parseInt(partcount);
- int part = partid == null ? 0 : Integer.parseInt(partid);
- int id = 0;
- while (files.indexOf(',') != -1) {
- String file = files.substring(0, files.indexOf(','));
- files = files.substring(files.indexOf(',') + 1);
- File f = new File(file);
- if (f.isDirectory()) {
- scanDirectory("", f, suite, clazz);
- } else {
- ZipFile zip = new ZipFile(file);
- Enumeration<? extends ZipEntry> entries = zip.entries();
- while (entries.hasMoreElements()) {
- ZipEntry e = entries.nextElement();
- String n = e.getName();
- String p = n.replace('/', '.');
- if (n.endsWith(".class")
- && (clazz == null || p.indexOf(clazz) != -1)) {
- n = p.substring(0, p.length() - 6);
- if (id % parts == part) {
- InputStream is = zip.getInputStream(e);
- AbstractTest t = getClass().newInstance();
- t.init(n, is);
- suite.addTest(t);
- }
- ++id;
- }
- }
- }
- }
- return suite;
- }
-
- private void scanDirectory(final String path, final File f,
- final TestSuite suite, final String clazz) throws Exception {
- File[] fs = f.listFiles();
- for (int i = 0; i < fs.length; ++i) {
- String n = fs[i].getName();
- String qn = path.length() == 0 ? n : path + "." + n;
- if (fs[i].isDirectory()) {
- scanDirectory(qn, fs[i], suite, clazz);
- } else if (qn.endsWith(".class") && !qn.startsWith("invalid.")) {
- if (clazz == null || qn.startsWith("pkg.")
- || qn.indexOf(clazz) != -1) {
- qn = qn.substring(0, qn.length() - 6);
- InputStream is = new FileInputStream(fs[i]);
- AbstractTest t = getClass().newInstance();
- t.init(qn, is);
- suite.addTest(t);
- }
- }
- }
- }
-
- public abstract void test() throws Exception;
-
- public void assertEquals(final ClassReader cr1, final ClassReader cr2)
- throws Exception {
- assertEquals(cr1, cr2, null, null);
- }
-
- public void assertEquals(final ClassReader cr1, final ClassReader cr2,
- final ClassVisitor filter1, final ClassVisitor filter2)
- throws Exception {
- if (!Arrays.equals(cr1.b, cr2.b)) {
- StringWriter sw1 = new StringWriter();
- StringWriter sw2 = new StringWriter();
- ClassVisitor cv1 = new TraceClassVisitor(new PrintWriter(sw1));
- ClassVisitor cv2 = new TraceClassVisitor(new PrintWriter(sw2));
- if (filter1 != null) {
- filter1.cv = cv1;
- }
- if (filter2 != null) {
- filter2.cv = cv2;
- }
- cr1.accept(filter1 == null ? cv1 : filter1, 0);
- cr2.accept(filter2 == null ? cv2 : filter2, 0);
- String s1 = sw1.toString();
- String s2 = sw2.toString();
- try {
- assertEquals("different data", s1, s2);
- } catch (Throwable e) {
- /*
- * ClassReader may introduce unused labels in the code, due to
- * the way uninitialized frame types are handled (false
- * positives may occur, see the doc of ClassReader). These
- * unused labels may differ before / after a transformation, but
- * this does not change the method code itself. Thus, if a
- * difference occurs, we retry a comparison, this time by
- * removing the unused labels first (we do not do this in the
- * first place because it is costly).
- */
- sw1 = new StringWriter();
- sw2 = new StringWriter();
- cv1 = new RemoveUnusedLabelsAdapter(new TraceClassVisitor(
- new PrintWriter(sw1)));
- cv2 = new RemoveUnusedLabelsAdapter(new TraceClassVisitor(
- new PrintWriter(sw2)));
- if (filter1 != null) {
- filter1.cv = cv1;
- }
- if (filter2 != null) {
- filter2.cv = cv2;
- }
- cr1.accept(filter1 == null ? cv1 : filter1, 0);
- cr2.accept(filter2 == null ? cv2 : filter2, 0);
- s1 = sw1.toString();
- s2 = sw2.toString();
- assertEquals("different data", s1, s2);
- }
- }
- }
-
- @Override
- public String getName() {
- return super.getName() + ": " + n;
- }
-
- public static class VerifierTest extends TestCase {
-
- public VerifierTest() {
- super("testVerifier");
- }
-
- public void testVerifier() throws Exception {
- try {
- Class.forName("invalid.Invalid", true, getClass()
- .getClassLoader());
- fail("The new JDK 7 verifier does not trigger!");
- } catch (VerifyError ve) {
- // This is expected since the class is invalid.
- ve.printStackTrace();
- }
- }
- }
-
- static class RemoveUnusedLabelsAdapter extends ClassVisitor {
-
- public RemoveUnusedLabelsAdapter(ClassVisitor cv) {
- super(Opcodes.ASM4, cv);
- }
-
- @Override
- public MethodVisitor visitMethod(int access, String name, String desc,
- String signature, String[] exceptions) {
- return new MethodNode(access, name, desc, signature, exceptions) {
-
- /**
- * The labels used in this method.
- */
- Set<LabelNode> usedLabels = new HashSet<LabelNode>();
-
- @Override
- public void visitLabel(final Label label) {
- instructions.add(super.getLabelNode(label));
- }
-
- @Override
- public void visitEnd() {
- // removes unused labels
- ListIterator<AbstractInsnNode> i = instructions.iterator();
- while (i.hasNext()) {
- AbstractInsnNode n = i.next();
- if (n instanceof LabelNode && !usedLabels.contains(n)) {
- i.remove();
- }
- }
- // visits the transformed code
- accept(cv);
- }
-
- @Override
- protected LabelNode getLabelNode(final Label l) {
- LabelNode n = super.getLabelNode(l);
- usedLabels.add(n);
- return n;
- }
- };
- }
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/AnnotationsTest.java b/asm4/test/conform/org/objectweb/asm/AnnotationsTest.java
deleted file mode 100644
index 8a2e92e..0000000
--- a/asm4/test/conform/org/objectweb/asm/AnnotationsTest.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm;
-
-import junit.framework.TestSuite;
-
-/**
- * Annotations tests.
- *
- * @author Eric Bruneton
- */
-public class AnnotationsTest extends AbstractTest {
-
- public static TestSuite suite() throws Exception {
- return new AnnotationsTest().getSuite();
- }
-
- @Override
- public void test() throws Exception {
- ClassReader cr = new ClassReader(is);
- ClassWriter cw1 = new ClassWriter(0);
- ClassWriter cw2 = new ClassWriter(0);
- cr.accept(new RemoveAnnotationsAdapter1(cw1), 0);
- cr.accept(new RemoveAnnotationsAdapter2(cw2), 0);
- assertEquals(new ClassReader(cw2.toByteArray()),
- new ClassReader(cw1.toByteArray()));
- }
-
- static class EmptyAnnotationVisitor extends AnnotationVisitor {
-
- public EmptyAnnotationVisitor() {
- super(Opcodes.ASM4);
- }
-
- @Override
- public AnnotationVisitor visitAnnotation(String name, String desc) {
- return this;
- }
-
- @Override
- public AnnotationVisitor visitArray(String name) {
- return this;
- }
- }
-
- static class RemoveAnnotationsAdapter1 extends ClassVisitor {
-
- public RemoveAnnotationsAdapter1(final ClassVisitor cv) {
- super(Opcodes.ASM4, cv);
- }
-
- @Override
- public AnnotationVisitor visitAnnotation(final String desc,
- final boolean visible) {
- return new EmptyAnnotationVisitor();
- }
-
- @Override
- public MethodVisitor visitMethod(final int access, final String name,
- final String desc, final String signature,
- final String[] exceptions) {
- return new MethodVisitor(Opcodes.ASM4, cv.visitMethod(access, name,
- desc, signature, exceptions)) {
-
- @Override
- public AnnotationVisitor visitAnnotationDefault() {
- return new EmptyAnnotationVisitor();
- }
-
- @Override
- public AnnotationVisitor visitAnnotation(String desc,
- boolean visible) {
- return new EmptyAnnotationVisitor();
- }
-
- @Override
- public AnnotationVisitor visitParameterAnnotation(
- int parameter, String desc, boolean visible) {
- return new EmptyAnnotationVisitor();
- }
- };
- }
- }
-
- static class RemoveAnnotationsAdapter2 extends ClassVisitor {
-
- public RemoveAnnotationsAdapter2(final ClassVisitor cv) {
- super(Opcodes.ASM4, cv);
- }
-
- @Override
- public AnnotationVisitor visitAnnotation(final String desc,
- final boolean visible) {
- return null;
- }
-
- @Override
- public MethodVisitor visitMethod(final int access, final String name,
- final String desc, final String signature,
- final String[] exceptions) {
- return new MethodVisitor(Opcodes.ASM4, cv.visitMethod(access, name,
- desc, signature, exceptions)) {
-
- @Override
- public AnnotationVisitor visitAnnotationDefault() {
- return null;
- }
-
- @Override
- public AnnotationVisitor visitAnnotation(String desc,
- boolean visible) {
- return null;
- }
-
- @Override
- public AnnotationVisitor visitParameterAnnotation(
- int parameter, String desc, boolean visible) {
- return null;
- }
- };
- }
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/AttributeUnitTest.java b/asm4/test/conform/org/objectweb/asm/AttributeUnitTest.java
deleted file mode 100644
index ee74d4a..0000000
--- a/asm4/test/conform/org/objectweb/asm/AttributeUnitTest.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm;
-
-import junit.framework.TestCase;
-
-/**
- * Attribute unit tests.
- *
- * @author Eric Bruneton
- */
-public class AttributeUnitTest extends TestCase {
-
- public void testUnknown() {
- assertTrue(new Attribute("Comment").isUnknown());
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/ClassAdapterTest.java b/asm4/test/conform/org/objectweb/asm/ClassAdapterTest.java
deleted file mode 100644
index 3963c4b..0000000
--- a/asm4/test/conform/org/objectweb/asm/ClassAdapterTest.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm;
-
-import junit.framework.TestSuite;
-
-/**
- * ClassVisitor tests.
- *
- * @author Eric Bruneton
- */
-public class ClassAdapterTest extends AbstractTest {
-
- private final static TestClassLoader LOADER = new TestClassLoader();
-
- public static TestSuite suite() throws Exception {
- return new ClassAdapterTest().getSuite();
- }
-
- @Override
- public void test() throws Exception {
- ClassReader cr = new ClassReader(is);
- ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
- cr.accept(new ClassVisitor(Opcodes.ASM4, cw) {
-
- @Override
- public FieldVisitor visitField(int access, String name,
- String desc, String signature, Object value) {
- return new FieldVisitor(Opcodes.ASM4, super.visitField(access,
- name, desc, signature, value)) {
- @Override
- public AnnotationVisitor visitAnnotation(String desc,
- boolean visible) {
- return new AnnotationAdapter(super.visitAnnotation(
- desc, visible));
- }
- };
- }
-
- @Override
- public MethodVisitor visitMethod(int access, String name,
- String desc, String signature, String[] exceptions) {
- return new MethodVisitor(Opcodes.ASM4, super.visitMethod(
- access, name, desc, signature, exceptions)) {
- @Override
- public AnnotationVisitor visitAnnotationDefault() {
- return new AnnotationAdapter(super
- .visitAnnotationDefault());
- }
-
- @Override
- public AnnotationVisitor visitAnnotation(String desc,
- boolean visible) {
- return new AnnotationAdapter(super.visitAnnotation(
- desc, visible));
- }
-
- @Override
- public AnnotationVisitor visitParameterAnnotation(
- int parameter, String desc, boolean visible) {
- return new AnnotationAdapter(super
- .visitParameterAnnotation(parameter, desc,
- visible));
- }
- };
- }
- }, 0);
- byte[] b = cw.toByteArray();
- try {
- LOADER.defineClass(n, b);
- } catch (ClassFormatError cfe) {
- fail(cfe.getMessage());
- } catch (Throwable ignored) {
- }
- }
-
- static class AnnotationAdapter extends AnnotationVisitor {
-
- public AnnotationAdapter(final AnnotationVisitor av) {
- super(Opcodes.ASM4, av);
- }
-
- @Override
- public AnnotationVisitor visitAnnotation(String name, String desc) {
- return new AnnotationAdapter(super.visitAnnotation(name, desc));
- }
-
- @Override
- public AnnotationVisitor visitArray(String name) {
- return new AnnotationAdapter(super.visitArray(name));
- }
- }
-
- // ------------------------------------------------------------------------
-
- static class TestClassLoader extends ClassLoader {
-
- public Class<?> defineClass(final String name, final byte[] b) {
- return defineClass(name, b, 0, b.length);
- }
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/ClassReaderTest.java b/asm4/test/conform/org/objectweb/asm/ClassReaderTest.java
deleted file mode 100644
index 212dba4..0000000
--- a/asm4/test/conform/org/objectweb/asm/ClassReaderTest.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm;
-
-import junit.framework.TestSuite;
-
-/**
- * ClassReader tests.
- *
- * @author Eric Bruneton
- */
-public class ClassReaderTest extends AbstractTest {
-
- public static TestSuite suite() throws Exception {
- return new ClassReaderTest().getSuite();
- }
-
- @Override
- public void test() throws Exception {
- new ClassReader(is).accept(new ClassVisitor(Opcodes.ASM4) {
-
- AnnotationVisitor av = new AnnotationVisitor(Opcodes.ASM4) {
-
- @Override
- public AnnotationVisitor visitAnnotation(String name,
- String desc) {
- return this;
- }
-
- @Override
- public AnnotationVisitor visitArray(String name) {
- return this;
- }
- };
-
- @Override
- public AnnotationVisitor visitAnnotation(String desc,
- boolean visible) {
- return av;
- }
-
- @Override
- public FieldVisitor visitField(int access, String name,
- String desc, String signature, Object value) {
- return new FieldVisitor(Opcodes.ASM4) {
-
- @Override
- public AnnotationVisitor visitAnnotation(String desc,
- boolean visible) {
- return av;
- }
- };
- }
-
- @Override
- public MethodVisitor visitMethod(int access, String name,
- String desc, String signature, String[] exceptions) {
- return new MethodVisitor(Opcodes.ASM4) {
-
- @Override
- public AnnotationVisitor visitAnnotationDefault() {
- return av;
- }
-
- @Override
- public AnnotationVisitor visitAnnotation(String desc,
- boolean visible) {
- return av;
- }
-
- @Override
- public AnnotationVisitor visitParameterAnnotation(
- int parameter, String desc, boolean visible) {
- return av;
- }
- };
- }
- }, 0);
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/ClassReaderUnitTest.java b/asm4/test/conform/org/objectweb/asm/ClassReaderUnitTest.java
deleted file mode 100644
index 5f1c1ad..0000000
--- a/asm4/test/conform/org/objectweb/asm/ClassReaderUnitTest.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import junit.framework.TestCase;
-
-/**
- * ClassReader unit tests.
- *
- * @author Eric Bruneton
- * @author Eugene Kuleshov
- */
-public class ClassReaderUnitTest extends TestCase implements Opcodes {
-
- public void testIllegalConstructorArgument() {
- try {
- new ClassReader((InputStream) null);
- fail();
- } catch (IOException e) {
- }
- }
-
- public void testGetItem() throws IOException {
- ClassReader cr = new ClassReader(getClass().getName());
- int item = cr.getItem(1);
- assertTrue(item >= 10);
- assertTrue(item < cr.header);
- }
-
- public void testReadByte() throws IOException {
- ClassReader cr = new ClassReader(getClass().getName());
- assertEquals(cr.b[0] & 0xFF, cr.readByte(0));
- }
-
- public void testGetAccess() throws Exception {
- String name = getClass().getName();
- assertEquals(Opcodes.ACC_PUBLIC | Opcodes.ACC_SUPER, new ClassReader(
- name).getAccess());
- }
-
- public void testGetClassName() throws Exception {
- String name = getClass().getName();
- assertEquals(name.replace('.', '/'),
- new ClassReader(name).getClassName());
- }
-
- public void testGetSuperName() throws Exception {
- assertEquals(TestCase.class.getName().replace('.', '/'),
- new ClassReader(getClass().getName()).getSuperName());
- assertEquals(null,
- new ClassReader(Object.class.getName()).getSuperName());
- }
-
- public void testGetInterfaces() throws Exception {
- String[] interfaces = new ClassReader(getClass().getName())
- .getInterfaces();
- assertNotNull(interfaces);
- assertEquals(1, interfaces.length);
- assertEquals(Opcodes.class.getName().replace('.', '/'), interfaces[0]);
-
- interfaces = new ClassReader(Opcodes.class.getName()).getInterfaces();
- assertNotNull(interfaces);
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/ClassWriterComputeFramesDeadCodeTest.java b/asm4/test/conform/org/objectweb/asm/ClassWriterComputeFramesDeadCodeTest.java
deleted file mode 100644
index 4efbddc..0000000
--- a/asm4/test/conform/org/objectweb/asm/ClassWriterComputeFramesDeadCodeTest.java
+++ /dev/null
@@ -1,242 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm;
-
-import java.io.PrintWriter;
-import java.lang.instrument.ClassFileTransformer;
-import java.lang.instrument.IllegalClassFormatException;
-import java.lang.instrument.Instrumentation;
-import java.security.ProtectionDomain;
-import java.util.Random;
-
-import org.objectweb.asm.util.TraceClassVisitor;
-
-import junit.framework.TestSuite;
-
-/**
- * ClassWriter tests.
- *
- * @author Eric Bruneton
- */
-public class ClassWriterComputeFramesDeadCodeTest extends AbstractTest {
-
- public static void premain(final String agentArgs,
- final Instrumentation inst) {
- inst.addTransformer(new ClassFileTransformer() {
- public byte[] transform(final ClassLoader loader,
- final String className, final Class<?> classBeingRedefined,
- final ProtectionDomain domain, final byte[] classFileBuffer)
- throws IllegalClassFormatException {
- String n = className.replace('/', '.');
- if (n.indexOf("javax") == -1 || n.startsWith("invalid.")) {
- return null;
- }
- if (agentArgs.length() == 0 || n.indexOf(agentArgs) != -1) {
- return transformClass(n, classFileBuffer);
- } else {
- return null;
- }
- }
- });
- }
-
- static byte[] transformClass(final String n, final byte[] clazz) {
- ClassReader cr = new ClassReader(clazz);
- ClassWriter cw = new ComputeClassWriter(ClassWriter.COMPUTE_FRAMES);
- cr.accept(new ClassVisitor(Opcodes.ASM4, cw) {
-
- private String className;
-
- @Override
- public void visit(final int version, final int access,
- final String name, final String signature,
- final String superName, final String[] interfaces) {
- className = name;
- // Set V1_7 version to prevent fallback to old verifier.
- super.visit((version & 0xFFFF) < Opcodes.V1_7 ? Opcodes.V1_7
- : version, access, name, signature, superName,
- interfaces);
- }
-
- @Override
- public MethodVisitor visitMethod(int access, String name,
- String desc, String signature, String[] exceptions) {
- int seed = (className + "." + name + desc).hashCode();
- return new MethodDeadCodeInserter(seed, super.visitMethod(
- access, name, desc, signature, exceptions));
- }
-
- }, ClassReader.SKIP_FRAMES | ClassReader.SKIP_DEBUG);
- byte[] b = cw.toByteArray();
- if (n.equals("javax.imageio.ImageIO"))
- new ClassReader(b).accept(new TraceClassVisitor(new PrintWriter(
- System.err)), 0);
-
- return b;
- }
-
- public static TestSuite suite() throws Exception {
- TestSuite suite = new ClassWriterComputeFramesDeadCodeTest().getSuite();
- suite.addTest(new VerifierTest());
- return suite;
- }
-
- @Override
- public void test() throws Exception {
- try {
- Class.forName(n, true, getClass().getClassLoader());
- } catch (NoClassDefFoundError ncdfe) {
- // ignored
- } catch (UnsatisfiedLinkError ule) {
- // ignored
- } catch (ClassFormatError cfe) {
- fail(cfe.getMessage());
- } catch (VerifyError ve) {
- // String s = n.replace('.', '/') + ".class";
- // InputStream is =
- // getClass().getClassLoader().getResourceAsStream(s);
- // ClassReader cr = new ClassReader(is);
- // byte[] b = transformClass("", cr.b);
- // StringWriter sw1 = new StringWriter();
- // StringWriter sw2 = new StringWriter();
- // sw2.write(ve.toString() + "\n");
- // ClassVisitor cv1 = new TraceClassVisitor(new PrintWriter(sw1));
- // ClassVisitor cv2 = new TraceClassVisitor(new PrintWriter(sw2));
- // cr.accept(cv1, 0);
- // new ClassReader(b).accept(cv2, 0);
- // String s1 = sw1.toString();
- // String s2 = sw2.toString();
- // assertEquals("different data", s1, s2);
- fail(ve.getMessage());
- }
- }
-}
-
-class MethodDeadCodeInserter extends MethodVisitor implements Opcodes {
-
- private Random r;
-
- public MethodDeadCodeInserter(int seed, final MethodVisitor mv) {
- super(ASM4, mv);
- r = new Random(seed);
- }
-
- @Override
- public void visitInsn(int opcode) {
- super.visitInsn(opcode);
- insertDeadcode();
- }
-
- @Override
- public void visitIntInsn(int opcode, int operand) {
- super.visitIntInsn(opcode, operand);
- insertDeadcode();
- }
-
- @Override
- public void visitVarInsn(int opcode, int var) {
- super.visitVarInsn(opcode, var);
- insertDeadcode();
- }
-
- @Override
- public void visitTypeInsn(int opcode, String type) {
- super.visitTypeInsn(opcode, type);
- insertDeadcode();
- }
-
- @Override
- public void visitFieldInsn(int opcode, String owner, String name,
- String desc) {
- super.visitFieldInsn(opcode, owner, name, desc);
- insertDeadcode();
- }
-
- @Override
- public void visitMethodInsn(int opcode, String owner, String name,
- String desc) {
- super.visitMethodInsn(opcode, owner, name, desc);
- insertDeadcode();
- }
-
- @Override
- public void visitInvokeDynamicInsn(String name, String desc, Handle bsm,
- Object... bsmArgs) {
- super.visitInvokeDynamicInsn(name, desc, bsm, bsmArgs);
- insertDeadcode();
- }
-
- @Override
- public void visitJumpInsn(int opcode, Label label) {
- super.visitJumpInsn(opcode, label);
- insertDeadcode();
- }
-
- @Override
- public void visitLdcInsn(Object cst) {
- super.visitLdcInsn(cst);
- insertDeadcode();
- }
-
- @Override
- public void visitIincInsn(int var, int increment) {
- super.visitIincInsn(var, increment);
- insertDeadcode();
- }
-
- @Override
- public void visitTableSwitchInsn(int min, int max, Label dflt,
- Label... labels) {
- super.visitTableSwitchInsn(min, max, dflt, labels);
- insertDeadcode();
- }
-
- @Override
- public void visitLookupSwitchInsn(Label dflt, int[] keys, Label[] labels) {
- super.visitLookupSwitchInsn(dflt, keys, labels);
- insertDeadcode();
- }
-
- @Override
- public void visitMultiANewArrayInsn(String desc, int dims) {
- super.visitMultiANewArrayInsn(desc, dims);
- insertDeadcode();
- }
-
- private void insertDeadcode() {
- // inserts dead code once every 50 instructions in average
- if (r.nextFloat() < 1.0 / 50.0) {
- Label end = new Label();
- mv.visitJumpInsn(Opcodes.GOTO, end);
- mv.visitLdcInsn("DEAD CODE");
- mv.visitLabel(end);
- }
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/ClassWriterComputeFramesTest.java b/asm4/test/conform/org/objectweb/asm/ClassWriterComputeFramesTest.java
deleted file mode 100644
index 573aa1a..0000000
--- a/asm4/test/conform/org/objectweb/asm/ClassWriterComputeFramesTest.java
+++ /dev/null
@@ -1,269 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.lang.instrument.ClassFileTransformer;
-import java.lang.instrument.IllegalClassFormatException;
-import java.lang.instrument.Instrumentation;
-import java.security.ProtectionDomain;
-
-import junit.framework.TestSuite;
-
-import org.objectweb.asm.util.TraceClassVisitor;
-
-/**
- * ClassWriter tests.
- *
- * @author Eric Bruneton
- */
-public class ClassWriterComputeFramesTest extends AbstractTest {
-
- public static void premain(final String agentArgs,
- final Instrumentation inst) {
- inst.addTransformer(new ClassFileTransformer() {
- public byte[] transform(final ClassLoader loader,
- final String className, final Class<?> classBeingRedefined,
- final ProtectionDomain domain, final byte[] classFileBuffer)
- throws IllegalClassFormatException {
- String n = className.replace('/', '.');
- if (n.indexOf("junit") != -1 || n.startsWith("invalid.")) {
- return null;
- }
- if (agentArgs.length() == 0 || n.indexOf(agentArgs) != -1) {
- return transformClass(n, classFileBuffer);
- } else {
- return null;
- }
- }
- });
- }
-
- static byte[] transformClass(final String n, final byte[] clazz) {
- ClassReader cr = new ClassReader(clazz);
- ClassWriter cw = new ComputeClassWriter(ClassWriter.COMPUTE_FRAMES);
- cr.accept(new ClassVisitor(Opcodes.ASM4, cw) {
-
- @Override
- public void visit(final int version, final int access,
- final String name, final String signature,
- final String superName, final String[] interfaces) {
- // Set V1_7 version to prevent fallback to old verifier.
- super.visit((version & 0xFFFF) < Opcodes.V1_7 ? Opcodes.V1_7
- : version, access, name, signature, superName,
- interfaces);
- }
-
- }, ClassReader.SKIP_FRAMES);
- return cw.toByteArray();
- }
-
- public static TestSuite suite() throws Exception {
- TestSuite suite = new ClassWriterComputeFramesTest().getSuite();
- suite.addTest(new VerifierTest());
- return suite;
- }
-
- @Override
- public void test() throws Exception {
- try {
- Class.forName(n, true, getClass().getClassLoader());
- } catch (NoClassDefFoundError ncdfe) {
- // ignored
- } catch (UnsatisfiedLinkError ule) {
- // ignored
- } catch (ClassFormatError cfe) {
- fail(cfe.getMessage());
- } catch (VerifyError ve) {
- String s = n.replace('.', '/') + ".class";
- InputStream is = getClass().getClassLoader().getResourceAsStream(s);
- ClassReader cr = new ClassReader(is);
- byte[] b = transformClass("", cr.b);
- StringWriter sw1 = new StringWriter();
- StringWriter sw2 = new StringWriter();
- sw2.write(ve.toString() + "\n");
- ClassVisitor cv1 = new TraceClassVisitor(new PrintWriter(sw1));
- ClassVisitor cv2 = new TraceClassVisitor(new PrintWriter(sw2));
- cr.accept(cv1, 0);
- new ClassReader(b).accept(cv2, 0);
- String s1 = sw1.toString();
- String s2 = sw2.toString();
- assertEquals("different data", s1, s2);
- }
- }
-}
-
-/**
- * A ClassWriter that computes the common super class of two classes without
- * actually loading them with a ClassLoader.
- *
- * @author Eric Bruneton
- */
-class ComputeClassWriter extends ClassWriter {
-
- private ClassLoader l = getClass().getClassLoader();
-
- public ComputeClassWriter(final int flags) {
- super(flags);
- }
-
- @Override
- protected String getCommonSuperClass(final String type1, final String type2) {
- try {
- ClassReader info1 = typeInfo(type1);
- ClassReader info2 = typeInfo(type2);
- if ((info1.getAccess() & Opcodes.ACC_INTERFACE) != 0) {
- if (typeImplements(type2, info2, type1)) {
- return type1;
- }
- if ((info2.getAccess() & Opcodes.ACC_INTERFACE) != 0) {
- if (typeImplements(type1, info1, type2)) {
- return type2;
- }
- }
- return "java/lang/Object";
- }
- if ((info2.getAccess() & Opcodes.ACC_INTERFACE) != 0) {
- if (typeImplements(type1, info1, type2)) {
- return type2;
- } else {
- return "java/lang/Object";
- }
- }
- StringBuilder b1 = typeAncestors(type1, info1);
- StringBuilder b2 = typeAncestors(type2, info2);
- String result = "java/lang/Object";
- int end1 = b1.length();
- int end2 = b2.length();
- while (true) {
- int start1 = b1.lastIndexOf(";", end1 - 1);
- int start2 = b2.lastIndexOf(";", end2 - 1);
- if (start1 != -1 && start2 != -1
- && end1 - start1 == end2 - start2) {
- String p1 = b1.substring(start1 + 1, end1);
- String p2 = b2.substring(start2 + 1, end2);
- if (p1.equals(p2)) {
- result = p1;
- end1 = start1;
- end2 = start2;
- } else {
- return result;
- }
- } else {
- return result;
- }
- }
- } catch (IOException e) {
- throw new RuntimeException(e.toString());
- }
- }
-
- /**
- * Returns the internal names of the ancestor classes of the given type.
- *
- * @param type
- * the internal name of a class or interface.
- * @param info
- * the ClassReader corresponding to 'type'.
- * @return a StringBuilder containing the ancestor classes of 'type',
- * separated by ';'. The returned string has the following format:
- * ";type1;type2 ... ;typeN", where type1 is 'type', and typeN is a
- * direct subclass of Object. If 'type' is Object, the returned
- * string is empty.
- * @throws IOException
- * if the bytecode of 'type' or of some of its ancestor class
- * cannot be loaded.
- */
- private StringBuilder typeAncestors(String type, ClassReader info)
- throws IOException {
- StringBuilder b = new StringBuilder();
- while (!"java/lang/Object".equals(type)) {
- b.append(';').append(type);
- type = info.getSuperName();
- info = typeInfo(type);
- }
- return b;
- }
-
- /**
- * Returns true if the given type implements the given interface.
- *
- * @param type
- * the internal name of a class or interface.
- * @param info
- * the ClassReader corresponding to 'type'.
- * @param itf
- * the internal name of a interface.
- * @return true if 'type' implements directly or indirectly 'itf'
- * @throws IOException
- * if the bytecode of 'type' or of some of its ancestor class
- * cannot be loaded.
- */
- private boolean typeImplements(String type, ClassReader info, String itf)
- throws IOException {
- while (!"java/lang/Object".equals(type)) {
- String[] itfs = info.getInterfaces();
- for (int i = 0; i < itfs.length; ++i) {
- if (itfs[i].equals(itf)) {
- return true;
- }
- }
- for (int i = 0; i < itfs.length; ++i) {
- if (typeImplements(itfs[i], typeInfo(itfs[i]), itf)) {
- return true;
- }
- }
- type = info.getSuperName();
- info = typeInfo(type);
- }
- return false;
- }
-
- /**
- * Returns a ClassReader corresponding to the given class or interface.
- *
- * @param type
- * the internal name of a class or interface.
- * @return the ClassReader corresponding to 'type'.
- * @throws IOException
- * if the bytecode of 'type' cannot be loaded.
- */
- private ClassReader typeInfo(final String type) throws IOException {
- InputStream is = l.getResourceAsStream(type + ".class");
- try {
- return new ClassReader(is);
- } finally {
- is.close();
- }
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/ClassWriterComputeMaxsTest.java b/asm4/test/conform/org/objectweb/asm/ClassWriterComputeMaxsTest.java
deleted file mode 100644
index 79ba0a4..0000000
--- a/asm4/test/conform/org/objectweb/asm/ClassWriterComputeMaxsTest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm;
-
-import junit.framework.TestSuite;
-
-/**
- * ClassWriter tests.
- *
- * @author Eric Bruneton
- */
-public class ClassWriterComputeMaxsTest extends AbstractTest {
-
- public static TestSuite suite() throws Exception {
- return new ClassWriterComputeMaxsTest().getSuite();
- }
-
- @Override
- public void test() throws Exception {
- ClassReader cr = new ClassReader(is);
- ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
- cr.accept(cw, 0);
- // computed maxStack and maxLocals may differ from original class
- // assertEquals(cr, new ClassReader(cw.toByteArray()));
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/ClassWriterComputeMaxsUnitTest.java b/asm4/test/conform/org/objectweb/asm/ClassWriterComputeMaxsUnitTest.java
deleted file mode 100644
index edca835..0000000
--- a/asm4/test/conform/org/objectweb/asm/ClassWriterComputeMaxsUnitTest.java
+++ /dev/null
@@ -1,963 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm;
-
-import java.io.ByteArrayInputStream;
-import java.io.FileInputStream;
-import java.lang.reflect.Field;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import java.util.StringTokenizer;
-
-import junit.framework.TestCase;
-
-/**
- * ClassWriter unit tests for COMPUTE_MAXS option with JSR instructions.
- *
- * @author Eric Bruneton
- */
-public class ClassWriterComputeMaxsUnitTest extends TestCase {
-
- private Field successors;
-
- private Field successor;
-
- private Field succ;
-
- private Field next;
-
- protected ClassWriter cw;
-
- protected MethodVisitor mv;
-
- private Label start;
-
- @Override
- protected void setUp() throws Exception {
- Class<?> lClass = Label.class;
- Class<?> eClass = Edge.class;
- try {
- successors = lClass.getDeclaredField("successors");
- successor = lClass.getDeclaredField("successor");
- succ = eClass.getDeclaredField("successor");
- next = eClass.getDeclaredField("next");
- } catch (RuntimeException exception) {
- String f = "src/org/objectweb/asm/optimizer/shrink.properties";
- Properties p = new Properties();
- FileInputStream is = new FileInputStream(f);
- try {
- p.load(is);
- } finally {
- is.close();
- }
- String l = Type.getInternalName(lClass) + ".";
- String e = Type.getInternalName(eClass) + ".";
- successors = lClass.getDeclaredField(p
- .getProperty(l + "successors"));
- successor = lClass.getDeclaredField(p.getProperty(l + "successor"));
- succ = eClass.getDeclaredField(p.getProperty(e + "successor"));
- next = eClass.getDeclaredField(p.getProperty(e + "next"));
- }
- cw = new ClassWriter(isComputeMaxs() ? ClassWriter.COMPUTE_MAXS : 0);
- cw.visit(Opcodes.V1_1, Opcodes.ACC_PUBLIC, "C", null,
- "java/lang/Object", null);
- mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "<init>", "()V", null, null);
- mv.visitCode();
- mv.visitVarInsn(Opcodes.ALOAD, 0);
- mv.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/lang/Object", "<init>",
- "()V");
- mv.visitInsn(Opcodes.RETURN);
- mv.visitMaxs(1, 1);
- mv.visitEnd();
- mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "m", "()V", null, null);
- mv.visitCode();
- start = new Label();
- LABEL(start);
- }
-
- protected boolean isComputeMaxs() {
- return true;
- }
-
- private void NOP() {
- mv.visitInsn(Opcodes.NOP);
- }
-
- private void PUSH() {
- mv.visitInsn(Opcodes.ICONST_0);
- }
-
- private void ICONST_0() {
- mv.visitInsn(Opcodes.ICONST_0);
- }
-
- private void ISTORE(final int var) {
- mv.visitVarInsn(Opcodes.ISTORE, var);
- }
-
- private void ALOAD(final int var) {
- mv.visitVarInsn(Opcodes.ALOAD, var);
- }
-
- private void ILOAD(final int var) {
- mv.visitVarInsn(Opcodes.ILOAD, var);
- }
-
- private void ASTORE(final int var) {
- mv.visitVarInsn(Opcodes.ASTORE, var);
- }
-
- private void RET(final int var) {
- mv.visitVarInsn(Opcodes.RET, var);
- }
-
- private void ATHROW() {
- mv.visitInsn(Opcodes.ATHROW);
- }
-
- private void ACONST_NULL() {
- mv.visitInsn(Opcodes.ACONST_NULL);
- }
-
- private void RETURN() {
- mv.visitInsn(Opcodes.RETURN);
- }
-
- private void LABEL(final Label l) {
- mv.visitLabel(l);
- }
-
- private void IINC(final int var, final int amnt) {
- mv.visitIincInsn(var, amnt);
- }
-
- private void GOTO(final Label l) {
- mv.visitJumpInsn(Opcodes.GOTO, l);
- }
-
- private void JSR(final Label l) {
- mv.visitJumpInsn(Opcodes.JSR, l);
- }
-
- private void IFNONNULL(final Label l) {
- mv.visitJumpInsn(Opcodes.IFNONNULL, l);
- }
-
- private void IFNE(final Label l) {
- mv.visitJumpInsn(Opcodes.IFNE, l);
- }
-
- private void TRYCATCH(final Label start, final Label end,
- final Label handler) {
- mv.visitTryCatchBlock(start, end, handler, null);
- }
-
- protected void assertMaxs(final int maxStack, final int maxLocals) {
- mv.visitMaxs(0, 0);
- mv.visitEnd();
- cw.visitEnd();
- byte[] b = cw.toByteArray();
- ClassReader cr = new ClassReader(b);
- cr.accept(new ClassVisitor(Opcodes.ASM4) {
- @Override
- public MethodVisitor visitMethod(final int access,
- final String name, final String desc,
- final String signature, final String[] exceptions) {
- if (name.equals("m")) {
- return new MethodVisitor(Opcodes.ASM4) {
- @Override
- public void visitMaxs(final int realMaxStack,
- final int realMaxLocals) {
- assertEquals("maxStack", maxStack, realMaxStack);
- assertEquals("maxLocals", maxLocals, realMaxLocals);
- }
- };
- } else {
- return null;
- }
- }
- }, 0);
-
- try {
- TestClassLoader loader = new TestClassLoader();
- Class<?> c = loader.defineClass("C", b);
- c.newInstance();
- } catch (Throwable t) {
- fail(t.getMessage());
- }
- }
-
- protected void assertGraph(final String graph) {
- Map<String, Set<String>> expected = new HashMap<String, Set<String>>();
- Properties p = new Properties();
- try {
- p.load(new ByteArrayInputStream(graph.getBytes()));
- } catch (Exception e) {
- fail();
- }
- Iterator<Map.Entry<Object, Object>> i = p.entrySet().iterator();
- while (i.hasNext()) {
- Map.Entry<Object, Object> entry = i.next();
- String key = (String) entry.getKey();
- String value = (String) entry.getValue();
- StringTokenizer st = new StringTokenizer(value, ",");
- Set<String> s = new HashSet<String>();
- while (st.hasMoreTokens()) {
- s.add(st.nextToken());
- }
- expected.put(key, s);
- }
-
- Map<String, Set<String>> actual = new HashMap<String, Set<String>>();
- try {
- Label l = start;
- while (l != null) {
- String key = "N" + l.getOffset();
- Set<String> value = new HashSet<String>();
- Edge e = (Edge) successors.get(l);
- while (e != null) {
- value.add("N" + ((Label) succ.get(e)).getOffset());
- e = (Edge) next.get(e);
- }
- actual.put(key, value);
- l = (Label) successor.get(l);
- }
- } catch (IllegalAccessException e) {
- fail();
- }
-
- assertEquals(expected, actual);
- }
-
- protected static class TestClassLoader extends ClassLoader {
-
- public TestClassLoader() {
- }
-
- public Class<?> defineClass(final String name, final byte[] b) {
- return defineClass(name, b, 0, b.length);
- }
- }
-
- /**
- * Tests a method which has the most basic <code>try{}finally</code> form
- * imaginable:
- *
- * <pre>
- * public void a() {
- * int a = 0;
- * try {
- * a++;
- * } finally {
- * a--;
- * }
- * }
- * </pre>
- */
- public void testBasic() {
- Label L0 = new Label();
- Label L1 = new Label();
- Label L2 = new Label();
- Label L3 = new Label();
- Label L4 = new Label();
-
- ICONST_0(); // N0
- ISTORE(1);
-
- /* L0: body of try block */
- LABEL(L0); // N2
- IINC(1, 1);
- GOTO(L1);
-
- /* L2: exception handler */
- LABEL(L2); // N8
- ASTORE(3);
- JSR(L3);
- ALOAD(3); // N12
- ATHROW();
-
- /* L3: subroutine */
- LABEL(L3); // N14
- ASTORE(2);
- IINC(1, -1);
- PUSH();
- PUSH();
- RET(2);
-
- /* L1: non-exceptional exit from try block */
- LABEL(L1); // N22
- JSR(L3);
- PUSH(); // N25
- PUSH();
- LABEL(L4); // N27
- RETURN();
-
- TRYCATCH(L0, L2, L2);
- TRYCATCH(L1, L4, L2);
-
- assertMaxs(4, 4);
- assertGraph("N0=N2\n" + "N2=N22,N8\n" + "N8=N14,N12\n" + "N12=\n"
- + "N14=N12,N25\n" + "N22=N14,N25,N8\n" + "N25=N27,N8\n"
- + "N27=\n");
- }
-
- /**
- * Tests a method which has an if/else-if w/in the finally clause:
- *
- * <pre>
- * public void a() {
- * int a = 0;
- * try {
- * a++;
- * } finally {
- * if (a == 0)
- * a += 2;
- * else
- * a += 3;
- * }
- * }
- * </pre>
- */
- public void testIfElseInFinally() {
- Label L0 = new Label();
- Label L1 = new Label();
- Label L2 = new Label();
- Label L3 = new Label();
- Label L4 = new Label();
- Label L5 = new Label();
- Label L6 = new Label();
-
- ICONST_0(); // N0
- ISTORE(1);
-
- /* L0: body of try block */
- LABEL(L0); // N2
- IINC(1, 1);
- GOTO(L1);
-
- /* L2: exception handler */
- LABEL(L2); // N8
- ASTORE(3);
- JSR(L3);
- PUSH(); // N12
- PUSH();
- ALOAD(3);
- ATHROW();
-
- /* L3: subroutine */
- LABEL(L3); // N16
- ASTORE(2);
- PUSH();
- PUSH();
- ILOAD(1);
- IFNE(L4);
- IINC(1, 2);
- GOTO(L5);
-
- LABEL(L4); // N29
- IINC(1, 3);
-
- LABEL(L5); // N32 common exit
- RET(2);
-
- /* L1: non-exceptional exit from try block */
- LABEL(L1); // N34
- JSR(L3);
- LABEL(L6); // N37
- RETURN();
-
- TRYCATCH(L0, L2, L2);
- TRYCATCH(L1, L6, L2);
-
- assertMaxs(5, 4);
- assertGraph("N0=N2\n" + "N2=N34,N8\n" + "N8=N16,N12\n" + "N12=\n"
- + "N16=N29,N32\n" + "N29=N32\n" + "N32=N37,N12\n"
- + "N34=N16,N37,N8\n" + "N37=\n");
-
- }
-
- /**
- * Tests a simple nested finally:
- *
- * <pre>
- * public void a1() {
- * int a = 0;
- * try {
- * a += 1;
- * } finally {
- * try {
- * a += 2;
- * } finally {
- * a += 3;
- * }
- * }
- * }
- * </pre>
- */
- public void testSimpleNestedFinally() {
- Label L0 = new Label();
- Label L1 = new Label();
- Label L2 = new Label();
- Label L3 = new Label();
- Label L4 = new Label();
- Label L5 = new Label();
-
- ICONST_0(); // N0
- ISTORE(1);
-
- // L0: Body of try block:
- LABEL(L0); // N2
- IINC(1, 1);
- JSR(L3);
- GOTO(L1); // N8
-
- // L2: First exception handler:
- LABEL(L2); // N11
- ASTORE(4);
- JSR(L3);
- ALOAD(4); // N16
- ATHROW();
-
- // L3: First subroutine:
- LABEL(L3); // N19
- ASTORE(2);
- IINC(1, 2);
- JSR(L4);
- PUSH(); // N26
- PUSH();
- RET(2);
-
- // L5: Second exception handler:
- LABEL(L5); // N30
- ASTORE(5);
- JSR(L4);
- ALOAD(5); // N35
- ATHROW();
-
- // L4: Second subroutine:
- LABEL(L4); // N38
- ASTORE(3);
- PUSH();
- PUSH();
- IINC(1, 3);
- RET(3);
-
- // L1: On normal exit, try block jumps here:
- LABEL(L1); // N46
- RETURN();
-
- TRYCATCH(L0, L2, L2);
- TRYCATCH(L3, L5, L5);
-
- assertMaxs(5, 6);
- assertGraph("N0=N2\n" + "N2=N11,N19,N8\n" + "N8=N11,N46\n"
- + "N11=N19,N16\n" + "N16=\n" + "N19=N26,N30,N38\n"
- + "N26=N16,N30,N8\n" + "N30=N38,N35\n" + "N35=\n"
- + "N38=N26,N35\n" + "N46=\n");
- }
-
- /**
- * This tests a subroutine which has no ret statement, but ends in a
- * "return" instead.
- *
- * We structure this as a try/finally with a break in the finally. Because
- * the while loop is infinite, it's clear from the byte code that the only
- * path which reaches the RETURN instruction is through the subroutine.
- *
- * <pre>
- * public void a1() {
- * int a = 0;
- * while (true) {
- * try {
- * a += 1;
- * } finally {
- * a += 2;
- * break;
- * }
- * }
- * }
- * </pre>
- */
- public void testSubroutineWithNoRet() {
- Label L0 = new Label();
- Label L1 = new Label();
- Label L2 = new Label();
- Label L3 = new Label();
- Label L4 = new Label();
-
- ICONST_0(); // N0
- ISTORE(1);
-
- // L0: while loop header/try block
- LABEL(L0); // N2
- IINC(1, 1);
- JSR(L1);
- GOTO(L2); // N8
-
- // L3: implicit catch block
- LABEL(L3); // N11
- ASTORE(2);
- JSR(L1);
- PUSH(); // N15
- PUSH();
- ALOAD(2);
- ATHROW();
-
- // L1: subroutine ...
- LABEL(L1); // N19
- ASTORE(3);
- IINC(1, 2);
- GOTO(L4); // ...not that it does not return!
-
- // L2: end of the loop... goes back to the top!
- LABEL(L2); // N26
- GOTO(L0);
-
- // L4:
- LABEL(L4); // N29
- RETURN();
-
- TRYCATCH(L0, L3, L3);
-
- assertMaxs(1, 4);
- assertGraph("N0=N2\n" + "N2=N11,N19,N8\n" + "N8=N11,N26\n"
- + "N11=N19,N15\n" + "N15=\n" + "N19=N29\n" + "N26=N2\n"
- + "N29=\n");
- }
-
- /**
- * This tests a subroutine which has no ret statement, but ends in a
- * "return" instead.
- *
- * <pre>
- * ACONST_NULL
- * JSR L0
- * L0:
- * ASTORE 0
- * ASTORE 0
- * RETURN
- * </pre>
- */
- public void testSubroutineWithNoRet2() {
- Label L0 = new Label();
- Label L1 = new Label();
-
- ACONST_NULL(); // N0
- JSR(L0);
- NOP(); // N4
- LABEL(L0); // N5
- ASTORE(0);
- ASTORE(0);
- RETURN();
- LABEL(L1); // N8
- mv.visitLocalVariable("i", "I", null, L0, L1, 1);
-
- assertMaxs(2, 2);
- assertGraph("N0=N4,N5\n" + "N4=N5\n" + "N5=\n" + "N8=\n");
- }
-
- /**
- * This tests a subroutine which has no ret statement, but instead exits
- * implicitely by branching to code which is not part of the subroutine.
- * (Sadly, this is legal)
- *
- * We structure this as a try/finally in a loop with a break in the finally.
- * The loop is not trivially infinite, so the RETURN statement is reachable
- * both from the JSR subroutine and from the main entry point.
- *
- * <pre>
- * public void a1() {
- * int a = 0;
- * while (null == null) {
- * try {
- * a += 1;
- * } finally {
- * a += 2;
- * break;
- * }
- * }
- * }
- * </pre>
- */
- public void testImplicitExit() {
- Label L0 = new Label();
- Label L1 = new Label();
- Label L2 = new Label();
- Label L3 = new Label();
- Label L4 = new Label();
- Label L5 = new Label();
-
- ICONST_0(); // N0
- ISTORE(1);
-
- // L5: while loop header
- LABEL(L5); // N2
- ACONST_NULL();
- IFNONNULL(L4);
-
- // L0: try block
- LABEL(L0); // N6
- IINC(1, 1);
- JSR(L1);
- GOTO(L2); // N12
-
- // L3: implicit catch block
- LABEL(L3); // N15
- ASTORE(2);
- JSR(L1);
- ALOAD(2); // N19
- PUSH();
- PUSH();
- ATHROW();
-
- // L1: subroutine ...
- LABEL(L1); // N23
- ASTORE(3);
- IINC(1, 2);
- GOTO(L4); // ...not that it does not return!
-
- // L2: end of the loop... goes back to the top!
- LABEL(L2); // N30
- GOTO(L0);
-
- // L4:
- LABEL(L4); // N33
- RETURN();
-
- TRYCATCH(L0, L3, L3);
-
- assertMaxs(1, 4);
- assertGraph("N0=N2\n" + "N2=N6,N33\n" + "N6=N23,N12,N15\n"
- + "N12=N30,N15\n" + "N15=N23,N19\n" + "N19=\n" + "N23=N33\n"
- + "N30=N6\n" + "N33=\n");
- }
-
- /**
- * Tests a nested try/finally with implicit exit from one subroutine to the
- * other subroutine. Equivalent to the following java code:
- *
- * <pre>
- * void m(boolean b) {
- * try {
- * return;
- * } finally {
- * while (b) {
- * try {
- * return;
- * } finally {
- * // NOTE --- this break avoids the second return above (weird)
- * if (b)
- * break;
- * }
- * }
- * }
- * }
- * </pre>
- *
- * This example is from the paper, "Subroutine Inlining and Bytecode
- * Abstraction to Simplify Static and Dynamic Analysis" by Cyrille Artho and
- * Armin Biere.
- */
- public void testImplicitExitToAnotherSubroutine() {
- Label T1 = new Label();
- Label C1 = new Label();
- Label S1 = new Label();
- Label L = new Label();
- Label C2 = new Label();
- Label S2 = new Label();
- Label W = new Label();
- Label X = new Label();
-
- // variable numbers:
- int b = 1;
- int e1 = 2;
- int e2 = 3;
- int r1 = 4;
- int r2 = 5;
-
- ICONST_0(); // N0
- ISTORE(1);
-
- // T1: first try:
- LABEL(T1); // N2
- JSR(S1);
- RETURN(); // N5
-
- // C1: exception handler for first try
- LABEL(C1); // N6
- ASTORE(e1);
- JSR(S1);
- PUSH(); // N10
- PUSH();
- ALOAD(e1);
- ATHROW();
-
- // S1: first finally handler
- LABEL(S1); // N14
- ASTORE(r1);
- PUSH();
- PUSH();
- GOTO(W);
-
- // L: body of while loop, also second try
- LABEL(L); // N21
- JSR(S2);
- RETURN(); // N24
-
- // C2: exception handler for second try
- LABEL(C2); // N25
- ASTORE(e2);
- PUSH();
- PUSH();
- JSR(S2);
- ALOAD(e2); // N31
- ATHROW();
-
- // S2: second finally handler
- LABEL(S2); // N33
- ASTORE(r2);
- ILOAD(b);
- IFNE(X);
- RET(r2);
-
- // W: test for the while loop
- LABEL(W); // N41
- ILOAD(b);
- IFNE(L); // falls through to X
-
- // X: exit from finally{} block
- LABEL(X); // N45
- RET(r1);
-
- TRYCATCH(T1, C1, C1);
- TRYCATCH(L, C2, C2);
-
- assertMaxs(5, 6);
- assertGraph("N0=N2\n" + "N2=N6,N5,N14\n" + "N5=N6\n" + "N6=N14,N10\n"
- + "N10=\n" + "N14=N41\n" + "N21=N24,N25,N33\n" + "N24=N25\n"
- + "N25=N31,N33\n" + "N31=\n" + "N33=N31,N45,N24\n"
- + "N41=N45,N21\n" + "N45=N5,N10\n");
- }
-
- public void testImplicitExitToAnotherSubroutine2() {
- Label L1 = new Label();
- Label L2 = new Label();
- Label L3 = new Label();
-
- ICONST_0(); // N0
- ISTORE(1);
- JSR(L1);
- RETURN(); // N5
-
- LABEL(L1); // N6
- ASTORE(2);
- JSR(L2);
- GOTO(L3); // N10
-
- LABEL(L2); // N13
- ASTORE(3);
- ILOAD(1);
- IFNE(L3);
- RET(3);
-
- LABEL(L3); // N20
- RET(2);
-
- assertMaxs(1, 4);
- assertGraph("N0=N6,N5\n" + "N5=\n" + "N6=N10,N13\n" + "N10=N20\n"
- + "N13=N20,N10\n" + "N20=N5\n");
- }
-
- /**
- * This tests a simple subroutine where the control flow jumps back and
- * forth between the subroutine and the caller.
- *
- * This would not normally be produced by a java compiler.
- */
- public void testInterleavedCode() {
- Label L1 = new Label();
- Label L2 = new Label();
- Label L3 = new Label();
- Label L4 = new Label();
-
- ICONST_0(); // N0
- ISTORE(1);
- JSR(L1);
- GOTO(L2); // N5
-
- // L1: subroutine 1
- LABEL(L1); // N8
- ASTORE(2);
- IINC(1, 1);
- GOTO(L3);
-
- // L2: second part of main subroutine
- LABEL(L2); // N15
- IINC(1, 2);
- GOTO(L4);
-
- // L3: second part of subroutine 1
- LABEL(L3); // N21
- IINC(1, 4);
- PUSH();
- PUSH();
- RET(2);
-
- // L4: third part of main subroutine
- LABEL(L4); // N28
- PUSH();
- PUSH();
- RETURN();
-
- assertMaxs(4, 3);
- assertGraph("N0=N5,N8\n" + "N5=N15\n" + "N8=N21\n" + "N15=N28\n"
- + "N21=N5\n" + "N28=\n");
- }
-
- /**
- * Tests a nested try/finally with implicit exit from one subroutine to the
- * other subroutine, and with a surrounding try/catch thrown in the mix.
- * Equivalent to the following java code:
- *
- * <pre>
- * void m(int b) {
- * try {
- * try {
- * return;
- * } finally {
- * while (b) {
- * try {
- * return;
- * } finally {
- * // NOTE --- this break avoids the second return above
- * // (weird)
- * if (b)
- * break;
- * }
- * }
- * }
- * } catch (Exception e) {
- * b += 3;
- * return;
- * }
- * }
- * </pre>
- */
- public void testImplicitExitInTryCatch() {
- Label T1 = new Label();
- Label C1 = new Label();
- Label S1 = new Label();
- Label L = new Label();
- Label C2 = new Label();
- Label S2 = new Label();
- Label W = new Label();
- Label X = new Label();
- Label OC = new Label();
-
- // variable numbers:
- int b = 1;
- int e1 = 2;
- int e2 = 3;
- int r1 = 4;
- int r2 = 5;
-
- ICONST_0(); // N0
- ISTORE(1);
-
- // T1: first try:
- LABEL(T1); // N2
- JSR(S1);
- RETURN(); // N5
-
- // C1: exception handler for first try
- LABEL(C1); // N6
- ASTORE(e1);
- JSR(S1);
- ALOAD(e1); // N10
- ATHROW();
-
- // S1: first finally handler
- LABEL(S1); // N12
- ASTORE(r1);
- GOTO(W);
-
- // L: body of while loop, also second try
- LABEL(L); // N17
- JSR(S2);
- PUSH(); // N20
- PUSH();
- RETURN();
-
- // C2: exception handler for second try
- LABEL(C2); // N23
- ASTORE(e2);
- JSR(S2);
- ALOAD(e2); // N27
- ATHROW();
-
- // S2: second finally handler
- LABEL(S2); // N29
- ASTORE(r2);
- ILOAD(b);
- IFNE(X);
- PUSH();
- PUSH();
- RET(r2);
-
- // W: test for the while loop
- LABEL(W); // N39
- ILOAD(b);
- IFNE(L); // falls through to X
-
- // X: exit from finally{} block
- LABEL(X); // N43
- RET(r1);
-
- // OC: outermost catch
- LABEL(OC); // N45
- IINC(b, 3);
- RETURN();
-
- TRYCATCH(T1, C1, C1);
- TRYCATCH(L, C2, C2);
- TRYCATCH(T1, OC, OC);
-
- assertMaxs(4, 6);
- assertGraph("N0=N2\n" + "N2=N6,N45,N5,N12\n" + "N5=N6,N45\n"
- + "N6=N45,N12,N10\n" + "N10=N45\n" + "N12=N39,N45\n"
- + "N17=N23,N45,N20,N29\n" + "N20=N23,N45\n"
- + "N23=N45,N27,N29\n" + "N27=N45\n" + "N29=N43,N45,N20,N27\n"
- + "N39=N43,N45,N17\n" + "N43=N45,N5,N10\n" + "N45=\n");
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/ClassWriterCopyPoolTest.java b/asm4/test/conform/org/objectweb/asm/ClassWriterCopyPoolTest.java
deleted file mode 100644
index a2b6a07..0000000
--- a/asm4/test/conform/org/objectweb/asm/ClassWriterCopyPoolTest.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm;
-
-import junit.framework.TestSuite;
-
-/**
- * ClassWriter tests for copyPool() optimization.
- *
- * @author Eugene Kuleshov
- */
-public class ClassWriterCopyPoolTest extends AbstractTest {
-
- public static TestSuite suite() throws Exception {
- return new ClassWriterCopyPoolTest().getSuite();
- }
-
- @Override
- public void test() throws Exception {
- ClassReader cr = new ClassReader(is);
- ClassWriter cw1 = new ClassWriter(0);
- ClassWriter cw2 = new ClassWriter(cr, 0);
- cr.accept(new ChangeExceptionAdapter(cw1), 0);
- cr.accept(new ChangeExceptionAdapter(cw2), 0);
- assertEquals(new ClassReader(cw1.toByteArray()),
- new ClassReader(cw2.toByteArray()));
- }
-
- static class ChangeExceptionAdapter extends ClassVisitor {
-
- public ChangeExceptionAdapter(final ClassVisitor cv) {
- super(Opcodes.ASM4, cv);
- }
-
- @Override
- public MethodVisitor visitMethod(final int access, final String name,
- final String desc, final String signature,
- final String[] exceptions) {
- if (exceptions != null && exceptions.length > 0) {
- exceptions[0] = "java/lang/Throwable";
- }
- return super.visitMethod(access, name, desc, signature, exceptions);
- }
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/ClassWriterResizeInsnsTest.java b/asm4/test/conform/org/objectweb/asm/ClassWriterResizeInsnsTest.java
deleted file mode 100644
index a578356..0000000
--- a/asm4/test/conform/org/objectweb/asm/ClassWriterResizeInsnsTest.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm;
-
-import java.lang.instrument.ClassFileTransformer;
-import java.lang.instrument.IllegalClassFormatException;
-import java.lang.instrument.Instrumentation;
-import java.security.ProtectionDomain;
-import java.util.HashSet;
-
-import junit.framework.TestSuite;
-
-import org.objectweb.asm.attrs.CodeComment;
-
-public class ClassWriterResizeInsnsTest extends AbstractTest {
-
- public static void premain(final String agentArgs,
- final Instrumentation inst) {
- inst.addTransformer(new ClassFileTransformer() {
- public byte[] transform(final ClassLoader loader,
- final String className, final Class<?> classBeingRedefined,
- final ProtectionDomain domain, byte[] b)
- throws IllegalClassFormatException {
- String n = className.replace('/', '.');
- if (agentArgs.length() == 0 || n.indexOf(agentArgs) != -1) {
- try {
- b = transformClass(b, ClassWriter.COMPUTE_FRAMES);
- if (n.equals("pkg.FrameMap")) {
- transformClass(b, 0);
- }
- return b;
- } catch (Throwable e) {
- return transformClass(b, 0);
- }
- } else {
- return null;
- }
- }
- });
- }
-
- static byte[] transformClass(final byte[] clazz, final int flags) {
- ClassReader cr = new ClassReader(clazz);
- ClassWriter cw = new ComputeClassWriter(flags);
- ClassVisitor ca = new ClassVisitor(Opcodes.ASM4, cw) {
-
- boolean transformed = false;
-
- @Override
- public void visit(int version, int access, String name,
- String signature, String superName, String[] interfaces) {
- if (flags == ClassWriter.COMPUTE_FRAMES) {
- // Set V1_7 version to prevent fallback to old verifier.
- version = (version & 0xFFFF) < Opcodes.V1_7 ? Opcodes.V1_7
- : version;
- }
- super.visit(version, access, name, signature, superName,
- interfaces);
- }
-
- @Override
- public MethodVisitor visitMethod(final int access,
- final String name, final String desc,
- final String signature, final String[] exceptions) {
- return new MethodVisitor(Opcodes.ASM4, cv.visitMethod(access,
- name, desc, signature, exceptions)) {
- private final HashSet<Label> labels = new HashSet<Label>();
-
- @Override
- public void visitLabel(final Label label) {
- super.visitLabel(label);
- labels.add(label);
- }
-
- @Override
- public void visitJumpInsn(final int opcode,
- final Label label) {
- super.visitJumpInsn(opcode, label);
- if (opcode != Opcodes.GOTO) {
- if (!transformed && !labels.contains(label)) {
- transformed = true;
- for (int i = 0; i < 33000; ++i) {
- mv.visitInsn(Opcodes.NOP);
- }
- }
- }
- }
- };
- }
- };
- cr.accept(ca, new Attribute[] { new CodeComment() }, 0);
- return cw.toByteArray();
- }
-
- public static TestSuite suite() throws Exception {
- TestSuite suite = new ClassWriterResizeInsnsTest().getSuite();
- suite.addTest(new VerifierTest());
- return suite;
- }
-
- @Override
- public void test() throws Exception {
- try {
- Class.forName(n, true, getClass().getClassLoader());
- } catch (NoClassDefFoundError ncdfe) {
- // ignored
- } catch (UnsatisfiedLinkError ule) {
- // ignored
- } catch (ClassFormatError cfe) {
- fail(cfe.getMessage());
- } catch (VerifyError ve) {
- fail(ve.toString());
- }
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/ClassWriterTest.java b/asm4/test/conform/org/objectweb/asm/ClassWriterTest.java
deleted file mode 100644
index 7dc1a49..0000000
--- a/asm4/test/conform/org/objectweb/asm/ClassWriterTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm;
-
-import junit.framework.TestSuite;
-
-/**
- * ClassWriter tests.
- *
- * @author Eric Bruneton
- */
-public class ClassWriterTest extends AbstractTest {
-
- public static TestSuite suite() throws Exception {
- return new ClassWriterTest().getSuite();
- }
-
- @Override
- public void test() throws Exception {
- ClassReader cr = new ClassReader(is);
- ClassWriter cw = new ClassWriter(0);
- cr.accept(cw, 0);
- // Also test the ClassReader(byte[],int,int) constructor
- byte[] b = cw.toByteArray();
- byte[] c = new byte[b.length + 1];
- System.arraycopy(b, 0, c, 1, b.length);
- assertEquals(cr, new ClassReader(c, 1, b.length));
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/ClassWriterUnitTest.java b/asm4/test/conform/org/objectweb/asm/ClassWriterUnitTest.java
deleted file mode 100644
index d79aa3a..0000000
--- a/asm4/test/conform/org/objectweb/asm/ClassWriterUnitTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm;
-
-import junit.framework.TestCase;
-
-/**
- * ClassWriter unit tests.
- *
- * @author Eric Bruneton
- */
-public class ClassWriterUnitTest extends TestCase {
-
- public void testNewConst() {
- ClassWriter cw = new ClassWriter(0);
- cw.newConst(new Byte((byte) 0));
- cw.newConst(new Character('0'));
- cw.newConst(new Short((short) 0));
- cw.newConst(Boolean.FALSE);
- cw.newField("A", "f", "I");
- cw.newMethod("A", "m", "()V", false);
- }
-
- public void testIllegalNewConstArgument() {
- ClassWriter cw = new ClassWriter(0);
- try {
- cw.newConst(new Object());
- fail();
- } catch (RuntimeException e) {
- }
- }
-
- public void testIllegalGetCommonSuperClassArguments() {
- ClassWriter cw = new ClassWriter(0);
- try {
- cw.getCommonSuperClass("-", "-");
- fail();
- } catch (RuntimeException e) {
- }
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/LabelUnitTest.java b/asm4/test/conform/org/objectweb/asm/LabelUnitTest.java
deleted file mode 100644
index 8866743..0000000
--- a/asm4/test/conform/org/objectweb/asm/LabelUnitTest.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm;
-
-import junit.framework.TestCase;
-
-/**
- * Label unit tests.
- *
- * @author Eric Bruneton
- */
-public class LabelUnitTest extends TestCase {
-
- public void testToString() {
- new Label().toString();
- }
-
- public void testGetOffset() {
- Label l = new Label();
- ClassWriter cw = new ClassWriter(0);
- MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "m", "()V", null,
- null);
- mv.visitCode();
- mv.visitLabel(l);
- assertEquals(0, l.getOffset());
- }
-
- public void testIllegalGetOffsetState() {
- try {
- new Label().getOffset();
- fail();
- } catch (RuntimeException e) {
- }
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/TypeUnitTest.java b/asm4/test/conform/org/objectweb/asm/TypeUnitTest.java
deleted file mode 100644
index 93545cf..0000000
--- a/asm4/test/conform/org/objectweb/asm/TypeUnitTest.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-import java.util.Arrays;
-
-import junit.framework.TestCase;
-
-/**
- * Type unit tests.
- *
- * @author Eric Bruneton
- */
-public class TypeUnitTest extends TestCase implements Opcodes {
-
- public void testConstants() {
- assertEquals(Type.INT_TYPE, Type.getType(Integer.TYPE));
- assertEquals(Type.VOID_TYPE, Type.getType(Void.TYPE));
- assertEquals(Type.BOOLEAN_TYPE, Type.getType(Boolean.TYPE));
- assertEquals(Type.BYTE_TYPE, Type.getType(Byte.TYPE));
- assertEquals(Type.CHAR_TYPE, Type.getType(Character.TYPE));
- assertEquals(Type.SHORT_TYPE, Type.getType(Short.TYPE));
- assertEquals(Type.DOUBLE_TYPE, Type.getType(Double.TYPE));
- assertEquals(Type.FLOAT_TYPE, Type.getType(Float.TYPE));
- assertEquals(Type.LONG_TYPE, Type.getType(Long.TYPE));
- }
-
- public void testInternalName() {
- String s1 = Type.getType(TypeUnitTest.class).getInternalName();
- String s2 = Type.getInternalName(TypeUnitTest.class);
- assertEquals(s1, s2);
- }
-
- public void testConstructorDescriptor() {
- for (int i = 0; i < String.class.getConstructors().length; ++i) {
- Constructor<?> c = String.class.getConstructors()[i];
- Type.getConstructorDescriptor(c);
- }
- }
-
- public void testMethodDescriptor() {
- for (int i = 0; i < Arrays.class.getMethods().length; ++i) {
- Method m = Arrays.class.getMethods()[i];
- Type[] args = Type.getArgumentTypes(m);
- Type r = Type.getReturnType(m);
- String d1 = Type.getMethodDescriptor(r, args);
- String d2 = Type.getMethodDescriptor(m);
- assertEquals(d1, d2);
- }
- }
-
- public void testGetOpcode() {
- Type object = Type.getType("Ljava/lang/Object;");
- assertEquals(BALOAD, Type.BOOLEAN_TYPE.getOpcode(IALOAD));
- assertEquals(BALOAD, Type.BYTE_TYPE.getOpcode(IALOAD));
- assertEquals(CALOAD, Type.CHAR_TYPE.getOpcode(IALOAD));
- assertEquals(SALOAD, Type.SHORT_TYPE.getOpcode(IALOAD));
- assertEquals(IALOAD, Type.INT_TYPE.getOpcode(IALOAD));
- assertEquals(FALOAD, Type.FLOAT_TYPE.getOpcode(IALOAD));
- assertEquals(LALOAD, Type.LONG_TYPE.getOpcode(IALOAD));
- assertEquals(DALOAD, Type.DOUBLE_TYPE.getOpcode(IALOAD));
- assertEquals(AALOAD, object.getOpcode(IALOAD));
- assertEquals(IADD, Type.BOOLEAN_TYPE.getOpcode(IADD));
- assertEquals(IADD, Type.BYTE_TYPE.getOpcode(IADD));
- assertEquals(IADD, Type.CHAR_TYPE.getOpcode(IADD));
- assertEquals(IADD, Type.SHORT_TYPE.getOpcode(IADD));
- assertEquals(IADD, Type.INT_TYPE.getOpcode(IADD));
- assertEquals(FADD, Type.FLOAT_TYPE.getOpcode(IADD));
- assertEquals(LADD, Type.LONG_TYPE.getOpcode(IADD));
- assertEquals(DADD, Type.DOUBLE_TYPE.getOpcode(IADD));
- }
-
- public void testHashcode() {
- Type.getType("Ljava/lang/Object;").hashCode();
- }
-
- public void testObjectType() throws Exception {
- Type t1 = Type.getObjectType("java/lang/Object");
- Type t2 = Type.getType("Ljava/lang/Object;");
- assertEquals(t2.getSort(), t1.getSort());
- assertEquals(t2.getClassName(), t1.getClassName());
- assertEquals(t2.getDescriptor(), t1.getDescriptor());
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/attrs/CodeComment.java b/asm4/test/conform/org/objectweb/asm/attrs/CodeComment.java
deleted file mode 100644
index 11ceb45..0000000
--- a/asm4/test/conform/org/objectweb/asm/attrs/CodeComment.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.attrs;
-
-import java.util.Map;
-
-import org.objectweb.asm.Attribute;
-import org.objectweb.asm.ByteVector;
-import org.objectweb.asm.ClassReader;
-import org.objectweb.asm.ClassWriter;
-import org.objectweb.asm.Label;
-import org.objectweb.asm.util.ASMifiable;
-import org.objectweb.asm.util.Textifiable;
-
-/**
- * A non standard code attribute used for testing purposes.
- *
- * @author Eric Bruneton
- */
-public class CodeComment extends Attribute implements ASMifiable, Textifiable {
-
- public CodeComment() {
- super("CodeComment");
- }
-
- @Override
- public boolean isUnknown() {
- return false;
- }
-
- @Override
- public boolean isCodeAttribute() {
- return true;
- }
-
- @Override
- protected Attribute read(final ClassReader cr, final int off,
- final int len, final char[] buf, final int codeOff,
- final Label[] labels) {
-
- return new CodeComment();
- }
-
- @Override
- protected ByteVector write(final ClassWriter cw, final byte[] code,
- final int len, final int maxStack, final int maxLocals) {
- return new ByteVector();
- }
-
- @Override
- protected Label[] getLabels() {
- super.getLabels();
- return new Label[] { new Label() };
- }
-
- public void asmify(final StringBuffer buf, final String varName,
- final Map<Label, String> labelNames) {
- buf.append("Attribute ").append(varName)
- .append(" = new org.objectweb.asm.attrs.CodeComment();");
- }
-
- public void textify(final StringBuffer buf,
- final Map<Label, String> labelNames) {
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/attrs/Comment.java b/asm4/test/conform/org/objectweb/asm/attrs/Comment.java
deleted file mode 100644
index ff203cb..0000000
--- a/asm4/test/conform/org/objectweb/asm/attrs/Comment.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.attrs;
-
-import java.util.Map;
-
-import org.objectweb.asm.Attribute;
-import org.objectweb.asm.ByteVector;
-import org.objectweb.asm.ClassReader;
-import org.objectweb.asm.ClassWriter;
-import org.objectweb.asm.Label;
-import org.objectweb.asm.util.ASMifiable;
-import org.objectweb.asm.util.Textifiable;
-
-/**
- * A non standard attribute used for testing purposes.
- *
- * @author Eric Bruneton
- */
-public class Comment extends Attribute implements ASMifiable, Textifiable {
-
- public Comment() {
- super("Comment");
- }
-
- @Override
- public boolean isUnknown() {
- return false;
- }
-
- @Override
- protected Attribute read(final ClassReader cr, final int off,
- final int len, final char[] buf, final int codeOff,
- final Label[] labels) {
-
- return new Comment();
- }
-
- @Override
- protected ByteVector write(final ClassWriter cw, final byte[] code,
- final int len, final int maxStack, final int maxLocals) {
- return new ByteVector();
- }
-
- public void asmify(final StringBuffer buf, final String varName,
- final Map<Label, String> labelNames) {
- buf.append("Attribute ").append(varName)
- .append(" = new org.objectweb.asm.attrs.Comment();");
- }
-
- public void textify(final StringBuffer buf,
- final Map<Label, String> labelNames) {
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/commons/AdviceAdapterTest.java b/asm4/test/conform/org/objectweb/asm/commons/AdviceAdapterTest.java
deleted file mode 100644
index 65b9ceb..0000000
--- a/asm4/test/conform/org/objectweb/asm/commons/AdviceAdapterTest.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.commons;
-
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
-
-import org.objectweb.asm.AbstractTest;
-import org.objectweb.asm.ClassReader;
-import org.objectweb.asm.ClassVisitor;
-import org.objectweb.asm.ClassWriter;
-import org.objectweb.asm.MethodVisitor;
-import org.objectweb.asm.Opcodes;
-
-/**
- * AdviceAdapter tests.
- *
- * @author Eugene Kuleshov
- */
-public class AdviceAdapterTest extends AbstractTest {
-
- public static void main(final String[] args) throws Exception {
- TestRunner.run(AdviceAdapterTest.suite());
- }
-
- public static TestSuite suite() throws Exception {
- return new AdviceAdapterTest().getSuite();
- }
-
- @Override
- public void test() throws Exception {
- ClassReader cr = new ClassReader(is);
- ClassWriter cw1 = new ClassWriter(0);
- ClassWriter cw2 = new ClassWriter(0);
- cr.accept(new ReferenceClassAdapter(cw1), ClassReader.EXPAND_FRAMES);
- cr.accept(new AdviceClassAdapter(cw2), ClassReader.EXPAND_FRAMES);
- assertEquals(new ClassReader(cw1.toByteArray()),
- new ClassReader(cw2.toByteArray()));
- }
-
- static class ReferenceClassAdapter extends ClassVisitor {
-
- public ReferenceClassAdapter(final ClassVisitor cv) {
- super(Opcodes.ASM4, cv);
- }
-
- @Override
- public MethodVisitor visitMethod(final int access, final String name,
- final String desc, final String signature,
- final String[] exceptions) {
- MethodVisitor mv = cv.visitMethod(access, name, desc, signature,
- exceptions);
-
- if (mv == null
- || (access & (Opcodes.ACC_ABSTRACT | Opcodes.ACC_NATIVE)) > 0) {
- return mv;
- }
-
- return new LocalVariablesSorter(access, desc, mv);
- }
- }
-
- static class AdviceClassAdapter extends ClassVisitor {
-
- public AdviceClassAdapter(final ClassVisitor cv) {
- super(Opcodes.ASM4, cv);
- }
-
- @Override
- public MethodVisitor visitMethod(final int access, final String name,
- final String desc, final String signature,
- final String[] exceptions) {
- MethodVisitor mv = cv.visitMethod(access, name, desc, signature,
- exceptions);
-
- if (mv == null
- || (access & (Opcodes.ACC_ABSTRACT | Opcodes.ACC_NATIVE)) > 0) {
- return mv;
- }
-
- return new AdviceAdapter(Opcodes.ASM4, mv, access, name, desc) {
-
- @Override
- protected void onMethodEnter() {
- // mv.visitInsn(NOP);
- // mv.visitInsn(NOP);
- // mv.visitInsn(NOP);
- }
-
- @Override
- protected void onMethodExit(final int opcode) {
- // mv.visitInsn(NOP);
- // mv.visitInsn(NOP);
- // mv.visitInsn(NOP);
- // mv.visitInsn(NOP);
- }
- };
- }
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/commons/AdviceAdapterUnitTest.java b/asm4/test/conform/org/objectweb/asm/commons/AdviceAdapterUnitTest.java
deleted file mode 100644
index 0e705b4..0000000
--- a/asm4/test/conform/org/objectweb/asm/commons/AdviceAdapterUnitTest.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.commons;
-
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-import org.objectweb.asm.AbstractTest;
-import org.objectweb.asm.ClassReader;
-import org.objectweb.asm.ClassVisitor;
-import org.objectweb.asm.ClassWriter;
-import org.objectweb.asm.MethodVisitor;
-import org.objectweb.asm.Opcodes;
-
-/**
- * Simple example of using AdviceAdapter to implement tracing callback
- *
- * @author Eugene Kuleshov
- */
-public class AdviceAdapterUnitTest extends AbstractTest {
-
- @Override
- public void test() throws Exception {
- Class<?> c = getClass();
- String name = c.getName();
- AdvisingClassLoader cl = new AdvisingClassLoader(name + "$");
- Class<?> cc = cl.loadClass(name + "$B");
- Method m = cc.getMethod("run", new Class<?>[] { Integer.TYPE });
- try {
- m.invoke(null, new Object[] { new Integer(0) });
- } catch (InvocationTargetException e) {
- throw (Exception) e.getTargetException();
- }
- }
-
- private static class AdvisingClassLoader extends ClassLoader {
- private String prefix;
-
- public AdvisingClassLoader(final String prefix) throws IOException {
- this.prefix = prefix;
- }
-
- @Override
- public Class<?> loadClass(final String name)
- throws ClassNotFoundException {
- if (name.startsWith(prefix)) {
- try {
- ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
- ClassReader cr = new ClassReader(getClass()
- .getResourceAsStream(
- "/" + name.replace('.', '/') + ".class"));
- cr.accept(new AdviceClassAdapter(cw),
- ClassReader.EXPAND_FRAMES);
- byte[] bytecode = cw.toByteArray();
- return super
- .defineClass(name, bytecode, 0, bytecode.length);
- } catch (IOException ex) {
- throw new ClassNotFoundException("Load error: "
- + ex.toString(), ex);
- }
- }
- return super.loadClass(name);
- }
-
- }
-
- // test callback
- private static int n = 0;
-
- public static void enter(final String msg) {
- System.err.println(off().append("enter ").append(msg).toString());
- n++;
- }
-
- public static void exit(final String msg) {
- n--;
- System.err.println(off().append("<").toString());
- }
-
- private static StringBuffer off() {
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < n; i++) {
- sb.append(" ");
- }
- return sb;
- }
-
- static class AdviceClassAdapter extends ClassVisitor implements Opcodes {
- String cname;
-
- public AdviceClassAdapter(final ClassVisitor cv) {
- super(Opcodes.ASM4, cv);
- }
-
- @Override
- public void visit(final int version, final int access,
- final String name, final String signature,
- final String superName, final String[] interfaces) {
- this.cname = name;
- super.visit(version, access, name, signature, superName, interfaces);
- }
-
- @Override
- public MethodVisitor visitMethod(final int access, final String name,
- final String desc, final String signature,
- final String[] exceptions) {
- MethodVisitor mv = cv.visitMethod(access, name, desc, signature,
- exceptions);
-
- if (mv == null
- || (access & (Opcodes.ACC_ABSTRACT | Opcodes.ACC_NATIVE)) > 0) {
- return mv;
- }
-
- return new AdviceAdapter(Opcodes.ASM4, mv, access, name, desc) {
-
- @Override
- protected void onMethodEnter() {
- mv.visitLdcInsn(cname + "." + name + desc);
- mv.visitMethodInsn(INVOKESTATIC,
- "org/objectweb/asm/commons/AdviceAdapterUnitTest",
- "enter", "(Ljava/lang/String;)V");
- }
-
- @Override
- protected void onMethodExit(final int opcode) {
- mv.visitLdcInsn(cname + "." + name + desc);
- mv.visitMethodInsn(INVOKESTATIC,
- "org/objectweb/asm/commons/AdviceAdapterUnitTest",
- "exit", "(Ljava/lang/String;)V");
- }
-
- };
- }
- }
-
- // TEST CLASSES
-
- public static class A {
- final String s;
-
- public A(final String s) {
- this.s = s;
- }
-
- public A(final A a) {
- this.s = a.s;
- }
- }
-
- public static class B extends A {
-
- public B() {
- super(new B(""));
- test(this);
- }
-
- public B(final A a) {
- super(a);
- test(this);
- }
-
- public B(final String s) {
- super(s == null ? new A("") : new A(s));
- test(this);
- }
-
- private static A aa;
-
- public B(final String s, final A a) {
- this(s == null ? aa = new A(s) : a);
- A aa = new A("");
- test(aa);
- }
-
- public B(final String s, final String s1) {
- super(s != null ? new A(getA(s1).s) : new A(s));
- test(this);
- }
-
- private void test(final Object b) {
- }
-
- private static A getA(final String s) {
- return new A(s);
- }
-
- // execute all
- public static void run(final int n) {
- new B();
- new B(new A(""));
- new B(new B());
- new B("", new A(""));
- new B("", "");
- }
-
- }
-} \ No newline at end of file
diff --git a/asm4/test/conform/org/objectweb/asm/commons/AnalyzerAdapterTest.java b/asm4/test/conform/org/objectweb/asm/commons/AnalyzerAdapterTest.java
deleted file mode 100644
index c564b93..0000000
--- a/asm4/test/conform/org/objectweb/asm/commons/AnalyzerAdapterTest.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.commons;
-
-import junit.framework.TestSuite;
-
-import org.objectweb.asm.AbstractTest;
-import org.objectweb.asm.ClassReader;
-import org.objectweb.asm.ClassVisitor;
-import org.objectweb.asm.ClassWriter;
-import org.objectweb.asm.MethodVisitor;
-import org.objectweb.asm.Opcodes;
-
-/**
- * AnalyzerAdapter tests.
- *
- * @author Eric Bruneton
- */
-public class AnalyzerAdapterTest extends AbstractTest {
-
- public static TestSuite suite() throws Exception {
- return new AnalyzerAdapterTest().getSuite();
- }
-
- @Override
- public void test() throws Exception {
- ClassReader cr = new ClassReader(is);
- if (cr.readInt(4) != Opcodes.V1_6) {
- try {
- ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES);
- cr.accept(cw, 0);
- cr = new ClassReader(cw.toByteArray());
- } catch (Exception e) {
- skipTest();
- return;
- }
- }
- ClassWriter cw = new ClassWriter(0);
- ClassVisitor cv = new ClassVisitor(Opcodes.ASM4, cw) {
-
- private String owner;
-
- @Override
- public void visit(final int version, final int access,
- final String name, final String signature,
- final String superName, final String[] interfaces) {
- owner = name;
- cv.visit(version, access, name, signature, superName,
- interfaces);
- }
-
- @Override
- public MethodVisitor visitMethod(final int access,
- final String name, final String desc,
- final String signature, final String[] exceptions) {
- MethodVisitor mv = cv.visitMethod(access, name, desc,
- signature, exceptions);
- return new AnalyzerAdapter(owner, access, name, desc, mv);
- }
- };
- cr.accept(cv, ClassReader.EXPAND_FRAMES);
- }
-
- /**
- * Dummy method to avoid a FindBugs warning.
- */
- private void skipTest() {
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/commons/CodeSizeEvaluatorTest.java b/asm4/test/conform/org/objectweb/asm/commons/CodeSizeEvaluatorTest.java
deleted file mode 100644
index b4b0fee..0000000
--- a/asm4/test/conform/org/objectweb/asm/commons/CodeSizeEvaluatorTest.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.commons;
-
-import junit.framework.TestSuite;
-
-import org.objectweb.asm.AbstractTest;
-import org.objectweb.asm.ClassReader;
-import org.objectweb.asm.ClassVisitor;
-import org.objectweb.asm.ClassWriter;
-import org.objectweb.asm.Label;
-import org.objectweb.asm.MethodVisitor;
-import org.objectweb.asm.Opcodes;
-
-public class CodeSizeEvaluatorTest extends AbstractTest {
-
- public static TestSuite suite() throws Exception {
- return new CodeSizeEvaluatorTest().getSuite();
- }
-
- @Override
- public void test() throws Exception {
- ClassReader cr = new ClassReader(is);
- cr.accept(new ClassVisitor(Opcodes.ASM4, new ClassWriter(0)) {
- @Override
- public MethodVisitor visitMethod(final int access,
- final String name, final String desc,
- final String signature, final String[] exceptions) {
- MethodVisitor mv = cv.visitMethod(access, name, desc,
- signature, exceptions);
- return new CodeSizeEvaluator(mv) {
- @Override
- public void visitMaxs(final int maxStack,
- final int maxLocals) {
- Label end = new Label();
- mv.visitLabel(end);
- mv.visitMaxs(maxStack, maxLocals);
- int size = end.getOffset();
- assertTrue(getMinSize() + " <= " + size + " <= "
- + getMaxSize(), getMinSize() <= size
- && size <= getMaxSize());
- }
- };
- }
- }, 0);
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/commons/GASMifier.java b/asm4/test/conform/org/objectweb/asm/commons/GASMifier.java
deleted file mode 100644
index 04bb644..0000000
--- a/asm4/test/conform/org/objectweb/asm/commons/GASMifier.java
+++ /dev/null
@@ -1,927 +0,0 @@
-/***
- * ASM: a very small and fast Java bytecode manipulation framework
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.commons;
-
-import java.io.FileInputStream;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.objectweb.asm.ClassReader;
-import org.objectweb.asm.Handle;
-import org.objectweb.asm.Label;
-import org.objectweb.asm.MethodVisitor;
-import org.objectweb.asm.Opcodes;
-import org.objectweb.asm.Type;
-import org.objectweb.asm.util.ASMifier;
-import org.objectweb.asm.util.TraceClassVisitor;
-
-/**
- * A {@link MethodVisitor} that prints the ASM code that generates the methods
- * it visits by using the GeneratorAdapter class.
- *
- * @author Eric Bruneton
- * @author Eugene Kuleshov
- */
-public class GASMifier extends ASMifier implements Opcodes {
-
- int access;
-
- Type[] argumentTypes;
-
- int firstLocal;
-
- Map<Integer, Integer> locals;
-
- List<String> localTypes;
-
- public GASMifier() {
- }
-
- public GASMifier(final String name, final int id) {
- super(Opcodes.ASM4, name, id);
- }
-
- public GASMifier(final int access, final String desc) {
- super(Opcodes.ASM4, "mg", 0);
- this.access = access;
- this.argumentTypes = Type.getArgumentTypes(desc);
- int nextLocal = (Opcodes.ACC_STATIC & access) != 0 ? 0 : 1;
- for (int i = 0; i < argumentTypes.length; i++) {
- nextLocal += argumentTypes[i].getSize();
- }
- this.firstLocal = nextLocal;
- this.locals = new HashMap<Integer, Integer>();
- this.localTypes = new ArrayList<String>();
- }
-
- /**
- * Prints the ASM source code to generate the given class to the standard
- * output.
- * <p>
- * Usage: ASMifierClassVisitor [-debug] &lt;fully qualified class name or
- * class file name&gt;
- *
- * @param args
- * the command line arguments.
- *
- * @throws Exception
- * if the class cannot be found, or if an IO exception occurs.
- */
- public static void main(final String[] args) throws Exception {
- int i = 0;
- int flags = ClassReader.SKIP_DEBUG;
-
- boolean ok = true;
- if (args.length < 1 || args.length > 2) {
- ok = false;
- }
- if (ok && args[0].equals("-debug")) {
- i = 1;
- flags = 0;
- if (args.length != 2) {
- ok = false;
- }
- }
- if (!ok) {
- System.err
- .println("Prints the ASM code to generate the given class.");
- System.err.println("Usage: GASMifierClassVisitor [-debug] "
- + "<fully qualified class name or class file name>");
- System.exit(-1);
- }
- ClassReader cr;
- if (args[i].endsWith(".class")) {
- cr = new ClassReader(new FileInputStream(args[i]));
- } else {
- cr = new ClassReader(args[i]);
- }
- cr.accept(new TraceClassVisitor(null, new GASMifier(), new PrintWriter(
- System.out)), ClassReader.EXPAND_FRAMES | flags);
- }
-
- @Override
- public void visit(final int version, final int access, final String name,
- final String signature, final String superName,
- final String[] interfaces) {
- super.visit(version, access, name, signature, superName, interfaces);
- int n;
- if (name.lastIndexOf('/') != -1) {
- n = 1;
- } else {
- n = 0;
- }
- text.set(n + 5,
- "ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);\n");
- text.set(n + 7, "GeneratorAdapter mg;\n");
- text.add(n + 1, "import org.objectweb.asm.commons.*;\n");
- }
-
- @Override
- public ASMifier visitMethod(final int access, final String name,
- final String desc, final String signature, final String[] exceptions) {
- buf.setLength(0);
- buf.append("{\n");
- buf.append("mg = new GeneratorAdapter(");
- buf.append(access);
- buf.append(", ");
- buf.append(getMethod(name, desc));
- buf.append(", ");
- if (signature == null) {
- buf.append("null");
- } else {
- buf.append('"').append(signature).append('"');
- }
- buf.append(", ");
- if (exceptions != null && exceptions.length > 0) {
- buf.append("new Type[] {");
- for (int i = 0; i < exceptions.length; ++i) {
- buf.append(i == 0 ? " " : ", ");
- buf.append(getType(exceptions[i]));
- }
- buf.append(" }");
- } else {
- buf.append("null");
- }
- buf.append(", cw);\n");
- text.add(buf.toString());
- GASMifier av = new GASMifier(access, desc);
- text.add(av.getText());
- text.add("}\n");
- return av;
- }
-
- @Override
- public void visitInsn(final int opcode) {
- buf.setLength(0);
- switch (opcode) {
- case IRETURN:
- case LRETURN:
- case FRETURN:
- case DRETURN:
- case ARETURN:
- case RETURN:
- buf.append("mg.returnValue();\n");
- break;
- case NOP:
- buf.append("mg.visitInsn(Opcodes.NOP);\n");
- break;
- case ACONST_NULL:
- buf.append("mg.push((String)null);\n");
- break;
- case ICONST_M1:
- case ICONST_0:
- case ICONST_1:
- case ICONST_2:
- case ICONST_3:
- case ICONST_4:
- case ICONST_5:
- buf.append("mg.push(").append(opcode - ICONST_0).append(");\n");
- break;
- case LCONST_0:
- case LCONST_1:
- buf.append("mg.push(").append(opcode - LCONST_0).append("L);\n");
- break;
- case FCONST_0:
- case FCONST_1:
- case FCONST_2:
- buf.append("mg.push(").append(opcode - FCONST_0).append("f);\n");
- break;
- case DCONST_0:
- case DCONST_1:
- buf.append("mg.push(").append(opcode - DCONST_0).append("d);\n");
- break;
- case POP:
- buf.append("mg.pop();\n");
- break;
- case POP2:
- buf.append("mg.pop2();\n");
- break;
- case DUP:
- buf.append("mg.dup();\n");
- break;
- case DUP_X1:
- buf.append("mg.dupX1();\n");
- break;
- case DUP_X2:
- buf.append("mg.dupX2();\n");
- break;
- case DUP2:
- buf.append("mg.dup2();\n");
- break;
- case DUP2_X1:
- buf.append("mg.dup2X1();\n");
- break;
- case DUP2_X2:
- buf.append("mg.dup2X2();\n");
- break;
- case SWAP:
- buf.append("mg.swap();\n");
- break;
- case MONITORENTER:
- buf.append("mg.monitorEnter();\n");
- break;
- case MONITOREXIT:
- buf.append("mg.monitorExit();\n");
- break;
- case ARRAYLENGTH:
- buf.append("mg.arrayLength();\n");
- break;
- case IALOAD:
- buf.append("mg.arrayLoad(Type.INT_TYPE);\n");
- break;
- case LALOAD:
- buf.append("mg.arrayLoad(Type.LONG_TYPE);\n");
- break;
- case FALOAD:
- buf.append("mg.arrayLoad(Type.FLOAT_TYPE);\n");
- break;
- case DALOAD:
- buf.append("mg.arrayLoad(Type.DOUBLE_TYPE);\n");
- break;
- case AALOAD:
- buf.append("mg.arrayLoad(" + getType("java/lang/Object") + ");\n");
- break;
- case BALOAD:
- buf.append("mg.arrayLoad(Type.BYTE_TYPE);\n");
- break;
- case CALOAD:
- buf.append("mg.arrayLoad(Type.CHAR_TYPE);\n");
- break;
- case SALOAD:
- buf.append("mg.arrayLoad(Type.SHORT_TYPE);\n");
- break;
- case IASTORE:
- buf.append("mg.arrayStore(Type.INT_TYPE);\n");
- break;
- case LASTORE:
- buf.append("mg.arrayStore(Type.LONG_TYPE);\n");
- break;
- case FASTORE:
- buf.append("mg.arrayStore(Type.FLOAT_TYPE);\n");
- break;
- case DASTORE:
- buf.append("mg.arrayStore(Type.DOUBLE_TYPE);\n");
- break;
- case AASTORE:
- buf.append("mg.arrayStore(" + getType("java/lang/Object") + ");\n");
- break;
- case BASTORE:
- buf.append("mg.arrayStore(Type.BYTE_TYPE);\n");
- break;
- case CASTORE:
- buf.append("mg.arrayStore(Type.CHAR_TYPE);\n");
- break;
- case SASTORE:
- buf.append("mg.arrayStore(Type.SHORT_TYPE);\n");
- break;
- case IADD:
- buf.append("mg.math(GeneratorAdapter.ADD, Type.INT_TYPE);\n");
- break;
- case LADD:
- buf.append("mg.math(GeneratorAdapter.ADD, Type.LONG_TYPE);\n");
- break;
- case FADD:
- buf.append("mg.math(GeneratorAdapter.ADD, Type.FLOAT_TYPE);\n");
- break;
- case DADD:
- buf.append("mg.math(GeneratorAdapter.ADD, Type.DOUBLE_TYPE);\n");
- break;
- case ISUB:
- buf.append("mg.math(GeneratorAdapter.SUB, Type.INT_TYPE);\n");
- break;
- case LSUB:
- buf.append("mg.math(GeneratorAdapter.SUB, Type.LONG_TYPE);\n");
- break;
- case FSUB:
- buf.append("mg.math(GeneratorAdapter.SUB, Type.FLOAT_TYPE);\n");
- break;
- case DSUB:
- buf.append("mg.math(GeneratorAdapter.SUB, Type.DOUBLE_TYPE);\n");
- break;
- case IMUL:
- buf.append("mg.math(GeneratorAdapter.MUL, Type.INT_TYPE);\n");
- break;
- case LMUL:
- buf.append("mg.math(GeneratorAdapter.MUL, Type.LONG_TYPE);\n");
- break;
- case FMUL:
- buf.append("mg.math(GeneratorAdapter.MUL, Type.FLOAT_TYPE);\n");
- break;
- case DMUL:
- buf.append("mg.math(GeneratorAdapter.MUL, Type.DOUBLE_TYPE);\n");
- break;
- case IDIV:
- buf.append("mg.math(GeneratorAdapter.DIV, Type.INT_TYPE);\n");
- break;
- case LDIV:
- buf.append("mg.math(GeneratorAdapter.DIV, Type.LONG_TYPE);\n");
- break;
- case FDIV:
- buf.append("mg.math(GeneratorAdapter.DIV, Type.FLOAT_TYPE);\n");
- break;
- case DDIV:
- buf.append("mg.math(GeneratorAdapter.DIV, Type.DOUBLE_TYPE);\n");
- break;
- case IREM:
- buf.append("mg.math(GeneratorAdapter.REM, Type.INT_TYPE);\n");
- break;
- case LREM:
- buf.append("mg.math(GeneratorAdapter.REM, Type.LONG_TYPE);\n");
- break;
- case FREM:
- buf.append("mg.math(GeneratorAdapter.REM, Type.FLOAT_TYPE);\n");
- break;
- case DREM:
- buf.append("mg.math(GeneratorAdapter.REM, Type.DOUBLE_TYPE);\n");
- break;
- case INEG:
- buf.append("mg.math(GeneratorAdapter.NEG, Type.INT_TYPE);\n");
- break;
- case LNEG:
- buf.append("mg.math(GeneratorAdapter.NEG, Type.LONG_TYPE);\n");
- break;
- case FNEG:
- buf.append("mg.math(GeneratorAdapter.NEG, Type.FLOAT_TYPE);\n");
- break;
- case DNEG:
- buf.append("mg.math(GeneratorAdapter.NEG, Type.DOUBLE_TYPE);\n");
- break;
- case ISHL:
- buf.append("mg.math(GeneratorAdapter.SHL, Type.INT_TYPE);\n");
- break;
- case LSHL:
- buf.append("mg.math(GeneratorAdapter.SHL, Type.LONG_TYPE);\n");
- break;
- case ISHR:
- buf.append("mg.math(GeneratorAdapter.SHR, Type.INT_TYPE);\n");
- break;
- case LSHR:
- buf.append("mg.math(GeneratorAdapter.SHR, Type.LONG_TYPE);\n");
- break;
- case IUSHR:
- buf.append("mg.math(GeneratorAdapter.USHR, Type.INT_TYPE);\n");
- break;
- case LUSHR:
- buf.append("mg.math(GeneratorAdapter.USHR, Type.LONG_TYPE);\n");
- break;
- case IAND:
- buf.append("mg.math(GeneratorAdapter.AND, Type.INT_TYPE);\n");
- break;
- case LAND:
- buf.append("mg.math(GeneratorAdapter.AND, Type.LONG_TYPE);\n");
- break;
- case IOR:
- buf.append("mg.math(GeneratorAdapter.OR, Type.INT_TYPE);\n");
- break;
- case LOR:
- buf.append("mg.math(GeneratorAdapter.OR, Type.LONG_TYPE);\n");
- break;
- case IXOR:
- buf.append("mg.math(GeneratorAdapter.XOR, Type.INT_TYPE);\n");
- break;
- case LXOR:
- buf.append("mg.math(GeneratorAdapter.XOR, Type.LONG_TYPE);\n");
- break;
- case ATHROW:
- buf.append("mg.throwException();\n");
- break;
- case I2L:
- buf.append("mg.cast(Type.INT_TYPE, Type.LONG_TYPE);\n");
- break;
- case I2F:
- buf.append("mg.cast(Type.INT_TYPE, Type.FLOAT_TYPE);\n");
- break;
- case I2D:
- buf.append("mg.cast(Type.INT_TYPE, Type.DOUBLE_TYPE);\n");
- break;
- case L2I:
- buf.append("mg.cast(Type.LONG_TYPE, Type.INT_TYPE);\n");
- break;
- case L2F:
- buf.append("mg.cast(Type.LONG_TYPE, Type.FLOAT_TYPE);\n");
- break;
- case L2D:
- buf.append("mg.cast(Type.LONG_TYPE, Type.DOUBLE_TYPE);\n");
- break;
- case F2I:
- buf.append("mg.cast(Type.FLOAT_TYPE, Type.INT_TYPE);\n");
- break;
- case F2L:
- buf.append("mg.cast(Type.FLOAT_TYPE, Type.LONG_TYPE);\n");
- break;
- case F2D:
- buf.append("mg.cast(Type.FLOAT_TYPE, Type.DOUBLE_TYPE);\n");
- break;
- case D2I:
- buf.append("mg.cast(Type.DOUBLE_TYPE, Type.INT_TYPE);\n");
- break;
- case D2L:
- buf.append("mg.cast(Type.DOUBLE_TYPE, Type.LONG_TYPE);\n");
- break;
- case D2F:
- buf.append("mg.cast(Type.DOUBLE_TYPE, Type.FLOAT_TYPE);\n");
- break;
- case I2B:
- // TODO detect if previous element in 'text' is a cast,
- // for possible optimisations (e.g. cast(F,I) cast(I,B) =
- // cast(F,B))
- buf.append("mg.cast(Type.INT_TYPE, Type.BYTE_TYPE);\n");
- break;
- case I2C: // idem
- buf.append("mg.cast(Type.INT_TYPE, Type.CHAR_TYPE);\n");
- break;
- case I2S: // idem
- buf.append("mg.cast(Type.INT_TYPE, Type.SHORT_TYPE);\n");
- break;
- case LCMP:
- case FCMPL:
- case FCMPG:
- case DCMPL:
- case DCMPG:
- // TODO detect xCMPy IF_ICMP -> ifCmp(..., ..., label)
- buf.append("mg.visitInsn(").append(OPCODES[opcode]).append(");\n");
- break;
- default:
- throw new RuntimeException("unexpected case");
- }
- text.add(buf.toString());
- }
-
- @Override
- public void visitIntInsn(final int opcode, final int operand) {
- buf.setLength(0);
- if (opcode == NEWARRAY) {
- String type;
- switch (operand) {
- case T_BOOLEAN:
- type = "Type.BOOLEAN_TYPE";
- break;
- case T_CHAR:
- type = "Type.CHAR_TYPE";
- break;
- case T_FLOAT:
- type = "Type.FLOAT_TYPE";
- break;
- case T_DOUBLE:
- type = "Type.DOUBLE_TYPE";
- break;
- case T_BYTE:
- type = "Type.BYTE_TYPE";
- break;
- case T_SHORT:
- type = "Type.SHORT_TYPE";
- break;
- case T_INT:
- type = "Type.INT_TYPE";
- break;
- case T_LONG:
- type = "Type.LONG_TYPE";
- break;
- default:
- throw new RuntimeException("unexpected case");
- }
- buf.append("mg.newArray(").append(type).append(");\n");
- } else {
- buf.append("mg.push(").append(operand).append(");\n");
- }
- text.add(buf.toString());
- }
-
- @Override
- public void visitVarInsn(final int opcode, final int var) {
- buf.setLength(0);
- try {
- switch (opcode) {
- case RET:
- if (var < firstLocal) {
- buf.append("mg.ret(");
- buf.append(var);
- buf.append(");\n");
- } else {
- int v = generateNewLocal(var, "Type.INT_TYPE");
- buf.append("mg.ret(");
- buf.append("local").append(v);
- buf.append(");\n");
- }
- break;
-
- case ILOAD:
- generateLoadLocal(var, "Type.INT_TYPE");
- break;
- case LLOAD:
- generateLoadLocal(var, "Type.LONG_TYPE");
- break;
- case FLOAD:
- generateLoadLocal(var, "Type.FLOAT_TYPE");
- break;
- case DLOAD:
- generateLoadLocal(var, "Type.DOUBLE_TYPE");
- break;
- case ALOAD:
- generateLoadLocal(var, getType("java/lang/Object"));
- break;
-
- case ISTORE:
- generateStoreLocal(var, "Type.INT_TYPE");
- break;
- case LSTORE:
- generateStoreLocal(var, "Type.LONG_TYPE");
- break;
- case FSTORE:
- generateStoreLocal(var, "Type.FLOAT_TYPE");
- break;
- case DSTORE:
- generateStoreLocal(var, "Type.DOUBLE_TYPE");
- break;
- case ASTORE:
- generateStoreLocal(var, getType("java/lang/Object"));
- break;
-
- default:
- throw new RuntimeException("unexpected case");
- }
- } catch (RuntimeException e) {
- buf.append("mg.visitVarInsn(" + OPCODES[opcode] + ", " + var
- + ");\n");
- }
- text.add(buf.toString());
- }
-
- private void generateLoadLocal(final int var, final String type) {
- if (var < firstLocal) {
- if (var == 0 && (access & ACC_STATIC) == 0) {
- buf.append("mg.loadThis();\n");
- } else {
- int index = getArgIndex(var);
- buf.append("mg.loadArg(").append(index).append(");\n");
- }
- } else {
- int local = generateNewLocal(var, type);
- buf.append("mg.loadLocal(local").append(local);
- if (!type.equals(localTypes.get(local))) {
- localTypes.set(local, type);
- buf.append(", ").append(type);
- }
- buf.append(");\n");
- }
- }
-
- private void generateStoreLocal(final int var, final String type) {
- if (var < firstLocal) {
- if (var == 0 && (access & ACC_STATIC) == 0) {
- buf.append("mg.visitVarInsn(ASTORE, " + var + ");\n");
- } else {
- int index = getArgIndex(var);
- buf.append("mg.storeArg(").append(index).append(");\n");
- }
- } else {
- int local = generateNewLocal(var, type);
- buf.append("mg.storeLocal(local").append(local);
- if (!type.equals(localTypes.get(local))) {
- localTypes.set(local, type);
- buf.append(", ").append(type);
- }
- buf.append(");\n");
- }
- }
-
- private int generateNewLocal(final int var, final String type) {
- Integer i = locals.get(new Integer(var));
- if (i == null) {
- int local = locals.size();
- locals.put(new Integer(var), new Integer(local));
- localTypes.add(type);
- buf.append("int local" + local + " = mg.newLocal(" + type + ");\n");
- return local;
- }
- return i.intValue();
- }
-
- private int getArgIndex(final int var) {
- int nextLocal = (Opcodes.ACC_STATIC & access) != 0 ? 0 : 1;
- int i = 0;
- while (nextLocal != var) {
- nextLocal += argumentTypes[i++].getSize();
- }
- return i;
- }
-
- @Override
- public void visitTypeInsn(final int opcode, final String type) {
- String typ = getType(type);
- buf.setLength(0);
- if (opcode == NEW) {
- buf.append("mg.newInstance(").append(typ).append(");\n");
- } else if (opcode == ANEWARRAY) {
- buf.append("mg.newArray(").append(typ).append(");\n");
- } else if (opcode == CHECKCAST) {
- buf.append("mg.checkCast(").append(typ).append(");\n");
- } else if (opcode == INSTANCEOF) {
- buf.append("mg.instanceOf(").append(typ).append(");\n");
- }
- text.add(buf.toString());
- }
-
- @Override
- public void visitFieldInsn(final int opcode, final String owner,
- final String name, final String desc) {
- buf.setLength(0);
- switch (opcode) {
- case GETFIELD:
- buf.append("mg.getField(");
- break;
- case PUTFIELD:
- buf.append("mg.putField(");
- break;
- case GETSTATIC:
- buf.append("mg.getStatic(");
- break;
- case PUTSTATIC:
- buf.append("mg.putStatic(");
- break;
- default:
- throw new RuntimeException("unexpected case");
- }
- buf.append(getType(owner));
- buf.append(", \"");
- buf.append(name);
- buf.append("\", ");
- buf.append(getDescType(desc));
- buf.append(");\n");
- text.add(buf.toString());
- }
-
- @Override
- public void visitMethodInsn(final int opcode, final String owner,
- final String name, final String desc) {
- buf.setLength(0);
- switch (opcode) {
- case INVOKEVIRTUAL:
- buf.append("mg.invokeVirtual(");
- break;
- case INVOKESPECIAL:
- buf.append("mg.invokeConstructor(");
- break;
- case INVOKESTATIC:
- buf.append("mg.invokeStatic(");
- break;
- case INVOKEINTERFACE:
- buf.append("mg.invokeInterface(");
- break;
- default:
- throw new RuntimeException("unexpected case");
- }
- if (owner.charAt(0) == '[') {
- buf.append(getDescType(owner));
- } else {
- buf.append(getType(owner));
- }
- buf.append(", ");
- buf.append(getMethod(name, desc));
- buf.append(");\n");
- text.add(buf.toString());
- }
-
- @Override
- public void visitInvokeDynamicInsn(String name, String desc, Handle bsm,
- Object... bsmArgs) {
- buf.setLength(0);
- buf.append("mg.invokeDynamic(");
- appendConstant(name);
- buf.append(", ");
- appendConstant(desc);
- buf.append(", ");
- appendConstant(bsm);
- buf.append(", new Object[] {");
- for (int i = 0; i < bsmArgs.length; ++i) {
- appendConstant(bsmArgs[i]);
- if (i != bsmArgs.length - 1) {
- buf.append(", ");
- }
- }
- buf.append("});\n");
- text.add(buf.toString());
- }
-
- @Override
- public void visitJumpInsn(final int opcode, final Label label) {
- buf.setLength(0);
- declareLabel(label);
- if (opcode == GOTO || opcode == IFNULL || opcode == IFNONNULL) {
- if (opcode == GOTO) {
- buf.append("mg.goTo(");
- }
- if (opcode == IFNULL) {
- buf.append("mg.ifNull(");
- }
- if (opcode == IFNONNULL) {
- buf.append("mg.ifNonNull(");
- }
- appendLabel(label);
- buf.append(");\n");
- } else if (opcode == IF_ICMPEQ) {
- buf.append("mg.ifICmp(GeneratorAdapter.EQ, ");
- appendLabel(label);
- buf.append(");\n");
- } else if (opcode == IF_ICMPNE) {
- buf.append("mg.ifICmp(GeneratorAdapter.NE, ");
- appendLabel(label);
- buf.append(");\n");
- } else if (opcode == IF_ICMPLT) {
- buf.append("mg.ifICmp(GeneratorAdapter.LT, ");
- appendLabel(label);
- buf.append(");\n");
- } else if (opcode == IF_ICMPGE) {
- buf.append("mg.ifICmp(GeneratorAdapter.GE, ");
- appendLabel(label);
- buf.append(");\n");
- } else if (opcode == IF_ICMPGT) {
- buf.append("mg.ifICmp(GeneratorAdapter.GT, ");
- appendLabel(label);
- buf.append(");\n");
- } else if (opcode == IF_ICMPLE) {
- buf.append("mg.ifICmp(GeneratorAdapter.LE, ");
- appendLabel(label);
- buf.append(");\n");
- } else if (opcode == IF_ACMPEQ) {
- buf.append("mg.ifCmp(");
- buf.append(getType("java/lang/Object")).append(", ")
- .append("GeneratorAdapter.EQ, ");
- appendLabel(label);
- buf.append(");\n");
- } else if (opcode == IF_ACMPNE) {
- buf.append("mg.ifCmp(");
- buf.append(getType("java/lang/Object")).append(", ")
- .append("GeneratorAdapter.NE, ");
- appendLabel(label);
- buf.append(");\n");
- } else if (opcode == IFEQ) {
- buf.append("mg.ifZCmp(GeneratorAdapter.EQ, ");
- appendLabel(label);
- buf.append(");\n");
- } else if (opcode == IFNE) {
- buf.append("mg.ifZCmp(GeneratorAdapter.NE, ");
- appendLabel(label);
- buf.append(");\n");
- } else if (opcode == IFLT) {
- buf.append("mg.ifZCmp(GeneratorAdapter.LT, ");
- appendLabel(label);
- buf.append(");\n");
- } else if (opcode == IFGE) {
- buf.append("mg.ifZCmp(GeneratorAdapter.GE, ");
- appendLabel(label);
- buf.append(");\n");
- } else if (opcode == IFGT) {
- buf.append("mg.ifZCmp(GeneratorAdapter.GT, ");
- appendLabel(label);
- buf.append(");\n");
- } else if (opcode == IFLE) {
- buf.append("mg.ifZCmp(GeneratorAdapter.LE, ");
- appendLabel(label);
- buf.append(");\n");
- } else {
- buf.append("mg.visitJumpInsn(").append(OPCODES[opcode])
- .append(", ");
- appendLabel(label);
- buf.append(");\n");
- }
- text.add(buf.toString());
- }
-
- @Override
- public void visitLabel(final Label label) {
- buf.setLength(0);
- declareLabel(label);
- buf.append("mg.mark(");
- appendLabel(label);
- buf.append(");\n");
- text.add(buf.toString());
- }
-
- @Override
- public void visitLdcInsn(final Object cst) {
- buf.setLength(0);
- buf.append("mg.push(");
- appendConstant(cst);
- buf.append(");\n");
- text.add(buf.toString());
- }
-
- @Override
- public void visitIincInsn(final int var, final int increment) {
- buf.setLength(0);
- if (var < firstLocal) {
- buf.append("mg.iinc(").append(var);
- } else {
- int v = generateNewLocal(var, "Type.INT_TYPE");
- buf.append("mg.iinc(local").append(v);
- }
- buf.append(", ").append(increment).append(");\n");
- text.add(buf.toString());
- }
-
- @Override
- public void visitMaxs(final int maxStack, final int maxLocals) {
- text.add("mg.endMethod();\n");
- }
-
- @Override
- protected ASMifier createASMifier(final String name, final int id) {
- return new GASMifier(name, id);
- }
-
- static String getType(final String internalName) {
- return "Type.getObjectType(\"" + internalName + "\")";
- }
-
- static String getDescType(final String desc) {
- if (desc.equals("Z")) {
- return "Type.BOOLEAN_TYPE";
- }
- if (desc.equals("B")) {
- return "Type.BYTE_TYPE";
- }
- if (desc.equals("C")) {
- return "Type.CHAR_TYPE";
- }
- if (desc.equals("D")) {
- return "Type.DOUBLE_TYPE";
- }
- if (desc.equals("F")) {
- return "Type.FLOAT_TYPE";
- }
- if (desc.equals("I")) {
- return "Type.INT_TYPE";
- }
- if (desc.equals("J")) {
- return "Type.LONG_TYPE";
- }
- if (desc.equals("S")) {
- return "Type.SHORT_TYPE";
- }
- if (desc.equals("V")) {
- return "Type.VOID_TYPE";
- }
- return "Type.getType(\"" + desc + "\")";
- }
-
- static String getMethod(final String name, final String desc) {
- Type rt = Type.getReturnType(desc);
- Type[] argt = Type.getArgumentTypes(desc);
- StringBuffer buf = new StringBuffer();
- buf.append("Method.getMethod(\"");
- buf.append(rt.getClassName()).append(' ');
- buf.append(name).append('(');
- for (int i = 0; i < argt.length; ++i) {
- if (i > 0) {
- buf.append(',');
- }
- buf.append(argt[i].getClassName());
- }
- buf.append(")\")");
- return buf.toString();
- }
-
- @Override
- protected void declareLabel(final Label l) {
- if (labelNames == null) {
- labelNames = new HashMap<Label, String>();
- }
- String name = labelNames.get(l);
- if (name == null) {
- name = "label" + labelNames.size();
- labelNames.put(l, name);
- buf.append("Label ").append(name).append(" = mg.newLabel();\n");
- }
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/commons/GASMifierTest.java b/asm4/test/conform/org/objectweb/asm/commons/GASMifierTest.java
deleted file mode 100644
index 6c2bc88..0000000
--- a/asm4/test/conform/org/objectweb/asm/commons/GASMifierTest.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.commons;
-
-import java.io.PrintWriter;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.net.URL;
-import java.net.URLClassLoader;
-
-import junit.framework.TestSuite;
-
-import org.codehaus.janino.ClassLoaderIClassLoader;
-import org.codehaus.janino.DebuggingInformation;
-import org.codehaus.janino.IClassLoader;
-import org.codehaus.janino.Parser;
-import org.codehaus.janino.Scanner;
-import org.codehaus.janino.UnitCompiler;
-import org.objectweb.asm.AbstractTest;
-import org.objectweb.asm.Attribute;
-import org.objectweb.asm.ClassReader;
-import org.objectweb.asm.ClassVisitor;
-import org.objectweb.asm.ClassWriter;
-import org.objectweb.asm.MethodVisitor;
-import org.objectweb.asm.Opcodes;
-import org.objectweb.asm.attrs.CodeComment;
-import org.objectweb.asm.attrs.Comment;
-import org.objectweb.asm.util.TraceClassVisitor;
-
-/**
- * GASMifier tests.
- *
- * @author Eugene Kuleshov
- * @author Eric Bruneton
- */
-public class GASMifierTest extends AbstractTest {
-
- public static final Compiler COMPILER = new Compiler();
-
- private final static TestClassLoader LOADER = new TestClassLoader();
-
- public static TestSuite suite() throws Exception {
- return new GASMifierTest().getSuite();
- }
-
- @Override
- public void test() throws Exception {
- ClassReader cr = new ClassReader(is);
-
- if (cr.b.length > 20000) {
- return;
- }
-
- StringWriter sw = new StringWriter();
- TraceClassVisitor cv = new TraceClassVisitor(null, new GASMifier(),
- new PrintWriter(sw));
- cr.accept(new ClassLocalVariablesSorter(cv), new Attribute[] {
- new Comment(), new CodeComment() }, ClassReader.EXPAND_FRAMES);
-
- String generated = sw.toString();
-
- byte[] generatorClassData;
- try {
- generatorClassData = COMPILER.compile(n, generated);
- } catch (Exception ex) {
- trace(generated);
- throw ex;
- }
-
- ClassWriter cw = new ClassWriter(0);
- cr.accept(new ClassLocalVariablesSorter(cw), new Attribute[] {
- new Comment(), new CodeComment() }, ClassReader.EXPAND_FRAMES);
- cr = new ClassReader(cw.toByteArray());
-
- String nd = n + "Dump";
- if (n.indexOf('.') != -1) {
- nd = "asm." + nd;
- }
-
- Class<?> c = LOADER.defineClass(nd, generatorClassData);
- Method m = c.getMethod("dump", new Class<?>[0]);
- byte[] b;
- try {
- b = (byte[]) m.invoke(null, new Object[0]);
- } catch (InvocationTargetException ex) {
- trace(generated);
- throw (Exception) ex.getTargetException();
- }
-
- try {
- assertEquals(cr, new ClassReader(b), new Filter(), new Filter());
- } catch (Throwable e) {
- trace(generated);
- assertEquals(cr, new ClassReader(b), new Filter(), new Filter());
- }
- }
-
- private void trace(final String generated) {
- if (System.getProperty("asm.test.class") != null) {
- System.err.println(generated);
- }
- }
-
- static class TestClassLoader extends ClassLoader {
-
- public Class<?> defineClass(final String name, final byte[] b) {
- return defineClass(name, b, 0, b.length);
- }
- }
-
- static class Compiler {
-
- final static IClassLoader CL = new ClassLoaderIClassLoader(
- new URLClassLoader(new URL[0]));
-
- public byte[] compile(final String name, final String source)
- throws Exception {
- Parser p = new Parser(new Scanner(name, new StringReader(source)));
- UnitCompiler uc = new UnitCompiler(p.parseCompilationUnit(), CL);
- return uc.compileUnit(DebuggingInformation.ALL)[0].toByteArray();
- }
- }
-
- static class ClassLocalVariablesSorter extends ClassVisitor {
-
- public ClassLocalVariablesSorter(final ClassVisitor cv) {
- super(Opcodes.ASM4, cv);
- }
-
- @Override
- public MethodVisitor visitMethod(final int access, final String name,
- final String desc, final String signature,
- final String[] exceptions) {
- return new LocalVariablesSorter(access, desc, super.visitMethod(
- access, name, desc, signature, exceptions));
- }
- }
-
- static class Filter extends ClassVisitor {
-
- public Filter() {
- super(Opcodes.ASM4);
- }
-
- @Override
- public MethodVisitor visitMethod(final int access, final String name,
- final String desc, final String signature,
- final String[] exceptions) {
- return new MethodVisitor(Opcodes.ASM4, super.visitMethod(access,
- name, desc, signature, exceptions)) {
- @Override
- public void visitMaxs(final int maxStack, final int maxLocals) {
- super.visitMaxs(0, 0);
- }
- };
- }
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/commons/JSRInlinerAdapterTest.java b/asm4/test/conform/org/objectweb/asm/commons/JSRInlinerAdapterTest.java
deleted file mode 100644
index 02c7549..0000000
--- a/asm4/test/conform/org/objectweb/asm/commons/JSRInlinerAdapterTest.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.commons;
-
-import junit.framework.TestSuite;
-
-import org.objectweb.asm.AbstractTest;
-import org.objectweb.asm.ClassReader;
-import org.objectweb.asm.ClassVisitor;
-import org.objectweb.asm.ClassWriter;
-import org.objectweb.asm.MethodVisitor;
-import org.objectweb.asm.Opcodes;
-
-/**
- * JSRInliner tests.
- *
- * @author Eric Bruneton
- */
-public class JSRInlinerAdapterTest extends AbstractTest {
-
- private final static TestClassLoader LOADER = new TestClassLoader();
-
- public static TestSuite suite() throws Exception {
- return new JSRInlinerAdapterTest().getSuite();
- }
-
- @Override
- public void test() throws Exception {
- ClassReader cr = new ClassReader(is);
- ClassWriter cw = new ClassWriter(0);
- cr.accept(new ClassVisitor(Opcodes.ASM4, cw) {
-
- @Override
- public MethodVisitor visitMethod(final int access,
- final String name, final String desc,
- final String signature, final String[] exceptions) {
- MethodVisitor mv = super.visitMethod(access, name, desc,
- signature, exceptions);
- return new JSRInlinerAdapter(mv, access, name, desc, signature,
- exceptions);
- }
- }, 0);
- byte[] b = cw.toByteArray();
- try {
- LOADER.defineClass(n, b);
- } catch (ClassFormatError cfe) {
- fail(cfe.getMessage());
- } catch (Throwable ignored) {
- }
- }
-
- // ------------------------------------------------------------------------
-
- static class TestClassLoader extends ClassLoader {
-
- public Class<?> defineClass(final String name, final byte[] b) {
- return defineClass(name, b, 0, b.length);
- }
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/commons/JSRInlinerAdapterUnitTest.java b/asm4/test/conform/org/objectweb/asm/commons/JSRInlinerAdapterUnitTest.java
deleted file mode 100644
index f501160..0000000
--- a/asm4/test/conform/org/objectweb/asm/commons/JSRInlinerAdapterUnitTest.java
+++ /dev/null
@@ -1,1874 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.commons;
-
-import junit.framework.TestCase;
-
-import org.objectweb.asm.ClassWriter;
-import org.objectweb.asm.Label;
-import org.objectweb.asm.MethodVisitor;
-import org.objectweb.asm.Opcodes;
-import org.objectweb.asm.tree.MethodNode;
-import org.objectweb.asm.util.TraceMethodVisitor;
-import org.objectweb.asm.util.Textifier;
-
-/**
- * JsrInlinerTest
- *
- * @author Eugene Kuleshov, Niko Matsakis, Eric Bruneton
- */
-public class JSRInlinerAdapterUnitTest extends TestCase {
-
- private JSRInlinerAdapter jsr;
- private MethodNode exp;
- private MethodVisitor current;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- jsr = new JSRInlinerAdapter(null, 0, "m", "()V", null, null) {
- @Override
- public void visitEnd() {
- System.err.println("started w/ method:" + name);
- Textifier t = new Textifier();
- TraceMethodVisitor mv = new TraceMethodVisitor(t);
- for (int i = 0; i < instructions.size(); ++i) {
- instructions.get(i).accept(mv);
- System.err.print(Integer.toString(i + 100000).substring(1));
- System.err.print(" : " + t.text.get(i));
- }
- super.visitEnd();
- System.err.println("finished w/ method:" + name);
- }
- };
- exp = new MethodNode(0, "m", "()V", null, null);
- }
-
- private void setCurrent(final MethodVisitor cv) {
- this.current = cv;
- }
-
- private void ICONST_0() {
- this.current.visitInsn(Opcodes.ICONST_0);
- }
-
- private void ISTORE(final int var) {
- this.current.visitVarInsn(Opcodes.ISTORE, var);
- }
-
- private void ALOAD(final int var) {
- this.current.visitVarInsn(Opcodes.ALOAD, var);
- }
-
- private void ILOAD(final int var) {
- this.current.visitVarInsn(Opcodes.ILOAD, var);
- }
-
- private void ASTORE(final int var) {
- this.current.visitVarInsn(Opcodes.ASTORE, var);
- }
-
- private void RET(final int var) {
- this.current.visitVarInsn(Opcodes.RET, var);
- }
-
- private void ATHROW() {
- this.current.visitInsn(Opcodes.ATHROW);
- }
-
- private void ACONST_NULL() {
- this.current.visitInsn(Opcodes.ACONST_NULL);
- }
-
- private void RETURN() {
- this.current.visitInsn(Opcodes.RETURN);
- }
-
- private void LABEL(final Label l) {
- this.current.visitLabel(l);
- }
-
- private void IINC(final int var, final int amnt) {
- this.current.visitIincInsn(var, amnt);
- }
-
- private void GOTO(final Label l) {
- this.current.visitJumpInsn(Opcodes.GOTO, l);
- }
-
- private void JSR(final Label l) {
- this.current.visitJumpInsn(Opcodes.JSR, l);
- }
-
- private void IFNONNULL(final Label l) {
- this.current.visitJumpInsn(Opcodes.IFNONNULL, l);
- }
-
- private void IFNE(final Label l) {
- this.current.visitJumpInsn(Opcodes.IFNE, l);
- }
-
- private void TRYCATCH(final Label start, final Label end,
- final Label handler) {
- this.current.visitTryCatchBlock(start, end, handler, null);
- }
-
- private void LINE(final int line, final Label start) {
- this.current.visitLineNumber(line, start);
- }
-
- private void LOCALVAR(final String name, final String desc,
- final int index, final Label start, final Label end) {
- this.current.visitLocalVariable(name, desc, null, start, end, index);
- }
-
- private void END(final int maxStack, final int maxLocals) {
- this.current.visitMaxs(maxStack, maxLocals);
- this.current.visitEnd();
- ClassWriter cw = new ClassWriter(0);
- cw.visit(Opcodes.V1_1, Opcodes.ACC_PUBLIC, "C", null,
- "java/lang/Object", null);
- MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "<init>", "()V",
- null, null);
- mv.visitCode();
- mv.visitVarInsn(Opcodes.ALOAD, 0);
- mv.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/lang/Object", "<init>",
- "()V");
- mv.visitInsn(Opcodes.RETURN);
- mv.visitMaxs(1, 1);
- mv.visitEnd();
- ((MethodNode) this.current).accept(cw);
- cw.visitEnd();
- byte[] b = cw.toByteArray();
- try {
- TestClassLoader loader = new TestClassLoader();
- Class<?> c = loader.defineClass("C", b);
- c.newInstance();
- } catch (Throwable t) {
- fail(t.getMessage());
- }
- this.current = null;
- }
-
- static class TestClassLoader extends ClassLoader {
-
- public Class<?> defineClass(final String name, final byte[] b) {
- return defineClass(name, b, 0, b.length);
- }
- }
-
- /**
- * Tests a method which has the most basic <code>try{}finally</code> form
- * imaginable:
- *
- * <pre>
- * public void a() {
- * int a = 0;
- * try {
- * a++;
- * } finally {
- * a--;
- * }
- * }
- * </pre>
- */
- public void testBasic() {
- {
- Label L0 = new Label();
- Label L1 = new Label();
- Label L2 = new Label();
- Label L3 = new Label();
- Label L4 = new Label();
-
- setCurrent(jsr);
- ICONST_0();
- ISTORE(1);
-
- /* L0: body of try block */
- LABEL(L0);
- IINC(1, 1);
- GOTO(L1);
-
- /* L2: exception handler */
- LABEL(L2);
- ASTORE(3);
- JSR(L3);
- ALOAD(3);
- ATHROW();
-
- /* L3: subroutine */
- LABEL(L3);
- ASTORE(2);
- IINC(1, -1);
- RET(2);
-
- /* L1: non-exceptional exit from try block */
- LABEL(L1);
- JSR(L3);
- LABEL(L4); // L4
- RETURN();
-
- TRYCATCH(L0, L2, L2);
- TRYCATCH(L1, L4, L2);
-
- END(1, 4);
- }
-
- {
- Label L0 = new Label();
- Label L1 = new Label();
- Label L2 = new Label();
- Label L3_1a = new Label();
- Label L3_1b = new Label();
- Label L3_2a = new Label();
- Label L3_2b = new Label();
- Label L4 = new Label();
-
- setCurrent(exp);
- ICONST_0();
- ISTORE(1);
- // L0: try/catch block
- LABEL(L0);
- IINC(1, 1);
- GOTO(L1);
-
- // L2: Exception handler:
- LABEL(L2);
- ASTORE(3);
- ACONST_NULL();
- GOTO(L3_1a);
- LABEL(L3_1b); // L3_1b;
- ALOAD(3);
- ATHROW();
-
- // L1: On non-exceptional exit, try block leads here:
- LABEL(L1);
- ACONST_NULL();
- GOTO(L3_2a);
- LABEL(L3_2b); // L3_2b
- LABEL(L4); // L4
- RETURN();
-
- // L3_1a: First instantiation of subroutine:
- LABEL(L3_1a);
- ASTORE(2);
- IINC(1, -1);
- GOTO(L3_1b);
- LABEL(new Label()); // extra label emitted due to impl quirks
-
- // L3_2a: Second instantiation of subroutine:
- LABEL(L3_2a);
- ASTORE(2);
- IINC(1, -1);
- GOTO(L3_2b);
- LABEL(new Label()); // extra label emitted due to impl quirks
-
- TRYCATCH(L0, L2, L2);
- TRYCATCH(L1, L4, L2);
-
- END(1, 4);
- }
-
- assertEquals(exp, jsr);
- }
-
- /**
- * Tests a method which has an if/else-if w/in the finally clause:
- *
- * <pre>
- * public void a() {
- * int a = 0;
- * try {
- * a++;
- * } finally {
- * if (a == 0)
- * a += 2;
- * else
- * a += 3;
- * }
- * }
- * </pre>
- */
- public void testIfElseInFinally() {
- {
- Label L0 = new Label();
- Label L1 = new Label();
- Label L2 = new Label();
- Label L3 = new Label();
- Label L4 = new Label();
- Label L5 = new Label();
- Label L6 = new Label();
-
- setCurrent(jsr);
- ICONST_0();
- ISTORE(1);
-
- /* L0: body of try block */
- LABEL(L0);
- IINC(1, 1);
- GOTO(L1);
-
- /* L2: exception handler */
- LABEL(L2);
- ASTORE(3);
- JSR(L3);
- ALOAD(3);
- ATHROW();
-
- /* L3: subroutine */
- LABEL(L3);
- ASTORE(2);
- ILOAD(1);
- IFNE(L4);
- IINC(1, 2);
- GOTO(L5);
- LABEL(L4); // L4: a != 0
- IINC(1, 3);
- LABEL(L5); // L5: common exit
- RET(2);
-
- /* L1: non-exceptional exit from try block */
- LABEL(L1);
- JSR(L3);
- LABEL(L6); // L6 is used in the TRYCATCH below
- RETURN();
-
- TRYCATCH(L0, L2, L2);
- TRYCATCH(L1, L6, L2);
-
- END(1, 4);
- }
-
- {
- Label L0 = new Label();
- Label L1 = new Label();
- Label L2 = new Label();
- Label L3_1a = new Label();
- Label L3_1b = new Label();
- Label L3_2a = new Label();
- Label L3_2b = new Label();
- Label L4_1 = new Label();
- Label L4_2 = new Label();
- Label L5_1 = new Label();
- Label L5_2 = new Label();
- Label L6 = new Label();
-
- setCurrent(exp);
- ICONST_0();
- ISTORE(1);
- // L0: try/catch block
- LABEL(L0);
- IINC(1, 1);
- GOTO(L1);
-
- // L2: Exception handler:
- LABEL(L2);
- ASTORE(3);
- ACONST_NULL();
- GOTO(L3_1a);
- LABEL(L3_1b); // L3_1b;
- ALOAD(3);
- ATHROW();
-
- // L1: On non-exceptional exit, try block leads here:
- LABEL(L1);
- ACONST_NULL();
- GOTO(L3_2a);
- LABEL(L3_2b); // L3_2b
- LABEL(L6); // L6
- RETURN();
-
- // L3_1a: First instantiation of subroutine:
- LABEL(L3_1a);
- ASTORE(2);
- ILOAD(1);
- IFNE(L4_1);
- IINC(1, 2);
- GOTO(L5_1);
- LABEL(L4_1); // L4_1: a != 0
- IINC(1, 3);
- LABEL(L5_1); // L5_1: common exit
- GOTO(L3_1b);
- LABEL(new Label()); // extra label emitted due to impl quirks
-
- // L3_2a: First instantiation of subroutine:
- LABEL(L3_2a);
- ASTORE(2);
- ILOAD(1);
- IFNE(L4_2);
- IINC(1, 2);
- GOTO(L5_2);
- LABEL(L4_2); // L4_2: a != 0
- IINC(1, 3);
- LABEL(L5_2); // L5_2: common exit
- GOTO(L3_2b);
- LABEL(new Label()); // extra label emitted due to impl quirks
-
- TRYCATCH(L0, L2, L2);
- TRYCATCH(L1, L6, L2);
-
- END(1, 4);
- }
-
- assertEquals(exp, jsr);
- }
-
- /**
- * Tests a simple nested finally:
- *
- * <pre>
- * public void a1() {
- * int a = 0;
- * try {
- * a += 1;
- * } finally {
- * try {
- * a += 2;
- * } finally {
- * a += 3;
- * }
- * }
- * }
- * </pre>
- */
- public void testSimpleNestedFinally() {
- {
- Label L0 = new Label();
- Label L1 = new Label();
- Label L2 = new Label();
- Label L3 = new Label();
- Label L4 = new Label();
- Label L5 = new Label();
-
- setCurrent(jsr);
-
- ICONST_0();
- ISTORE(1);
-
- // L0: Body of try block:
- LABEL(L0);
- IINC(1, 1);
- JSR(L3);
- GOTO(L1);
-
- // L2: First exception handler:
- LABEL(L2);
- JSR(L3);
- ATHROW();
-
- // L3: First subroutine:
- LABEL(L3);
- ASTORE(2);
- IINC(1, 2);
- JSR(L4);
- RET(2);
-
- // L5: Second exception handler:
- LABEL(L5);
- JSR(L4);
- ATHROW();
-
- // L4: Second subroutine:
- LABEL(L4);
- ASTORE(3);
- IINC(1, 3);
- RET(3);
-
- // L1: On normal exit, try block jumps here:
- LABEL(L1);
- RETURN();
-
- TRYCATCH(L0, L2, L2);
- TRYCATCH(L3, L5, L5);
-
- END(2, 6);
- }
-
- {
- Label L0 = new Label();
- Label L1 = new Label();
- Label L2 = new Label();
- Label L3_1a = new Label();
- Label L3_1b = new Label();
- Label L3_2a = new Label();
- Label L3_2b = new Label();
- Label L4_1a = new Label();
- Label L4_1b = new Label();
- Label L4_2a = new Label();
- Label L4_2b = new Label();
- Label L4_3a = new Label();
- Label L4_3b = new Label();
- Label L4_4a = new Label();
- Label L4_4b = new Label();
- Label L5_1 = new Label();
- Label L5_2 = new Label();
-
- setCurrent(exp);
-
- ICONST_0();
- ISTORE(1);
-
- // L0: Body of try block:
- LABEL(L0);
- IINC(1, 1);
- ACONST_NULL();
- GOTO(L3_1a);
- LABEL(L3_1b); // L3_1b
- GOTO(L1);
-
- // L2: First exception handler:
- LABEL(L2);
- ACONST_NULL();
- GOTO(L3_2a);
- LABEL(L3_2b); // L3_2b
- ATHROW();
-
- // L1: On normal exit, try block jumps here:
- LABEL(L1);
- RETURN();
-
- // L3_1a: First instantiation of first subroutine:
- LABEL(L3_1a);
- ASTORE(2);
- IINC(1, 2);
- ACONST_NULL();
- GOTO(L4_1a);
- LABEL(L4_1b); // L4_1b
- GOTO(L3_1b);
- LABEL(L5_1); // L5_1
- ACONST_NULL();
- GOTO(L4_2a);
- LABEL(L4_2b); // L4_2b
- ATHROW();
- LABEL(new Label()); // extra label emitted due to impl quirks
-
- // L3_2a: Second instantiation of first subroutine:
- LABEL(L3_2a);
- ASTORE(2);
- IINC(1, 2);
- ACONST_NULL();
- GOTO(L4_3a);
- LABEL(L4_3b); // L4_3b
- GOTO(L3_2b);
- LABEL(L5_2); // L5_2
- ACONST_NULL();
- GOTO(L4_4a);
- LABEL(L4_4b); // L4_4b
- ATHROW();
- LABEL(new Label()); // extra label emitted due to impl quirks
-
- // L4_1a: First instantiation of second subroutine:
- LABEL(L4_1a);
- ASTORE(3);
- IINC(1, 3);
- GOTO(L4_1b);
- LABEL(new Label()); // extra label emitted due to impl quirks
-
- // L4_2a: Second instantiation of second subroutine:
- LABEL(L4_2a);
- ASTORE(3);
- IINC(1, 3);
- GOTO(L4_2b);
- LABEL(new Label()); // extra label emitted due to impl quirks
-
- // L4_3a: Third instantiation of second subroutine:
- LABEL(L4_3a);
- ASTORE(3);
- IINC(1, 3);
- GOTO(L4_3b);
- LABEL(new Label()); // extra label emitted due to impl quirks
-
- // L4_4a: Fourth instantiation of second subroutine:
- LABEL(L4_4a);
- ASTORE(3);
- IINC(1, 3);
- GOTO(L4_4b);
- LABEL(new Label()); // extra label emitted due to impl quirks
-
- TRYCATCH(L0, L2, L2);
- TRYCATCH(L3_1a, L5_1, L5_1);
- TRYCATCH(L3_2a, L5_2, L5_2);
-
- END(2, 6);
- }
-
- assertEquals(exp, jsr);
- }
-
- /**
- * This tests a subroutine which has no ret statement, but ends in a
- * "return" instead.
- *
- * We structure this as a try/finally with a break in the finally. Because
- * the while loop is infinite, it's clear from the byte code that the only
- * path which reaches the RETURN instruction is through the subroutine.
- *
- * <pre>
- * public void a1() {
- * int a = 0;
- * while (true) {
- * try {
- * a += 1;
- * } finally {
- * a += 2;
- * break;
- * }
- * }
- * }
- * </pre>
- */
- public void testSubroutineWithNoRet() {
- {
- Label L0 = new Label();
- Label L1 = new Label();
- Label L2 = new Label();
- Label L3 = new Label();
- Label L4 = new Label();
-
- setCurrent(jsr);
- ICONST_0();
- ISTORE(1);
-
- // L0: while loop header/try block
- LABEL(L0);
- IINC(1, 1);
- JSR(L1);
- GOTO(L2);
-
- // L3: implicit catch block
- LABEL(L3);
- ASTORE(2);
- JSR(L1);
- ALOAD(2);
- ATHROW();
-
- // L1: subroutine ...
- LABEL(L1);
- ASTORE(3);
- IINC(1, 2);
- GOTO(L4); // ...not that it does not return!
-
- // L2: end of the loop... goes back to the top!
- LABEL(L2);
- GOTO(L0);
-
- // L4:
- LABEL(L4);
- RETURN();
-
- TRYCATCH(L0, L3, L3);
-
- END(1, 4);
- }
-
- {
- Label L0 = new Label();
- Label L1_1a = new Label();
- Label L1_1b = new Label();
- Label L1_2a = new Label();
- Label L1_2b = new Label();
- Label L2 = new Label();
- Label L3 = new Label();
- Label L4_1 = new Label();
- Label L4_2 = new Label();
-
- setCurrent(exp);
- ICONST_0();
- ISTORE(1);
-
- // L0: while loop header/try block
- LABEL(L0);
- IINC(1, 1);
- ACONST_NULL();
- GOTO(L1_1a);
- LABEL(L1_1b); // L1_1b
- GOTO(L2);
-
- // L3: implicit catch block
- LABEL(L3);
- ASTORE(2);
- ACONST_NULL();
- GOTO(L1_2a);
- LABEL(L1_2b); // L1_2b
- ALOAD(2);
- ATHROW();
-
- // L2: end of the loop... goes back to the top!
- LABEL(L2);
- GOTO(L0);
- LABEL(new Label()); // extra label emitted due to impl quirks
-
- // L1_1a: first instantiation of subroutine ...
- LABEL(L1_1a);
- ASTORE(3);
- IINC(1, 2);
- GOTO(L4_1); // ...not that it does not return!
- LABEL(L4_1);
- RETURN();
-
- // L1_2a: second instantiation of subroutine ...
- LABEL(L1_2a);
- ASTORE(3);
- IINC(1, 2);
- GOTO(L4_2); // ...not that it does not return!
- LABEL(L4_2);
- RETURN();
-
- TRYCATCH(L0, L3, L3);
-
- END(1, 4);
- }
-
- assertEquals(exp, jsr);
- }
-
- /**
- * This tests a subroutine which has no ret statement, but ends in a
- * "return" instead.
- *
- * <pre>
- * JSR L0
- * L0:
- * ASTORE 0
- * RETURN
- * </pre>
- */
- public void testSubroutineWithNoRet2() {
- {
- Label L0 = new Label();
-
- setCurrent(jsr);
- JSR(L0);
- LABEL(L0);
- ASTORE(0);
- RETURN();
- END(1, 1);
- }
-
- {
- Label L0_1a = new Label();
- Label L0_1b = new Label();
-
- setCurrent(exp);
-
- ACONST_NULL();
- GOTO(L0_1a);
- LABEL(L0_1b);
-
- // L0_1a: First instantiation of subroutine:
- LABEL(L0_1a);
- ASTORE(0);
- RETURN();
- LABEL(new Label()); // extra label emitted due to impl quirks
-
- END(1, 1);
- }
-
- assertEquals(exp, jsr);
- }
-
- /**
- * This tests a subroutine which has no ret statement, but instead exits
- * implicitely by branching to code which is not part of the subroutine.
- * (Sadly, this is legal)
- *
- * We structure this as a try/finally in a loop with a break in the finally.
- * The loop is not trivially infinite, so the RETURN statement is reachable
- * both from the JSR subroutine and from the main entry point.
- *
- * <pre>
- * public void a1() {
- * int a = 0;
- * while (null == null) {
- * try {
- * a += 1;
- * } finally {
- * a += 2;
- * break;
- * }
- * }
- * }
- * </pre>
- */
- public void testImplicitExit() {
- {
- Label L0 = new Label();
- Label L1 = new Label();
- Label L2 = new Label();
- Label L3 = new Label();
- Label L4 = new Label();
- Label L5 = new Label();
-
- setCurrent(jsr);
- ICONST_0();
- ISTORE(1);
-
- // L5: while loop header
- LABEL(L5);
- ACONST_NULL();
- IFNONNULL(L4);
-
- // L0: try block
- LABEL(L0);
- IINC(1, 1);
- JSR(L1);
- GOTO(L2);
-
- // L3: implicit catch block
- LABEL(L3);
- ASTORE(2);
- JSR(L1);
- ALOAD(2);
- ATHROW();
-
- // L1: subroutine ...
- LABEL(L1);
- ASTORE(3);
- IINC(1, 2);
- GOTO(L4); // ...not that it does not return!
-
- // L2: end of the loop... goes back to the top!
- LABEL(L2);
- GOTO(L0);
-
- // L4:
- LABEL(L4);
- RETURN();
-
- TRYCATCH(L0, L3, L3);
-
- END(1, 4);
- }
-
- {
- Label L0 = new Label();
- Label L1_1a = new Label();
- Label L1_1b = new Label();
- Label L1_2a = new Label();
- Label L1_2b = new Label();
- Label L2 = new Label();
- Label L3 = new Label();
- Label L4 = new Label();
- Label L5 = new Label();
-
- setCurrent(exp);
- ICONST_0();
- ISTORE(1);
-
- // L5: while loop header
- LABEL(L5);
- ACONST_NULL();
- IFNONNULL(L4);
-
- // L0: while loop header/try block
- LABEL(L0);
- IINC(1, 1);
- ACONST_NULL();
- GOTO(L1_1a);
- LABEL(L1_1b); // L1_1b
- GOTO(L2);
-
- // L3: implicit catch block
- LABEL(L3);
- ASTORE(2);
- ACONST_NULL();
- GOTO(L1_2a);
- LABEL(L1_2b); // L1_2b
- ALOAD(2);
- ATHROW();
-
- // L2: end of the loop... goes back to the top!
- LABEL(L2);
- GOTO(L0);
-
- // L4: exit, not part of subroutine
- // Note that the two subroutine instantiations branch here
- LABEL(L4);
- RETURN();
-
- // L1_1a: first instantiation of subroutine ...
- LABEL(L1_1a);
- ASTORE(3);
- IINC(1, 2);
- GOTO(L4); // ...note that it does not return!
- LABEL(new Label()); // extra label emitted due to impl quirks
-
- // L1_2a: second instantiation of subroutine ...
- LABEL(L1_2a);
- ASTORE(3);
- IINC(1, 2);
- GOTO(L4); // ...note that it does not return!
- LABEL(new Label()); // extra label emitted due to impl quirks
-
- TRYCATCH(L0, L3, L3);
-
- END(1, 4);
- }
-
- assertEquals(exp, jsr);
- }
-
- /**
- * Tests a nested try/finally with implicit exit from one subroutine to the
- * other subroutine. Equivalent to the following java code:
- *
- * <pre>
- * void m(boolean b) {
- * try {
- * return;
- * } finally {
- * while (b) {
- * try {
- * return;
- * } finally {
- * // NOTE --- this break avoids the second return above (weird)
- * if (b)
- * break;
- * }
- * }
- * }
- * }
- * </pre>
- *
- * This example is from the paper, "Subroutine Inlining and Bytecode
- * Abstraction to Simplify Static and Dynamic Analysis" by Cyrille Artho and
- * Armin Biere.
- */
- public void testImplicitExitToAnotherSubroutine() {
- {
- Label T1 = new Label();
- Label C1 = new Label();
- Label S1 = new Label();
- Label L = new Label();
- Label C2 = new Label();
- Label S2 = new Label();
- Label W = new Label();
- Label X = new Label();
-
- // variable numbers:
- int b = 1;
- int e1 = 2;
- int e2 = 3;
- int r1 = 4;
- int r2 = 5;
-
- setCurrent(jsr);
-
- ICONST_0();
- ISTORE(1);
-
- // T1: first try:
- LABEL(T1);
- JSR(S1);
- RETURN();
-
- // C1: exception handler for first try
- LABEL(C1);
- ASTORE(e1);
- JSR(S1);
- ALOAD(e1);
- ATHROW();
-
- // S1: first finally handler
- LABEL(S1);
- ASTORE(r1);
- GOTO(W);
-
- // L: body of while loop, also second try
- LABEL(L);
- JSR(S2);
- RETURN();
-
- // C2: exception handler for second try
- LABEL(C2);
- ASTORE(e2);
- JSR(S2);
- ALOAD(e2);
- ATHROW();
-
- // S2: second finally handler
- LABEL(S2);
- ASTORE(r2);
- ILOAD(b);
- IFNE(X);
- RET(r2);
-
- // W: test for the while loop
- LABEL(W);
- ILOAD(b);
- IFNE(L); // falls through to X
-
- // X: exit from finally{} block
- LABEL(X);
- RET(r1);
-
- TRYCATCH(T1, C1, C1);
- TRYCATCH(L, C2, C2);
-
- END(1, 6);
- }
-
- {
- Label T1 = new Label();
- Label C1 = new Label();
- Label S1_1a = new Label();
- Label S1_1b = new Label();
- Label S1_2a = new Label();
- Label S1_2b = new Label();
- Label L_1 = new Label();
- Label L_2 = new Label();
- Label C2_1 = new Label();
- Label C2_2 = new Label();
- Label S2_1_1a = new Label();
- Label S2_1_1b = new Label();
- Label S2_1_2a = new Label();
- Label S2_1_2b = new Label();
- Label S2_2_1a = new Label();
- Label S2_2_1b = new Label();
- Label S2_2_2a = new Label();
- Label S2_2_2b = new Label();
- Label W_1 = new Label();
- Label W_2 = new Label();
- Label X_1 = new Label();
- Label X_2 = new Label();
-
- // variable numbers:
- int b = 1;
- int e1 = 2;
- int e2 = 3;
- int r1 = 4;
- int r2 = 5;
-
- setCurrent(exp);
-
- // --- Main Subroutine ---
-
- ICONST_0();
- ISTORE(1);
-
- // T1: first try:
- LABEL(T1);
- ACONST_NULL();
- GOTO(S1_1a);
- LABEL(S1_1b);
- RETURN();
-
- // C1: exception handler for first try
- LABEL(C1);
- ASTORE(e1);
- ACONST_NULL();
- GOTO(S1_2a);
- LABEL(S1_2b);
- ALOAD(e1);
- ATHROW();
- LABEL(new Label()); // extra label emitted due to impl quirks
-
- // --- First instantiation of first subroutine ---
-
- // S1: first finally handler
- LABEL(S1_1a);
- ASTORE(r1);
- GOTO(W_1);
-
- // L_1: body of while loop, also second try
- LABEL(L_1);
- ACONST_NULL();
- GOTO(S2_1_1a);
- LABEL(S2_1_1b);
- RETURN();
-
- // C2_1: exception handler for second try
- LABEL(C2_1);
- ASTORE(e2);
- ACONST_NULL();
- GOTO(S2_1_2a);
- LABEL(S2_1_2b);
- ALOAD(e2);
- ATHROW();
-
- // W_1: test for the while loop
- LABEL(W_1);
- ILOAD(b);
- IFNE(L_1); // falls through to X_1
-
- // X_1: exit from finally{} block
- LABEL(X_1);
- GOTO(S1_1b);
-
- // --- Second instantiation of first subroutine ---
-
- // S1: first finally handler
- LABEL(S1_2a);
- ASTORE(r1);
- GOTO(W_2);
-
- // L_2: body of while loop, also second try
- LABEL(L_2);
- ACONST_NULL();
- GOTO(S2_2_1a);
- LABEL(S2_2_1b);
- RETURN();
-
- // C2_2: exception handler for second try
- LABEL(C2_2);
- ASTORE(e2);
- ACONST_NULL();
- GOTO(S2_2_2a);
- LABEL(S2_2_2b);
- ALOAD(e2);
- ATHROW();
-
- // W_2: test for the while loop
- LABEL(W_2);
- ILOAD(b);
- IFNE(L_2); // falls through to X_2
-
- // X_2: exit from finally{} block
- LABEL(X_2);
- GOTO(S1_2b);
-
- // --- Second subroutine's 4 instantiations ---
-
- // S2_1_1a:
- LABEL(S2_1_1a);
- ASTORE(r2);
- ILOAD(b);
- IFNE(X_1);
- GOTO(S2_1_1b);
- LABEL(new Label()); // extra label emitted due to impl quirks
-
- // S2_1_2a:
- LABEL(S2_1_2a);
- ASTORE(r2);
- ILOAD(b);
- IFNE(X_1);
- GOTO(S2_1_2b);
- LABEL(new Label()); // extra label emitted due to impl quirks
-
- // S2_2_1a:
- LABEL(S2_2_1a);
- ASTORE(r2);
- ILOAD(b);
- IFNE(X_2);
- GOTO(S2_2_1b);
- LABEL(new Label()); // extra label emitted due to impl quirks
-
- // S2_2_2a:
- LABEL(S2_2_2a);
- ASTORE(r2);
- ILOAD(b);
- IFNE(X_2);
- GOTO(S2_2_2b);
- LABEL(new Label()); // extra label emitted due to impl quirks
-
- TRYCATCH(T1, C1, C1);
- TRYCATCH(L_1, C2_1, C2_1); // duplicated try/finally for each...
- TRYCATCH(L_2, C2_2, C2_2); // ...instantiation of first sub
-
- END(1, 6);
- }
-
- assertEquals(exp, jsr);
- }
-
- /**
- * This tests two subroutines, neither of which exit. Instead, they both
- * branch to a common set of code which returns from the method. This code
- * is not reachable except through these subroutines, and since they do not
- * invoke each other, it must be copied into both of them.
- *
- * I don't believe this can be represented in Java.
- */
- public void testCommonCodeWhichMustBeDuplicated() {
- {
- Label L1 = new Label();
- Label L2 = new Label();
- Label L3 = new Label();
-
- setCurrent(jsr);
- ICONST_0();
- ISTORE(1);
-
- // Invoke the two subroutines, each twice:
- JSR(L1);
- JSR(L1);
- JSR(L2);
- JSR(L2);
- RETURN();
-
- // L1: subroutine 1
- LABEL(L1);
- IINC(1, 1);
- GOTO(L3); // ...note that it does not return!
-
- // L2: subroutine 2
- LABEL(L2);
- IINC(1, 2);
- GOTO(L3); // ...note that it does not return!
-
- // L3: common code to both subroutines: exit method
- LABEL(L3);
- RETURN();
-
- END(1, 2);
- }
-
- {
- Label L1_1a = new Label();
- Label L1_1b = new Label();
- Label L1_2a = new Label();
- Label L1_2b = new Label();
- Label L2_1a = new Label();
- Label L2_1b = new Label();
- Label L2_2a = new Label();
- Label L2_2b = new Label();
- Label L3_1 = new Label();
- Label L3_2 = new Label();
- Label L3_3 = new Label();
- Label L3_4 = new Label();
-
- setCurrent(exp);
- ICONST_0();
- ISTORE(1);
-
- // Invoke the two subroutines, each twice:
- ACONST_NULL();
- GOTO(L1_1a);
- LABEL(L1_1b);
- ACONST_NULL();
- GOTO(L1_2a);
- LABEL(L1_2b);
- ACONST_NULL();
- GOTO(L2_1a);
- LABEL(L2_1b);
- ACONST_NULL();
- GOTO(L2_2a);
- LABEL(L2_2b);
- RETURN();
- LABEL(new Label()); // extra label emitted due to impl quirks
-
- // L1_1a: instantiation 1 of subroutine 1
- LABEL(L1_1a);
- IINC(1, 1);
- GOTO(L3_1); // ...note that it does not return!
- LABEL(L3_1);
- RETURN();
-
- // L1_2a: instantiation 2 of subroutine 1
- LABEL(L1_2a);
- IINC(1, 1);
- GOTO(L3_2); // ...note that it does not return!
- LABEL(L3_2);
- RETURN();
-
- // L2_1a: instantiation 1 of subroutine 2
- LABEL(L2_1a);
- IINC(1, 2);
- GOTO(L3_3); // ...note that it does not return!
- LABEL(L3_3);
- RETURN();
-
- // L2_2a: instantiation 2 of subroutine 2
- LABEL(L2_2a);
- IINC(1, 2);
- GOTO(L3_4); // ...note that it does not return!
- LABEL(L3_4);
- RETURN();
-
- END(1, 2);
- }
-
- assertEquals(exp, jsr);
- }
-
- /**
- * This tests a simple subroutine where the control flow jumps back and
- * forth between the subroutine and the caller.
- *
- * This would not normally be produced by a java compiler.
- */
- public void testInterleavedCode() {
- {
- Label L1 = new Label();
- Label L2 = new Label();
- Label L3 = new Label();
- Label L4 = new Label();
-
- setCurrent(jsr);
- ICONST_0();
- ISTORE(1);
-
- // Invoke the subroutine, each twice:
- JSR(L1);
- GOTO(L2);
-
- // L1: subroutine 1
- LABEL(L1);
- ASTORE(2);
- IINC(1, 1);
- GOTO(L3);
-
- // L2: second part of main subroutine
- LABEL(L2);
- IINC(1, 2);
- GOTO(L4);
-
- // L3: second part of subroutine 1
- LABEL(L3);
- IINC(1, 4);
- RET(2);
-
- // L4: third part of main subroutine
- LABEL(L4);
- JSR(L1);
- RETURN();
-
- END(1, 3);
- }
-
- {
- Label L1_1a = new Label();
- Label L1_1b = new Label();
- Label L1_2a = new Label();
- Label L1_2b = new Label();
- Label L2 = new Label();
- Label L3_1 = new Label();
- Label L3_2 = new Label();
- Label L4 = new Label();
-
- setCurrent(exp);
-
- // Main routine:
- ICONST_0();
- ISTORE(1);
- ACONST_NULL();
- GOTO(L1_1a);
- LABEL(L1_1b);
- GOTO(L2);
- LABEL(L2);
- IINC(1, 2);
- GOTO(L4);
- LABEL(L4);
- ACONST_NULL();
- GOTO(L1_2a);
- LABEL(L1_2b);
- RETURN();
-
- // L1_1: instantiation #1
- LABEL(L1_1a);
- ASTORE(2);
- IINC(1, 1);
- GOTO(L3_1);
- LABEL(L3_1);
- IINC(1, 4);
- GOTO(L1_1b);
- LABEL(new Label()); // extra label emitted due to impl quirks
-
- // L1_2: instantiation #2
- LABEL(L1_2a);
- ASTORE(2);
- IINC(1, 1);
- GOTO(L3_2);
- LABEL(L3_2);
- IINC(1, 4);
- GOTO(L1_2b);
- LABEL(new Label()); // extra label emitted due to impl quirks
-
- END(1, 3);
- }
-
- assertEquals(exp, jsr);
- }
-
- /**
- * Tests a nested try/finally with implicit exit from one subroutine to the
- * other subroutine, and with a surrounding try/catch thrown in the mix.
- * Equivalent to the following java code:
- *
- * <pre>
- * void m(int b) {
- * try {
- * try {
- * return;
- * } finally {
- * while (b) {
- * try {
- * return;
- * } finally {
- * // NOTE --- this break avoids the second return above
- * // (weird)
- * if (b)
- * break;
- * }
- * }
- * }
- * } catch (Exception e) {
- * b += 3;
- * return;
- * }
- * }
- * </pre>
- */
- public void testImplicitExitInTryCatch() {
- {
- Label T1 = new Label();
- Label C1 = new Label();
- Label S1 = new Label();
- Label L = new Label();
- Label C2 = new Label();
- Label S2 = new Label();
- Label W = new Label();
- Label X = new Label();
- Label OT = new Label();
- Label OC = new Label();
-
- // variable numbers:
- int b = 1;
- int e1 = 2;
- int e2 = 3;
- int r1 = 4;
- int r2 = 5;
-
- setCurrent(jsr);
-
- ICONST_0();
- ISTORE(1);
-
- // OT: outermost try
- LABEL(OT);
-
- // T1: first try:
- LABEL(T1);
- JSR(S1);
- RETURN();
-
- // C1: exception handler for first try
- LABEL(C1);
- ASTORE(e1);
- JSR(S1);
- ALOAD(e1);
- ATHROW();
-
- // S1: first finally handler
- LABEL(S1);
- ASTORE(r1);
- GOTO(W);
-
- // L: body of while loop, also second try
- LABEL(L);
- JSR(S2);
- RETURN();
-
- // C2: exception handler for second try
- LABEL(C2);
- ASTORE(e2);
- JSR(S2);
- ALOAD(e2);
- ATHROW();
-
- // S2: second finally handler
- LABEL(S2);
- ASTORE(r2);
- ILOAD(b);
- IFNE(X);
- RET(r2);
-
- // W: test for the while loop
- LABEL(W);
- ILOAD(b);
- IFNE(L); // falls through to X
-
- // X: exit from finally{} block
- LABEL(X);
- RET(r1);
-
- // OC: outermost catch
- LABEL(OC);
- IINC(b, 3);
- RETURN();
-
- TRYCATCH(T1, C1, C1);
- TRYCATCH(L, C2, C2);
- TRYCATCH(OT, OC, OC);
-
- END(1, 6);
- }
-
- {
- Label T1 = new Label();
- Label C1 = new Label();
- Label S1_1a = new Label();
- Label S1_1b = new Label();
- Label S1_2a = new Label();
- Label S1_2b = new Label();
- Label L_1 = new Label();
- Label L_2 = new Label();
- Label C2_1 = new Label();
- Label C2_2 = new Label();
- Label S2_1_1a = new Label();
- Label S2_1_1b = new Label();
- Label S2_1_2a = new Label();
- Label S2_1_2b = new Label();
- Label S2_2_1a = new Label();
- Label S2_2_1b = new Label();
- Label S2_2_2a = new Label();
- Label S2_2_2b = new Label();
- Label W_1 = new Label();
- Label W_2 = new Label();
- Label X_1 = new Label();
- Label X_2 = new Label();
- Label OT_1 = S1_1a;
- Label OT_2 = S1_2a;
- Label OT_1_1 = S2_1_1a;
- Label OT_1_2 = S2_1_2a;
- Label OT_2_1 = S2_2_1a;
- Label OT_2_2 = S2_2_2a;
- Label OC = new Label();
- Label OC_1 = new Label();
- Label OC_2 = new Label();
- Label OC_1_1 = new Label();
- Label OC_1_2 = new Label();
- Label OC_2_1 = new Label();
- Label OC_2_2 = new Label();
-
- // variable numbers:
- int b = 1;
- int e1 = 2;
- int e2 = 3;
- int r1 = 4;
- int r2 = 5;
-
- setCurrent(exp);
-
- // --- Main Subroutine ---
-
- ICONST_0();
- ISTORE(1);
-
- // T1: outermost try / first try:
- LABEL(T1);
- ACONST_NULL();
- GOTO(S1_1a);
- LABEL(S1_1b);
- RETURN();
-
- // C1: exception handler for first try
- LABEL(C1);
- ASTORE(e1);
- ACONST_NULL();
- GOTO(S1_2a);
- LABEL(S1_2b);
- ALOAD(e1);
- ATHROW();
-
- // OC: Outermost catch
- LABEL(OC);
- IINC(b, 3);
- RETURN();
-
- // --- First instantiation of first subroutine ---
-
- // S1: first finally handler
- LABEL(S1_1a);
- ASTORE(r1);
- GOTO(W_1);
-
- // L_1: body of while loop, also second try
- LABEL(L_1);
- ACONST_NULL();
- GOTO(S2_1_1a);
- LABEL(S2_1_1b);
- RETURN();
-
- // C2_1: exception handler for second try
- LABEL(C2_1);
- ASTORE(e2);
- ACONST_NULL();
- GOTO(S2_1_2a);
- LABEL(S2_1_2b);
- ALOAD(e2);
- ATHROW();
-
- // W_1: test for the while loop
- LABEL(W_1);
- ILOAD(b);
- IFNE(L_1); // falls through to X_1
-
- // X_1: exit from finally{} block
- LABEL(X_1);
- GOTO(S1_1b);
-
- LABEL(OC_1);
-
- // --- Second instantiation of first subroutine ---
-
- // S1: first finally handler
- LABEL(S1_2a);
- ASTORE(r1);
- GOTO(W_2);
-
- // L_2: body of while loop, also second try
- LABEL(L_2);
- ACONST_NULL();
- GOTO(S2_2_1a);
- LABEL(S2_2_1b);
- RETURN();
-
- // C2_2: exception handler for second try
- LABEL(C2_2);
- ASTORE(e2);
- ACONST_NULL();
- GOTO(S2_2_2a);
- LABEL(S2_2_2b);
- ALOAD(e2);
- ATHROW();
-
- // W_2: test for the while loop
- LABEL(W_2);
- ILOAD(b);
- IFNE(L_2); // falls through to X_2
-
- // X_2: exit from finally{} block
- LABEL(X_2);
- GOTO(S1_2b);
-
- LABEL(OC_2);
-
- // --- Second subroutine's 4 instantiations ---
-
- // S2_1_1a:
- LABEL(S2_1_1a);
- ASTORE(r2);
- ILOAD(b);
- IFNE(X_1);
- GOTO(S2_1_1b);
- LABEL(OC_1_1);
-
- // S2_1_2a:
- LABEL(S2_1_2a);
- ASTORE(r2);
- ILOAD(b);
- IFNE(X_1);
- GOTO(S2_1_2b);
- LABEL(OC_1_2);
-
- // S2_2_1a:
- LABEL(S2_2_1a);
- ASTORE(r2);
- ILOAD(b);
- IFNE(X_2);
- GOTO(S2_2_1b);
- LABEL(OC_2_1);
-
- // S2_2_2a:
- LABEL(S2_2_2a);
- ASTORE(r2);
- ILOAD(b);
- IFNE(X_2);
- GOTO(S2_2_2b);
- LABEL(OC_2_2);
-
- // main subroutine handlers:
- TRYCATCH(T1, C1, C1);
- TRYCATCH(T1, OC, OC);
-
- // first instance of first sub try/catch handlers:
- TRYCATCH(L_1, C2_1, C2_1);
- TRYCATCH(OT_1, OC_1, OC); // note: reuses handler code from main
- // sub
-
- // second instance of first sub try/catch handlers:
- TRYCATCH(L_2, C2_2, C2_2);
- TRYCATCH(OT_2, OC_2, OC);
-
- // all 4 instances of second sub:
- TRYCATCH(OT_1_1, OC_1_1, OC);
- TRYCATCH(OT_1_2, OC_1_2, OC);
- TRYCATCH(OT_2_1, OC_2_1, OC);
- TRYCATCH(OT_2_2, OC_2_2, OC);
-
- END(1, 6);
- }
-
- assertEquals(exp, jsr);
- }
-
- /**
- * Tests a method which has line numbers and local variable declarations.
- *
- * <pre>
- * public void a() {
- * 1 int a = 0;
- * 2 try {
- * 3 a++;
- * 4 } finally {
- * 5 a--;
- * 6 }
- * }
- * LV "a" from 1 to 6
- * </pre>
- */
- public void testBasicLineNumberAndLocalVars() {
- {
- Label LM1 = new Label();
- Label L0 = new Label();
- Label L1 = new Label();
- Label L2 = new Label();
- Label L3 = new Label();
- Label L4 = new Label();
-
- setCurrent(jsr);
- LABEL(LM1);
- LINE(1, LM1);
- ICONST_0();
- ISTORE(1);
-
- /* L0: body of try block */
- LABEL(L0);
- LINE(3, L0);
- IINC(1, 1);
- GOTO(L1);
-
- /* L2: exception handler */
- LABEL(L2);
- ASTORE(3);
- JSR(L3);
- ALOAD(3);
- ATHROW();
-
- /* L3: subroutine */
- LABEL(L3);
- LINE(5, L3);
- ASTORE(2);
- IINC(1, -1);
- RET(2);
-
- /* L1: non-exceptional exit from try block */
- LABEL(L1);
- JSR(L3);
- LABEL(L4); // L4
- RETURN();
-
- TRYCATCH(L0, L2, L2);
- TRYCATCH(L1, L4, L2);
- LOCALVAR("a", "I", 1, LM1, L4);
-
- END(1, 4);
- }
-
- {
- Label LM1 = new Label();
- Label L0 = new Label();
- Label L1 = new Label();
- Label L2 = new Label();
- Label L3_1a = new Label();
- Label L3_1b = new Label();
- Label L3_1c = new Label();
- Label L3_2a = new Label();
- Label L3_2b = new Label();
- Label L3_2c = new Label();
- Label L4 = new Label();
-
- setCurrent(exp);
- LABEL(LM1);
- LINE(1, LM1);
- ICONST_0();
- ISTORE(1);
- // L0: try/catch block
- LABEL(L0);
- LINE(3, L0);
- IINC(1, 1);
- GOTO(L1);
-
- // L2: Exception handler:
- LABEL(L2);
- ASTORE(3);
- ACONST_NULL();
- GOTO(L3_1a);
- LABEL(L3_1b); // L3_1b;
- ALOAD(3);
- ATHROW();
-
- // L1: On non-exceptional exit, try block leads here:
- LABEL(L1);
- ACONST_NULL();
- GOTO(L3_2a);
- LABEL(L3_2b); // L3_2b
- LABEL(L4); // L4
- RETURN();
-
- // L3_1a: First instantiation of subroutine:
- LABEL(L3_1a);
- LINE(5, L3_1a);
- ASTORE(2);
- IINC(1, -1);
- GOTO(L3_1b);
- LABEL(L3_1c);
-
- // L3_2a: Second instantiation of subroutine:
- LABEL(L3_2a);
- LINE(5, L3_2a);
- ASTORE(2);
- IINC(1, -1);
- GOTO(L3_2b);
- LABEL(L3_2c);
-
- TRYCATCH(L0, L2, L2);
- TRYCATCH(L1, L4, L2);
- LOCALVAR("a", "I", 1, LM1, L4);
- LOCALVAR("a", "I", 1, L3_1a, L3_1c);
- LOCALVAR("a", "I", 1, L3_2a, L3_2c);
-
- END(1, 4);
- }
-
- assertEquals(exp, jsr);
- }
-
- public void assertEquals(final MethodNode exp, final MethodNode actual) {
- String textexp = getText(exp);
- String textact = getText(actual);
- System.err.println("Expected=" + textexp);
- System.err.println("Actual=" + textact);
- assertEquals(textexp, textact);
- }
-
- private String getText(final MethodNode mn) {
- Textifier tv = new Textifier();
- TraceMethodVisitor tmv = new TraceMethodVisitor(tv);
- mn.accept(tmv);
-
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < tv.text.size(); i++) {
- sb.append(tv.text.get(i));
- }
- return sb.toString();
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/commons/LocalVariablesSorterTest.java b/asm4/test/conform/org/objectweb/asm/commons/LocalVariablesSorterTest.java
deleted file mode 100644
index 294834a..0000000
--- a/asm4/test/conform/org/objectweb/asm/commons/LocalVariablesSorterTest.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.commons;
-
-import junit.framework.TestSuite;
-
-import org.objectweb.asm.AbstractTest;
-import org.objectweb.asm.ClassReader;
-import org.objectweb.asm.ClassVisitor;
-import org.objectweb.asm.ClassWriter;
-import org.objectweb.asm.MethodVisitor;
-import org.objectweb.asm.Opcodes;
-
-/**
- * LocalVariableSorter tests.
- *
- * @author Eric Bruneton
- */
-public class LocalVariablesSorterTest extends AbstractTest {
-
- private final static TestClassLoader LOADER = new TestClassLoader();
-
- public static TestSuite suite() throws Exception {
- return new LocalVariablesSorterTest().getSuite();
- }
-
- @Override
- public void test() throws Exception {
- ClassReader cr = new ClassReader(is);
- ClassWriter cw = new ClassWriter(0);
- cr.accept(new ClassVisitor(Opcodes.ASM4, cw) {
- @Override
- public MethodVisitor visitMethod(final int access,
- final String name, final String desc,
- final String signature, final String[] exceptions) {
- return new LocalVariablesSorter(access, desc, super
- .visitMethod(access, name, desc, signature, exceptions));
- }
- }, ClassReader.EXPAND_FRAMES);
- byte[] b = cw.toByteArray();
- try {
- LOADER.defineClass(n, b);
- } catch (ClassFormatError cfe) {
- fail(cfe.getMessage());
- } catch (Throwable ignored) {
- }
- }
-
- // ------------------------------------------------------------------------
-
- static class TestClassLoader extends ClassLoader {
-
- public Class<?> defineClass(final String name, final byte[] b) {
- return defineClass(name, b, 0, b.length);
- }
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/commons/LocalVariablesSorterTest2.java b/asm4/test/conform/org/objectweb/asm/commons/LocalVariablesSorterTest2.java
deleted file mode 100644
index 013da27..0000000
--- a/asm4/test/conform/org/objectweb/asm/commons/LocalVariablesSorterTest2.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.commons;
-
-import java.io.InputStream;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.lang.instrument.ClassFileTransformer;
-import java.lang.instrument.IllegalClassFormatException;
-import java.lang.instrument.Instrumentation;
-import java.security.ProtectionDomain;
-
-import junit.framework.TestSuite;
-
-import org.objectweb.asm.AbstractTest;
-import org.objectweb.asm.ClassReader;
-import org.objectweb.asm.ClassVisitor;
-import org.objectweb.asm.ClassWriter;
-import org.objectweb.asm.MethodVisitor;
-import org.objectweb.asm.Opcodes;
-import org.objectweb.asm.util.TraceClassVisitor;
-
-/**
- * LocalVariablesSorter tests.
- *
- * @author Eric Bruneton
- */
-public class LocalVariablesSorterTest2 extends AbstractTest {
-
- public static void premain(final String agentArgs,
- final Instrumentation inst) {
- inst.addTransformer(new ClassFileTransformer() {
- public byte[] transform(final ClassLoader loader,
- final String className, final Class<?> classBeingRedefined,
- final ProtectionDomain domain, final byte[] classFileBuffer)
- throws IllegalClassFormatException {
- String n = className.replace('/', '.');
- if (agentArgs.length() == 0 || n.indexOf(agentArgs) != -1) {
- return transformClass(classFileBuffer);
- } else {
- return null;
- }
- }
- });
- }
-
- static byte[] transformClass(final byte[] clazz) {
- ClassReader cr = new ClassReader(clazz);
- ClassWriter cw = new ClassWriter(0);
- cr.accept(new ClassVisitor(Opcodes.ASM4, cw) {
-
- @Override
- public MethodVisitor visitMethod(final int access,
- final String name, final String desc,
- final String signature, final String[] exceptions) {
- return new LocalVariablesSorter(access, desc, cv.visitMethod(
- access, name, desc, signature, exceptions));
- }
-
- }, ClassReader.EXPAND_FRAMES);
- return cw.toByteArray();
- }
-
- public static TestSuite suite() throws Exception {
- TestSuite suite = new LocalVariablesSorterTest2().getSuite();
- suite.addTest(new VerifierTest());
- return suite;
- }
-
- @Override
- public void test() throws Exception {
- try {
- Class.forName(n, true, getClass().getClassLoader());
- } catch (NoClassDefFoundError ncdfe) {
- // ignored
- } catch (UnsatisfiedLinkError ule) {
- // ignored
- } catch (ClassFormatError cfe) {
- fail(cfe.getMessage());
- } catch (VerifyError ve) {
- String s = n.replace('.', '/') + ".class";
- InputStream is = getClass().getClassLoader().getResourceAsStream(s);
- ClassReader cr = new ClassReader(is);
- byte[] b = transformClass(cr.b);
- StringWriter sw1 = new StringWriter();
- StringWriter sw2 = new StringWriter();
- sw2.write(ve.toString() + "\n");
- ClassVisitor cv1 = new TraceClassVisitor(new PrintWriter(sw1));
- ClassVisitor cv2 = new TraceClassVisitor(new PrintWriter(sw2));
- cr.accept(cv1, 0);
- new ClassReader(b).accept(cv2, 0);
- String s1 = sw1.toString();
- String s2 = sw2.toString();
- assertEquals("different data", s1, s2);
- }
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/commons/RemappingClassAdapterTest.java b/asm4/test/conform/org/objectweb/asm/commons/RemappingClassAdapterTest.java
deleted file mode 100644
index 4467fb2..0000000
--- a/asm4/test/conform/org/objectweb/asm/commons/RemappingClassAdapterTest.java
+++ /dev/null
@@ -1,250 +0,0 @@
-/***
- * ASM: a very small and fast Java bytecode manipulation framework
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package org.objectweb.asm.commons;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.ListIterator;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.objectweb.asm.ClassVisitor;
-import org.objectweb.asm.Label;
-import org.objectweb.asm.MethodVisitor;
-import org.objectweb.asm.Opcodes;
-import org.objectweb.asm.Type;
-import org.objectweb.asm.tree.AbstractInsnNode;
-import org.objectweb.asm.tree.ClassNode;
-import org.objectweb.asm.tree.FieldInsnNode;
-import org.objectweb.asm.tree.FieldNode;
-import org.objectweb.asm.tree.FrameNode;
-import org.objectweb.asm.tree.InnerClassNode;
-import org.objectweb.asm.tree.LdcInsnNode;
-import org.objectweb.asm.tree.MethodInsnNode;
-import org.objectweb.asm.tree.MethodNode;
-import org.objectweb.asm.tree.MultiANewArrayInsnNode;
-import org.objectweb.asm.tree.TryCatchBlockNode;
-import org.objectweb.asm.tree.TypeInsnNode;
-
-public class RemappingClassAdapterTest extends TestCase implements Opcodes {
-
- public void testRemappingClassAdapter() throws Exception {
- Map<String, String> map = new HashMap<String, String>();
- map.put("Boo", "B1");
- map.put("Coo", "C1");
- map.put("Doo", "D1");
- Remapper remapper = new SimpleRemapper(map);
-
- ClassNode cn = new ClassNode();
- dump(new RemappingClassAdapter(cn, remapper));
-
- assertEquals("D1", cn.name);
- assertEquals("B1", cn.superName);
- assertEquals(Arrays.asList(new String[] { "I", "I", "C1", "J", "B1" }),
- cn.interfaces);
-
- assertEquals("LB1;", field(cn, 0).desc);
- assertEquals("[LB1;", field(cn, 1).desc);
-
- assertEquals("D1", innerClass(cn, 0).name);
- assertEquals("B1", innerClass(cn, 0).outerName);
- // assertEquals("Doo", innerClass(cn, 0).innerName);
-
- assertEquals("B1", cn.outerClass);
- assertEquals("([[LB1;LC1;LD1;)LC1;", cn.outerMethodDesc);
-
- MethodNode mn0 = cn.methods.get(0);
- ListIterator<AbstractInsnNode> it = mn0.instructions.iterator();
-
- FieldInsnNode n0 = (FieldInsnNode) it.next();
- assertEquals("D1", n0.owner);
- assertEquals("LB1;", n0.desc);
-
- assertEquals(Type.getType("LB1;"), ((LdcInsnNode) it.next()).cst);
- assertEquals(Type.getType("[LD1;"), ((LdcInsnNode) it.next()).cst);
- assertEquals(Type.getType("[I"), ((LdcInsnNode) it.next()).cst);
- assertEquals(Type.getType("J"), ((LdcInsnNode) it.next()).cst);
-
- assertEquals("B1", ((TypeInsnNode) it.next()).desc);
- assertEquals("[LD1;", ((TypeInsnNode) it.next()).desc);
- assertEquals("[I", ((TypeInsnNode) it.next()).desc);
- assertEquals("J", ((TypeInsnNode) it.next()).desc);
-
- MultiANewArrayInsnNode n3 = (MultiANewArrayInsnNode) it.next();
- assertEquals("[[LB1;", n3.desc);
-
- MethodInsnNode n4 = (MethodInsnNode) it.next();
- assertEquals("D1", n4.owner);
- assertEquals("([[LB1;LC1;LD1;)LC1;", n4.desc);
-
- FrameNode fn0 = (FrameNode) it.next();
- assertEquals(Collections.EMPTY_LIST, fn0.local);
- assertEquals(Collections.EMPTY_LIST, fn0.stack);
-
- assertEquals(Arrays.asList(new Object[] { "B1", "C1", "D1" }),
- ((FrameNode) it.next()).local);
- assertEquals(
- Arrays.asList(new Object[] { Opcodes.INTEGER, "C1",
- Opcodes.INTEGER, "D1" }), ((FrameNode) it.next()).local);
- assertEquals(Arrays.asList(new Object[] { Opcodes.INTEGER,
- Opcodes.INTEGER }), ((FrameNode) it.next()).local);
- // assertEquals(Collections.EMPTY_LIST, fn0.stack);
-
- TryCatchBlockNode tryCatchBlockNode = mn0.tryCatchBlocks.get(0);
- assertEquals("C1", tryCatchBlockNode.type);
-
- MethodNode mn1 = cn.methods.get(1);
- assertEquals("([[LB1;LC1;LD1;)V", mn1.desc);
- assertEquals(Arrays.asList(new String[] { "I", "J" }), mn1.exceptions);
- }
-
- private FieldNode field(ClassNode cn, int n) {
- return cn.fields.get(n);
- }
-
- private InnerClassNode innerClass(ClassNode cn, int n) {
- return cn.innerClasses.get(n);
- }
-
- public static void dump(ClassVisitor cv) throws Exception {
- cv.visit(V1_5, 0, "Doo", null, "Boo", new String[] { "I", "I", "Coo",
- "J", "Boo" });
-
- cv.visitInnerClass("Doo", "Boo", "Doo", 0);
-
- cv.visitOuterClass("Boo", "foo", "([[LBoo;LCoo;LDoo;)LCoo;");
-
- cv.visitField(0, "boo", "LBoo;", null, null).visitEnd();
- cv.visitField(0, "boo1", "[LBoo;", null, null).visitEnd();
- cv.visitField(0, "s", "Ljava/lang/String;", null, null).visitEnd();
- cv.visitField(0, "i", "I", null, null).visitEnd();
-
- MethodVisitor mv;
-
- mv = cv.visitMethod(0, "foo", "()V", null, null);
- mv.visitCode();
- mv.visitFieldInsn(GETFIELD, "Doo", "boo", "LBoo;");
-
- mv.visitLdcInsn(Type.getType("LBoo;"));
- mv.visitLdcInsn(Type.getType("[LDoo;"));
- mv.visitLdcInsn(Type.getType("[I"));
- mv.visitLdcInsn(Type.getType("J"));
-
- mv.visitTypeInsn(ANEWARRAY, "Boo");
- mv.visitTypeInsn(ANEWARRAY, "[LDoo;");
- mv.visitTypeInsn(ANEWARRAY, "[I");
- mv.visitTypeInsn(ANEWARRAY, "J");
-
- mv.visitMultiANewArrayInsn("[[LBoo;", 2);
- mv.visitMethodInsn(INVOKEVIRTUAL, "Doo", "goo",
- "([[LBoo;LCoo;LDoo;)LCoo;");
-
- mv.visitFrame(Opcodes.F_NEW, 0, new Object[5], 0, new Object[10]);
- mv.visitFrame(Opcodes.F_NEW, 3, new Object[] { "Boo", "Coo", "Doo" },
- 0, new Object[0]);
- mv.visitFrame(Opcodes.F_NEW, 4, new Object[] { Opcodes.INTEGER, "Coo",
- Opcodes.INTEGER, "Doo" }, 0, new Object[0]);
- mv.visitFrame(Opcodes.F_NEW, 2, new Object[] { Opcodes.INTEGER,
- Opcodes.INTEGER }, 0, new Object[0]);
-
- Label l = new Label();
-
- mv.visitLocalVariable("boo", "LBoo;", null, l, l, 1);
- mv.visitLocalVariable("boo1", "[LBoo;", null, l, l, 3);
- mv.visitLocalVariable("boo2", "[[LBoo;", null, l, l, 4);
- mv.visitMaxs(0, 0);
-
- mv.visitTryCatchBlock(l, l, l, "Coo");
-
- mv.visitEnd();
-
- mv = cv.visitMethod(0, "goo", "([[LBoo;LCoo;LDoo;)V", null,
- new String[] { "I", "J" });
- mv.visitEnd();
-
- cv.visitEnd();
- }
-
- // /*
- public static class Boo {
- }
-
- public static interface Coo {
- }
-
- public static class Doo extends Boo implements Coo {
- Boo boo = new Boo();
- Boo[] boo1 = new Boo[2];
- String s = "";
- int i = 5;
-
- static final Class<?> c1 = Boo.class;
- static final Class<?> c2 = Boo[].class;
-
- public Doo() {
- }
-
- public Doo(int i, Coo coo, Boo boo) {
- }
-
- void foo() {
- class Eoo {
- String s;
- }
-
- Eoo e = new Eoo();
- e.s = "aaa";
-
- // visitFieldInsn(int, String, String, String)
- // visitLocalVariable(String, String, String, Label, Label, int)
- Boo boo = this.boo;
-
- // visitLdcInsn(Object)
- Class<?> cc = Boo.class;
-
- // visitTypeInsn(int, String)
- Boo[] boo1 = new Boo[2];
-
- // visitMultiANewArrayInsn(String, int)
- Boo[][] boo2 = new Boo[2][2];
-
- // visitMethodInsn(int, String, String, String)
- goo(boo2, this, this);
- }
-
- Coo goo(Boo[][] boo2, Coo coo, Doo doo) {
- return null;
- }
- }
- // */
-}
diff --git a/asm4/test/conform/org/objectweb/asm/commons/RemappingClassAdapterTest2.java b/asm4/test/conform/org/objectweb/asm/commons/RemappingClassAdapterTest2.java
deleted file mode 100644
index 65a4dc5..0000000
--- a/asm4/test/conform/org/objectweb/asm/commons/RemappingClassAdapterTest2.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/***
- * ASM: a very small and fast Java bytecode manipulation framework
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package org.objectweb.asm.commons;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import junit.framework.TestSuite;
-
-import org.objectweb.asm.AbstractTest;
-import org.objectweb.asm.ClassReader;
-import org.objectweb.asm.ClassWriter;
-
-public class RemappingClassAdapterTest2 extends AbstractTest {
-
- public static TestSuite suite() throws Exception {
- return new RemappingClassAdapterTest2().getSuite();
- }
-
- @Override
- public void test() throws Exception {
- ClassWriter cw = new ClassWriter(0);
- ClassReader cr = new ClassReader(is);
- Map<String, String> map = new HashMap<String, String>() {
- @Override
- public String get(Object key) {
- return "Foo";
- }
- };
- cr.accept(new RemappingClassAdapter(cw, new SimpleRemapper(map)),
- ClassReader.EXPAND_FRAMES);
- }
-
-}
diff --git a/asm4/test/conform/org/objectweb/asm/commons/SerialVersionUIDAdderTest.java b/asm4/test/conform/org/objectweb/asm/commons/SerialVersionUIDAdderTest.java
deleted file mode 100644
index 561ee55..0000000
--- a/asm4/test/conform/org/objectweb/asm/commons/SerialVersionUIDAdderTest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.commons;
-
-import junit.framework.TestSuite;
-
-import org.objectweb.asm.AbstractTest;
-import org.objectweb.asm.ClassReader;
-
-/**
- * SerialVerionUIDAdder tests.
- *
- * @author Eric Bruneton
- */
-public class SerialVersionUIDAdderTest extends AbstractTest {
-
- public static TestSuite suite() throws Exception {
- return new SerialVersionUIDAdderTest().getSuite();
- }
-
- @Override
- public void test() throws Exception {
- ClassReader cr = new ClassReader(is);
- cr.accept(new SerialVersionUIDAdder(null), 0);
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/commons/SerialVersionUIDAdderUnitTest.java b/asm4/test/conform/org/objectweb/asm/commons/SerialVersionUIDAdderUnitTest.java
deleted file mode 100644
index 8019890..0000000
--- a/asm4/test/conform/org/objectweb/asm/commons/SerialVersionUIDAdderUnitTest.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.commons;
-
-import java.io.IOException;
-import java.io.Serializable;
-
-import junit.framework.TestCase;
-
-import org.objectweb.asm.ClassReader;
-import org.objectweb.asm.ClassVisitor;
-
-/**
- * Test for the SerialVerionUid computation.
- *
- * @author Alexandre Vasseur
- * @author Eric Bruneton
- */
-public class SerialVersionUIDAdderUnitTest extends TestCase implements
- Serializable {
-
- protected final static int aField = 32;
-
- static {
- System.setIn(System.in);
- }
-
- public Object[] aMethod() {
- return null;
- }
-
- private long computeSerialVersionUID(final String className)
- throws IOException {
- final long[] svuid = new long[1];
- ClassVisitor cv = new SerialVersionUIDAdder(null) {
- @Override
- protected long computeSVUID() throws IOException {
- svuid[0] = super.computeSVUID();
- return svuid[0];
- }
- };
- new ClassReader(className).accept(cv, 0);
- return svuid[0];
- }
-
- public void test() throws Throwable {
- long UID = computeSerialVersionUID(getClass().getName());
- assertEquals(194753646298127968L, UID);
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/commons/StaticInitMergerTest.java b/asm4/test/conform/org/objectweb/asm/commons/StaticInitMergerTest.java
deleted file mode 100644
index a90703c..0000000
--- a/asm4/test/conform/org/objectweb/asm/commons/StaticInitMergerTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.commons;
-
-import junit.framework.TestCase;
-
-import org.objectweb.asm.ClassVisitor;
-import org.objectweb.asm.ClassWriter;
-import org.objectweb.asm.MethodVisitor;
-import org.objectweb.asm.Opcodes;
-
-/**
- * StaticInitMerger tests.
- *
- * @author Eric Bruneton
- */
-public class StaticInitMergerTest extends TestCase implements Opcodes {
-
- private final static TestClassLoader LOADER = new TestClassLoader();
-
- public void test() throws Exception {
- ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
- ClassVisitor cv = new StaticInitMerger("$clinit$", cw);
- cv.visit(V1_1, ACC_PUBLIC, "A", null, "java/lang/Object", null);
- cv.visitField(ACC_PUBLIC + ACC_STATIC, "counter", "I", null, null);
- for (int i = 0; i < 5; ++i) {
- MethodVisitor mv = cv.visitMethod(ACC_PUBLIC, "<clinit>", "()V",
- null, null);
- mv.visitFieldInsn(GETSTATIC, "A", "counter", "I");
- mv.visitInsn(ICONST_1);
- mv.visitInsn(IADD);
- mv.visitFieldInsn(PUTSTATIC, "A", "counter", "I");
- mv.visitInsn(RETURN);
- mv.visitMaxs(0, 0);
- }
- MethodVisitor mv = cv.visitMethod(ACC_PUBLIC, "<init>", "()V", null,
- null);
- mv.visitVarInsn(ALOAD, 0);
- mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V");
- mv.visitInsn(RETURN);
- mv.visitMaxs(0, 0);
- cv.visitEnd();
-
- Class<?> c = LOADER.defineClass("A", cw.toByteArray());
- assertEquals(c.getField("counter").getInt(c.newInstance()), 5);
- }
-
- // ------------------------------------------------------------------------
-
- static class TestClassLoader extends ClassLoader {
-
- public Class<?> defineClass(final String name, final byte[] b) {
- return defineClass(name, b, 0, b.length);
- }
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/signature/SignatureUnitTest.java b/asm4/test/conform/org/objectweb/asm/signature/SignatureUnitTest.java
deleted file mode 100644
index 337bbe0..0000000
--- a/asm4/test/conform/org/objectweb/asm/signature/SignatureUnitTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.signature;
-
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.objectweb.asm.util.TraceSignatureVisitorUnitTest;
-import org.objectweb.asm.util.TraceSignatureVisitorUnitTest.TestData;
-
-/**
- * Signature tests.
- *
- * @author Eugene Kuleshov
- * @author Eric Bruneton
- */
-public class SignatureUnitTest extends TestCase {
-
- public static TestSuite suite() {
- TestSuite suite = new TestSuite(SignatureUnitTest.class.getName());
- for (int i = 0; i < TraceSignatureVisitorUnitTest.DATA.length; i++) {
- suite.addTest(new SignatureUnitTest(new TestData(
- TraceSignatureVisitorUnitTest.DATA[i])));
- }
- return suite;
- }
-
- private TestData data;
-
- private SignatureUnitTest(final TestData data) {
- super("testSignature");
- this.data = data;
- }
-
- public void testSignature() {
- SignatureWriter wrt = new SignatureWriter();
- SignatureReader rdr = new SignatureReader(data.signature);
- switch (data.type) {
- case 'C':
- case 'M':
- rdr.accept(wrt);
- break;
- case 'F':
- rdr.acceptType(wrt);
- break;
- default:
- return;
- }
- assertEquals(data.signature, wrt.toString());
- }
-
- @Override
- public String getName() {
- return super.getName() + " " + data.signature;
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/signature/SignatureWriterTest.java b/asm4/test/conform/org/objectweb/asm/signature/SignatureWriterTest.java
deleted file mode 100644
index 3dc97a9..0000000
--- a/asm4/test/conform/org/objectweb/asm/signature/SignatureWriterTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.signature;
-
-import junit.framework.TestSuite;
-
-import org.objectweb.asm.AbstractTest;
-import org.objectweb.asm.ClassReader;
-import org.objectweb.asm.ClassVisitor;
-import org.objectweb.asm.FieldVisitor;
-import org.objectweb.asm.MethodVisitor;
-import org.objectweb.asm.Opcodes;
-
-/**
- * Signature tests.
- *
- * @author Eric Bruneton
- */
-public class SignatureWriterTest extends AbstractTest {
-
- public static TestSuite suite() throws Exception {
- return new SignatureWriterTest().getSuite();
- }
-
- @Override
- public void test() throws Exception {
- ClassReader cr = new ClassReader(is);
- cr.accept(new ClassVisitor(Opcodes.ASM4) {
- @Override
- public void visit(int version, int access, String name,
- String signature, String superName, String[] interfaces) {
- if (signature != null) {
- SignatureReader sr = new SignatureReader(signature);
- SignatureWriter sw = new SignatureWriter();
- sr.accept(sw);
- assertEquals(signature, sw.toString());
- }
- }
-
- @Override
- public FieldVisitor visitField(int access, String name,
- String desc, String signature, Object value) {
- if (signature != null) {
- SignatureReader sr = new SignatureReader(signature);
- SignatureWriter sw = new SignatureWriter();
- sr.acceptType(sw);
- assertEquals(signature, sw.toString());
- }
- return null;
- }
-
- @Override
- public MethodVisitor visitMethod(int access, String name,
- String desc, String signature, String[] exceptions) {
- if (signature != null) {
- SignatureReader sr = new SignatureReader(signature);
- SignatureWriter sw = new SignatureWriter();
- sr.accept(sw);
- assertEquals(signature, sw.toString());
- }
- return null;
- }
-
- }, 0);
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/test/cases/Annotation.java b/asm4/test/conform/org/objectweb/asm/test/cases/Annotation.java
deleted file mode 100644
index afa6e7b..0000000
--- a/asm4/test/conform/org/objectweb/asm/test/cases/Annotation.java
+++ /dev/null
@@ -1,313 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.test.cases;
-
-import java.io.IOException;
-
-import org.objectweb.asm.AnnotationVisitor;
-import org.objectweb.asm.ClassWriter;
-import org.objectweb.asm.FieldVisitor;
-import org.objectweb.asm.MethodVisitor;
-import org.objectweb.asm.Type;
-
-/**
- * Generates an annotation class with values of all types and a class using it.
- *
- * @author Eric Bruneton
- */
-public class Annotation extends Generator {
-
- final static int M = ACC_PUBLIC + ACC_ABSTRACT;
-
- final static String STRING = "Ljava/lang/String;";
-
- final static String CLASS = "Ljava/lang/Class;";
-
- final static String DOC = "Ljava/lang/annotation/Documented;";
-
- final static String DEPRECATED = "Ljava/lang/Deprecated;";
-
- @Override
- public void generate(final String dir) throws IOException {
- generate(dir, "pkg/Annotation.class", dumpAnnotation());
- generate(dir, "pkg/Annotated.class", dumpAnnotated());
- }
-
- public byte[] dumpAnnotation() {
- ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
- MethodVisitor mv;
- AnnotationVisitor av0, av1;
-
- cw.visit(V1_5, ACC_PUBLIC + ACC_ANNOTATION + ACC_ABSTRACT
- + ACC_INTERFACE, "pkg/Annotation", null, "java/lang/Object",
- new String[] { "java/lang/annotation/Annotation" });
-
- mv = cw.visitMethod(M, "byteValue", "()B", null, null);
- av0 = mv.visitAnnotationDefault();
- av0.visit(null, new Byte((byte) 1));
- av0.visitEnd();
- mv.visitEnd();
-
- mv = cw.visitMethod(M, "charValue", "()C", null, null);
- av0 = mv.visitAnnotationDefault();
- av0.visit(null, new Character((char) 1));
- av0.visitEnd();
- mv.visitEnd();
-
- mv = cw.visitMethod(M, "booleanValue", "()Z", null, null);
- av0 = mv.visitAnnotationDefault();
- av0.visit(null, Boolean.TRUE);
- av0.visitEnd();
- mv.visitEnd();
-
- mv = cw.visitMethod(M, "intValue", "()I", null, null);
- av0 = mv.visitAnnotationDefault();
- av0.visit(null, new Integer(1));
- av0.visitEnd();
- mv.visitEnd();
-
- mv = cw.visitMethod(M, "shortValue", "()S", null, null);
- av0 = mv.visitAnnotationDefault();
- av0.visit(null, new Short((short) 1));
- av0.visitEnd();
- mv.visitEnd();
-
- mv = cw.visitMethod(M, "longValue", "()J", null, null);
- av0 = mv.visitAnnotationDefault();
- av0.visit(null, new Long(1L));
- av0.visitEnd();
- mv.visitEnd();
-
- mv = cw.visitMethod(M, "floatValue", "()F", null, null);
- av0 = mv.visitAnnotationDefault();
- av0.visit(null, new Float("1.0"));
- av0.visitEnd();
- mv.visitEnd();
-
- mv = cw.visitMethod(M, "doubleValue", "()D", null, null);
- av0 = mv.visitAnnotationDefault();
- av0.visit(null, new Double("1.0"));
- av0.visitEnd();
- mv.visitEnd();
-
- mv = cw.visitMethod(M, "stringValue", "()" + STRING, null, null);
- av0 = mv.visitAnnotationDefault();
- av0.visit(null, "1");
- av0.visitEnd();
- mv.visitEnd();
-
- mv = cw.visitMethod(M, "classValue", "()" + CLASS, null, null);
- av0 = mv.visitAnnotationDefault();
- av0.visit(null, Type.getType("Lpkg/Annotation;"));
- av0.visitEnd();
- mv.visitEnd();
-
- mv = cw.visitMethod(M, "enumValue", "()Lpkg/Enum;", null, null);
- av0 = mv.visitAnnotationDefault();
- av0.visitEnum(null, "Lpkg/Enum;", "V1");
- av0.visitEnd();
- mv.visitEnd();
-
- mv = cw.visitMethod(M, "annotationValue", "()" + DOC, null, null);
- av0 = mv.visitAnnotationDefault();
- av1 = av0.visitAnnotation(null, DOC);
- av1.visitEnd();
- av0.visitEnd();
- mv.visitEnd();
-
- mv = cw.visitMethod(M, "byteArrayValue", "()[B", null, null);
- av0 = mv.visitAnnotationDefault();
- av0.visit(null, new byte[] { 0, 1 });
- av0.visitEnd();
- mv.visitEnd();
-
- mv = cw.visitMethod(M, "charArrayValue", "()[C", null, null);
- av0 = mv.visitAnnotationDefault();
- av0.visit(null, new char[] { '0', '1' });
- av0.visitEnd();
- mv.visitEnd();
-
- mv = cw.visitMethod(M, "booleanArrayValue", "()[Z", null, null);
- av0 = mv.visitAnnotationDefault();
- av0.visit(null, new boolean[] { false, true });
- av0.visitEnd();
- mv.visitEnd();
-
- mv = cw.visitMethod(M, "intArrayValue", "()[I", null, null);
- av0 = mv.visitAnnotationDefault();
- av0.visit(null, new int[] { 0, 1 });
- av0.visitEnd();
- mv.visitEnd();
-
- mv = cw.visitMethod(M, "shortArrayValue", "()[S", null, null);
- av0 = mv.visitAnnotationDefault();
- av0.visit(null, new short[] { (short) 0, (short) 1 });
- av0.visitEnd();
- mv.visitEnd();
-
- mv = cw.visitMethod(M, "longArrayValue", "()[J", null, null);
- av0 = mv.visitAnnotationDefault();
- av0.visit(null, new long[] { 0L, 1L });
- av0.visitEnd();
- mv.visitEnd();
-
- mv = cw.visitMethod(M, "floatArrayValue", "()[F", null, null);
- av0 = mv.visitAnnotationDefault();
- av0.visit(null, new float[] { 0.0f, 1.0f });
- av0.visitEnd();
- mv.visitEnd();
-
- mv = cw.visitMethod(M, "doubleArrayValue", "()[D", null, null);
- av0 = mv.visitAnnotationDefault();
- av0.visit(null, new double[] { 0.0d, 1.0d });
- av0.visitEnd();
- mv.visitEnd();
-
- mv = cw.visitMethod(M, "stringArrayValue", "()" + STRING, null, null);
- av0 = mv.visitAnnotationDefault();
- av1 = av0.visitArray(null);
- av1.visit(null, "0");
- av1.visit(null, "1");
- av1.visitEnd();
- av0.visitEnd();
- mv.visitEnd();
-
- mv = cw.visitMethod(M, "classArrayValue", "()[" + CLASS, null, null);
- av0 = mv.visitAnnotationDefault();
- av1 = av0.visitArray(null);
- av1.visit(null, Type.getType("Lpkg/Annotation;"));
- av1.visit(null, Type.getType("Lpkg/Annotation;"));
- av1.visitEnd();
- av0.visitEnd();
- mv.visitEnd();
-
- mv = cw.visitMethod(M, "enumArrayValue", "()[Lpkg/Enum;", null, null);
- av0 = mv.visitAnnotationDefault();
- av1 = av0.visitArray(null);
- av1.visitEnum(null, "Lpkg/Enum;", "V0");
- av1.visitEnum(null, "Lpkg/Enum;", "V1");
- av1.visitEnd();
- av0.visitEnd();
- mv.visitEnd();
-
- mv = cw.visitMethod(M, "annotationArrayValue", "()[" + DOC, null, null);
- av0 = mv.visitAnnotationDefault();
- av1 = av0.visitArray(null);
- av1.visitAnnotation(null, DOC).visitEnd();
- av1.visitAnnotation(null, DOC).visitEnd();
- av1.visitEnd();
- av0.visitEnd();
- mv.visitEnd();
-
- cw.visitEnd();
-
- return cw.toByteArray();
- }
-
- public byte[] dumpAnnotated() {
- ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
- FieldVisitor fv;
- MethodVisitor mv;
- AnnotationVisitor av0, av1;
-
- cw.visit(V1_5, ACC_PUBLIC + ACC_SUPER, "pkg/Annotated", null,
- "java/lang/Object", null);
-
- // visible class annotation
- cw.visitAnnotation(DEPRECATED, true).visitEnd();
-
- // invisible class annotation, with values of all types
- av0 = cw.visitAnnotation("Lpkg/Annotation;", false);
- av0.visit("byteValue", new Byte((byte) 0));
- av0.visit("charValue", new Character((char) 48));
- av0.visit("booleanValue", Boolean.FALSE);
- av0.visit("intValue", new Integer(0));
- av0.visit("shortValue", new Short((short) 0));
- av0.visit("longValue", new Long(0L));
- av0.visit("floatValue", new Float("0.0"));
- av0.visit("doubleValue", new Double("0.0"));
- av0.visit("stringValue", "0");
- av0.visitEnum("enumValue", "Lpkg/Enum;", "V0");
- av0.visitAnnotation("annotationValue", DOC).visitEnd();
- av0.visit("classValue", Type.getType("Lpkg/Annotation;"));
- av0.visit("byteArrayValue", new byte[] { 1, 0 });
- av0.visit("charArrayValue", new char[] { '1', '0' });
- av0.visit("booleanArrayValue", new boolean[] { true, false });
- av0.visit("intArrayValue", new int[] { 1, 0 });
- av0.visit("shortArrayValue", new short[] { (short) 1, (short) 0 });
- av0.visit("longArrayValue", new long[] { 1L, 0L });
- av0.visit("floatArrayValue", new float[] { 1.0f, 0.0f });
- av0.visit("doubleArrayValue", new double[] { 1.0d, 0.0d });
- av1 = av0.visitArray("stringArrayValue");
- av1.visit(null, "1");
- av1.visit(null, "0");
- av1.visitEnd();
- av0.visitArray("classArrayValue").visitEnd();
- av1 = av0.visitArray("enumArrayValue");
- av1.visitEnum(null, "Lpkg/Enum;", "V1");
- av1.visitEnum(null, "Lpkg/Enum;", "V2");
- av1.visitEnd();
- av0.visitArray("annotationArrayValue").visitEnd();
- av0.visitEnd();
-
- fv = cw.visitField(ACC_PUBLIC, "f", "I", null, null);
- // visible field annotation
- fv.visitAnnotation(DEPRECATED, true).visitEnd();
- // invisible field annotation
- av0 = fv.visitAnnotation("Lpkg/Annotation;", false);
- av0.visitEnum("enumValue", "Lpkg/Enum;", "V0");
- av0.visitEnd();
- fv.visitEnd();
-
- mv = cw.visitMethod(ACC_PUBLIC, "<init>", "(IIIIIIIIII)V", null, null);
- // visible method annotation
- mv.visitAnnotation(DEPRECATED, true).visitEnd();
- // invisible method annotation
- av0 = mv.visitAnnotation("Lpkg/Annotation;", false);
- av0.visitAnnotation("annotationValue", DOC).visitEnd();
- av0.visitEnd();
- // synthetic parameter annotation
- mv.visitParameterAnnotation(0, "Ljava/lang/Synthetic;", false);
- // visible parameter annotation
- mv.visitParameterAnnotation(8, DEPRECATED, true).visitEnd();
- // invisible parameter annotation
- av0 = mv.visitParameterAnnotation(8, "Lpkg/Annotation;", false);
- av0.visitArray("stringArrayValue").visitEnd();
- av0.visitEnd();
- mv.visitCode();
- mv.visitVarInsn(ALOAD, 0);
- mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V");
- mv.visitInsn(RETURN);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
-
- return cw.toByteArray();
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/test/cases/Attribute.java b/asm4/test/conform/org/objectweb/asm/test/cases/Attribute.java
deleted file mode 100644
index b59238b..0000000
--- a/asm4/test/conform/org/objectweb/asm/test/cases/Attribute.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.test.cases;
-
-import java.io.IOException;
-
-import org.objectweb.asm.ClassWriter;
-import org.objectweb.asm.FieldVisitor;
-import org.objectweb.asm.Label;
-import org.objectweb.asm.MethodVisitor;
-import org.objectweb.asm.attrs.CodeComment;
-import org.objectweb.asm.attrs.Comment;
-
-/**
- * Generates a class with non standard attributes. Covers class, field, method
- * and code attributes. Also covers the V1_3 class version and the SYNTHETIC
- * access flag for classes.
- *
- * @author Eric Bruneton
- */
-public class Attribute extends Generator {
-
- @Override
- public void generate(final String dir) throws IOException {
- generate(dir, "pkg/Attribute.class", dump());
- }
-
- public byte[] dump() {
- ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
- FieldVisitor fv;
- MethodVisitor mv;
-
- cw.visit(V1_3, ACC_PUBLIC + ACC_SYNTHETIC, "pkg/Attribute", null,
- "java/lang/Object", null);
-
- cw.visitAttribute(new Comment());
-
- fv = cw.visitField(ACC_PUBLIC, "f", "I", null, null);
- fv.visitAttribute(new Comment());
- fv.visitEnd();
-
- mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
- mv.visitAttribute(new Comment());
- mv.visitCode();
- mv.visitVarInsn(ALOAD, 0);
- mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V");
-
- /*
- * the following instructions are designed so that this method will be
- * resized by the method resizing test, in order to cover the code that
- * recomputes the code attribute labels in the resizeInstructions method
- * (see MethodWriter).
- */
- Label l0 = new Label();
- mv.visitInsn(ICONST_0);
- mv.visitJumpInsn(IFEQ, l0);
- // many NOPs will be introduced here by the method resizing test
- mv.visitJumpInsn(GOTO, l0);
- mv.visitLabel(l0);
-
- mv.visitInsn(RETURN);
- mv.visitMaxs(0, 0);
- mv.visitAttribute(new CodeComment());
- mv.visitEnd();
-
- cw.visitEnd();
- return cw.toByteArray();
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/test/cases/Debug.java b/asm4/test/conform/org/objectweb/asm/test/cases/Debug.java
deleted file mode 100644
index 8a1dd19..0000000
--- a/asm4/test/conform/org/objectweb/asm/test/cases/Debug.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.test.cases;
-
-import java.io.IOException;
-
-import org.objectweb.asm.ClassWriter;
-import org.objectweb.asm.FieldVisitor;
-import org.objectweb.asm.Label;
-import org.objectweb.asm.MethodVisitor;
-
-/**
- * Generates a class with debug information. Covers line number tables, local
- * variable tables, source file, source debug, etc. Also covers the
- * serialVersionUID field (to cover a branch in SerialVersionUIDAdder).
- *
- * @author Eric Bruneton
- */
-public class Debug extends Generator {
-
- @Override
- public void generate(final String dir) throws IOException {
- generate(dir, "pkg/Debug.class", dump());
- }
-
- public byte[] dump() {
- ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
-
- cw.visit(V1_5, ACC_PUBLIC + ACC_SUPER, "pkg/Debug", null,
- "java/lang/Object", new String[] { "java/io/Serializable" });
-
- cw.visitSource("Debug.java", "source-debug");
-
- FieldVisitor fv = cw.visitField(ACC_FINAL + ACC_STATIC,
- "serialVersionUID", "J", null, new Long(1L));
- fv.visitEnd();
-
- MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null,
- null);
- mv.visitCode();
- Label l0 = new Label();
- Label l1 = new Label();
- Label l2 = new Label();
- mv.visitLabel(l0);
- mv.visitLineNumber(3, l0);
- mv.visitVarInsn(ALOAD, 0);
- mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V");
- mv.visitInsn(ICONST_0);
- mv.visitJumpInsn(IFEQ, l1);
- mv.visitJumpInsn(GOTO, l1);
- mv.visitLabel(l1);
- mv.visitLineNumber(3, l1);
- mv.visitInsn(RETURN);
- mv.visitLabel(l2);
- mv.visitLocalVariable("this", "Lpkg/Debug;", "Lpkg/Debug;", l0, l2, 0);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
-
- cw.visitEnd();
-
- return cw.toByteArray();
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/test/cases/Enum.java b/asm4/test/conform/org/objectweb/asm/test/cases/Enum.java
deleted file mode 100644
index 525f88f..0000000
--- a/asm4/test/conform/org/objectweb/asm/test/cases/Enum.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.test.cases;
-
-import java.io.IOException;
-
-import org.objectweb.asm.ClassWriter;
-import org.objectweb.asm.FieldVisitor;
-import org.objectweb.asm.MethodVisitor;
-import org.objectweb.asm.Type;
-
-/**
- * Generates an enum class.
- *
- * @author Eric Bruneton
- */
-public class Enum extends Generator {
-
- @Override
- public void generate(final String dir) throws IOException {
- generate(dir, "pkg/Enum.class", dump());
- }
-
- public byte[] dump() {
- ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
- FieldVisitor fv;
- MethodVisitor mv;
-
- cw.visit(V1_5, ACC_PUBLIC + ACC_FINAL + ACC_SUPER + ACC_ENUM,
- "pkg/Enum", "Ljava/lang/Enum<Lpkg/Enum;>;", "java/lang/Enum",
- null);
-
- fv = cw.visitField(ACC_PUBLIC + ACC_FINAL + ACC_STATIC + ACC_ENUM,
- "V0", "Lpkg/Enum;", null, null);
- fv.visitEnd();
-
- fv = cw.visitField(ACC_PUBLIC + ACC_FINAL + ACC_STATIC + ACC_ENUM,
- "V1", "Lpkg/Enum;", null, null);
- fv.visitEnd();
-
- fv = cw.visitField(ACC_PUBLIC + ACC_FINAL + ACC_STATIC + ACC_ENUM,
- "V2", "Lpkg/Enum;", null, null);
- fv.visitEnd();
-
- fv = cw.visitField(
- ACC_PRIVATE + ACC_FINAL + ACC_STATIC + ACC_SYNTHETIC,
- "$VALUES", "[Lpkg/Enum;", null, null);
- fv.visitEnd();
-
- mv = cw.visitMethod(ACC_PUBLIC + ACC_FINAL + ACC_STATIC, "values",
- "()[Lpkg/Enum;", null, null);
- mv.visitCode();
- mv.visitFieldInsn(GETSTATIC, "pkg/Enum", "$VALUES", "[Lpkg/Enum;");
- mv.visitMethodInsn(INVOKEVIRTUAL, "[Lpkg/Enum;", "clone",
- "()Ljava/lang/Object;");
- mv.visitTypeInsn(CHECKCAST, "[Lpkg/Enum;");
- mv.visitInsn(ARETURN);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
-
- mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "valueOf",
- "(Ljava/lang/String;)Lpkg/Enum;", null, null);
- mv.visitCode();
- mv.visitLdcInsn(Type.getType("Lpkg/Enum;"));
- mv.visitVarInsn(ALOAD, 0);
- mv.visitMethodInsn(INVOKESTATIC, "java/lang/Enum", "valueOf",
- "(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Enum;");
- mv.visitTypeInsn(CHECKCAST, "pkg/Enum");
- mv.visitInsn(ARETURN);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
-
- mv = cw.visitMethod(ACC_PRIVATE, "<init>", "(Ljava/lang/String;I)V",
- "()V", null);
- mv.visitCode();
- mv.visitVarInsn(ALOAD, 0);
- mv.visitVarInsn(ALOAD, 1);
- mv.visitVarInsn(ILOAD, 2);
- mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Enum", "<init>",
- "(Ljava/lang/String;I)V");
- mv.visitInsn(RETURN);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
-
- mv = cw.visitMethod(ACC_STATIC, "<clinit>", "()V", null, null);
- mv.visitCode();
- mv.visitTypeInsn(NEW, "pkg/Enum");
- mv.visitInsn(DUP);
- mv.visitLdcInsn("V0");
- mv.visitInsn(ICONST_0);
- mv.visitMethodInsn(INVOKESPECIAL, "pkg/Enum", "<init>",
- "(Ljava/lang/String;I)V");
- mv.visitFieldInsn(PUTSTATIC, "pkg/Enum", "V0", "Lpkg/Enum;");
- mv.visitTypeInsn(NEW, "pkg/Enum");
- mv.visitInsn(DUP);
- mv.visitLdcInsn("V1");
- mv.visitInsn(ICONST_1);
- mv.visitMethodInsn(INVOKESPECIAL, "pkg/Enum", "<init>",
- "(Ljava/lang/String;I)V");
- mv.visitFieldInsn(PUTSTATIC, "pkg/Enum", "V1", "Lpkg/Enum;");
- mv.visitTypeInsn(NEW, "pkg/Enum");
- mv.visitInsn(DUP);
- mv.visitLdcInsn("V2");
- mv.visitInsn(ICONST_2);
- mv.visitMethodInsn(INVOKESPECIAL, "pkg/Enum", "<init>",
- "(Ljava/lang/String;I)V");
- mv.visitFieldInsn(PUTSTATIC, "pkg/Enum", "V2", "Lpkg/Enum;");
- mv.visitInsn(ICONST_3);
- mv.visitTypeInsn(ANEWARRAY, "pkg/Enum");
- mv.visitInsn(DUP);
- mv.visitInsn(ICONST_0);
- mv.visitFieldInsn(GETSTATIC, "pkg/Enum", "V0", "Lpkg/Enum;");
- mv.visitInsn(AASTORE);
- mv.visitInsn(DUP);
- mv.visitInsn(ICONST_1);
- mv.visitFieldInsn(GETSTATIC, "pkg/Enum", "V1", "Lpkg/Enum;");
- mv.visitInsn(AASTORE);
- mv.visitInsn(DUP);
- mv.visitInsn(ICONST_2);
- mv.visitFieldInsn(GETSTATIC, "pkg/Enum", "V2", "Lpkg/Enum;");
- mv.visitInsn(AASTORE);
- mv.visitFieldInsn(PUTSTATIC, "pkg/Enum", "$VALUES", "[Lpkg/Enum;");
- mv.visitInsn(RETURN);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
-
- cw.visitEnd();
-
- return cw.toByteArray();
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/test/cases/Frames.java b/asm4/test/conform/org/objectweb/asm/test/cases/Frames.java
deleted file mode 100644
index 31ffedc..0000000
--- a/asm4/test/conform/org/objectweb/asm/test/cases/Frames.java
+++ /dev/null
@@ -1,732 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.test.cases;
-
-import java.io.IOException;
-
-import org.objectweb.asm.ClassReader;
-import org.objectweb.asm.ClassVisitor;
-import org.objectweb.asm.ClassWriter;
-import org.objectweb.asm.FieldVisitor;
-import org.objectweb.asm.Label;
-import org.objectweb.asm.MethodVisitor;
-import org.objectweb.asm.Opcodes;
-
-/**
- * Generates classes with StackMap and StackMapTable attributes. Covers all
- * frame (FULL, SAME, etc.) and frame element types (TOP, NULL, INTEGER, etc.).
- * Also covers the V1_6 class version.
- *
- * @author Eric Bruneton
- */
-public class Frames extends Generator {
-
- final static int M = ACC_STATIC;
- final static String I1 = "Ljava/io/Serializable;";
- final static String I2 = "Ljava/lang/Comparable;";
-
- @Override
- public void generate(final String dir) throws IOException {
- byte[] b = dump();
- ClassWriter cw = new ClassWriter(0);
- ClassReader cr = new ClassReader(b);
- cr.accept(new RenameAdapter(cw), ClassReader.EXPAND_FRAMES);
-
- generate(dir, "pkg/FrameTable.class", b);
- generate(dir, "pkg/FrameMap.class", cw.toByteArray());
- }
-
- public byte[] dump() {
- ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
- MethodVisitor mv;
- FieldVisitor fv;
-
- cw.visit(V1_6, ACC_PUBLIC + ACC_SUPER, "pkg/FrameTable", null,
- "java/lang/Object", null);
-
- fv = cw.visitField(M, "long", "Ljava/lang/Long;", null, null);
- fv.visitEnd();
-
- fv = cw.visitField(M, "double", "Ljava/lang/Double;", null, null);
- fv.visitEnd();
-
- fv = cw.visitField(M, "number", "Ljava/lang/Number;", null, null);
- fv.visitEnd();
-
- fv = cw.visitField(M, "serializable", I1, null, null);
- fv.visitEnd();
-
- fv = cw.visitField(M, "comparable", I2, null, null);
- fv.visitEnd();
-
- fv = cw.visitField(M, "longArray", "[Ljava/lang/Long;", null, null);
- fv.visitEnd();
-
- fv = cw.visitField(M, "intArray", "[I", null, null);
- fv.visitEnd();
-
- fv = cw.visitField(M, "floatArray", "[F", null, null);
- fv.visitEnd();
-
- fv = cw.visitField(M, "objectArray", "[Ljava/lang/Object;", null, null);
- fv.visitEnd();
-
- mv = cw.visitMethod(ACC_PUBLIC, "<init>", "(Ljava/lang/Object;)V",
- null, null);
- mv.visitCode();
- mv.visitVarInsn(ALOAD, 0);
- mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V");
- mv.visitInsn(RETURN);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
-
- uninitializedThisType(cw);
- uninitializedLocalType(cw);
- uninitializedStackType(cw);
- nullType(cw);
- topType(cw);
- arrayTypes(cw);
-
- mergeTypes(cw);
- mergeStackTypes(cw);
- mergeNullArray(cw);
-
- appendAndChopFrame(cw);
- sameLocals1stackItemFrame(cw);
- sameLocals1stackItemFrame2(cw);
- sameLocals1stackItemFrameExtended(cw);
- sameFrameExtended(cw);
-
- deadCode(cw);
-
- cw.visitEnd();
-
- return cw.toByteArray();
- }
-
- private void uninitializedThisType(final ClassWriter cw) {
- MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "<init>", "(I)V", null,
- null);
- mv.visitCode();
- mv.visitVarInsn(ALOAD, 0);
- Label l0 = new Label();
- mv.visitLabel(l0);
- mv.visitTypeInsn(NEW, "pkg/FrameTable");
- mv.visitInsn(DUP);
- mv.visitVarInsn(ILOAD, 1);
- Label l1 = new Label();
- mv.visitJumpInsn(IFNE, l1);
- mv.visitInsn(ACONST_NULL);
- Label l2 = new Label();
- mv.visitJumpInsn(GOTO, l2);
- mv.visitFrame(F_FULL, 2, new Object[] { UNINITIALIZED_THIS, INTEGER },
- 3, new Object[] { UNINITIALIZED_THIS, l0, l0 });
- mv.visitLabel(l1);
- mv.visitTypeInsn(NEW, "java/lang/Object");
- mv.visitInsn(DUP);
- mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V");
- mv.visitFrame(F_FULL, 2, new Object[] { UNINITIALIZED_THIS, INTEGER },
- 4, new Object[] { UNINITIALIZED_THIS, l0, l0,
- "java/lang/Object" });
- mv.visitLabel(l2);
- mv.visitMethodInsn(INVOKESPECIAL, "pkg/FrameTable", "<init>",
- "(Ljava/lang/Object;)V");
- mv.visitMethodInsn(INVOKESPECIAL, "pkg/FrameTable", "<init>",
- "(Ljava/lang/Object;)V");
- mv.visitInsn(RETURN);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
- }
-
- private void uninitializedLocalType(final ClassWriter cw) {
- MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "uninitializedLocalType",
- "(Z)V", null, null);
- mv.visitCode();
- Label l0 = new Label();
- mv.visitLabel(l0);
- mv.visitTypeInsn(NEW, "java/lang/Long");
- mv.visitVarInsn(ASTORE, 2);
- mv.visitVarInsn(ALOAD, 2);
- mv.visitVarInsn(ILOAD, 1);
- Label l1 = new Label();
- mv.visitJumpInsn(IFEQ, l1);
- mv.visitInsn(LCONST_0);
- Label l2 = new Label();
- mv.visitJumpInsn(GOTO, l2);
- mv.visitFrame(F_FULL, 3,
- new Object[] { "pkg/FrameTable", INTEGER, l0 }, 1,
- new Object[] { l0 });
- mv.visitLabel(l1);
- mv.visitInsn(LCONST_1);
- mv.visitFrame(F_FULL, 3,
- new Object[] { "pkg/FrameTable", INTEGER, l0 }, 2,
- new Object[] { l0, LONG });
- mv.visitLabel(l2);
- mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Long", "<init>", "(J)V");
- mv.visitInsn(RETURN);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
- }
-
- private void uninitializedStackType(final ClassWriter cw) {
- MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "uninitializedStackType",
- "(Z)V", null, null);
- mv.visitCode();
- Label l0 = new Label();
- mv.visitLabel(l0);
- mv.visitTypeInsn(NEW, "java/lang/Long");
- mv.visitInsn(DUP);
- mv.visitVarInsn(ILOAD, 1);
- Label l1 = new Label();
- mv.visitJumpInsn(IFEQ, l1);
- mv.visitInsn(LCONST_0);
- mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Long", "<init>", "(J)V");
- Label l2 = new Label();
- mv.visitJumpInsn(GOTO, l2);
- mv.visitFrame(F_FULL, 1, new Object[] { "pkg/FrameTable" }, 2,
- new Object[] { l0, l0 });
- mv.visitLabel(l1);
- mv.visitInsn(LCONST_1);
- mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Long", "<init>", "(J)V");
- mv.visitFrame(F_SAME1, 0, null, 1, new Object[] { "java/lang/Long" });
- mv.visitLabel(l2);
- mv.visitVarInsn(ASTORE, 2);
- mv.visitInsn(RETURN);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
- }
-
- private void nullType(final ClassWriter cw) {
- MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "nullType",
- "(Ljava/lang/String;Ljava/lang/String;)V", null, null);
- mv.visitCode();
- mv.visitInsn(ACONST_NULL);
- mv.visitVarInsn(ASTORE, 2);
- mv.visitVarInsn(ALOAD, 0);
- mv.visitInsn(ACONST_NULL);
- mv.visitVarInsn(ALOAD, 1);
- Label l0 = new Label();
- mv.visitJumpInsn(IFNONNULL, l0);
- mv.visitVarInsn(ALOAD, 2);
- Label l1 = new Label();
- mv.visitJumpInsn(GOTO, l1);
- mv.visitFrame(F_FULL, 3, new Object[] { "pkg/FrameTable",
- "java/lang/String", NULL }, 2, new Object[] { "pkg/FrameTable",
- NULL });
- mv.visitLabel(l0);
- mv.visitVarInsn(ALOAD, 1);
- mv.visitFrame(F_FULL, 3, new Object[] { "pkg/FrameTable",
- "java/lang/String", NULL }, 3, new Object[] { "pkg/FrameTable",
- NULL, "java/lang/String" });
- mv.visitLabel(l1);
- mv.visitMethodInsn(INVOKEVIRTUAL, "pkg/FrameTable", "nullType",
- "(Ljava/lang/String;Ljava/lang/String;)V");
- mv.visitInsn(RETURN);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
- }
-
- private void topType(final ClassWriter cw) {
- MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "topType",
- "(ZBCSIFJDLjava/lang/Object;)V", null, null);
- mv.visitCode();
- mv.visitVarInsn(ILOAD, 5);
- mv.visitVarInsn(ISTORE, 13);
- mv.visitVarInsn(ILOAD, 1);
- Label l0 = new Label();
- mv.visitJumpInsn(IFEQ, l0);
- mv.visitInsn(RETURN);
- mv.visitFrame(F_APPEND, 2, new Object[] { TOP, INTEGER }, 0, null);
- mv.visitLabel(l0);
- mv.visitInsn(RETURN);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
- }
-
- private void arrayTypes(final ClassWriter cw) {
- MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "fullFrame",
- "(Ljava/lang/String;[[Z[B[C[S[I[F[J[D[Ljava/lang/Object;)V",
- null, null);
- mv.visitCode();
- mv.visitLdcInsn(new Long(11L));
- mv.visitVarInsn(LSTORE, 11);
- mv.visitLdcInsn(new Long(11L));
- mv.visitVarInsn(LSTORE, 13);
- mv.visitLdcInsn(new Long(11L));
- mv.visitVarInsn(LSTORE, 15);
- mv.visitLdcInsn(new Long(11L));
- mv.visitVarInsn(LSTORE, 17);
- mv.visitVarInsn(ALOAD, 1);
- Label l0 = new Label();
- mv.visitJumpInsn(IFNONNULL, l0);
- mv.visitInsn(RETURN);
- mv.visitFrame(F_FULL, 15, new Object[] { "pkg/FrameTable",
- "java/lang/String", "[[Z", "[B", "[C", "[S", "[I", "[F", "[J",
- "[D", "[Ljava/lang/Object;", LONG, LONG, LONG, LONG }, 0,
- new Object[] {});
- mv.visitLabel(l0);
- mv.visitInsn(RETURN);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
- }
-
- private void mergeTypes(final ClassWriter cw) {
- MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "mergeTypes", "(Z)V",
- null, null);
- mv.visitCode();
- Label l0 = new Label();
- mv.visitFieldInsn(GETSTATIC, "pkg/FrameTable", "long",
- "Ljava/lang/Long;");
- mv.visitVarInsn(ASTORE, 2);
- mv.visitFieldInsn(GETSTATIC, "pkg/FrameTable", "number",
- "Ljava/lang/Number;");
- mv.visitVarInsn(ASTORE, 3);
- mv.visitFieldInsn(GETSTATIC, "pkg/FrameTable", "number",
- "Ljava/lang/Long;");
- mv.visitVarInsn(ASTORE, 4);
- mv.visitFieldInsn(GETSTATIC, "pkg/FrameTable", "comparable",
- "Ljava/lang/Comparable;");
- mv.visitVarInsn(ASTORE, 5);
- mv.visitInsn(ACONST_NULL);
- mv.visitVarInsn(ASTORE, 6);
- mv.visitFieldInsn(GETSTATIC, "pkg/FrameTable", "double",
- "Ljava/lang/Double;");
- mv.visitVarInsn(ASTORE, 7);
- mv.visitInsn(ICONST_0);
- mv.visitVarInsn(ISTORE, 8);
- mv.visitFieldInsn(GETSTATIC, "pkg/FrameTable", "intArray", "[I");
- mv.visitVarInsn(ASTORE, 9);
- mv.visitFieldInsn(GETSTATIC, "pkg/FrameTable", "double",
- "Ljava/lang/Double;");
- mv.visitVarInsn(ASTORE, 10);
- mv.visitInsn(ACONST_NULL);
- mv.visitVarInsn(ASTORE, 11);
-
- mv.visitFrame(F_FULL, 12,
- new Object[] { "pkg/FrameTable", INTEGER, "java/lang/Number",
- "java/lang/Number", "java/lang/Number",
- "java/lang/Object", NULL, "java/lang/Double", TOP,
- "java/lang/Object", "java/lang/Object",
- "[Ljava/lang/Object;" }, 0, null);
- mv.visitLabel(l0);
- mv.visitVarInsn(ALOAD, 11);
- mv.visitInsn(ICONST_0);
- mv.visitInsn(ACONST_NULL);
- mv.visitInsn(AASTORE);
-
- mv.visitFieldInsn(GETSTATIC, "pkg/FrameTable", "double",
- "Ljava/lang/Double;");
- mv.visitVarInsn(ASTORE, 2);
- mv.visitFieldInsn(GETSTATIC, "pkg/FrameTable", "double",
- "Ljava/lang/Double;");
- mv.visitVarInsn(ASTORE, 3);
- mv.visitFieldInsn(GETSTATIC, "pkg/FrameTable", "number",
- "Ljava/lang/Number;");
- mv.visitVarInsn(ASTORE, 4);
- mv.visitFieldInsn(GETSTATIC, "pkg/FrameTable", "serializable",
- "Ljava/io/Serializable;");
- mv.visitVarInsn(ASTORE, 5);
- mv.visitInsn(ACONST_NULL);
- mv.visitVarInsn(ASTORE, 6);
- mv.visitInsn(ACONST_NULL);
- mv.visitVarInsn(ASTORE, 7);
- mv.visitInsn(ACONST_NULL);
- mv.visitVarInsn(ASTORE, 8);
- mv.visitFieldInsn(GETSTATIC, "pkg/FrameTable", "floatArray", "[F");
- mv.visitVarInsn(ASTORE, 9);
- mv.visitFieldInsn(GETSTATIC, "pkg/FrameTable", "intArray", "[I");
- mv.visitVarInsn(ASTORE, 10);
- mv.visitInsn(ICONST_1);
- mv.visitTypeInsn(ANEWARRAY, "java/lang/Object");
- mv.visitVarInsn(ASTORE, 11);
-
- mv.visitJumpInsn(GOTO, l0);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
- }
-
- private void mergeStackTypes(final ClassWriter cw) {
- MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "mergeStackTypes",
- "(Z)V", null, null);
- mv.visitCode();
- mv.visitInsn(ICONST_0);
- mv.visitInsn(ICONST_1);
- mv.visitVarInsn(ILOAD, 1);
- Label l0 = new Label();
- mv.visitJumpInsn(IFEQ, l0);
- mv.visitInsn(ICONST_0);
- Label l1 = new Label();
- mv.visitJumpInsn(GOTO, l1);
- mv.visitFrame(F_FULL, 1, new Object[] { "pkg/FrameTable" }, 2,
- new Object[] { INTEGER, INTEGER });
- mv.visitLabel(l0);
- mv.visitInsn(DUP);
- mv.visitFrame(F_FULL, 1, new Object[] { "pkg/FrameTable" }, 3,
- new Object[] { INTEGER, INTEGER, INTEGER });
- mv.visitLabel(l1);
- mv.visitInsn(RETURN);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
- }
-
- private void mergeNullArray(final ClassWriter cw) {
- MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "mergeNullArray", "(Z)I",
- null, null);
- mv.visitCode();
- mv.visitVarInsn(ILOAD, 1);
- Label l1 = new Label();
- mv.visitJumpInsn(IFEQ, l1);
- mv.visitInsn(ACONST_NULL);
- mv.visitVarInsn(ASTORE, 2);
- mv.visitVarInsn(ILOAD, 1);
- Label l2 = new Label();
- mv.visitJumpInsn(IFEQ, l2);
- mv.visitFieldInsn(GETSTATIC, "pkg/FrameTable", "longArray",
- "[Ljava/lang/Long;");
- mv.visitVarInsn(ASTORE, 2);
- mv.visitFrame(F_APPEND, 1, new Object[] { "[Ljava/lang/Long;" }, 0,
- null);
- mv.visitLabel(l2);
- mv.visitVarInsn(ALOAD, 2);
- Label l3 = new Label();
- mv.visitJumpInsn(IFNULL, l3);
- mv.visitVarInsn(ALOAD, 2);
- mv.visitInsn(ARRAYLENGTH);
- Label l4 = new Label();
- mv.visitJumpInsn(IFNE, l4);
- mv.visitFrame(F_SAME, 0, null, 0, null);
- mv.visitLabel(l3);
- mv.visitInsn(ACONST_NULL);
- mv.visitVarInsn(ASTORE, 3);
- Label l5 = new Label();
- mv.visitJumpInsn(GOTO, l5);
- mv.visitFrame(F_SAME, 0, null, 0, null);
- mv.visitLabel(l4);
- mv.visitVarInsn(ALOAD, 2);
- mv.visitInsn(ICONST_0);
- mv.visitInsn(AALOAD);
- mv.visitVarInsn(ASTORE, 3);
- mv.visitVarInsn(ILOAD, 1);
- mv.visitJumpInsn(IFNE, l5);
- mv.visitInsn(ACONST_NULL);
- mv.visitVarInsn(ASTORE, 3);
- mv.visitFrame(F_SAME, 0, null, 0, null);
- mv.visitLabel(l5);
- mv.visitVarInsn(ILOAD, 1);
- mv.visitInsn(IRETURN);
- mv.visitFrame(F_CHOP, 1, null, 0, null);
- mv.visitLabel(l1);
- mv.visitVarInsn(ILOAD, 1);
- mv.visitInsn(IRETURN);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
- }
-
- private void appendAndChopFrame(final ClassWriter cw) {
- MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "appendAndChopFrame",
- "(I)V", null, null);
- mv.visitCode();
- mv.visitInsn(ICONST_0);
- mv.visitVarInsn(ISTORE, 2);
- mv.visitFrame(F_APPEND, 1, new Object[] { INTEGER }, 0, null);
- Label l0 = new Label();
- mv.visitLabel(l0);
- mv.visitVarInsn(ILOAD, 2);
- mv.visitVarInsn(ILOAD, 1);
- Label l1 = new Label();
- mv.visitJumpInsn(IF_ICMPGE, l1);
- mv.visitIincInsn(2, 1);
- mv.visitJumpInsn(GOTO, l0);
- mv.visitFrame(F_CHOP, 1, null, 0, null);
- mv.visitLabel(l1);
- mv.visitInsn(RETURN);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
- }
-
- private void sameLocals1stackItemFrame(final ClassWriter cw) {
- MethodVisitor mv = cw.visitMethod(ACC_PUBLIC,
- "sameLocals1stackItemFrame", "()I", null, null);
- mv.visitCode();
- Label l0 = new Label();
- Label l1 = new Label();
- mv.visitTryCatchBlock(l0, l1, l0, null);
- mv.visitInsn(ICONST_0);
- mv.visitInsn(IRETURN);
- mv.visitFrame(F_SAME1, 0, null, 1,
- new Object[] { "java/lang/Throwable" });
- mv.visitLabel(l0);
- mv.visitVarInsn(ASTORE, 1);
- mv.visitLabel(l1);
- mv.visitInsn(ICONST_0);
- mv.visitInsn(IRETURN);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
- }
-
- private void sameLocals1stackItemFrame2(final ClassWriter cw) {
- MethodVisitor mv = cw.visitMethod(ACC_PUBLIC,
- "sameLocals1stackItemFrame2", "()V", null, null);
- mv.visitCode();
- Label l0 = new Label();
- Label l1 = new Label();
- Label l2 = new Label();
- mv.visitTryCatchBlock(l0, l1, l2, "java/lang/Exception");
- Label l3 = new Label();
- mv.visitTryCatchBlock(l0, l1, l3, null);
- Label l4 = new Label();
- mv.visitTryCatchBlock(l2, l4, l3, null);
- Label l5 = new Label();
- mv.visitTryCatchBlock(l3, l5, l3, null);
- mv.visitLabel(l0);
- mv.visitTypeInsn(NEW, "java/lang/Object");
- mv.visitInsn(DUP);
- mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V");
- mv.visitVarInsn(ASTORE, 1);
- mv.visitLabel(l1);
- Label l6 = new Label();
- mv.visitJumpInsn(GOTO, l6);
- mv.visitFrame(F_SAME1, 0, null, 1,
- new Object[] { "java/lang/Exception" });
- mv.visitLabel(l2);
- mv.visitVarInsn(ASTORE, 2);
- mv.visitLabel(l4);
- mv.visitJumpInsn(GOTO, l6);
- mv.visitFrame(F_SAME1, 0, null, 1,
- new Object[] { "java/lang/Throwable" });
- mv.visitLabel(l3);
- mv.visitVarInsn(ASTORE, 3);
- mv.visitLabel(l5);
- mv.visitVarInsn(ALOAD, 3);
- mv.visitInsn(ATHROW);
- mv.visitFrame(F_SAME, 0, null, 0, null);
- mv.visitLabel(l6);
- mv.visitInsn(RETURN);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
- }
-
- private void sameLocals1stackItemFrameExtended(final ClassWriter cw) {
- MethodVisitor mv = cw.visitMethod(ACC_PUBLIC,
- "sameLocals1stackItemFrameExtended", "()I", null, null);
- mv.visitCode();
- Label l0 = new Label();
- Label l1 = new Label();
- Label l2 = new Label();
- mv.visitTryCatchBlock(l0, l1, l2, null);
- Label l3 = new Label();
- mv.visitTryCatchBlock(l2, l3, l2, null);
- mv.visitLabel(l0);
- mv.visitLdcInsn(new Long(11L));
- mv.visitVarInsn(LSTORE, 1);
- mv.visitLdcInsn(new Long(11L));
- mv.visitVarInsn(LSTORE, 3);
- mv.visitLdcInsn(new Long(11L));
- mv.visitVarInsn(LSTORE, 5);
- mv.visitLdcInsn(new Long(11L));
- mv.visitVarInsn(LSTORE, 7);
- mv.visitLdcInsn(new Long(11L));
- mv.visitVarInsn(LSTORE, 9);
- mv.visitLdcInsn(new Long(11L));
- mv.visitVarInsn(LSTORE, 11);
- mv.visitLdcInsn(new Long(11L));
- mv.visitVarInsn(LSTORE, 13);
- mv.visitLdcInsn(new Long(11L));
- mv.visitVarInsn(LSTORE, 15);
- mv.visitLdcInsn(new Long(11L));
- mv.visitVarInsn(LSTORE, 17);
- mv.visitLdcInsn(new Long(11L));
- mv.visitVarInsn(LSTORE, 19);
- mv.visitLdcInsn(new Long(11L));
- mv.visitVarInsn(LSTORE, 21);
- mv.visitLdcInsn(new Long(11L));
- mv.visitVarInsn(LSTORE, 23);
- mv.visitLdcInsn(new Long(11L));
- mv.visitVarInsn(LSTORE, 25);
- mv.visitLabel(l1);
- mv.visitInsn(ICONST_0);
- mv.visitInsn(IRETURN);
- mv.visitFrame(F_SAME1, 0, null, 1,
- new Object[] { "java/lang/Throwable" });
- mv.visitLabel(l2);
- mv.visitVarInsn(ASTORE, 27);
- mv.visitLabel(l3);
- mv.visitInsn(ICONST_0);
- mv.visitInsn(IRETURN);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
- }
-
- private void sameFrameExtended(final ClassWriter cw) {
- MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "sameFrameExtended",
- "(Z)V", null, null);
- mv.visitCode();
- mv.visitFrame(F_SAME, 0, null, 0, null);
- Label l0 = new Label();
- mv.visitLabel(l0);
- mv.visitLdcInsn(new Long(11L));
- mv.visitVarInsn(LSTORE, 2);
- mv.visitLdcInsn(new Long(11L));
- mv.visitVarInsn(LSTORE, 4);
- mv.visitLdcInsn(new Long(11L));
- mv.visitVarInsn(LSTORE, 6);
- mv.visitLdcInsn(new Long(11L));
- mv.visitVarInsn(LSTORE, 8);
- mv.visitLdcInsn(new Long(11L));
- mv.visitVarInsn(LSTORE, 10);
- mv.visitLdcInsn(new Long(11L));
- mv.visitVarInsn(LSTORE, 12);
- mv.visitLdcInsn(new Long(11L));
- mv.visitVarInsn(LSTORE, 14);
- mv.visitLdcInsn(new Long(11L));
- mv.visitVarInsn(LSTORE, 16);
- mv.visitLdcInsn(new Long(11L));
- mv.visitVarInsn(LSTORE, 18);
- mv.visitLdcInsn(new Long(11L));
- mv.visitVarInsn(LSTORE, 20);
- mv.visitLdcInsn(new Long(11L));
- mv.visitVarInsn(LSTORE, 22);
- mv.visitLdcInsn(new Long(11L));
- mv.visitVarInsn(LSTORE, 24);
- mv.visitLdcInsn(new Long(11L));
- mv.visitVarInsn(LSTORE, 26);
- mv.visitVarInsn(ILOAD, 1);
- Label l1 = new Label();
- mv.visitJumpInsn(IFEQ, l1);
- mv.visitInsn(RETURN);
- mv.visitFrame(F_SAME, 0, null, 0, null);
- mv.visitLabel(l1);
- mv.visitJumpInsn(GOTO, l0);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
- }
-
- private void deadCode(final ClassWriter cw) {
- MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "deadCode", "(Z)V", null,
- null);
- mv.visitCode();
- Label l0 = new Label();
- Label l1 = new Label();
- Label l2 = new Label();
- Label l3 = new Label();
- mv.visitTryCatchBlock(l0, l1, l1, "java/lang/Exception");
- mv.visitTryCatchBlock(l2, l3, l3, "java/lang/Exception");
- mv.visitJumpInsn(GOTO, l2);
- mv.visitFrame(F_SAME, 0, null, 0, null);
- mv.visitLabel(l0);
- mv.visitInsn(RETURN);
- mv.visitFrame(F_SAME1, 0, null, 1,
- new Object[] { "java/lang/Exception" });
- mv.visitLabel(l1);
- mv.visitVarInsn(ASTORE, 2);
- mv.visitInsn(RETURN);
- mv.visitFrame(F_FULL, 0, new Object[] { "pkg/FrameTable", INTEGER }, 0,
- null);
- mv.visitLabel(l2);
- mv.visitInsn(RETURN);
- mv.visitFrame(F_SAME1, 0, null, 1,
- new Object[] { "java/lang/Exception" });
- mv.visitLabel(l3);
- mv.visitVarInsn(ASTORE, 2);
- mv.visitInsn(RETURN);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
- }
-
- /**
- * Ad hoc class adapter used to rename the FrameTable class and to change
- * its class version.
- *
- * @author Eric Bruneton
- */
- static class RenameAdapter extends ClassVisitor {
-
- public RenameAdapter(final ClassVisitor cv) {
- super(Opcodes.ASM4, cv);
- }
-
- @Override
- public void visit(final int version, final int access,
- final String name, final String signature,
- final String superName, final String[] interfaces) {
- super.visit(V1_5, access, "pkg/FrameMap", signature, superName,
- interfaces);
- }
-
- @Override
- public MethodVisitor visitMethod(final int access, final String name,
- final String desc, final String signature,
- final String[] exceptions) {
- return new MethodVisitor(Opcodes.ASM4, super.visitMethod(access,
- name, desc, signature, exceptions)) {
- @Override
- public void visitFrame(final int type, final int nLocal,
- final Object[] local, final int nStack,
- final Object[] stack) {
- Object[] clocal = new Object[local.length];
- for (int i = 0; i < clocal.length; ++i) {
- clocal[i] = local[i];
- if ("pkg/FrameTable".equals(clocal[i])) {
- clocal[i] = "pkg/FrameMap";
- }
- }
- Object[] cstack = new Object[stack.length];
- for (int i = 0; i < cstack.length; ++i) {
- cstack[i] = stack[i];
- if ("pkg/FrameTable".equals(cstack[i])) {
- cstack[i] = "pkg/FrameMap";
- }
- }
- super.visitFrame(type, nLocal, clocal, nStack, cstack);
- }
-
- @Override
- public void visitTypeInsn(final int opcode, final String desc) {
- if (desc.equals("pkg/FrameTable")) {
- super.visitTypeInsn(opcode, "pkg/FrameMap");
- } else {
- super.visitTypeInsn(opcode, desc);
- }
- }
-
- @Override
- public void visitMethodInsn(final int opcode,
- final String owner, final String name, final String desc) {
- if (owner.equals("pkg/FrameTable")) {
- super.visitMethodInsn(opcode, "pkg/FrameMap", name,
- desc);
- } else {
- super.visitMethodInsn(opcode, owner, name, desc);
- }
- }
- };
- }
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/test/cases/Generator.java b/asm4/test/conform/org/objectweb/asm/test/cases/Generator.java
deleted file mode 100644
index 133b522..0000000
--- a/asm4/test/conform/org/objectweb/asm/test/cases/Generator.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.test.cases;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-
-import org.objectweb.asm.Opcodes;
-
-/**
- * Generates classes designed so that the "conform" test suite, applied to these
- * classes, covers all the ASM code base.
- *
- * @author Eric Bruneton
- */
-public class Generator implements Opcodes {
-
- public static void main(final String[] args) throws IOException {
- Generator generators[] = { new Annotation(), new Attribute(),
- new Debug(), new Enum(), new Frames(), new Insns(),
- new Interface(), new Invalid(), new JSR(), new Outer(),
- new Wide(), new InvokeDynamic() };
- for (int i = 0; i < generators.length; ++i) {
- generators[i].generate(args[0]);
- }
- }
-
- protected void generate(final String dir) throws IOException {
- }
-
- protected void generate(final String dir, final String path,
- final byte[] clazz) throws IOException {
- File f = new File(new File(dir), path);
- if (!f.getParentFile().exists() && !f.getParentFile().mkdirs()) {
- throw new IOException("Cannot create directory "
- + f.getParentFile());
- }
- FileOutputStream o = new FileOutputStream(f);
- o.write(clazz);
- o.close();
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/test/cases/Insns.java b/asm4/test/conform/org/objectweb/asm/test/cases/Insns.java
deleted file mode 100644
index bfd0899..0000000
--- a/asm4/test/conform/org/objectweb/asm/test/cases/Insns.java
+++ /dev/null
@@ -1,750 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.test.cases;
-
-import java.io.IOException;
-
-import org.objectweb.asm.ClassWriter;
-import org.objectweb.asm.FieldVisitor;
-import org.objectweb.asm.Label;
-import org.objectweb.asm.MethodVisitor;
-import org.objectweb.asm.Type;
-
-/**
- * Generates a class that contain all bytecode instruction types (except JSR and
- * RET). Also covers access flags, signatures, and unicode characters.
- *
- * @author Eric Bruneton
- */
-public class Insns extends Generator {
-
- @Override
- public void generate(final String dir) throws IOException {
- generate(dir, "pkg/Insns.class", dump());
- }
-
- public byte[] dump() {
- ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
- FieldVisitor fv;
- MethodVisitor mv;
-
- cw.visit(
- V1_5,
- ACC_PUBLIC + ACC_SUPER,
- "pkg/Insns",
- "<E:Ljava/lang/Object;F:Ljava/lang/Exception;>Ljava/util/ArrayList<Ljava/lang/String;>;LInterface<TE;>;",
- "java/util/ArrayList", new String[] { "Interface" });
-
- fv = cw.visitField(ACC_PRIVATE + ACC_FINAL, "z", "Z", null,
- new Integer(1));
- fv.visitEnd();
-
- fv = cw.visitField(ACC_PROTECTED, "b", "B", null, null);
- fv.visitEnd();
-
- fv = cw.visitField(ACC_PUBLIC, "c", "C", null, null);
- fv.visitEnd();
-
- fv = cw.visitField(ACC_STATIC, "s", "S", null, null);
- fv.visitEnd();
-
- fv = cw.visitField(ACC_PRIVATE + ACC_TRANSIENT, "i", "I", null, null);
- fv.visitEnd();
-
- fv = cw.visitField(ACC_PRIVATE + ACC_VOLATILE, "l", "J", null, null);
- fv.visitEnd();
-
- fv = cw.visitField(0, "f", "F", null, null);
- fv.visitEnd();
-
- fv = cw.visitField(0, "d", "D", null, null);
- fv.visitEnd();
-
- fv = cw.visitField(0, "str", "Ljava/lang/String;", null, "");
- fv.visitEnd();
-
- fv = cw.visitField(0, "e", "Ljava/lang/Object;", "TE;", null);
- fv.visitEnd();
-
- mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
- mv.visitCode();
- mv.visitVarInsn(ALOAD, 0);
- mv.visitMethodInsn(INVOKESPECIAL, "java/util/ArrayList", "<init>",
- "()V");
- mv.visitInsn(RETURN);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
-
- mv = cw.visitMethod(ACC_PUBLIC + ACC_SYNCHRONIZED, "m",
- "(ZBCSIFJDLjava/lang/Object;)Ljava/lang/Object;",
- "(ZBCSIFJDTE;)TE;", null);
- mv.visitCode();
- mv.visitInsn(ACONST_NULL);
- mv.visitInsn(ARETURN);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
-
- // instruction types
- constInsns(cw);
- varInsns(cw);
- arrayInsns(cw);
- stackInsns(cw);
- mathInsns(cw);
- castInsns(cw);
- jumpInsns(cw);
- returnInsns(cw);
- fieldInsns(cw);
- methodInsns(cw);
- monitorInsns(cw);
-
- // various method types not covered by other test cases
- varargMethod(cw);
- bridgeMethod(cw);
- nativeMethod(cw);
- clinitMethod(cw);
-
- cw.visitEnd();
-
- return cw.toByteArray();
- }
-
- private void constInsns(final ClassWriter cw) {
- MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "constInsns", "()V",
- null, null);
- mv.visitInsn(NOP);
- mv.visitInsn(ACONST_NULL);
- mv.visitInsn(ICONST_M1);
- mv.visitInsn(ICONST_0);
- mv.visitInsn(ICONST_1);
- mv.visitInsn(ICONST_2);
- mv.visitInsn(ICONST_3);
- mv.visitInsn(ICONST_4);
- mv.visitInsn(ICONST_5);
- mv.visitInsn(LCONST_0);
- mv.visitInsn(LCONST_1);
- mv.visitInsn(FCONST_0);
- mv.visitInsn(FCONST_1);
- mv.visitInsn(FCONST_2);
- mv.visitInsn(DCONST_0);
- mv.visitInsn(DCONST_1);
- mv.visitIntInsn(BIPUSH, 16);
- mv.visitIntInsn(SIPUSH, 256);
- mv.visitLdcInsn(new Integer(65536));
- mv.visitLdcInsn(new Long(128L));
- mv.visitLdcInsn(new Float("128.0"));
- mv.visitLdcInsn(new Double("128.0"));
- mv.visitLdcInsn("\n\r\u0009\"\\");
- mv.visitLdcInsn("\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u1111\u0111\u0011\u0001");
- mv.visitLdcInsn(Type.getType("Ljava/lang/Object;"));
- mv.visitInsn(RETURN);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
- }
-
- private void varInsns(final ClassWriter cw) {
- MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "varInsns", "(IJFDD)V",
- null, null);
- mv.visitVarInsn(ILOAD, 1);
- mv.visitVarInsn(IINC, 1);
- mv.visitVarInsn(ISTORE, 1);
- mv.visitVarInsn(LLOAD, 2);
- mv.visitVarInsn(LSTORE, 2);
- mv.visitVarInsn(FLOAD, 4);
- mv.visitVarInsn(FSTORE, 4);
- mv.visitVarInsn(DLOAD, 5);
- mv.visitVarInsn(DSTORE, 5);
- mv.visitVarInsn(ALOAD, 0);
- mv.visitVarInsn(ASTORE, 0);
- mv.visitInsn(ICONST_0);
- mv.visitVarInsn(ISTORE, 3);
- mv.visitInsn(LCONST_0);
- mv.visitVarInsn(LSTORE, 6);
- mv.visitInsn(RETURN);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
- }
-
- private void arrayInsns(final ClassWriter cw) {
- MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "arrayInsns", "()V",
- null, null);
- // boolean arrays
- mv.visitInsn(ICONST_1);
- mv.visitIntInsn(NEWARRAY, T_BOOLEAN);
- mv.visitInsn(DUP);
- mv.visitInsn(ICONST_0);
- mv.visitInsn(ICONST_0);
- mv.visitInsn(BASTORE);
- mv.visitInsn(ICONST_0);
- mv.visitInsn(BALOAD);
- // byte arrays
- mv.visitInsn(ICONST_1);
- mv.visitIntInsn(NEWARRAY, T_BYTE);
- mv.visitInsn(DUP);
- mv.visitInsn(ICONST_0);
- mv.visitInsn(ICONST_0);
- mv.visitInsn(BASTORE);
- mv.visitInsn(ICONST_0);
- mv.visitInsn(BALOAD);
- // char arrays
- mv.visitInsn(ICONST_1);
- mv.visitIntInsn(NEWARRAY, T_CHAR);
- mv.visitInsn(DUP);
- mv.visitInsn(ICONST_0);
- mv.visitInsn(ICONST_0);
- mv.visitInsn(CASTORE);
- mv.visitInsn(ICONST_0);
- mv.visitInsn(CALOAD);
- // short arrays
- mv.visitInsn(ICONST_1);
- mv.visitIntInsn(NEWARRAY, T_SHORT);
- mv.visitInsn(DUP);
- mv.visitInsn(ICONST_0);
- mv.visitInsn(ICONST_0);
- mv.visitInsn(SASTORE);
- mv.visitInsn(ICONST_0);
- mv.visitInsn(SALOAD);
- // int arrays
- mv.visitInsn(ICONST_1);
- mv.visitIntInsn(NEWARRAY, T_INT);
- mv.visitInsn(DUP);
- mv.visitInsn(ICONST_0);
- mv.visitInsn(ICONST_0);
- mv.visitInsn(IASTORE);
- mv.visitInsn(ICONST_0);
- mv.visitInsn(IALOAD);
- // long arrays
- mv.visitInsn(ICONST_1);
- mv.visitIntInsn(NEWARRAY, T_LONG);
- mv.visitInsn(DUP);
- mv.visitInsn(ICONST_0);
- mv.visitInsn(LCONST_0);
- mv.visitInsn(LASTORE);
- mv.visitInsn(ICONST_0);
- mv.visitInsn(LALOAD);
- // float arrays
- mv.visitInsn(ICONST_1);
- mv.visitIntInsn(NEWARRAY, T_FLOAT);
- mv.visitInsn(DUP);
- mv.visitInsn(ICONST_0);
- mv.visitInsn(FCONST_0);
- mv.visitInsn(FASTORE);
- mv.visitInsn(ICONST_0);
- mv.visitInsn(FALOAD);
- // double arrays
- mv.visitInsn(ICONST_1);
- mv.visitIntInsn(NEWARRAY, T_DOUBLE);
- mv.visitInsn(DUP);
- mv.visitInsn(ICONST_0);
- mv.visitInsn(DCONST_0);
- mv.visitInsn(DASTORE);
- mv.visitInsn(ICONST_0);
- mv.visitInsn(DALOAD);
- // object arrays
- mv.visitInsn(ICONST_1);
- mv.visitTypeInsn(ANEWARRAY, "java/lang/Object");
- mv.visitInsn(DUP);
- mv.visitInsn(ICONST_0);
- mv.visitInsn(ACONST_NULL);
- mv.visitInsn(AASTORE);
- mv.visitInsn(ICONST_0);
- mv.visitInsn(AALOAD);
- // multi dimensional arrays
- mv.visitInsn(ICONST_1);
- mv.visitTypeInsn(ANEWARRAY, "[I");
- mv.visitInsn(ICONST_1);
- mv.visitInsn(ICONST_2);
- mv.visitInsn(ICONST_3);
- mv.visitMultiANewArrayInsn("[[[I", 3);
- // array length
- mv.visitInsn(ARRAYLENGTH);
- // end method
- mv.visitInsn(RETURN);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
- }
-
- private void stackInsns(final ClassWriter cw) {
- MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "stackInsns", "()V",
- null, null);
- // pop
- mv.visitInsn(ICONST_0);
- mv.visitInsn(POP);
- // pop2 (two variants)
- mv.visitInsn(ICONST_0);
- mv.visitInsn(ICONST_0);
- mv.visitInsn(POP2);
- mv.visitInsn(LCONST_0);
- mv.visitInsn(POP2);
- // dup
- mv.visitInsn(ICONST_0);
- mv.visitInsn(DUP);
- // dup_x1
- mv.visitInsn(ICONST_0);
- mv.visitInsn(ICONST_0);
- mv.visitInsn(DUP_X1);
- // dup_x2 (two variants)
- mv.visitInsn(ICONST_0);
- mv.visitInsn(ICONST_0);
- mv.visitInsn(ICONST_0);
- mv.visitInsn(DUP_X2);
- mv.visitInsn(LCONST_0);
- mv.visitInsn(ICONST_0);
- mv.visitInsn(DUP_X2);
- // dup2 (two variants)
- mv.visitInsn(ICONST_0);
- mv.visitInsn(ICONST_0);
- mv.visitInsn(DUP2);
- mv.visitInsn(LCONST_0);
- mv.visitInsn(DUP2);
- // dup2_x1 (two variants)
- mv.visitInsn(ICONST_0);
- mv.visitInsn(ICONST_0);
- mv.visitInsn(ICONST_0);
- mv.visitInsn(DUP2_X1);
- mv.visitInsn(ICONST_0);
- mv.visitInsn(LCONST_0);
- mv.visitInsn(DUP2_X1);
- // dup2_x2 (four variants)
- mv.visitInsn(ICONST_0);
- mv.visitInsn(ICONST_0);
- mv.visitInsn(ICONST_0);
- mv.visitInsn(ICONST_0);
- mv.visitInsn(DUP2_X2);
- mv.visitInsn(LCONST_0);
- mv.visitInsn(ICONST_0);
- mv.visitInsn(ICONST_0);
- mv.visitInsn(DUP2_X2);
- mv.visitInsn(ICONST_0);
- mv.visitInsn(ICONST_0);
- mv.visitInsn(LCONST_0);
- mv.visitInsn(DUP2_X2);
- mv.visitInsn(LCONST_0);
- mv.visitInsn(LCONST_0);
- mv.visitInsn(DUP2_X2);
- // swap
- mv.visitInsn(ICONST_0);
- mv.visitInsn(ICONST_1);
- mv.visitInsn(SWAP);
- // end method
- mv.visitInsn(RETURN);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
- }
-
- private void mathInsns(final ClassWriter cw) {
- MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "mathInsns", "(IJFD)V",
- null, null);
- // int math insns
- for (int i = 0; i < 12; ++i) {
- mv.visitVarInsn(ILOAD, 1);
- }
- mv.visitInsn(IADD);
- mv.visitInsn(ISUB);
- mv.visitInsn(IMUL);
- mv.visitInsn(IDIV);
- mv.visitInsn(IREM);
- mv.visitInsn(INEG);
- mv.visitInsn(ISHL);
- mv.visitInsn(ISHR);
- mv.visitInsn(IUSHR);
- mv.visitInsn(IAND);
- mv.visitInsn(IOR);
- mv.visitInsn(IXOR);
- // long math insns
- for (int i = 0; i < 9; ++i) {
- mv.visitVarInsn(LLOAD, 2);
- }
- mv.visitInsn(LADD);
- mv.visitInsn(LSUB);
- mv.visitInsn(LMUL);
- mv.visitInsn(LDIV);
- mv.visitInsn(LREM);
- mv.visitInsn(LNEG);
- mv.visitVarInsn(ILOAD, 1);
- mv.visitInsn(LSHL);
- mv.visitVarInsn(ILOAD, 1);
- mv.visitInsn(LSHR);
- mv.visitVarInsn(ILOAD, 1);
- mv.visitInsn(LUSHR);
- mv.visitInsn(LAND);
- mv.visitInsn(LOR);
- mv.visitInsn(LXOR);
- // float math insns
- for (int i = 0; i < 6; ++i) {
- mv.visitVarInsn(FLOAD, 4);
- }
- mv.visitInsn(FADD);
- mv.visitInsn(FSUB);
- mv.visitInsn(FMUL);
- mv.visitInsn(FDIV);
- mv.visitInsn(FREM);
- mv.visitInsn(FNEG);
- // double math insns
- for (int i = 0; i < 6; ++i) {
- mv.visitVarInsn(DLOAD, 5);
- }
- mv.visitInsn(DADD);
- mv.visitInsn(DSUB);
- mv.visitInsn(DMUL);
- mv.visitInsn(DDIV);
- mv.visitInsn(DREM);
- mv.visitInsn(DNEG);
- // end method
- mv.visitInsn(RETURN);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
- }
-
- private void castInsns(final ClassWriter cw) {
- MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "castInsns", "(IJFD)V",
- null, null);
- // I2x
- mv.visitVarInsn(ILOAD, 1);
- mv.visitInsn(I2L);
- mv.visitVarInsn(LSTORE, 2);
- mv.visitVarInsn(ILOAD, 1);
- mv.visitInsn(I2F);
- mv.visitVarInsn(FSTORE, 4);
- mv.visitVarInsn(ILOAD, 1);
- mv.visitInsn(I2D);
- mv.visitVarInsn(DSTORE, 5);
- // L2x
- mv.visitVarInsn(LLOAD, 2);
- mv.visitInsn(L2I);
- mv.visitVarInsn(ISTORE, 1);
- mv.visitVarInsn(LLOAD, 2);
- mv.visitInsn(L2F);
- mv.visitVarInsn(FSTORE, 4);
- mv.visitVarInsn(LLOAD, 2);
- mv.visitInsn(L2D);
- mv.visitVarInsn(DSTORE, 5);
- // F2x
- mv.visitVarInsn(FLOAD, 4);
- mv.visitInsn(F2I);
- mv.visitVarInsn(ISTORE, 1);
- mv.visitVarInsn(FLOAD, 4);
- mv.visitInsn(F2L);
- mv.visitVarInsn(LSTORE, 2);
- mv.visitVarInsn(FLOAD, 4);
- mv.visitInsn(F2D);
- mv.visitVarInsn(DSTORE, 5);
- // D2x
- mv.visitVarInsn(DLOAD, 5);
- mv.visitInsn(D2I);
- mv.visitVarInsn(ISTORE, 1);
- mv.visitVarInsn(DLOAD, 5);
- mv.visitInsn(D2L);
- mv.visitVarInsn(LSTORE, 2);
- mv.visitVarInsn(DLOAD, 5);
- mv.visitInsn(D2F);
- mv.visitVarInsn(FSTORE, 4);
- // I2B
- mv.visitVarInsn(ALOAD, 0);
- mv.visitVarInsn(ILOAD, 1);
- mv.visitInsn(I2B);
- mv.visitFieldInsn(PUTFIELD, "pkg/Insns", "b", "B");
- // I2C
- mv.visitVarInsn(ALOAD, 0);
- mv.visitVarInsn(ILOAD, 1);
- mv.visitInsn(I2C);
- mv.visitFieldInsn(PUTFIELD, "pkg/Insns", "c", "C");
- // I2S
- mv.visitVarInsn(ILOAD, 1);
- mv.visitInsn(I2S);
- mv.visitFieldInsn(PUTSTATIC, "pkg/Insns", "s", "S");
- // checkcast
- mv.visitInsn(ACONST_NULL);
- mv.visitTypeInsn(CHECKCAST, "java/lang/String");
- mv.visitInsn(ACONST_NULL);
- mv.visitTypeInsn(CHECKCAST, "[[I");
- // instanceof
- mv.visitInsn(ACONST_NULL);
- mv.visitTypeInsn(INSTANCEOF, "java/lang/String");
- // end method
- mv.visitInsn(RETURN);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
- }
-
- private void jumpInsns(final ClassWriter cw) {
- MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "jumpInsns", "(IJFD)V",
- null, null);
- Label l0 = new Label();
- // ifxx
- mv.visitVarInsn(ILOAD, 1);
- mv.visitJumpInsn(IFNE, l0);
- mv.visitVarInsn(ILOAD, 1);
- mv.visitJumpInsn(IFEQ, l0);
- mv.visitVarInsn(ILOAD, 1);
- mv.visitJumpInsn(IFLE, l0);
- mv.visitVarInsn(ILOAD, 1);
- mv.visitJumpInsn(IFGE, l0);
- mv.visitVarInsn(ILOAD, 1);
- mv.visitJumpInsn(IFLT, l0);
- mv.visitVarInsn(ILOAD, 1);
- mv.visitJumpInsn(IFGT, l0);
- // ificmpxx
- mv.visitVarInsn(ILOAD, 1);
- mv.visitVarInsn(ILOAD, 1);
- mv.visitJumpInsn(IF_ICMPNE, l0);
- mv.visitVarInsn(ILOAD, 1);
- mv.visitVarInsn(ILOAD, 1);
- mv.visitJumpInsn(IF_ICMPEQ, l0);
- mv.visitVarInsn(ILOAD, 1);
- mv.visitVarInsn(ILOAD, 1);
- mv.visitJumpInsn(IF_ICMPLE, l0);
- mv.visitVarInsn(ILOAD, 1);
- mv.visitVarInsn(ILOAD, 1);
- mv.visitJumpInsn(IF_ICMPGE, l0);
- mv.visitVarInsn(ILOAD, 1);
- mv.visitVarInsn(ILOAD, 1);
- mv.visitJumpInsn(IF_ICMPLT, l0);
- mv.visitVarInsn(ILOAD, 1);
- mv.visitVarInsn(ILOAD, 1);
- mv.visitJumpInsn(IF_ICMPGT, l0);
- // lcmp
- mv.visitVarInsn(LLOAD, 2);
- mv.visitVarInsn(LLOAD, 2);
- mv.visitInsn(LCMP);
- mv.visitJumpInsn(IFNE, l0);
- // fcmpx
- mv.visitVarInsn(FLOAD, 4);
- mv.visitVarInsn(FLOAD, 4);
- mv.visitInsn(FCMPL);
- mv.visitJumpInsn(IFNE, l0);
- mv.visitVarInsn(FLOAD, 4);
- mv.visitVarInsn(FLOAD, 4);
- mv.visitInsn(FCMPG);
- mv.visitJumpInsn(IFNE, l0);
- // dcmpx
- mv.visitVarInsn(DLOAD, 5);
- mv.visitVarInsn(DLOAD, 5);
- mv.visitInsn(DCMPL);
- mv.visitJumpInsn(IFNE, l0);
- mv.visitVarInsn(DLOAD, 5);
- mv.visitVarInsn(DLOAD, 5);
- mv.visitInsn(DCMPG);
- mv.visitJumpInsn(IFNE, l0);
- // ifacmp
- mv.visitVarInsn(ALOAD, 0);
- mv.visitVarInsn(ALOAD, 0);
- mv.visitJumpInsn(IF_ACMPNE, l0);
- mv.visitVarInsn(ALOAD, 0);
- mv.visitVarInsn(ALOAD, 0);
- mv.visitJumpInsn(IF_ACMPEQ, l0);
- // ifnull
- mv.visitVarInsn(ALOAD, 0);
- mv.visitJumpInsn(IFNULL, l0);
- mv.visitInsn(ICONST_0);
- mv.visitVarInsn(ISTORE, 7);
- mv.visitVarInsn(ALOAD, 0);
- mv.visitJumpInsn(IFNONNULL, l0);
- mv.visitInsn(ICONST_0);
- mv.visitVarInsn(ISTORE, 7);
- mv.visitVarInsn(ALOAD, 0);
- // tableswitch
- Label l1 = new Label();
- Label l2 = new Label();
- Label l3 = new Label();
- mv.visitVarInsn(ILOAD, 1);
- mv.visitTableSwitchInsn(0, 2, l3/* default */, l1, l2, l3);
- mv.visitLabel(l1);
- mv.visitInsn(ICONST_1);
- mv.visitVarInsn(ISTORE, 7);
- mv.visitJumpInsn(GOTO, l3);
- mv.visitLabel(l2);
- mv.visitInsn(ICONST_2);
- mv.visitVarInsn(ISTORE, 7);
- mv.visitJumpInsn(GOTO, l3);
- mv.visitLabel(l3);
- mv.visitVarInsn(ILOAD, 7);
- // lookupswitch
- Label l4 = new Label();
- Label l5 = new Label();
- Label l6 = new Label();
- mv.visitVarInsn(ILOAD, 1);
- mv.visitLookupSwitchInsn(l6, new int[] { 0, 1, 2 }, new Label[] { l4,
- l5, l6 });
- mv.visitLabel(l4);
- mv.visitInsn(ICONST_1);
- mv.visitVarInsn(ISTORE, 7);
- mv.visitJumpInsn(GOTO, l6);
- mv.visitLabel(l5);
- mv.visitInsn(ICONST_2);
- mv.visitVarInsn(ISTORE, 7);
- mv.visitJumpInsn(GOTO, l6);
- mv.visitLabel(l6);
- mv.visitVarInsn(ILOAD, 7);
- // throw
- mv.visitInsn(ACONST_NULL);
- mv.visitInsn(ATHROW);
- // misc instructions to cover code in MethodWriter.resizeInsns
- mv.visitLabel(l0);
- mv.visitInsn(ICONST_1);
- mv.visitInsn(ICONST_2);
- mv.visitMultiANewArrayInsn("[[I", 2);
- mv.visitVarInsn(ALOAD, 0);
- mv.visitMethodInsn(INVOKEINTERFACE, "java/util/List", "size", "()V");
- // end method
- mv.visitInsn(RETURN);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
- }
-
- private void returnInsns(final ClassWriter cw) {
- MethodVisitor mv;
- mv = cw.visitMethod(ACC_STATIC, "ireturnInsn", "()I", null, null);
- mv.visitCode();
- mv.visitInsn(ICONST_0);
- mv.visitInsn(IRETURN);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
- mv = cw.visitMethod(ACC_PRIVATE, "lreturnInsn", "()J", null, null);
- mv.visitCode();
- mv.visitInsn(LCONST_0);
- mv.visitInsn(LRETURN);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
- mv = cw.visitMethod(0, "freturnInsn", "()F", null, null);
- mv.visitCode();
- mv.visitInsn(FCONST_0);
- mv.visitInsn(FRETURN);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
- mv = cw.visitMethod(0, "dreturnInsn", "()D", null, null);
- mv.visitCode();
- mv.visitInsn(DCONST_0);
- mv.visitInsn(DRETURN);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
- }
-
- private void fieldInsns(final ClassWriter cw) {
- MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "fieldInsns", "()V",
- null, null);
- mv.visitFieldInsn(GETSTATIC, "pkg/Insns", "s", "S");
- mv.visitFieldInsn(PUTSTATIC, "pkg/Insns", "s", "S");
- mv.visitVarInsn(ALOAD, 0);
- mv.visitVarInsn(ALOAD, 0);
- mv.visitFieldInsn(GETFIELD, "pkg/Insns", "i", "I");
- mv.visitFieldInsn(PUTFIELD, "pkg/Insns", "i", "I");
- mv.visitVarInsn(ALOAD, 0);
- mv.visitVarInsn(ALOAD, 0);
- mv.visitFieldInsn(GETFIELD, "pkg/Insns", "l", "J");
- mv.visitFieldInsn(PUTFIELD, "pkg/Insns", "l", "J");
- mv.visitInsn(RETURN);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
- }
-
- private void methodInsns(final ClassWriter cw) {
- MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "methodInsns", "()V",
- null, null);
- // invokstatic
- mv.visitMethodInsn(INVOKESTATIC, "pkg/Insns", "ireturn", "()I");
- // invokespecial
- mv.visitVarInsn(ALOAD, 0);
- mv.visitMethodInsn(INVOKESPECIAL, "pkg/Insns", "lreturn", "()J");
- // invokevirtual
- mv.visitVarInsn(ALOAD, 0);
- mv.visitMethodInsn(INVOKEVIRTUAL, "pkg/Insns", "freturn", "()F");
- // invokeinterface
- mv.visitVarInsn(ALOAD, 0);
- mv.visitMethodInsn(INVOKEINTERFACE, "java/util/List", "size", "()I");
- mv.visitInsn(RETURN);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
- }
-
- private void monitorInsns(final ClassWriter cw) {
- MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "monitorInsns", "()V",
- null, null);
- mv.visitVarInsn(ALOAD, 0);
- mv.visitInsn(MONITORENTER);
- mv.visitVarInsn(ALOAD, 0);
- mv.visitInsn(MONITOREXIT);
- mv.visitInsn(RETURN);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
- }
-
- private void varargMethod(final ClassWriter cw) {
- MethodVisitor mv = cw.visitMethod(
- ACC_PUBLIC + ACC_VARARGS + ACC_STRICT, "varargMethod",
- "([Ljava/lang/Object;)V", "([Ljava/lang/Object;)V^TF;",
- new String[] { "java/lang/Exception" });
- mv.visitCode();
- mv.visitInsn(RETURN);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
- }
-
- private void bridgeMethod(final ClassWriter cw) {
- MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "get",
- "(I)Ljava/lang/String;", null, null);
- mv.visitCode();
- mv.visitVarInsn(ALOAD, 0);
- mv.visitVarInsn(ILOAD, 1);
- mv.visitMethodInsn(INVOKESPECIAL, "java/util/ArrayList", "get",
- "(I)Ljava/lang/Object;");
- mv.visitTypeInsn(CHECKCAST, "java/lang/String");
- mv.visitInsn(ARETURN);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
-
- mv = cw.visitMethod(ACC_PUBLIC + ACC_BRIDGE + ACC_SYNTHETIC, "get",
- "(I)Ljava/lang/Object;", "(I)TE;", null);
- mv.visitCode();
- mv.visitVarInsn(ALOAD, 0);
- mv.visitVarInsn(ILOAD, 1);
- mv.visitMethodInsn(INVOKEVIRTUAL, "pkg/Insns", "get",
- "(I)Ljava/lang/String;");
- mv.visitInsn(ARETURN);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
- }
-
- private void nativeMethod(final ClassWriter cw) {
- MethodVisitor mv = cw.visitMethod(ACC_PRIVATE + ACC_NATIVE,
- "nativeMethod", "()V", null, null);
- mv.visitEnd();
- }
-
- private void clinitMethod(final ClassWriter cw) {
- MethodVisitor mv = cw.visitMethod(ACC_STATIC, "<clinit>", "()V", null,
- null);
- mv.visitCode();
- mv.visitInsn(ICONST_1);
- mv.visitFieldInsn(PUTSTATIC, "pkg/Insns", "s", "S");
- mv.visitInsn(RETURN);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/test/cases/Interface.java b/asm4/test/conform/org/objectweb/asm/test/cases/Interface.java
deleted file mode 100644
index d44de36..0000000
--- a/asm4/test/conform/org/objectweb/asm/test/cases/Interface.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.test.cases;
-
-import java.io.IOException;
-
-import org.objectweb.asm.ClassWriter;
-import org.objectweb.asm.MethodVisitor;
-
-/**
- * Generates an interface class. Also covers signatures, default package and non
- * null minor class version number.
- *
- * @author Eric Bruneton
- */
-public class Interface extends Generator {
-
- @Override
- public void generate(final String dir) throws IOException {
- generate(dir, "Interface.class", dump());
- }
-
- public byte[] dump() {
- ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
-
- cw.visit(1 << 16 | V1_5, ACC_PUBLIC + ACC_ABSTRACT + ACC_INTERFACE,
- "Interface", "<E:Ljava/lang/Object;>Ljava/lang/Object;",
- "java/lang/Object", null);
-
- MethodVisitor mv = cw.visitMethod(ACC_PUBLIC + ACC_ABSTRACT, "m",
- "(ZBCSIFJDLjava/lang/Object;)Ljava/lang/Object;",
- "(ZBCSIFJDTE;)TE;", null);
- mv.visitEnd();
-
- cw.visitEnd();
-
- return cw.toByteArray();
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/test/cases/Invalid.java b/asm4/test/conform/org/objectweb/asm/test/cases/Invalid.java
deleted file mode 100644
index 7f32cea..0000000
--- a/asm4/test/conform/org/objectweb/asm/test/cases/Invalid.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.test.cases;
-
-import java.io.IOException;
-
-import org.objectweb.asm.ClassWriter;
-import org.objectweb.asm.Label;
-import org.objectweb.asm.MethodVisitor;
-
-/**
- * Generates a class with missing stack frames (to check that the new JDK7
- * verifier is triggered, without fallback to the old verifier).
- *
- * @author Eric Bruneton
- */
-public class Invalid extends Generator {
-
- @Override
- public void generate(final String dir) throws IOException {
- generate(dir, "invalid/Invalid.class", dump());
- }
-
- public byte[] dump() {
- ClassWriter cw = new ClassWriter(0);
- MethodVisitor mv;
-
- cw.visit(V1_7, ACC_PUBLIC, "invalid/Invalid", null, "java/lang/Object",
- null);
-
- mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
- mv.visitCode();
- mv.visitVarInsn(ALOAD, 0);
- mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V");
- mv.visitVarInsn(ALOAD, 0);
- Label ifnull = new Label();
- Label endif = new Label();
- mv.visitJumpInsn(IFNULL, ifnull);
- mv.visitInsn(ICONST_0);
- mv.visitJumpInsn(GOTO, endif);
- mv.visitLabel(ifnull);
- mv.visitInsn(FCONST_0);
- mv.visitLabel(endif);
- mv.visitVarInsn(ISTORE, 0);
- mv.visitInsn(RETURN);
- mv.visitMaxs(1, 1);
- mv.visitEnd();
-
- cw.visitEnd();
-
- return cw.toByteArray();
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/test/cases/InvokeDynamic.java b/asm4/test/conform/org/objectweb/asm/test/cases/InvokeDynamic.java
deleted file mode 100644
index 39ced1f..0000000
--- a/asm4/test/conform/org/objectweb/asm/test/cases/InvokeDynamic.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.test.cases;
-
-import java.io.IOException;
-
-import org.objectweb.asm.ClassWriter;
-import org.objectweb.asm.Handle;
-import org.objectweb.asm.MethodVisitor;
-import org.objectweb.asm.Type;
-
-/**
- * Generates a class using the invokedynamic instruction. Also covers method
- * types and method handles.
- *
- * @author Eric Bruneton
- */
-public class InvokeDynamic extends Generator {
-
- @Override
- public void generate(final String dir) throws IOException {
- generate(dir, "pkg/InvokeDynamic.class", dump());
- }
-
- public byte[] dump() {
- ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
- MethodVisitor mv;
-
- cw.visit(V1_7, ACC_PUBLIC, "pkg/InvokeDynamic", null,
- "java/lang/Object", null);
-
- mv = cw.visitMethod(ACC_PUBLIC, "foo", "()V", null, null);
- mv.visitCode();
- Handle h = new Handle(
- H_INVOKESTATIC,
- "C",
- "bsm1",
- "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;");
- mv.visitInvokeDynamicInsn("bar1", "()V", h, Type.getType("()V"));
- h = new Handle(
- H_INVOKESTATIC,
- "C",
- "bsm2",
- "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;)Ljava/lang/invoke/CallSite;");
- mv.visitInvokeDynamicInsn("bar2", "()V", h, Type.getType("()V"), h);
- mv.visitInsn(RETURN);
- mv.visitEnd();
-
- cw.visitEnd();
- return cw.toByteArray();
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/test/cases/JSR.java b/asm4/test/conform/org/objectweb/asm/test/cases/JSR.java
deleted file mode 100644
index 6bac970..0000000
--- a/asm4/test/conform/org/objectweb/asm/test/cases/JSR.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.test.cases;
-
-import java.io.IOException;
-
-import org.objectweb.asm.ClassWriter;
-import org.objectweb.asm.Label;
-import org.objectweb.asm.MethodVisitor;
-
-/**
- * Generates classes with JSR/RET instructions. Covers forward and backward JSR
- * and JSR_W instructions. Also covers the wide form of IFNULL instruction, and
- * the V1_1 class version (these jump instructions are not directly generated in
- * their 'wide' form, but are transformed to this form by the method resizing
- * test).
- *
- * @author Eric Bruneton
- *
- */
-public class JSR extends Generator {
-
- @Override
- public void generate(final String dir) throws IOException {
- generate(dir, "pkg/JSR1.class", dumpForwardJSR());
- generate(dir, "pkg/JSR2.class", dumpBackwardJSR());
- }
-
- public byte[] dumpForwardJSR() {
- ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
- MethodVisitor mv;
-
- cw.visit(V1_1, ACC_PUBLIC, "pkg/JSR1", null, "java/lang/Object", null);
-
- mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
- mv.visitCode();
- mv.visitVarInsn(ALOAD, 0);
- mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V");
- mv.visitInsn(RETURN);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
-
- mv = cw.visitMethod(ACC_PUBLIC, "forwardJSR", "([I)V", null, null);
- mv.visitCode();
- Label l0 = new Label();
- Label l1 = new Label();
- Label l2 = new Label();
- Label l3 = new Label();
- Label l4 = new Label();
- Label l5 = new Label();
- mv.visitTryCatchBlock(l0, l1, l2, null);
- mv.visitTryCatchBlock(l2, l3, l2, null);
- mv.visitLabel(l0);
- mv.visitVarInsn(ALOAD, 0);
- mv.visitVarInsn(ALOAD, 1);
- mv.visitMethodInsn(INVOKEVIRTUAL, "pkg/JSR1", "forwardJSR", "([I)V");
- mv.visitJumpInsn(JSR, l4); // forward JSR, will give forward JSR_W
-
- // many NOPs will be introduced here by the method resizing test
-
- mv.visitLabel(l1);
- mv.visitJumpInsn(GOTO, l5);
- mv.visitLabel(l2);
- mv.visitVarInsn(ASTORE, 2);
- mv.visitJumpInsn(JSR, l4);
- mv.visitLabel(l3);
- mv.visitVarInsn(ALOAD, 2);
- mv.visitInsn(ATHROW);
- mv.visitLabel(l4);
- mv.visitVarInsn(ASTORE, 3);
- mv.visitInsn(DCONST_0);
- mv.visitVarInsn(DSTORE, 4);
- mv.visitVarInsn(RET, 3);
- mv.visitLabel(l5);
- mv.visitInsn(RETURN);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
-
- cw.visitEnd();
-
- return cw.toByteArray();
- }
-
- public byte[] dumpBackwardJSR() {
- ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
- MethodVisitor mv;
-
- cw.visit(V1_1, ACC_PUBLIC, "pkg/JSR2", null, "java/lang/Object", null);
-
- mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
- mv.visitCode();
- mv.visitVarInsn(ALOAD, 0);
- mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V");
- mv.visitInsn(RETURN);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
-
- mv = cw.visitMethod(ACC_PUBLIC, "backwardJSR", "([I)V", null, null);
- mv.visitCode();
- Label l0 = new Label();
- Label l1 = new Label();
- Label l2 = new Label();
- Label l3 = new Label();
- Label l4 = new Label();
- Label l5 = new Label();
- Label l6 = new Label();
- mv.visitTryCatchBlock(l0, l1, l2, null);
- mv.visitTryCatchBlock(l2, l3, l2, null);
- mv.visitInsn(ICONST_0);
- mv.visitVarInsn(ISTORE, 4);
- mv.visitJumpInsn(GOTO, l0);
- mv.visitLabel(l4);
- mv.visitVarInsn(ASTORE, 3);
- mv.visitIincInsn(4, 1);
- mv.visitVarInsn(RET, 3);
-
- /* extra instructions only used to trigger method resizing */
- mv.visitLabel(l0);
- mv.visitInsn(ACONST_NULL);
- mv.visitJumpInsn(IFNULL, l6); // will give wide IFNULL
- // many NOPs will be introduced here by the method resizing test
- mv.visitJumpInsn(GOTO, l6);
- mv.visitLabel(l6);
-
- mv.visitJumpInsn(JSR, l4); // backward JSR, will give JSR_W
- mv.visitLabel(l1);
- mv.visitJumpInsn(GOTO, l5);
- mv.visitLabel(l2);
- mv.visitVarInsn(ASTORE, 2);
- mv.visitJumpInsn(JSR, l4);
- mv.visitLabel(l3);
- mv.visitVarInsn(ALOAD, 2);
- mv.visitInsn(ATHROW);
- mv.visitLabel(l5);
- mv.visitInsn(RETURN);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
-
- cw.visitEnd();
-
- return cw.toByteArray();
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/test/cases/Outer.java b/asm4/test/conform/org/objectweb/asm/test/cases/Outer.java
deleted file mode 100644
index 2d1437f..0000000
--- a/asm4/test/conform/org/objectweb/asm/test/cases/Outer.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.test.cases;
-
-import java.io.IOException;
-
-import org.objectweb.asm.ClassWriter;
-import org.objectweb.asm.FieldVisitor;
-import org.objectweb.asm.MethodVisitor;
-
-/**
- * Generates a class with two inner classes. Covers all features used by inner
- * classes (visitInner, visitOuter, synthetic members, etc). Also covers the
- * V1_4 class version and the DEPRECATED access flag.
- *
- * @author Eric Bruneton
- */
-public class Outer extends Generator {
-
- @Override
- public void generate(final String dir) throws IOException {
- generate(dir, "pkg/Outer.class", dump());
- generate(dir, "pkg/Outer$1.class", dump1());
- generate(dir, "pkg/Outer$Inner.class", dumpInner());
- }
-
- public byte[] dump() {
- ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
- FieldVisitor fv;
- MethodVisitor mv;
-
- cw.visit(V1_4, ACC_PUBLIC + ACC_SUPER + ACC_DEPRECATED, "pkg/Outer",
- null, "java/lang/Object", null);
-
- cw.visitInnerClass("pkg/Outer$Inner", "pkg/Outer", "C", 0);
- cw.visitInnerClass("pkg/Outer$1", null, null, 0);
-
- fv = cw.visitField(ACC_PRIVATE + ACC_DEPRECATED, "i", "I", null, null);
- fv.visitEnd();
-
- mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
- mv.visitCode();
- mv.visitVarInsn(ALOAD, 0);
- mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V");
- mv.visitInsn(RETURN);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
-
- mv = cw.visitMethod(ACC_DEPRECATED, "m", "()V", null, null);
- mv.visitCode();
- mv.visitTypeInsn(NEW, "pkg/Outer$1");
- mv.visitInsn(DUP);
- mv.visitVarInsn(ALOAD, 0);
- mv.visitMethodInsn(INVOKESPECIAL, "pkg/Outer$1", "<init>",
- "(Lpkg/Outer;)V");
- mv.visitInsn(POP);
- mv.visitInsn(RETURN);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
-
- mv = cw.visitMethod(ACC_STATIC + ACC_SYNTHETIC, "access$000",
- "(Lpkg/Outer;)I", null, null);
- mv.visitCode();
- mv.visitVarInsn(ALOAD, 0);
- mv.visitFieldInsn(GETFIELD, "pkg/Outer", "i", "I");
- mv.visitInsn(IRETURN);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
-
- cw.visitEnd();
-
- return cw.toByteArray();
- }
-
- public static byte[] dump1() {
- ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
- FieldVisitor fv;
- MethodVisitor mv;
-
- cw.visit(V1_4, ACC_SUPER, "pkg/Outer$1", null, "pkg/Outer", null);
-
- cw.visitOuterClass("pkg/Outer", "m", "()V");
- cw.visitInnerClass("pkg/Outer$1", null, null, 0);
-
- fv = cw.visitField(ACC_FINAL + ACC_SYNTHETIC, "this$0", "Lpkg/Outer;",
- null, null);
- fv.visitEnd();
-
- mv = cw.visitMethod(0, "<init>", "(Lpkg/Outer;)V", null, null);
- mv.visitCode();
- mv.visitVarInsn(ALOAD, 0);
- mv.visitVarInsn(ALOAD, 1);
- mv.visitFieldInsn(PUTFIELD, "pkg/Outer$1", "this$0", "Lpkg/Outer;");
- mv.visitVarInsn(ALOAD, 0);
- mv.visitMethodInsn(INVOKESPECIAL, "pkg/Outer", "<init>", "()V");
- mv.visitInsn(RETURN);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
-
- mv = cw.visitMethod(ACC_PUBLIC, "toString", "()Ljava/lang/String;",
- null, null);
- mv.visitCode();
- mv.visitTypeInsn(NEW, "java/lang/StringBuilder");
- mv.visitInsn(DUP);
- mv.visitMethodInsn(INVOKESPECIAL, "java/lang/StringBuilder", "<init>",
- "()V");
- mv.visitVarInsn(ALOAD, 0);
- mv.visitFieldInsn(GETFIELD, "pkg/Outer$1", "this$0", "Lpkg/Outer;");
- mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append",
- "(Ljava/lang/Object;)Ljava/lang/StringBuilder;");
- mv.visitLdcInsn(" ");
- mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append",
- "(Ljava/lang/String;)Ljava/lang/StringBuilder;");
- mv.visitVarInsn(ALOAD, 0);
- mv.visitFieldInsn(GETFIELD, "pkg/Outer$1", "this$0", "Lpkg/Outer;");
- mv.visitMethodInsn(INVOKESTATIC, "pkg/Outer", "access$000",
- "(Lpkg/Outer;)I");
- mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append",
- "(I)Ljava/lang/StringBuilder;");
- mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder",
- "toString", "()Ljava/lang/String;");
- mv.visitInsn(ARETURN);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
-
- cw.visitEnd();
-
- return cw.toByteArray();
- }
-
- public static byte[] dumpInner() {
- ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
- FieldVisitor fv;
- MethodVisitor mv;
-
- cw.visit(V1_4, ACC_SUPER, "pkg/Outer$Inner", null, "java/lang/Object",
- null);
-
- cw.visitInnerClass("pkg/Outer$Inner", "pkg/Outer", "C", 0);
-
- fv = cw.visitField(ACC_FINAL + ACC_SYNTHETIC, "this$0", "Lpkg/Outer;",
- null, null);
- fv.visitEnd();
-
- mv = cw.visitMethod(0, "<init>", "(Lpkg/Outer;)V", null, null);
- mv.visitCode();
- mv.visitVarInsn(ALOAD, 0);
- mv.visitVarInsn(ALOAD, 1);
- mv.visitFieldInsn(PUTFIELD, "pkg/Outer$Inner", "this$0", "Lpkg/Outer;");
- mv.visitVarInsn(ALOAD, 0);
- mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V");
- mv.visitInsn(RETURN);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
-
- cw.visitEnd();
-
- return cw.toByteArray();
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/test/cases/Wide.java b/asm4/test/conform/org/objectweb/asm/test/cases/Wide.java
deleted file mode 100644
index 1fb0b91..0000000
--- a/asm4/test/conform/org/objectweb/asm/test/cases/Wide.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.test.cases;
-
-import java.io.IOException;
-
-import org.objectweb.asm.ClassWriter;
-import org.objectweb.asm.Label;
-import org.objectweb.asm.MethodVisitor;
-
-/**
- * Generates a class which uses a lot of locals and constant pool values. Covers
- * the 'wide' form of instructions that have one (xLOAD and xSTORE, LDC, IINC,
- * GOTO and IF instructions - these jump instructions are not directly generated
- * in their 'wide' form, but are transformed to this form by the method resizing
- * test). Also covers the V1_2 class version.
- *
- * @author Eric Bruneton
- */
-public class Wide extends Generator {
-
- @Override
- public void generate(final String dir) throws IOException {
- generate(dir, "pkg/Wide.class", dump());
- }
-
- public byte[] dump() {
- ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
- MethodVisitor mv;
-
- cw.visit(V1_2, ACC_PUBLIC, "pkg/Wide", null, "java/lang/Object", null);
-
- mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
- mv.visitCode();
- mv.visitVarInsn(ALOAD, 0);
- mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V");
- for (int i = 0; i < 256; ++i) {
- mv.visitLdcInsn(Integer.toString(i)); // wide form
- mv.visitInsn(POP);
- }
- mv.visitInsn(RETURN);
- mv.visitMaxs(0, 0);
- mv.visitEnd();
-
- mv = cw.visitMethod(ACC_PUBLIC, "wideLocals", "(I)I", null, null);
- mv.visitCode();
- Label l0 = new Label();
- Label l1 = new Label();
- mv.visitJumpInsn(GOTO, l1); // will give GOTO_W
-
- mv.visitLabel(l0);
- mv.visitIincInsn(300, 1); // covers 'update maxlocals' in MethodWriter
- mv.visitVarInsn(ILOAD, 300); // will give wide form
- mv.visitJumpInsn(IFEQ, l1); // will give long forward jump
-
- // many NOPs will be introduced here by the method resizing test
-
- mv.visitVarInsn(ILOAD, 300); // will give wide form
- mv.visitInsn(IRETURN);
-
- mv.visitLabel(l1);
- for (int i = 1; i < 300; ++i) {
- mv.visitVarInsn(ILOAD, i);
- if (i <= 5) {
- mv.visitInsn(ICONST_0 + i);
- } else if (i <= Byte.MAX_VALUE) {
- mv.visitIntInsn(BIPUSH, i);
- } else {
- mv.visitIntInsn(SIPUSH, i);
- }
- mv.visitInsn(IADD);
- mv.visitVarInsn(ISTORE, i + 1);
- }
- mv.visitInsn(ICONST_0);
- mv.visitJumpInsn(IFEQ, l0); // will give long backward jump
- mv.visitJumpInsn(GOTO, l0); // will give long backward goto
-
- mv.visitMaxs(0, 0);
- mv.visitEnd();
-
- cw.visitEnd();
-
- return cw.toByteArray();
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/tree/ClassNodeTest.java b/asm4/test/conform/org/objectweb/asm/tree/ClassNodeTest.java
deleted file mode 100644
index 3eab6e3..0000000
--- a/asm4/test/conform/org/objectweb/asm/tree/ClassNodeTest.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.tree;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import junit.framework.TestSuite;
-
-import org.objectweb.asm.AbstractTest;
-import org.objectweb.asm.ClassReader;
-import org.objectweb.asm.ClassVisitor;
-import org.objectweb.asm.ClassWriter;
-import org.objectweb.asm.FieldVisitor;
-import org.objectweb.asm.MethodVisitor;
-import org.objectweb.asm.Opcodes;
-
-/**
- * ClassNode tests.
- *
- * @author Eric Bruneton
- */
-public class ClassNodeTest extends AbstractTest {
-
- public static TestSuite suite() throws Exception {
- return new ClassNodeTest().getSuite();
- }
-
- @Override
- public void test() throws Exception {
- ClassReader cr = new ClassReader(is);
- ClassNode cn = new ClassNode();
- cr.accept(cn, 0);
- // clone instructions for testing clone methods
- for (int i = 0; i < cn.methods.size(); ++i) {
- MethodNode mn = cn.methods.get(i);
- Iterator<AbstractInsnNode> it = mn.instructions.iterator();
- Map<LabelNode, LabelNode> m = new HashMap<LabelNode, LabelNode>() {
- @Override
- public LabelNode get(final Object o) {
- return (LabelNode) o;
- }
- };
- while (it.hasNext()) {
- AbstractInsnNode insn = it.next();
- mn.instructions.set(insn, insn.clone(m));
- }
- }
- // test accept with visitors that remove class members
- cn.accept(new ClassVisitor(Opcodes.ASM4) {
- @Override
- public FieldVisitor visitField(int access, String name,
- String desc, String signature, Object value) {
- return null;
- }
-
- @Override
- public MethodVisitor visitMethod(int access, String name,
- String desc, String signature, String[] exceptions) {
- return null;
- }
- });
- ClassWriter cw = new ClassWriter(0);
- cn.accept(cw);
- assertEquals(cr, new ClassReader(cw.toByteArray()));
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/tree/ClassNodeUnitTest.java b/asm4/test/conform/org/objectweb/asm/tree/ClassNodeUnitTest.java
deleted file mode 100644
index 988038b..0000000
--- a/asm4/test/conform/org/objectweb/asm/tree/ClassNodeUnitTest.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.tree;
-
-import junit.framework.TestCase;
-
-import org.objectweb.asm.Handle;
-import org.objectweb.asm.Label;
-import org.objectweb.asm.Opcodes;
-
-/**
- * ClassNode unit tests.
- *
- * @author Eric Bruneton
- */
-public class ClassNodeUnitTest extends TestCase implements Opcodes {
-
- public void testFrameNode() {
- FrameNode fn = new FrameNode(F_SAME, 0, null, 0, null);
- assertEquals(AbstractInsnNode.FRAME, fn.getType());
- }
-
- public void testInsnNode() {
- InsnNode in = new InsnNode(NOP);
- assertEquals(in.getOpcode(), NOP);
- assertEquals(AbstractInsnNode.INSN, in.getType());
- }
-
- public void testIntInsnNode() {
- IntInsnNode iin = new IntInsnNode(BIPUSH, 0);
- iin.setOpcode(SIPUSH);
- assertEquals(SIPUSH, iin.getOpcode());
- assertEquals(AbstractInsnNode.INT_INSN, iin.getType());
- }
-
- public void testVarInsnNode() {
- VarInsnNode vn = new VarInsnNode(ALOAD, 0);
- vn.setOpcode(ASTORE);
- assertEquals(ASTORE, vn.getOpcode());
- assertEquals(AbstractInsnNode.VAR_INSN, vn.getType());
- }
-
- public void testTypeInsnNode() {
- TypeInsnNode tin = new TypeInsnNode(NEW, "java/lang/Object");
- tin.setOpcode(CHECKCAST);
- assertEquals(CHECKCAST, tin.getOpcode());
- assertEquals(AbstractInsnNode.TYPE_INSN, tin.getType());
- }
-
- public void testFieldInsnNode() {
- FieldInsnNode fn = new FieldInsnNode(GETSTATIC, "owner", "name", "I");
- fn.setOpcode(PUTSTATIC);
- assertEquals(PUTSTATIC, fn.getOpcode());
- assertEquals(AbstractInsnNode.FIELD_INSN, fn.getType());
- }
-
- public void testMethodInsnNode() {
- MethodInsnNode mn = new MethodInsnNode(INVOKESTATIC, "owner", "name",
- "I");
- mn.setOpcode(INVOKESPECIAL);
- assertEquals(INVOKESPECIAL, mn.getOpcode());
- assertEquals(AbstractInsnNode.METHOD_INSN, mn.getType());
- }
-
- public void testInvokeDynamicInsnNode() {
- Handle bsm = new Handle(Opcodes.H_INVOKESTATIC, "owner", "name", "()V");
- InvokeDynamicInsnNode mn = new InvokeDynamicInsnNode("name", "()V",
- bsm, new Object[0]);
-
- assertEquals(INVOKEDYNAMIC, mn.getOpcode());
- assertEquals(AbstractInsnNode.INVOKE_DYNAMIC_INSN, mn.getType());
- }
-
- public void testJumpInsnNode() {
- JumpInsnNode jn = new JumpInsnNode(GOTO, new LabelNode());
- jn.setOpcode(IFEQ);
- assertEquals(IFEQ, jn.getOpcode());
- assertEquals(AbstractInsnNode.JUMP_INSN, jn.getType());
- }
-
- public void testLabelNode() {
- LabelNode ln = new LabelNode();
- assertEquals(AbstractInsnNode.LABEL, ln.getType());
- assertTrue(ln.getLabel() != null);
- // dummy assignment to instruct FindBugs that Label.info can
- // reference other objects than LabelNode instances
- ln.getLabel().info = new Object();
- }
-
- public void testIincInsnNode() {
- IincInsnNode iincn = new IincInsnNode(1, 1);
- assertEquals(AbstractInsnNode.IINC_INSN, iincn.getType());
- }
-
- public void testLdcInsnNode() {
- LdcInsnNode ldcn = new LdcInsnNode("s");
- assertEquals(AbstractInsnNode.LDC_INSN, ldcn.getType());
- }
-
- public void testLookupSwitchInsnNode() {
- LookupSwitchInsnNode lsn = new LookupSwitchInsnNode(null, null, null);
- assertEquals(AbstractInsnNode.LOOKUPSWITCH_INSN, lsn.getType());
- }
-
- public void testTableSwitchInsnNode() {
- TableSwitchInsnNode tsn = new TableSwitchInsnNode(0, 1, null,
- (LabelNode[]) null);
- assertEquals(AbstractInsnNode.TABLESWITCH_INSN, tsn.getType());
- }
-
- public void testMultiANewArrayInsnNode() {
- MultiANewArrayInsnNode manan = new MultiANewArrayInsnNode("[[I", 2);
- assertEquals(AbstractInsnNode.MULTIANEWARRAY_INSN, manan.getType());
- }
-
- public void testCloneMethod() {
- MethodNode n = new MethodNode();
- Label l0 = new Label();
- Label l1 = new Label();
- n.visitCode();
- n.visitLabel(l0);
- n.visitInsn(Opcodes.NOP);
- n.visitLabel(l1);
- n.visitEnd();
- MethodNode n1 = new MethodNode();
- n.accept(n1);
- n.accept(n1);
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/tree/InsnListUnitTest.java b/asm4/test/conform/org/objectweb/asm/tree/InsnListUnitTest.java
deleted file mode 100644
index a9f4feb..0000000
--- a/asm4/test/conform/org/objectweb/asm/tree/InsnListUnitTest.java
+++ /dev/null
@@ -1,780 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.tree;
-
-import java.util.ListIterator;
-import java.util.NoSuchElementException;
-
-import junit.framework.TestCase;
-
-import org.objectweb.asm.Label;
-import org.objectweb.asm.MethodVisitor;
-import org.objectweb.asm.Opcodes;
-
-/**
- * InsnList unit tests.
- *
- * @author Eric Bruneton
- * @author Eugene Kuleshov
- */
-public class InsnListUnitTest extends TestCase {
-
- InsnList l1;
-
- InsnList l2;
-
- InsnNode in1;
-
- InsnNode in2;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- l1 = new CheckedInsnList();
- l2 = new CheckedInsnList();
- in1 = new InsnNode(0);
- in2 = new InsnNode(0);
- l2.add(in1);
- l2.add(in2);
- }
-
- protected void assertEquals(final AbstractInsnNode[] expected,
- final AbstractInsnNode[] value) {
- assertEquals(expected.length, value.length);
- for (int i = 0; i < value.length; ++i) {
- assertEquals(expected[i], value[i]);
- }
- }
-
- public void testSize() {
- assertEquals(0, l1.size());
- }
-
- public void testGetFirst() {
- assertEquals(null, l1.getFirst());
- }
-
- public void testGetLast() {
- assertEquals(null, l1.getLast());
- }
-
- public void testInvalidGet() {
- try {
- l1.get(0);
- fail();
- } catch (IndexOutOfBoundsException e) {
- }
- }
-
- public void testContains() {
- assertEquals(false, l1.contains(new InsnNode(0)));
- }
-
- public void testIterator() {
- InsnNode insn = new InsnNode(0);
-
- // iteration
- ListIterator<AbstractInsnNode> it = l2.iterator();
- assertTrue(it.hasNext());
- assertEquals(in1, it.next());
- assertTrue(it.hasNext());
- assertEquals(in2, it.next());
- assertFalse(it.hasNext());
- assertTrue(it.hasPrevious());
- assertEquals(in2, it.previous());
- assertTrue(it.hasPrevious());
- assertEquals(in1, it.previous());
- assertFalse(it.hasPrevious());
-
- l2.add(insn);
-
- // remove()
- it = l2.iterator();
- assertTrue(it.hasNext());
- assertEquals(in1, it.next());
- assertTrue(it.hasNext());
- assertEquals(in2, it.next());
- assertTrue(it.hasNext());
- it.remove(); // remove in2
- assertTrue(it.hasNext());
- assertEquals(insn, it.next());
- assertFalse(it.hasNext());
- assertTrue(it.hasPrevious());
-
- it = l2.iterator();
- assertTrue(it.hasNext());
- assertEquals(in1, it.next());
- assertTrue(it.hasNext());
- assertEquals(insn, it.next());
- assertFalse(it.hasNext());
-
- l2.remove(insn);
- l2.insert(in1, in2);
-
- // add() then next()
- it = l2.iterator();
- assertTrue(it.hasNext());
- assertEquals(in1, it.next());
- it.add(insn);
- assertEquals(in2, it.next());
-
- l2.remove(insn);
-
- // add() then previous()
- it = l2.iterator();
- assertTrue(it.hasNext());
- assertEquals(in1, it.next());
- it.add(insn);
- assertEquals(insn, it.previous());
- assertEquals(insn, it.next());
- assertTrue(it.hasNext());
- assertEquals(in2, it.next());
- assertFalse(it.hasNext());
-
- l2.remove(insn);
-
- // set() then previous()
- it = l2.iterator();
- assertTrue(it.hasNext());
- assertEquals(in1, it.next());
- it.set(insn);
- assertEquals(insn, it.previous());
- assertEquals(insn, it.next());
- assertTrue(it.hasNext());
-
- l2.remove(insn);
- l2.insertBefore(in2, in1);
-
- // add() then next()
- it = l2.iterator();
- assertTrue(it.hasNext());
- assertEquals(in1, it.next());
- it.set(insn);
- assertEquals(in2, it.next());
- }
-
- public void testIterator2() {
- ListIterator<AbstractInsnNode> it = l2.iterator(l2.size());
-
- assertFalse(it.hasNext());
- assertTrue(it.hasPrevious());
- assertEquals(1, it.previousIndex());
- assertEquals(in2, it.previous());
- assertTrue(it.hasPrevious());
- assertEquals(0, it.previousIndex());
- assertEquals(in1, it.previous());
- assertFalse(it.hasPrevious());
-
- assertEquals(-1, it.previousIndex());
-
- assertTrue(it.hasNext());
- assertEquals(0, it.nextIndex());
- assertEquals(in1, it.next());
- assertTrue(it.hasNext());
- assertEquals(1, it.nextIndex());
-
- InsnNode insn = new InsnNode(0);
- it.add(insn);
-
- assertEquals(2, it.nextIndex());
- assertEquals(in2, it.next());
- assertFalse(it.hasNext());
- assertEquals(3, it.nextIndex());
- }
-
- public void testIterator3() {
- try {
- new InsnList().iterator().next();
- fail();
- } catch (NoSuchElementException e) {
- }
- }
-
- public void testInvalidIndexOf() {
- try {
- l1.indexOf(new InsnNode(0));
- fail();
- } catch (IllegalArgumentException e) {
- }
- }
-
- public void testToArray() {
- assertEquals(0, l1.toArray().length);
- }
-
- public void testInvalidSet() {
- try {
- l1.set(new InsnNode(0), new InsnNode(0));
- fail();
- } catch (IllegalArgumentException e) {
- }
- }
-
- public void testSet() {
- l1.add(new InsnNode(0));
- AbstractInsnNode insn = new InsnNode(0);
- l1.set(l1.getFirst(), insn);
- assertEquals(1, l1.size());
- assertEquals(insn, l1.getFirst());
-
- l1.remove(insn);
- l1.add(new InsnNode(0));
-
- l1.set(l1.get(0), insn);
- assertEquals(1, l1.size());
- assertEquals(insn, l1.getFirst());
-
- l1.remove(insn);
- l1.add(new InsnNode(0));
- l1.add(new InsnNode(0));
-
- l1.set(l1.get(1), insn);
- assertEquals(2, l1.size());
- assertEquals(insn, l1.get(1));
- }
-
- public void testInvalidAdd() {
- try {
- l1.add(in1);
- fail();
- } catch (IllegalArgumentException e) {
- }
- }
-
- public void testAddEmpty() {
- InsnNode insn = new InsnNode(0);
- l1.add(insn);
- assertEquals(1, l1.size());
- assertEquals(insn, l1.getFirst());
- assertEquals(insn, l1.getLast());
- assertEquals(insn, l1.get(0));
- assertEquals(true, l1.contains(insn));
- assertEquals(0, l1.indexOf(insn));
- assertEquals(new AbstractInsnNode[] { insn }, l1.toArray());
- assertEquals(null, insn.getPrevious());
- assertEquals(null, insn.getNext());
- }
-
- public void testAddNonEmpty() {
- InsnNode insn = new InsnNode(0);
- l1.add(new InsnNode(0));
- l1.add(insn);
- assertEquals(2, l1.size());
- assertEquals(insn, l1.getLast());
- assertEquals(1, l1.indexOf(insn));
- assertEquals(insn, l1.get(1));
- assertEquals(true, l1.contains(insn));
- }
-
- public void testAddEmptyList() {
- l1.add(new InsnList());
- assertEquals(0, l1.size());
- assertEquals(null, l1.getFirst());
- assertEquals(null, l1.getLast());
- assertEquals(new AbstractInsnNode[0], l1.toArray());
- }
-
- public void testInvalidAddAll() {
- try {
- l1.add(l1);
- fail();
- } catch (IllegalArgumentException e) {
- }
- }
-
- public void testAddAllEmpty() {
- l1.add(l2);
- assertEquals(2, l1.size());
- assertEquals(in1, l1.getFirst());
- assertEquals(in2, l1.getLast());
- assertEquals(in1, l1.get(0));
- assertEquals(true, l1.contains(in1));
- assertEquals(true, l1.contains(in2));
- assertEquals(0, l1.indexOf(in1));
- assertEquals(1, l1.indexOf(in2));
- assertEquals(new AbstractInsnNode[] { in1, in2 }, l1.toArray());
- }
-
- public void testAddAllNonEmpty() {
- InsnNode insn = new InsnNode(0);
- l1.add(insn);
- l1.add(l2);
- assertEquals(3, l1.size());
- assertEquals(insn, l1.getFirst());
- assertEquals(in2, l1.getLast());
- assertEquals(insn, l1.get(0));
- assertEquals(true, l1.contains(insn));
- assertEquals(true, l1.contains(in1));
- assertEquals(true, l1.contains(in2));
- assertEquals(0, l1.indexOf(insn));
- assertEquals(1, l1.indexOf(in1));
- assertEquals(2, l1.indexOf(in2));
- assertEquals(new AbstractInsnNode[] { insn, in1, in2 }, l1.toArray());
- }
-
- public void testInvalidInsert() {
- try {
- l1.insert(in1);
- fail();
- } catch (IllegalArgumentException e) {
- }
- }
-
- public void testInsertEmpty() {
- InsnNode insn = new InsnNode(0);
- l1.insert(insn);
- assertEquals(1, l1.size());
- assertEquals(insn, l1.getFirst());
- assertEquals(insn, l1.getLast());
- assertEquals(insn, l1.get(0));
- assertEquals(true, l1.contains(insn));
- assertEquals(0, l1.indexOf(insn));
- assertEquals(new AbstractInsnNode[] { insn }, l1.toArray());
- }
-
- public void testInsertNonEmpty() {
- InsnNode insn = new InsnNode(0);
- l1.add(new InsnNode(0));
- l1.insert(insn);
- assertEquals(2, l1.size());
- assertEquals(insn, l1.getFirst());
- assertEquals(insn, l1.get(0));
- assertEquals(true, l1.contains(insn));
- assertEquals(0, l1.indexOf(insn));
- }
-
- public void testInvalidInsertAll() {
- try {
- l1.insert(l1);
- fail();
- } catch (IllegalArgumentException e) {
- }
- }
-
- public void testInsertAllEmptyList() {
- l1.insert(new InsnList());
- assertEquals(0, l1.size());
- assertEquals(null, l1.getFirst());
- assertEquals(null, l1.getLast());
- assertEquals(new AbstractInsnNode[0], l1.toArray());
- }
-
- public void testInsertAllEmpty() {
- l1.insert(l2);
- assertEquals(2, l1.size(), 2);
- assertEquals(in1, l1.getFirst());
- assertEquals(in2, l1.getLast());
- assertEquals(in1, l1.get(0));
- assertEquals(true, l1.contains(in1));
- assertEquals(true, l1.contains(in2));
- assertEquals(0, l1.indexOf(in1));
- assertEquals(1, l1.indexOf(in2));
- assertEquals(new AbstractInsnNode[] { in1, in2 }, l1.toArray());
- }
-
- public void testInsertAllNonEmpty() {
- InsnNode insn = new InsnNode(0);
- l1.add(insn);
- l1.insert(l2);
- assertEquals(3, l1.size());
- assertEquals(in1, l1.getFirst());
- assertEquals(insn, l1.getLast());
- assertEquals(in1, l1.get(0));
- assertEquals(true, l1.contains(insn));
- assertEquals(true, l1.contains(in1));
- assertEquals(true, l1.contains(in2));
- assertEquals(0, l1.indexOf(in1));
- assertEquals(1, l1.indexOf(in2));
- assertEquals(2, l1.indexOf(insn));
- assertEquals(new AbstractInsnNode[] { in1, in2, insn }, l1.toArray());
- }
-
- public void testInvalidInsert2() {
- try {
- l1.insert(new InsnNode(0), new InsnNode(0));
- fail();
- } catch (IllegalArgumentException e) {
- }
- }
-
- public void testInsert2NotLast() {
- InsnNode insn = new InsnNode(0);
- l2.insert(in1, insn);
- assertEquals(3, l2.size());
- assertEquals(in1, l2.getFirst());
- assertEquals(in2, l2.getLast());
- assertEquals(in1, l2.get(0));
- assertEquals(true, l2.contains(insn));
- assertEquals(1, l2.indexOf(insn));
- assertEquals(new AbstractInsnNode[] { in1, insn, in2 }, l2.toArray());
- }
-
- public void testInsert2Last() {
- InsnNode insn = new InsnNode(0);
- l2.insert(in2, insn);
- assertEquals(3, l2.size());
- assertEquals(in1, l2.getFirst());
- assertEquals(insn, l2.getLast());
- assertEquals(in1, l2.get(0));
- assertEquals(true, l2.contains(insn));
- assertEquals(2, l2.indexOf(insn));
- assertEquals(new AbstractInsnNode[] { in1, in2, insn }, l2.toArray());
- }
-
- public void testInsertBefore() {
- InsnNode insn = new InsnNode(0);
- l2.insertBefore(in2, insn);
- assertEquals(3, l2.size());
- assertEquals(in1, l2.getFirst());
- assertEquals(in2, l2.getLast());
- assertEquals(insn, l2.get(1));
- assertEquals(true, l2.contains(insn));
- assertEquals(1, l2.indexOf(insn));
- assertEquals(new AbstractInsnNode[] { in1, insn, in2 }, l2.toArray());
- }
-
- public void testInsertBeforeFirst() {
- InsnNode insn = new InsnNode(0);
- l2.insertBefore(in1, insn);
- assertEquals(3, l2.size());
- assertEquals(insn, l2.getFirst());
- assertEquals(in2, l2.getLast());
- assertEquals(insn, l2.get(0));
- assertEquals(true, l2.contains(insn));
- assertEquals(0, l2.indexOf(insn));
- assertEquals(new AbstractInsnNode[] { insn, in1, in2 }, l2.toArray());
- }
-
- public void testInvalidInsertBefore() {
- try {
- l1.insertBefore(new InsnNode(0), new InsnNode(0));
- fail();
- } catch (IllegalArgumentException e) {
- }
- }
-
- public void testInvalidInsertAll2() {
- try {
- l1.insert(new InsnNode(0), new InsnList());
- fail();
- } catch (IllegalArgumentException e) {
- }
- }
-
- public void testInsertAll2EmptyList() {
- InsnNode insn = new InsnNode(0);
- l1.add(insn);
- l1.insert(insn, new InsnList());
- assertEquals(1, l1.size());
- assertEquals(insn, l1.getFirst());
- assertEquals(insn, l1.getLast());
- assertEquals(new AbstractInsnNode[] { insn }, l1.toArray());
- }
-
- public void testInsertAll2NotLast() {
- InsnNode insn = new InsnNode(0);
- l1.add(insn);
- l1.add(new InsnNode(0));
- l1.insert(insn, l2);
- assertEquals(4, l1.size());
- assertEquals(insn, l1.getFirst());
- assertEquals(insn, l1.get(0));
- assertEquals(true, l1.contains(insn));
- assertEquals(true, l1.contains(in1));
- assertEquals(true, l1.contains(in2));
- assertEquals(0, l1.indexOf(insn));
- assertEquals(1, l1.indexOf(in1));
- assertEquals(2, l1.indexOf(in2));
- }
-
- public void testInsertAll2Last() {
- InsnNode insn = new InsnNode(0);
- l1.add(insn);
- l1.insert(insn, l2);
- assertEquals(3, l1.size());
- assertEquals(insn, l1.getFirst());
- assertEquals(in2, l1.getLast());
- assertEquals(insn, l1.get(0));
- assertEquals(true, l1.contains(insn));
- assertEquals(true, l1.contains(in1));
- assertEquals(true, l1.contains(in2));
- assertEquals(0, l1.indexOf(insn));
- assertEquals(1, l1.indexOf(in1));
- assertEquals(2, l1.indexOf(in2));
- assertEquals(new AbstractInsnNode[] { insn, in1, in2 }, l1.toArray());
- }
-
- public void testInvalidInsertBeforeAll() {
- try {
- l1.insertBefore(new InsnNode(0), new InsnList());
- fail();
- } catch (IllegalArgumentException e) {
- }
- }
-
- public void testInsertBeforeAll2EmptyList() {
- InsnNode insn = new InsnNode(0);
- l1.add(insn);
- l1.insertBefore(insn, new InsnList());
- assertEquals(1, l1.size());
- assertEquals(insn, l1.getFirst());
- assertEquals(insn, l1.getLast());
- assertEquals(new AbstractInsnNode[] { insn }, l1.toArray());
- }
-
- public void testInsertBeforeAll2NotLast() {
- InsnNode insn = new InsnNode(0);
- l1.add(new InsnNode(0));
- l1.add(insn);
- l1.insertBefore(insn, l2);
- assertEquals(4, l1.size());
- assertEquals(in1, l1.get(1));
- assertEquals(in2, l1.get(2));
- assertEquals(true, l1.contains(insn));
- assertEquals(true, l1.contains(in1));
- assertEquals(true, l1.contains(in2));
- assertEquals(3, l1.indexOf(insn));
- assertEquals(1, l1.indexOf(in1));
- assertEquals(2, l1.indexOf(in2));
- }
-
- public void testInsertBeforeAll2First() {
- InsnNode insn = new InsnNode(0);
- l1.insert(insn);
- l1.insertBefore(insn, l2);
- assertEquals(3, l1.size());
- assertEquals(in1, l1.getFirst());
- assertEquals(insn, l1.getLast());
- assertEquals(in1, l1.get(0));
- assertEquals(true, l1.contains(insn));
- assertEquals(true, l1.contains(in1));
- assertEquals(true, l1.contains(in2));
- assertEquals(2, l1.indexOf(insn));
- assertEquals(0, l1.indexOf(in1));
- assertEquals(1, l1.indexOf(in2));
- assertEquals(new AbstractInsnNode[] { in1, in2, insn }, l1.toArray());
- }
-
- public void testInvalidRemove() {
- try {
- l1.remove(new InsnNode(0));
- } catch (IllegalArgumentException e) {
- }
- }
-
- public void testRemoveSingle() {
- InsnNode insn = new InsnNode(0);
- l1.add(insn);
- l1.remove(insn);
- assertEquals(0, l1.size());
- assertEquals(null, l1.getFirst());
- assertEquals(null, l1.getLast());
- assertEquals(false, l1.contains(insn));
- assertEquals(new AbstractInsnNode[0], l1.toArray());
- assertEquals(null, insn.getPrevious());
- assertEquals(null, insn.getNext());
- }
-
- public void testRemoveFirst() {
- InsnNode insn = new InsnNode(0);
- l1.add(insn);
- l1.add(new InsnNode(0));
- l1.remove(insn);
- assertEquals(false, l1.contains(insn));
- assertEquals(null, insn.getPrevious());
- assertEquals(null, insn.getNext());
- }
-
- public void testRemoveMiddle() {
- InsnNode insn = new InsnNode(0);
- l1.add(new InsnNode(0));
- l1.add(insn);
- l1.add(new InsnNode(0));
- l1.remove(insn);
- assertEquals(false, l1.contains(insn));
- assertEquals(null, insn.getPrevious());
- assertEquals(null, insn.getNext());
- }
-
- public void testRemoveLast() {
- InsnNode insn = new InsnNode(0);
- l1.add(new InsnNode(0));
- l1.add(insn);
- l1.remove(insn);
- assertEquals(false, l1.contains(insn));
- assertEquals(null, insn.getPrevious());
- assertEquals(null, insn.getNext());
- }
-
- public void testClear() {
- InsnNode insn = new InsnNode(0);
- l1.add(new InsnNode(0));
- l1.add(insn);
- l1.add(new InsnNode(0));
- l1.clear();
- assertEquals(0, l1.size());
- assertEquals(null, l1.getFirst());
- assertEquals(null, l1.getLast());
- assertEquals(false, l1.contains(insn));
- assertEquals(new AbstractInsnNode[0], l1.toArray());
- assertEquals(null, insn.getPrevious());
- assertEquals(null, insn.getNext());
- }
-
- public void testAcceptor1() {
- l1.add(new InsnNode(55));
- l1.add(new InsnNode(77));
-
- final InsnList lst = new InsnList();
- l1.accept(new MethodVisitor(Opcodes.ASM4) {
- @Override
- public void visitInsn(int opcode) {
- lst.add(new InsnNode(opcode));
- }
- });
-
- assertEquals(55, lst.get(0).opcode);
- assertEquals(77, lst.get(1).opcode);
- }
-
- public void testResetLabels() throws Exception {
- LabelNode labelNode = new LabelNode();
-
- l1.add(new InsnNode(55));
- l1.add(labelNode);
- l1.add(new InsnNode(55));
-
- Label label = labelNode.getLabel();
- assertNotNull(label);
-
- l1.resetLabels();
-
- assertNotSame(label, labelNode.getLabel());
- }
-}
-
-class CheckedInsnList extends InsnList {
-
- @Override
- public int indexOf(final AbstractInsnNode insn) {
- if (!contains(insn)) {
- throw new IllegalArgumentException();
- }
- return super.indexOf(insn);
- }
-
- @Override
- public void set(final AbstractInsnNode location, final AbstractInsnNode insn) {
- if (!(contains(location) && insn.index == -1)) {
- throw new IllegalArgumentException();
- }
- super.set(location, insn);
- }
-
- @Override
- public void add(final AbstractInsnNode insn) {
- if (insn.index != -1) {
- throw new IllegalArgumentException();
- }
- super.add(insn);
- }
-
- @Override
- public void add(final InsnList insns) {
- if (insns == this) {
- throw new IllegalArgumentException();
- }
- super.add(insns);
- }
-
- @Override
- public void insert(final AbstractInsnNode insn) {
- if (insn.index != -1) {
- throw new IllegalArgumentException();
- }
- super.insert(insn);
- }
-
- @Override
- public void insert(final InsnList insns) {
- if (insns == this) {
- throw new IllegalArgumentException();
- }
- super.insert(insns);
- }
-
- @Override
- public void insert(final AbstractInsnNode location,
- final AbstractInsnNode insn) {
- if (!(contains(location) && insn.index == -1)) {
- throw new IllegalArgumentException();
- }
- super.insert(location, insn);
- }
-
- @Override
- public void insert(final AbstractInsnNode location, final InsnList insns) {
- if (!(contains(location) && insns != this)) {
- throw new IllegalArgumentException();
- }
- super.insert(location, insns);
- }
-
- @Override
- public void insertBefore(final AbstractInsnNode location,
- final AbstractInsnNode insn) {
- if (!(contains(location) && insn.index == -1)) {
- throw new IllegalArgumentException();
- }
- super.insertBefore(location, insn);
- }
-
- @Override
- public void insertBefore(final AbstractInsnNode location,
- final InsnList insns) {
- if (!(contains(location) && insns != this)) {
- throw new IllegalArgumentException();
- }
- super.insertBefore(location, insns);
- }
-
- @Override
- public void remove(final AbstractInsnNode insn) {
- if (!contains(insn)) {
- throw new IllegalArgumentException();
- }
- super.remove(insn);
- }
-
- @Override
- public void clear() {
- super.removeAll(true);
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/tree/analysis/AnalyzerUnitTest.java b/asm4/test/conform/org/objectweb/asm/tree/analysis/AnalyzerUnitTest.java
deleted file mode 100644
index 9e5a835..0000000
--- a/asm4/test/conform/org/objectweb/asm/tree/analysis/AnalyzerUnitTest.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.tree.analysis;
-
-import org.objectweb.asm.ClassReader;
-import org.objectweb.asm.ClassVisitor;
-import org.objectweb.asm.ClassWriterComputeMaxsUnitTest;
-import org.objectweb.asm.MethodVisitor;
-import org.objectweb.asm.Opcodes;
-import org.objectweb.asm.tree.MethodNode;
-
-/**
- * Analyzer unit tests for methods with JSR instructions.
- *
- * @author Eric Bruneton
- */
-public class AnalyzerUnitTest extends ClassWriterComputeMaxsUnitTest {
-
- @Override
- protected boolean isComputeMaxs() {
- return false;
- }
-
- @Override
- protected void assertMaxs(final int maxStack, final int maxLocals) {
- mv.visitMaxs(maxStack, maxLocals);
- mv.visitEnd();
- cw.visitEnd();
- byte[] b = cw.toByteArray();
- ClassReader cr = new ClassReader(b);
- cr.accept(new ClassVisitor(Opcodes.ASM4) {
- @Override
- public MethodVisitor visitMethod(final int access,
- final String name, final String desc,
- final String signature, final String[] exceptions) {
- if (name.equals("m")) {
- return new MethodNode(access, name, desc, signature,
- exceptions) {
- @Override
- public void visitEnd() {
- Analyzer<BasicValue> a = new Analyzer<BasicValue>(
- new BasicInterpreter());
- try {
- Frame<BasicValue>[] frames = a.analyze("C",
- this);
- int mStack = 0;
- int mLocals = 0;
- for (int i = 0; i < frames.length; ++i) {
- if (frames[i] != null) {
- mStack = Math.max(mStack,
- frames[i].getStackSize());
- mLocals = Math.max(mLocals,
- frames[i].getLocals());
- }
- }
- assertEquals("maxStack", maxStack, mStack);
- assertEquals("maxLocals", maxLocals, mLocals);
- } catch (Exception e) {
- fail(e.getMessage());
- }
- }
- };
- } else {
- return null;
- }
- }
- }, 0);
-
- try {
- TestClassLoader loader = new TestClassLoader();
- Class<?> c = loader.defineClass("C", b);
- c.newInstance();
- } catch (Throwable t) {
- fail(t.getMessage());
- }
- }
-
- @Override
- protected void assertGraph(final String graph) {
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/tree/analysis/BasicInterpreterTest.java b/asm4/test/conform/org/objectweb/asm/tree/analysis/BasicInterpreterTest.java
deleted file mode 100644
index 79d654e..0000000
--- a/asm4/test/conform/org/objectweb/asm/tree/analysis/BasicInterpreterTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.tree.analysis;
-
-import java.util.List;
-
-import junit.framework.TestSuite;
-
-import org.objectweb.asm.AbstractTest;
-import org.objectweb.asm.ClassReader;
-import org.objectweb.asm.tree.ClassNode;
-import org.objectweb.asm.tree.MethodNode;
-
-/**
- * Analysis tests.
- *
- * @author Eric Bruneton
- */
-public class BasicInterpreterTest extends AbstractTest {
-
- public static TestSuite suite() throws Exception {
- return new BasicInterpreterTest().getSuite();
- }
-
- @Override
- public void test() throws Exception {
- ClassReader cr = new ClassReader(is);
- ClassNode cn = new ClassNode();
- cr.accept(cn, 0);
- List<MethodNode> methods = cn.methods;
- for (int i = 0; i < methods.size(); ++i) {
- MethodNode method = methods.get(i);
- Analyzer<BasicValue> a = new Analyzer<BasicValue>(
- new BasicInterpreter());
- a.analyze(cn.name, method);
- }
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/tree/analysis/BasicVerifierTest.java b/asm4/test/conform/org/objectweb/asm/tree/analysis/BasicVerifierTest.java
deleted file mode 100644
index ff7dba7..0000000
--- a/asm4/test/conform/org/objectweb/asm/tree/analysis/BasicVerifierTest.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.tree.analysis;
-
-import java.util.List;
-
-import junit.framework.TestSuite;
-
-import org.objectweb.asm.AbstractTest;
-import org.objectweb.asm.ClassReader;
-import org.objectweb.asm.tree.ClassNode;
-import org.objectweb.asm.tree.MethodNode;
-
-/**
- * Analysis tests.
- *
- * @author Eric Bruneton
- */
-public class BasicVerifierTest extends AbstractTest {
-
- public static TestSuite suite() throws Exception {
- return new BasicVerifierTest().getSuite();
- }
-
- @Override
- public void test() throws Exception {
- ClassReader cr = new ClassReader(is);
- ClassNode cn = new ClassNode();
- cr.accept(cn, 0);
- List<MethodNode> methods = cn.methods;
- for (int i = 0; i < methods.size(); ++i) {
- MethodNode method = methods.get(i);
- Analyzer<?> a = new Analyzer<BasicValue>(new BasicVerifier());
- a.analyze(cn.name, method);
- }
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/tree/analysis/SimpleVerifierTest.java b/asm4/test/conform/org/objectweb/asm/tree/analysis/SimpleVerifierTest.java
deleted file mode 100644
index ffe4808..0000000
--- a/asm4/test/conform/org/objectweb/asm/tree/analysis/SimpleVerifierTest.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.tree.analysis;
-
-import java.util.List;
-
-import junit.framework.TestSuite;
-
-import org.objectweb.asm.AbstractTest;
-import org.objectweb.asm.ClassReader;
-import org.objectweb.asm.tree.ClassNode;
-import org.objectweb.asm.tree.MethodNode;
-
-/**
- * Verifier tests.
- *
- * @author Eric Bruneton
- */
-public class SimpleVerifierTest extends AbstractTest {
-
- public static TestSuite suite() throws Exception {
- return new SimpleVerifierTest().getSuite();
- }
-
- @Override
- public void test() throws Exception {
- ClassReader cr = new ClassReader(is);
- ClassNode cn = new ClassNode();
- cr.accept(cn, 0);
- List<MethodNode> methods = cn.methods;
- for (int i = 0; i < methods.size(); ++i) {
- MethodNode method = methods.get(i);
- Analyzer<?> a = new Analyzer<BasicValue>(new SimpleVerifier());
- a.analyze(cn.name, method);
- }
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/tree/analysis/SimpleVerifierUnitTest.java b/asm4/test/conform/org/objectweb/asm/tree/analysis/SimpleVerifierUnitTest.java
deleted file mode 100644
index b6b2834..0000000
--- a/asm4/test/conform/org/objectweb/asm/tree/analysis/SimpleVerifierUnitTest.java
+++ /dev/null
@@ -1,451 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.tree.analysis;
-
-import junit.framework.TestCase;
-
-import org.objectweb.asm.Label;
-import org.objectweb.asm.MethodVisitor;
-import org.objectweb.asm.Opcodes;
-import org.objectweb.asm.Type;
-import org.objectweb.asm.tree.MethodNode;
-
-/**
- * SimpleVerifier unit tests.
- *
- * @author Eric Bruneton
- */
-public class SimpleVerifierUnitTest extends TestCase implements Opcodes {
-
- private Analyzer<?> a;
-
- private MethodNode mn;
-
- @Override
- protected void setUp() {
- Type c = Type.getType("LC;");
- Type d = Type.getType("Ljava/lang/Number;");
- a = new Analyzer<BasicValue>(new SimpleVerifier(c, d, false));
- mn = new MethodNode(ACC_PUBLIC, "m", "()V", null, null);
- }
-
- private void assertValid() throws AnalyzerException {
- mn.visitInsn(RETURN);
- mn.visitMaxs(10, 10);
- a.analyze("C", mn);
- Frame<?>[] frames = a.getFrames();
- for (int i = 0; i < frames.length; ++i) {
- if (frames[i] != null) {
- frames[i].toString();
- }
- }
- a.getHandlers(0);
- }
-
- private void assertInvalid() {
- mn.visitInsn(RETURN);
- mn.visitMaxs(10, 10);
- try {
- a.analyze("C", mn);
- fail();
- } catch (AnalyzerException e) {
- success();
- } catch (RuntimeException e) {
- }
- }
-
- public void testInvalidOpcode() {
- mn.visitInsn(-1);
- assertInvalid();
- }
-
- public void testInvalidPop() {
- mn.visitInsn(LCONST_0);
- mn.visitInsn(POP);
- assertInvalid();
- }
-
- public void testInvalidPop2() {
- mn.visitInsn(LCONST_0);
- mn.visitInsn(ICONST_0);
- mn.visitInsn(POP2);
- assertInvalid();
- }
-
- public void testInvalidDup() {
- mn.visitInsn(LCONST_0);
- mn.visitInsn(DUP);
- assertInvalid();
- }
-
- public void testInvalidDupx1() {
- mn.visitInsn(LCONST_0);
- mn.visitInsn(ICONST_0);
- mn.visitInsn(DUP_X1);
- assertInvalid();
- }
-
- public void testInvalidDupx2() {
- mn.visitInsn(LCONST_0);
- mn.visitInsn(ICONST_0);
- mn.visitInsn(ICONST_0);
- mn.visitInsn(DUP_X2);
- assertInvalid();
- }
-
- public void testInvalidDup2() {
- mn.visitInsn(LCONST_0);
- mn.visitInsn(ICONST_0);
- mn.visitInsn(DUP2);
- assertInvalid();
- }
-
- public void testInvalidDup2x1() {
- mn.visitInsn(LCONST_0);
- mn.visitInsn(ICONST_0);
- mn.visitInsn(ICONST_0);
- mn.visitInsn(DUP2_X1);
- assertInvalid();
- }
-
- public void testInvalidDup2x2() {
- mn.visitInsn(LCONST_0);
- mn.visitInsn(ICONST_0);
- mn.visitInsn(ICONST_0);
- mn.visitInsn(ICONST_0);
- mn.visitInsn(DUP2_X2);
- assertInvalid();
- }
-
- public void testInvalidSwap() {
- mn.visitInsn(LCONST_0);
- mn.visitInsn(ICONST_0);
- mn.visitInsn(SWAP);
- assertInvalid();
- }
-
- public void testInvalidGetLocal() {
- mn.visitVarInsn(ALOAD, 10);
- assertInvalid();
- }
-
- public void testInvalidSetLocal() {
- mn.visitInsn(ACONST_NULL);
- mn.visitVarInsn(ASTORE, 10);
- assertInvalid();
- }
-
- public void testInvalidEmptyStack() {
- mn.visitInsn(POP);
- assertInvalid();
- }
-
- public void testInvalidFullStack() {
- mn.visitInsn(ICONST_0);
- mn.visitInsn(ICONST_0);
- mn.visitInsn(ICONST_0);
- mn.visitInsn(ICONST_0);
- mn.visitInsn(ICONST_0);
- mn.visitInsn(ICONST_0);
- mn.visitInsn(ICONST_0);
- mn.visitInsn(ICONST_0);
- mn.visitInsn(ICONST_0);
- mn.visitInsn(ICONST_0);
- mn.visitInsn(ICONST_0);
- assertInvalid();
- }
-
- public void testInconsistentStackHeights() {
- Label l0 = new Label();
- mn.visitInsn(ICONST_0);
- mn.visitJumpInsn(IFEQ, l0);
- mn.visitInsn(ICONST_0);
- mn.visitLabel(l0);
- assertInvalid();
- }
-
- public void testInvalidNewArray() {
- mn.visitInsn(ICONST_1);
- mn.visitIntInsn(NEWARRAY, -1);
- assertInvalid();
- }
-
- public void testInvalidAload() {
- mn.visitInsn(ICONST_0);
- mn.visitVarInsn(ISTORE, 1);
- mn.visitVarInsn(ALOAD, 1);
- assertInvalid();
- }
-
- public void testInvalidAstore() {
- mn.visitInsn(ICONST_0);
- mn.visitVarInsn(ASTORE, 1);
- assertInvalid();
- }
-
- public void testInvalidIstore() {
- mn.visitInsn(ACONST_NULL);
- mn.visitVarInsn(ISTORE, 1);
- assertInvalid();
- }
-
- public void testInvalidCheckcast() {
- mn.visitInsn(ICONST_0);
- mn.visitTypeInsn(CHECKCAST, "java/lang/String");
- assertInvalid();
- }
-
- public void testInvalidArraylength() {
- mn.visitInsn(ICONST_0);
- mn.visitInsn(ARRAYLENGTH);
- assertInvalid();
- }
-
- public void testInvalidAthrow() {
- mn.visitInsn(ICONST_0);
- mn.visitInsn(ATHROW);
- assertInvalid();
- }
-
- public void testInvalidIneg() {
- mn.visitInsn(FCONST_0);
- mn.visitInsn(INEG);
- assertInvalid();
- }
-
- public void testInvalidIadd() {
- mn.visitInsn(FCONST_0);
- mn.visitInsn(ICONST_0);
- mn.visitInsn(IADD);
- assertInvalid();
- }
-
- public void testInvalidIsub() {
- mn.visitInsn(ICONST_0);
- mn.visitInsn(FCONST_0);
- mn.visitInsn(ISUB);
- assertInvalid();
- }
-
- public void testInvalidIastore() {
- mn.visitInsn(ICONST_1);
- mn.visitIntInsn(NEWARRAY, T_INT);
- mn.visitInsn(FCONST_0);
- mn.visitInsn(ICONST_0);
- mn.visitInsn(IASTORE);
- assertInvalid();
- }
-
- public void testInvalidFastore() {
- mn.visitInsn(ICONST_1);
- mn.visitIntInsn(NEWARRAY, T_FLOAT);
- mn.visitInsn(ICONST_0);
- mn.visitInsn(ICONST_0);
- mn.visitInsn(FASTORE);
- assertInvalid();
- }
-
- public void testInvalidLastore() {
- mn.visitInsn(ICONST_1);
- mn.visitInsn(ICONST_0);
- mn.visitInsn(LCONST_0);
- mn.visitInsn(LASTORE);
- assertInvalid();
- }
-
- public void testInvalidMultianewarray() {
- mn.visitInsn(FCONST_1);
- mn.visitInsn(ICONST_2);
- mn.visitMultiANewArrayInsn("[[I", 2);
- assertInvalid();
- }
-
- public void testInvalidInvokevirtual() {
- mn.visitInsn(ACONST_NULL);
- mn.visitTypeInsn(CHECKCAST, "java/lang/Object");
- mn.visitMethodInsn(INVOKEVIRTUAL, "java/util/ArrayList", "size", "()I");
- assertInvalid();
- }
-
- public void testInvalidInvokeinterface() {
- mn.visitInsn(ACONST_NULL);
- mn.visitTypeInsn(CHECKCAST, "java/util/List");
- mn.visitInsn(FCONST_0);
- mn.visitMethodInsn(INVOKEINTERFACE, "java/util/List", "get",
- "(I)Ljava/lang/Object;");
- assertInvalid();
- }
-
- public void testInvalidRet() {
- mn.visitVarInsn(RET, 1);
- assertInvalid();
- }
-
- public void testInvalidFalloff() {
- mn.visitMaxs(10, 10);
- try {
- a.analyze("C", mn);
- fail();
- } catch (AnalyzerException e) {
- success();
- } catch (RuntimeException e) {
- }
- }
-
- public void testInvalidSubroutineFalloff() {
- Label l0 = new Label();
- Label l1 = new Label();
- mn.visitJumpInsn(GOTO, l0);
- mn.visitLabel(l1);
- mn.visitVarInsn(ASTORE, 1);
- mn.visitVarInsn(RET, 1);
- mn.visitLabel(l0);
- mn.visitJumpInsn(JSR, l1);
- mn.visitMaxs(10, 10);
- try {
- a.analyze("C", mn);
- fail();
- } catch (AnalyzerException e) {
- success();
- } catch (RuntimeException e) {
- }
- }
-
- public void testNestedSubroutines() throws AnalyzerException {
- Label l0 = new Label();
- Label l1 = new Label();
- mn.visitJumpInsn(JSR, l0);
- mn.visitInsn(RETURN);
- mn.visitLabel(l0);
- mn.visitVarInsn(ASTORE, 1);
- mn.visitJumpInsn(JSR, l1);
- mn.visitJumpInsn(JSR, l1);
- mn.visitVarInsn(RET, 1);
- mn.visitLabel(l1);
- mn.visitVarInsn(ASTORE, 2);
- mn.visitVarInsn(RET, 2);
- assertValid();
- }
-
- public void testSubroutineLocalsAccess() throws AnalyzerException {
- MethodVisitor mv = mn;
- mv.visitCode();
- Label l0 = new Label();
- Label l1 = new Label();
- Label l2 = new Label();
- Label l3 = new Label();
- mv.visitTryCatchBlock(l0, l0, l1, null);
- mv.visitTryCatchBlock(l0, l2, l2, "java/lang/RuntimeException");
- mv.visitLabel(l0);
- mv.visitJumpInsn(JSR, l3);
- mv.visitInsn(RETURN);
- mv.visitLabel(l1);
- mv.visitVarInsn(ASTORE, 1);
- mv.visitJumpInsn(JSR, l3);
- mv.visitVarInsn(ALOAD, 1);
- mv.visitInsn(ATHROW);
- mv.visitLabel(l3);
- mv.visitVarInsn(ASTORE, 2);
- mv.visitInsn(ACONST_NULL);
- mv.visitVarInsn(ASTORE, 3);
- mv.visitVarInsn(RET, 2);
- mv.visitLabel(l2);
- mv.visitVarInsn(ASTORE, 4);
- mv.visitVarInsn(ALOAD, 4);
- mv.visitInsn(ATHROW);
- assertValid();
- }
-
- public void _testOverlappingSubroutines() {
- // TODO currently Analyzer can not detect this situation. The problem
- // is that other overlapping subroutine situations are valid, such as
- // when a nested subroutine implicitly returns to its parent
- // subroutine, without a RET.
- Label l0 = new Label();
- Label l1 = new Label();
- Label l2 = new Label();
- mn.visitJumpInsn(JSR, l0);
- mn.visitJumpInsn(JSR, l1);
- mn.visitInsn(RETURN);
- mn.visitLabel(l0);
- mn.visitVarInsn(ASTORE, 1);
- mn.visitJumpInsn(GOTO, l2);
- mn.visitLabel(l1);
- mn.visitVarInsn(ASTORE, 1);
- mn.visitLabel(l2);
- mn.visitVarInsn(RET, 1);
- assertInvalid();
- }
-
- public void testMerge() throws AnalyzerException {
- Label l0 = new Label();
- mn.visitVarInsn(ALOAD, 0);
- mn.visitVarInsn(ASTORE, 1);
- mn.visitInsn(ACONST_NULL);
- mn.visitTypeInsn(CHECKCAST, "java/lang/Number");
- mn.visitVarInsn(ASTORE, 2);
- mn.visitVarInsn(ALOAD, 0);
- mn.visitVarInsn(ASTORE, 3);
- mn.visitLabel(l0);
- mn.visitInsn(ACONST_NULL);
- mn.visitTypeInsn(CHECKCAST, "java/lang/Number");
- mn.visitVarInsn(ASTORE, 1);
- mn.visitVarInsn(ALOAD, 0);
- mn.visitVarInsn(ASTORE, 2);
- mn.visitInsn(ACONST_NULL);
- mn.visitTypeInsn(CHECKCAST, "java/lang/Integer");
- mn.visitVarInsn(ASTORE, 3);
- mn.visitJumpInsn(GOTO, l0);
- assertValid();
- }
-
- public void testClassNotFound() {
- Label l0 = new Label();
- mn.visitVarInsn(ALOAD, 0);
- mn.visitVarInsn(ASTORE, 1);
- mn.visitLabel(l0);
- mn.visitInsn(ACONST_NULL);
- mn.visitTypeInsn(CHECKCAST, "D");
- mn.visitVarInsn(ASTORE, 1);
- mn.visitJumpInsn(GOTO, l0);
- mn.visitMaxs(10, 10);
- try {
- a.analyze("C", mn);
- fail();
- } catch (Exception e) {
- }
- }
-
- /**
- * Dummy method to avoid a FindBugs warning.
- */
- private static void success() {
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/tree/analysis/SmallSetUnitTest.java b/asm4/test/conform/org/objectweb/asm/tree/analysis/SmallSetUnitTest.java
deleted file mode 100644
index a599ffc..0000000
--- a/asm4/test/conform/org/objectweb/asm/tree/analysis/SmallSetUnitTest.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.tree.analysis;
-
-import java.util.Set;
-
-import junit.framework.TestCase;
-
-/**
- * SmallSet unit tests.
- *
- * @author Eric Bruneton
- */
-public class SmallSetUnitTest extends TestCase {
-
- private final Object A = new Object();
- private final Object B = new Object();
- private final Object C = new Object();
- private final Object D = new Object();
-
- public void testSubsetUnion() {
- SmallSet<Object> s1 = new SmallSet<Object>(A, B);
- SmallSet<Object> s2 = new SmallSet<Object>(A, null);
- Set<Object> u = s1.union(s2);
- Set<Object> v = s2.union(s1);
- assertEquals(u, v);
- s1.remove();
- }
-
- public void testDisjointUnion() {
- SmallSet<Object> s1 = new SmallSet<Object>(A, B);
- SmallSet<Object> s2 = new SmallSet<Object>(C, D);
- Set<Object> u = s1.union(s2);
- Set<Object> v = s2.union(s1);
- assertEquals(u, v);
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/tree/analysis/SourceInterpreterTest.java b/asm4/test/conform/org/objectweb/asm/tree/analysis/SourceInterpreterTest.java
deleted file mode 100644
index fbecfe8..0000000
--- a/asm4/test/conform/org/objectweb/asm/tree/analysis/SourceInterpreterTest.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.tree.analysis;
-
-import java.util.List;
-
-import junit.framework.TestSuite;
-
-import org.objectweb.asm.AbstractTest;
-import org.objectweb.asm.ClassReader;
-import org.objectweb.asm.tree.ClassNode;
-import org.objectweb.asm.tree.MethodNode;
-
-/**
- * SourceInterpreter tests.
- *
- * @author Eric Bruneton
- */
-public class SourceInterpreterTest extends AbstractTest {
-
- public static TestSuite suite() throws Exception {
- return new SourceInterpreterTest().getSuite();
- }
-
- @Override
- public void test() throws Exception {
- ClassReader cr = new ClassReader(is);
- ClassNode cn = new ClassNode();
- cr.accept(cn, 0);
- List<MethodNode> methods = cn.methods;
- for (int i = 0; i < methods.size(); ++i) {
- MethodNode method = methods.get(i);
- Analyzer<?> a = new Analyzer<SourceValue>(new SourceInterpreter());
- a.analyze(cn.name, method);
- }
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/tree/analysis/ValueUnitTest.java b/asm4/test/conform/org/objectweb/asm/tree/analysis/ValueUnitTest.java
deleted file mode 100644
index ecb001b..0000000
--- a/asm4/test/conform/org/objectweb/asm/tree/analysis/ValueUnitTest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.tree.analysis;
-
-import junit.framework.TestCase;
-
-/**
- * BasicValue and SourceValue unit tests.
- *
- * @author Eric Bruneton
- */
-public class ValueUnitTest extends TestCase {
-
- public void testBasicValue() {
- assertFalse(BasicValue.INT_VALUE.equals(new Object()));
- BasicValue.INT_VALUE.hashCode();
- BasicValue.UNINITIALIZED_VALUE.toString();
- BasicValue.RETURNADDRESS_VALUE.toString();
- BasicValue.REFERENCE_VALUE.toString();
- }
-
- public void testSourceValue() {
- new SourceValue(1).hashCode();
- assertFalse(new SourceValue(1).equals(null));
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/util/ASMifierTest.java b/asm4/test/conform/org/objectweb/asm/util/ASMifierTest.java
deleted file mode 100644
index 603da7f..0000000
--- a/asm4/test/conform/org/objectweb/asm/util/ASMifierTest.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.util;
-
-import java.io.PrintWriter;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.lang.reflect.Method;
-import java.net.URL;
-import java.net.URLClassLoader;
-
-import junit.framework.TestSuite;
-
-import org.codehaus.janino.ClassLoaderIClassLoader;
-import org.codehaus.janino.DebuggingInformation;
-import org.codehaus.janino.IClassLoader;
-import org.codehaus.janino.Parser;
-import org.codehaus.janino.Scanner;
-import org.codehaus.janino.UnitCompiler;
-import org.objectweb.asm.AbstractTest;
-import org.objectweb.asm.Attribute;
-import org.objectweb.asm.ClassReader;
-import org.objectweb.asm.attrs.CodeComment;
-import org.objectweb.asm.attrs.Comment;
-
-/**
- * ASMifier tests.
- *
- * @author Eugene Kuleshov
- * @author Eric Bruneton
- */
-public class ASMifierTest extends AbstractTest {
-
- public static final TestClassLoader LOADER = new TestClassLoader();
-
- public static TestSuite suite() throws Exception {
- return new ASMifierTest().getSuite();
- }
-
- @Override
- public void test() throws Exception {
- ClassReader cr = new ClassReader(is);
-
- if (cr.b.length > 20000) {
- return;
- }
-
- StringWriter sw = new StringWriter();
- TraceClassVisitor cv = new TraceClassVisitor(null, new ASMifier(),
- new PrintWriter(sw));
- cr.accept(cv, new Attribute[] { new Comment(), new CodeComment() }, 0);
-
- String generated = sw.toString();
-
- byte[] generatorClassData;
- try {
- generatorClassData = Compiler.compile(n, generated);
- } catch (Exception ex) {
- System.err.println(generated);
- System.err.println("------------------");
- throw ex;
- }
-
- String nd = n + "Dump";
- if (n.indexOf('.') != -1) {
- nd = "asm." + nd;
- }
-
- Class<?> c = LOADER.defineClass(nd, generatorClassData);
- Method m = c.getMethod("dump", new Class[0]);
- byte[] b = (byte[]) m.invoke(null, new Object[0]);
-
- assertEquals(cr, new ClassReader(b));
- }
-
- public static class TestClassLoader extends ClassLoader {
-
- public Class<?> defineClass(final String name, final byte[] b) {
- return defineClass(name, b, 0, b.length);
- }
- }
-
- public static class Compiler {
-
- final static IClassLoader CL = new ClassLoaderIClassLoader(
- new URLClassLoader(new URL[0]));
-
- public static byte[] compile(final String name, final String source)
- throws Exception {
- Parser p = new Parser(new Scanner(name, new StringReader(source)));
- UnitCompiler uc = new UnitCompiler(p.parseCompilationUnit(), CL);
- return uc.compileUnit(DebuggingInformation.ALL)[0].toByteArray();
- }
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/util/ASMifierUnitTest.java b/asm4/test/conform/org/objectweb/asm/util/ASMifierUnitTest.java
deleted file mode 100644
index 3ba4e0f..0000000
--- a/asm4/test/conform/org/objectweb/asm/util/ASMifierUnitTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.util;
-
-import junit.framework.TestCase;
-
-/**
- * ASMifierClassVisitor unit tests
- *
- * @author Eric Bruneton
- */
-public class ASMifierUnitTest extends TestCase {
-
- public void testASMifierClassVisitor() throws Exception {
- String s = getClass().getName();
- ASMifier.main(new String[0]);
- ASMifier.main(new String[] { "-debug" });
- ASMifier.main(new String[] { s });
- ASMifier.main(new String[] { "-debug", s });
- ASMifier.main(new String[] { "output/test/cases/Interface.class" });
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/util/CheckClassAdapterTest.java b/asm4/test/conform/org/objectweb/asm/util/CheckClassAdapterTest.java
deleted file mode 100644
index 4a43e53..0000000
--- a/asm4/test/conform/org/objectweb/asm/util/CheckClassAdapterTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.util;
-
-import junit.framework.TestSuite;
-
-import org.objectweb.asm.AbstractTest;
-import org.objectweb.asm.ClassReader;
-import org.objectweb.asm.ClassWriter;
-
-/**
- * CheckClassAdapter tests.
- *
- * @author Eric Bruneton
- */
-public class CheckClassAdapterTest extends AbstractTest {
-
- public static TestSuite suite() throws Exception {
- return new CheckClassAdapterTest().getSuite();
- }
-
- @Override
- public void test() throws Exception {
- ClassReader cr = new ClassReader(is);
- ClassWriter cw = new ClassWriter(0);
- cr.accept(new CheckClassAdapter(cw), 0);
- assertEquals(cr, new ClassReader(cw.toByteArray()));
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/util/CheckClassAdapterUnitTest.java b/asm4/test/conform/org/objectweb/asm/util/CheckClassAdapterUnitTest.java
deleted file mode 100644
index 9e920a2..0000000
--- a/asm4/test/conform/org/objectweb/asm/util/CheckClassAdapterUnitTest.java
+++ /dev/null
@@ -1,887 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.util;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.HashMap;
-
-import junit.framework.TestCase;
-
-import org.objectweb.asm.AnnotationVisitor;
-import org.objectweb.asm.ClassReader;
-import org.objectweb.asm.ClassVisitor;
-import org.objectweb.asm.ClassWriter;
-import org.objectweb.asm.FieldVisitor;
-import org.objectweb.asm.Label;
-import org.objectweb.asm.MethodVisitor;
-import org.objectweb.asm.Opcodes;
-import org.objectweb.asm.attrs.Comment;
-
-public class CheckClassAdapterUnitTest extends TestCase implements Opcodes {
-
- public void testCheckClassVisitor() throws Exception {
- String s = getClass().getName();
- CheckClassAdapter.main(new String[0]);
- CheckClassAdapter.main(new String[] { s });
- CheckClassAdapter
- .main(new String[] { "output/test/cases/Interface.class" });
- }
-
- public void testVerifyValidClass() throws Exception {
- ClassReader cr = new ClassReader(getClass().getName());
- CheckClassAdapter.verify(cr, true, new PrintWriter(System.err));
- }
-
- public void testVerifyInvalidClass() {
- ClassWriter cw = new ClassWriter(0);
- cw.visit(V1_1, ACC_PUBLIC, "C", null, "java/lang/Object", null);
- MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "m", "()V", null, null);
- mv.visitCode();
- mv.visitVarInsn(ALOAD, 0);
- mv.visitVarInsn(ISTORE, 30);
- mv.visitInsn(RETURN);
- mv.visitMaxs(1, 31);
- mv.visitEnd();
- cw.visitEnd();
- ClassReader cr = new ClassReader(cw.toByteArray());
- CheckClassAdapter.verify(cr, true, new PrintWriter(System.err));
- }
-
- public void testIllegalClassAccessFlag() {
- ClassVisitor cv = new CheckClassAdapter(null);
- try {
- cv.visit(V1_1, 1 << 20, "C", null, "java/lang/Object", null);
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalSuperClass() {
- ClassVisitor cv = new CheckClassAdapter(null);
- try {
- cv.visit(V1_1, ACC_PUBLIC, "java/lang/Object", null,
- "java/lang/Object", null);
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalInterfaceSuperClass() {
- ClassVisitor cv = new CheckClassAdapter(null);
- try {
- cv.visit(V1_1, ACC_INTERFACE, "I", null, "C", null);
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalClassSignature() {
- ClassVisitor cv = new CheckClassAdapter(null);
- try {
- cv.visit(V1_1, ACC_PUBLIC, "C", "LC;I", "java/lang/Object", null);
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalClassAccessFlagSet() {
- ClassVisitor cv = new CheckClassAdapter(null);
- try {
- cv.visit(V1_1, ACC_FINAL + ACC_ABSTRACT, "C", null,
- "java/lang/Object", null);
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalClassMemberVisitBeforeStart() {
- ClassVisitor cv = new CheckClassAdapter(null);
- try {
- cv.visitSource(null, null);
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalClassAttribute() {
- ClassVisitor cv = new CheckClassAdapter(null);
- cv.visit(V1_1, ACC_PUBLIC, "C", null, "java/lang/Object", null);
- try {
- cv.visitAttribute(null);
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalMultipleVisitCalls() {
- ClassVisitor cv = new CheckClassAdapter(null);
- cv.visit(V1_1, ACC_PUBLIC, "C", null, "java/lang/Object", null);
- try {
- cv.visit(V1_1, ACC_PUBLIC, "C", null, "java/lang/Object", null);
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalMultipleVisitSourceCalls() {
- ClassVisitor cv = new CheckClassAdapter(null);
- cv.visit(V1_1, ACC_PUBLIC, "C", null, "java/lang/Object", null);
- cv.visitSource(null, null);
- try {
- cv.visitSource(null, null);
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalOuterClassName() {
- ClassVisitor cv = new CheckClassAdapter(null);
- cv.visit(V1_1, ACC_PUBLIC, "C", null, "java/lang/Object", null);
- try {
- cv.visitOuterClass(null, null, null);
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalMultipleVisitOuterClassCalls() {
- ClassVisitor cv = new CheckClassAdapter(null);
- cv.visit(V1_1, ACC_PUBLIC, "C", null, "java/lang/Object", null);
- cv.visitOuterClass("name", null, null);
- try {
- cv.visitOuterClass(null, null, null);
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalFieldAccessFlagSet() {
- ClassVisitor cv = new CheckClassAdapter(null);
- cv.visit(V1_1, ACC_PUBLIC, "C", null, "java/lang/Object", null);
- try {
- cv.visitField(ACC_PUBLIC + ACC_PRIVATE, "i", "I", null, null);
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalFieldSignature() {
- ClassVisitor cv = new CheckClassAdapter(null);
- cv.visit(V1_1, ACC_PUBLIC, "C", null, "java/lang/Object", null);
- try {
- cv.visitField(ACC_PUBLIC, "i", "I", "L;", null);
- fail();
- } catch (Exception e) {
- }
- try {
- cv.visitField(ACC_PUBLIC, "i", "I", "LC+", null);
- fail();
- } catch (Exception e) {
- }
- try {
- cv.visitField(ACC_PUBLIC, "i", "I", "LC;I", null);
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalClassMemberVisitAfterEnd() {
- ClassVisitor cv = new CheckClassAdapter(null);
- cv.visit(V1_1, ACC_PUBLIC, "C", null, "java/lang/Object", null);
- cv.visitEnd();
- try {
- cv.visitSource(null, null);
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalFieldMemberVisitAfterEnd() {
- FieldVisitor fv = new CheckFieldAdapter(null);
- fv.visitEnd();
- try {
- fv.visitAttribute(new Comment());
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalFieldAttribute() {
- FieldVisitor fv = new CheckFieldAdapter(null);
- try {
- fv.visitAttribute(null);
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalAnnotationDesc() {
- MethodVisitor mv = new CheckMethodAdapter(null);
- try {
- mv.visitParameterAnnotation(0, "'", true);
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalAnnotationName() {
- AnnotationVisitor av = new CheckAnnotationAdapter(null);
- try {
- av.visit(null, new Integer(0));
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalAnnotationValue() {
- AnnotationVisitor av = new CheckAnnotationAdapter(null);
- try {
- av.visit("name", new Object());
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalAnnotationEnumValue() {
- AnnotationVisitor av = new CheckAnnotationAdapter(null);
- try {
- av.visitEnum("name", "Lpkg/Enum;", null);
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalAnnotationValueAfterEnd() {
- AnnotationVisitor av = new CheckAnnotationAdapter(null);
- av.visitEnd();
- try {
- av.visit("name", new Integer(0));
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalMethodMemberVisitAfterEnd() {
- MethodVisitor mv = new CheckMethodAdapter(null);
- mv.visitEnd();
- try {
- mv.visitAttribute(new Comment());
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalMethodAttribute() {
- MethodVisitor mv = new CheckMethodAdapter(null);
- try {
- mv.visitAttribute(null);
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalMethodSignature() {
- ClassVisitor cv = new CheckClassAdapter(null);
- cv.visit(V1_1, ACC_PUBLIC, "C", null, "java/lang/Object", null);
- try {
- cv.visitMethod(ACC_PUBLIC, "m", "()V", "<T::LI.J<*+LA;>;>()V^LA;X",
- null);
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalMethodInsnVisitBeforeStart() {
- MethodVisitor mv = new CheckMethodAdapter(null);
- try {
- mv.visitInsn(NOP);
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalFrameType() {
- MethodVisitor mv = new CheckMethodAdapter(null);
- mv.visitCode();
- try {
- mv.visitFrame(123, 0, null, 0, null);
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalFrameLocalCount() {
- MethodVisitor mv = new CheckMethodAdapter(null);
- mv.visitCode();
- try {
- mv.visitFrame(F_SAME, 1, new Object[] { INTEGER }, 0, null);
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalFrameStackCount() {
- MethodVisitor mv = new CheckMethodAdapter(null);
- mv.visitCode();
- try {
- mv.visitFrame(F_SAME, 0, null, 1, new Object[] { INTEGER });
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalFrameLocalArray() {
- MethodVisitor mv = new CheckMethodAdapter(null);
- mv.visitCode();
- try {
- mv.visitFrame(F_APPEND, 1, new Object[0], 0, null);
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalFrameStackArray() {
- MethodVisitor mv = new CheckMethodAdapter(null);
- mv.visitCode();
- try {
- mv.visitFrame(F_SAME1, 0, null, 1, new Object[0]);
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalFrameValue() {
- MethodVisitor mv = new CheckMethodAdapter(null);
- mv.visitCode();
- try {
- mv.visitFrame(F_FULL, 1, new Object[] { "LC;" }, 0, null);
- fail();
- } catch (Exception e) {
- }
- try {
- mv.visitFrame(F_FULL, 1, new Object[] { new Integer(0) }, 0, null);
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalMethodInsn() {
- MethodVisitor mv = new CheckMethodAdapter(null);
- mv.visitCode();
- try {
- mv.visitInsn(-1);
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalByteInsnOperand() {
- MethodVisitor mv = new CheckMethodAdapter(null);
- mv.visitCode();
- try {
- mv.visitIntInsn(BIPUSH, Integer.MAX_VALUE);
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalShortInsnOperand() {
- MethodVisitor mv = new CheckMethodAdapter(null);
- mv.visitCode();
- try {
- mv.visitIntInsn(SIPUSH, Integer.MAX_VALUE);
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalVarInsnOperand() {
- MethodVisitor mv = new CheckMethodAdapter(null);
- mv.visitCode();
- try {
- mv.visitVarInsn(ALOAD, -1);
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalIntInsnOperand() {
- MethodVisitor mv = new CheckMethodAdapter(null);
- mv.visitCode();
- try {
- mv.visitIntInsn(NEWARRAY, 0);
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalTypeInsnOperand() {
- MethodVisitor mv = new CheckMethodAdapter(null);
- mv.visitCode();
- try {
- mv.visitTypeInsn(NEW, "[I");
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalLabelInsnOperand() {
- MethodVisitor mv = new CheckMethodAdapter(null);
- mv.visitCode();
- Label l = new Label();
- mv.visitLabel(l);
- try {
- mv.visitLabel(l);
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalDebugLabelUse() throws IOException {
- ClassReader cr = new ClassReader("java.lang.Object");
- ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_MAXS);
- ClassVisitor cv = new ClassVisitor(Opcodes.ASM4, cw) {
- @Override
- public MethodVisitor visitMethod(int access, String name,
- String desc, String signature, String[] exceptions) {
- final MethodVisitor next = cv.visitMethod(access, name, desc,
- signature, exceptions);
- if (next == null) {
- return next;
- }
- return new MethodVisitor(Opcodes.ASM4, new CheckMethodAdapter(
- next)) {
- private Label entryLabel = null;
-
- @Override
- public void visitLabel(Label label) {
- if (entryLabel == null) {
- entryLabel = label;
- }
- mv.visitLabel(label);
- }
-
- @Override
- public void visitMaxs(int maxStack, int maxLocals) {
- Label unwindhandler = new Label();
- mv.visitLabel(unwindhandler);
- mv.visitInsn(Opcodes.ATHROW); // rethrow
- mv.visitTryCatchBlock(entryLabel, unwindhandler,
- unwindhandler, null);
- mv.visitMaxs(maxStack, maxLocals);
- }
- };
- }
- };
- try {
- cr.accept(cv, ClassReader.EXPAND_FRAMES);
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalTableSwitchParameters1() {
- MethodVisitor mv = new CheckMethodAdapter(null);
- mv.visitCode();
- try {
- mv.visitTableSwitchInsn(1, 0, new Label(), new Label[0]);
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalTableSwitchParameters2() {
- MethodVisitor mv = new CheckMethodAdapter(null);
- mv.visitCode();
- try {
- mv.visitTableSwitchInsn(0, 1, null, new Label[0]);
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalTableSwitchParameters3() {
- MethodVisitor mv = new CheckMethodAdapter(null);
- mv.visitCode();
- try {
- mv.visitTableSwitchInsn(0, 1, new Label(), (Label[]) null);
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalTableSwitchParameters4() {
- MethodVisitor mv = new CheckMethodAdapter(null);
- mv.visitCode();
- try {
- mv.visitTableSwitchInsn(0, 1, new Label(), new Label[0]);
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalLookupSwitchParameters1() {
- MethodVisitor mv = new CheckMethodAdapter(null);
- mv.visitCode();
- try {
- mv.visitLookupSwitchInsn(new Label(), null, new Label[0]);
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalLookupSwitchParameters2() {
- MethodVisitor mv = new CheckMethodAdapter(null);
- mv.visitCode();
- try {
- mv.visitLookupSwitchInsn(new Label(), new int[0], null);
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalLookupSwitchParameters3() {
- MethodVisitor mv = new CheckMethodAdapter(null);
- mv.visitCode();
- try {
- mv.visitLookupSwitchInsn(new Label(), new int[0], new Label[1]);
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalFieldInsnNullOwner() {
- MethodVisitor mv = new CheckMethodAdapter(null);
- mv.visitCode();
- try {
- mv.visitFieldInsn(GETFIELD, null, "i", "I");
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalFieldInsnOwner() {
- MethodVisitor mv = new CheckMethodAdapter(null);
- mv.visitCode();
- try {
- mv.visitFieldInsn(GETFIELD, "-", "i", "I");
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalFieldInsnNullName() {
- MethodVisitor mv = new CheckMethodAdapter(null);
- mv.visitCode();
- try {
- mv.visitFieldInsn(GETFIELD, "C", null, "I");
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalFieldInsnName() {
- MethodVisitor mv = new CheckMethodAdapter(null);
- mv.visitCode();
- try {
- mv.visitFieldInsn(GETFIELD, "C", "-", "I");
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalFieldInsnName2() {
- MethodVisitor mv = new CheckMethodAdapter(null);
- mv.visitCode();
-
- try {
- mv.visitFieldInsn(GETFIELD, "C", "a-", "I");
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalFieldInsnNullDesc() {
- MethodVisitor mv = new CheckMethodAdapter(null);
- mv.visitCode();
- try {
- mv.visitFieldInsn(GETFIELD, "C", "i", null);
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalFieldInsnVoidDesc() {
- MethodVisitor mv = new CheckMethodAdapter(null);
- mv.visitCode();
- try {
- mv.visitFieldInsn(GETFIELD, "C", "i", "V");
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalFieldInsnPrimitiveDesc() {
- MethodVisitor mv = new CheckMethodAdapter(null);
- mv.visitCode();
- try {
- mv.visitFieldInsn(GETFIELD, "C", "i", "II");
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalFieldInsnArrayDesc() {
- MethodVisitor mv = new CheckMethodAdapter(null);
- mv.visitCode();
- try {
- mv.visitFieldInsn(GETFIELD, "C", "i", "[");
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalFieldInsnReferenceDesc() {
- MethodVisitor mv = new CheckMethodAdapter(null);
- mv.visitCode();
- try {
- mv.visitFieldInsn(GETFIELD, "C", "i", "L");
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalFieldInsnReferenceDesc2() {
- MethodVisitor mv = new CheckMethodAdapter(null);
- mv.visitCode();
- try {
- mv.visitFieldInsn(GETFIELD, "C", "i", "L-;");
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalMethodInsnNullName() {
- MethodVisitor mv = new CheckMethodAdapter(null);
- mv.visitCode();
- try {
- mv.visitMethodInsn(INVOKEVIRTUAL, "C", null, "()V");
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalMethodInsnName() {
- MethodVisitor mv = new CheckMethodAdapter(null);
- mv.visitCode();
- try {
- mv.visitMethodInsn(INVOKEVIRTUAL, "C", "-", "()V");
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalMethodInsnName2() {
- MethodVisitor mv = new CheckMethodAdapter(null);
- mv.visitCode();
- try {
- mv.visitMethodInsn(INVOKEVIRTUAL, "C", "a-", "()V");
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalMethodInsnNullDesc() {
- MethodVisitor mv = new CheckMethodAdapter(null);
- mv.visitCode();
- try {
- mv.visitMethodInsn(INVOKEVIRTUAL, "C", "m", null);
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalMethodInsnDesc() {
- MethodVisitor mv = new CheckMethodAdapter(null);
- mv.visitCode();
- try {
- mv.visitMethodInsn(INVOKEVIRTUAL, "C", "m", "I");
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalMethodInsnParameterDesc() {
- MethodVisitor mv = new CheckMethodAdapter(null);
- mv.visitCode();
- try {
- mv.visitMethodInsn(INVOKEVIRTUAL, "C", "m", "(V)V");
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalMethodInsnReturnDesc() {
- MethodVisitor mv = new CheckMethodAdapter(null);
- mv.visitCode();
- try {
- mv.visitMethodInsn(INVOKEVIRTUAL, "C", "m", "()VV");
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalLdcInsnOperand() {
- MethodVisitor mv = new CheckMethodAdapter(null);
- mv.visitCode();
- try {
- mv.visitLdcInsn(new Object());
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalMultiANewArrayDesc() {
- MethodVisitor mv = new CheckMethodAdapter(null);
- mv.visitCode();
- try {
- mv.visitMultiANewArrayInsn("I", 1);
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalMultiANewArrayDims() {
- MethodVisitor mv = new CheckMethodAdapter(null);
- mv.visitCode();
- try {
- mv.visitMultiANewArrayInsn("[[I", 0);
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalMultiANewArrayDims2() {
- MethodVisitor mv = new CheckMethodAdapter(null);
- mv.visitCode();
- try {
- mv.visitMultiANewArrayInsn("[[I", 3);
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalTryCatchBlock() {
- MethodVisitor mv = new CheckMethodAdapter(null);
- mv.visitCode();
- Label m = new Label();
- Label n = new Label();
- mv.visitLabel(m);
- try {
- mv.visitTryCatchBlock(m, n, n, null);
- fail();
- } catch (Exception e) {
- }
- try {
- mv.visitTryCatchBlock(n, m, n, null);
- fail();
- } catch (Exception e) {
- }
- try {
- mv.visitTryCatchBlock(n, n, m, null);
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalDataflow() {
- MethodVisitor mv = new CheckMethodAdapter(ACC_PUBLIC, "m", "(I)V",
- null, new HashMap<Label, Integer>());
- mv.visitCode();
- mv.visitVarInsn(ILOAD, 1);
- mv.visitInsn(IRETURN);
- mv.visitMaxs(1, 2);
- try {
- mv.visitEnd();
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalDataflobjectweb() {
- MethodVisitor mv = new CheckMethodAdapter(ACC_PUBLIC, "m", "(I)I",
- null, new HashMap<Label, Integer>());
- mv.visitCode();
- mv.visitInsn(RETURN);
- mv.visitMaxs(0, 2);
- try {
- mv.visitEnd();
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalLocalVariableLabels() {
- MethodVisitor mv = new CheckMethodAdapter(null);
- mv.visitCode();
- Label m = new Label();
- Label n = new Label();
- mv.visitLabel(n);
- mv.visitInsn(NOP);
- mv.visitLabel(m);
- try {
- mv.visitLocalVariable("i", "I", null, m, n, 0);
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalLineNumerLabel() {
- MethodVisitor mv = new CheckMethodAdapter(null);
- mv.visitCode();
- try {
- mv.visitLineNumber(0, new Label());
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalInsnVisitAfterEnd() {
- MethodVisitor mv = new CheckMethodAdapter(null);
- mv.visitCode();
- mv.visitMaxs(0, 0);
- try {
- mv.visitInsn(NOP);
- fail();
- } catch (Exception e) {
- }
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/util/CheckSignatureAdapterTest.java b/asm4/test/conform/org/objectweb/asm/util/CheckSignatureAdapterTest.java
deleted file mode 100644
index 9bd1161..0000000
--- a/asm4/test/conform/org/objectweb/asm/util/CheckSignatureAdapterTest.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.util;
-
-import junit.framework.TestSuite;
-
-import org.objectweb.asm.AbstractTest;
-import org.objectweb.asm.ClassReader;
-import org.objectweb.asm.ClassVisitor;
-import org.objectweb.asm.FieldVisitor;
-import org.objectweb.asm.MethodVisitor;
-import org.objectweb.asm.Opcodes;
-import org.objectweb.asm.signature.SignatureReader;
-import org.objectweb.asm.signature.SignatureWriter;
-
-/**
- * CheckSignatureAdapter tests.
- *
- * @author Eric Bruneton
- */
-public class CheckSignatureAdapterTest extends AbstractTest {
-
- public static TestSuite suite() throws Exception {
- return new CheckSignatureAdapterTest().getSuite();
- }
-
- @Override
- public void test() throws Exception {
- ClassReader cr = new ClassReader(is);
- cr.accept(new ClassVisitor(Opcodes.ASM4) {
- @Override
- public void visit(int version, int access, String name,
- String signature, String superName, String[] interfaces) {
- if (signature != null) {
- SignatureReader sr = new SignatureReader(signature);
- SignatureWriter sw = new SignatureWriter();
- sr.accept(new CheckSignatureAdapter(
- CheckSignatureAdapter.CLASS_SIGNATURE, sw));
- assertEquals(signature, sw.toString());
- }
- }
-
- @Override
- public FieldVisitor visitField(int access, String name,
- String desc, String signature, Object value) {
- if (signature != null) {
- SignatureReader sr = new SignatureReader(signature);
- SignatureWriter sw = new SignatureWriter();
- sr.acceptType(new CheckSignatureAdapter(
- CheckSignatureAdapter.TYPE_SIGNATURE, sw));
- assertEquals(signature, sw.toString());
- }
- return null;
- }
-
- @Override
- public MethodVisitor visitMethod(int access, String name,
- String desc, String signature, String[] exceptions) {
- if (signature != null) {
- SignatureReader sr = new SignatureReader(signature);
- SignatureWriter sw = new SignatureWriter();
- sr.accept(new CheckSignatureAdapter(
- CheckSignatureAdapter.METHOD_SIGNATURE, sw));
- assertEquals(signature, sw.toString());
- }
- return null;
- }
-
- }, 0);
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/util/CheckSignatureAdapterUnitTest.java b/asm4/test/conform/org/objectweb/asm/util/CheckSignatureAdapterUnitTest.java
deleted file mode 100644
index c134c67..0000000
--- a/asm4/test/conform/org/objectweb/asm/util/CheckSignatureAdapterUnitTest.java
+++ /dev/null
@@ -1,269 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.util;
-
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.objectweb.asm.signature.SignatureReader;
-import org.objectweb.asm.signature.SignatureVisitor;
-import org.objectweb.asm.signature.SignatureWriter;
-import org.objectweb.asm.util.TraceSignatureVisitorUnitTest.TestData;
-
-/**
- * CheckSignatureAdapter tests.
- *
- * @author Eric Bruneton
- */
-public class CheckSignatureAdapterUnitTest extends TestCase {
-
- public static TestSuite suite() {
- TestSuite suite = new TestSuite(
- CheckSignatureAdapterUnitTest.class.getName());
- for (int i = 0; i < TraceSignatureVisitorUnitTest.DATA.length; i++) {
- suite.addTest(new CheckSignatureAdapterUnitTest(new TestData(
- TraceSignatureVisitorUnitTest.DATA[i])));
- }
- suite.addTestSuite(CheckSignatureAdapterUnitTest.class);
- return suite;
- }
-
- private TestData data;
-
- private SignatureVisitor sv;
-
- public CheckSignatureAdapterUnitTest() {
- }
-
- private CheckSignatureAdapterUnitTest(final TestData data) {
- super("checkSignature");
- this.data = data;
- }
-
- public void checkSignature() {
- SignatureWriter wrt = new SignatureWriter();
- SignatureReader rdr = new SignatureReader(data.signature);
- switch (data.type) {
- case 'C':
- rdr.accept(new CheckSignatureAdapter(
- CheckSignatureAdapter.CLASS_SIGNATURE, wrt));
- break;
- case 'M':
- rdr.accept(new CheckSignatureAdapter(
- CheckSignatureAdapter.METHOD_SIGNATURE, wrt));
- break;
- case 'F':
- rdr.acceptType(new CheckSignatureAdapter(
- CheckSignatureAdapter.TYPE_SIGNATURE, wrt));
- break;
- default:
- return;
- }
- assertEquals(data.signature, wrt.toString());
- }
-
- public void testIllegalFormalTypeParam() {
- setup(CheckSignatureAdapter.TYPE_SIGNATURE);
- try {
- sv.visitFormalTypeParameter("T");
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalClassBound() {
- setup(CheckSignatureAdapter.CLASS_SIGNATURE);
- try {
- sv.visitClassBound();
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalInterfaceBound() {
- setup(CheckSignatureAdapter.CLASS_SIGNATURE);
- try {
- sv.visitInterfaceBound();
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalSuperclass() {
- setup(CheckSignatureAdapter.METHOD_SIGNATURE);
- try {
- sv.visitSuperclass();
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalInterface() {
- setup(CheckSignatureAdapter.CLASS_SIGNATURE);
- try {
- sv.visitInterface();
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalParameterType() {
- setup(CheckSignatureAdapter.CLASS_SIGNATURE);
- try {
- sv.visitParameterType();
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalReturnType() {
- setup(CheckSignatureAdapter.METHOD_SIGNATURE);
- try {
- sv.visitReturnType();
- sv.visitReturnType();
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalExceptionType() {
- setup(CheckSignatureAdapter.METHOD_SIGNATURE);
- try {
- sv.visitExceptionType();
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalBaseType() {
- setup(CheckSignatureAdapter.TYPE_SIGNATURE);
- try {
- sv.visitBaseType('I');
- sv.visitBaseType('I');
- fail();
- } catch (Exception e) {
- }
- setup(CheckSignatureAdapter.TYPE_SIGNATURE);
- try {
- sv.visitBaseType('V');
- fail();
- } catch (Exception e) {
- }
- setup(CheckSignatureAdapter.TYPE_SIGNATURE);
- try {
- sv.visitBaseType('A');
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalTypeVariable() {
- setup(CheckSignatureAdapter.TYPE_SIGNATURE);
- try {
- sv.visitTypeVariable("T");
- sv.visitTypeVariable("T");
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalArrayType() {
- setup(CheckSignatureAdapter.TYPE_SIGNATURE);
- try {
- sv.visitArrayType();
- sv.visitArrayType();
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalClassType() {
- setup(CheckSignatureAdapter.TYPE_SIGNATURE);
- try {
- sv.visitClassType("A");
- sv.visitClassType("A");
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalInnerClassType() {
- setup(CheckSignatureAdapter.TYPE_SIGNATURE);
- try {
- sv.visitInnerClassType("A");
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalTypeArgument() {
- setup(CheckSignatureAdapter.TYPE_SIGNATURE);
- try {
- sv.visitTypeArgument();
- fail();
- } catch (Exception e) {
- }
- setup(CheckSignatureAdapter.TYPE_SIGNATURE);
- try {
- sv.visitTypeArgument('+');
- fail();
- } catch (Exception e) {
- }
- setup(CheckSignatureAdapter.TYPE_SIGNATURE);
- try {
- sv.visitClassType("A");
- sv.visitTypeArgument('*');
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testIllegalEnd() {
- setup(CheckSignatureAdapter.TYPE_SIGNATURE);
- try {
- sv.visitEnd();
- fail();
- } catch (Exception e) {
- }
- }
-
- @Override
- public String getName() {
- if (data == null) {
- return super.getName();
- } else {
- return super.getName() + " " + data.signature;
- }
- }
-
- private void setup(int type) {
- sv = new CheckSignatureAdapter(type, null);
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/util/TraceClassAdapterTest.java b/asm4/test/conform/org/objectweb/asm/util/TraceClassAdapterTest.java
deleted file mode 100644
index 000690a..0000000
--- a/asm4/test/conform/org/objectweb/asm/util/TraceClassAdapterTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.util;
-
-import java.io.CharArrayWriter;
-import java.io.PrintWriter;
-
-import junit.framework.TestSuite;
-
-import org.objectweb.asm.AbstractTest;
-import org.objectweb.asm.Attribute;
-import org.objectweb.asm.ClassReader;
-import org.objectweb.asm.ClassVisitor;
-import org.objectweb.asm.ClassWriter;
-import org.objectweb.asm.attrs.CodeComment;
-import org.objectweb.asm.attrs.Comment;
-
-/**
- * CheckClassAdapter tests.
- *
- * @author Eric Bruneton
- */
-public class TraceClassAdapterTest extends AbstractTest {
-
- public static TestSuite suite() throws Exception {
- return new TraceClassAdapterTest().getSuite();
- }
-
- @Override
- public void test() throws Exception {
- ClassReader cr = new ClassReader(is);
- ClassWriter cw = new ClassWriter(0);
- ClassVisitor cv = new TraceClassVisitor(cw, new PrintWriter(
- new CharArrayWriter()));
- cr.accept(cv, new Attribute[] { new Comment(), new CodeComment() }, 0);
- assertEquals(cr, new ClassReader(cw.toByteArray()));
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/util/TraceClassAdapterUnitTest.java b/asm4/test/conform/org/objectweb/asm/util/TraceClassAdapterUnitTest.java
deleted file mode 100644
index b38ecfd..0000000
--- a/asm4/test/conform/org/objectweb/asm/util/TraceClassAdapterUnitTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.util;
-
-import junit.framework.TestCase;
-
-/**
- * TraceClassAdapter unit tests
- *
- * @author Eric Bruneton
- */
-public class TraceClassAdapterUnitTest extends TestCase {
-
- public void testTraceClassVisitor() throws Exception {
- String s = getClass().getName();
- Textifier.main(new String[0]);
- Textifier.main(new String[] { "-debug" });
- Textifier.main(new String[] { s });
- Textifier.main(new String[] { "-debug", s });
- Textifier.main(new String[] { "output/test/cases/Interface.class" });
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/util/TraceSignatureVisitorUnitTest.java b/asm4/test/conform/org/objectweb/asm/util/TraceSignatureVisitorUnitTest.java
deleted file mode 100644
index a7b1068..0000000
--- a/asm4/test/conform/org/objectweb/asm/util/TraceSignatureVisitorUnitTest.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.util;
-
-import java.util.StringTokenizer;
-
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.objectweb.asm.Opcodes;
-import org.objectweb.asm.signature.SignatureReader;
-
-/**
- * TraceSignatureVisitor unit tests.
- *
- * @author Eugene Kuleshov
- */
-public class TraceSignatureVisitorUnitTest extends TestCase {
-
- public final static String[] DATA = {
- "C|E|<E extends java.lang.Enum<E>> implements java.lang.Comparable<E>, java.io.Serializable"
- + "|<E:Ljava/lang/Enum<TE;>;>Ljava/lang/Object;Ljava/lang/Comparable<TE;>;Ljava/io/Serializable;",
-
- "C|I|<D extends java.lang.reflect.GenericDeclaration> extends java.lang.reflect.Type"
- + "|<D::Ljava/lang/reflect/GenericDeclaration;>Ljava/lang/Object;Ljava/lang/reflect/Type;",
-
- "C|C|<K, V> extends java.util.AbstractMap<K, V> implements java.util.concurrent.ConcurrentMap<K, V>, java.io.Serializable"
- + "|<K:Ljava/lang/Object;V:Ljava/lang/Object;>Ljava/util/AbstractMap<TK;TV;>;Ljava/util/concurrent/ConcurrentMap<TK;TV;>;Ljava/io/Serializable;",
-
- "C|C|<K extends java.lang.Enum<K>, V> extends java.util.AbstractMap<K, V> implements java.io.Serializable, java.lang.Cloneable"
- + "|<K:Ljava/lang/Enum<TK;>;V:Ljava/lang/Object;>Ljava/util/AbstractMap<TK;TV;>;Ljava/io/Serializable;Ljava/lang/Cloneable;",
-
- "F|C|java.lang.Class<?>|Ljava/lang/Class<*>;",
-
- "F|C|java.lang.reflect.Constructor<T>|Ljava/lang/reflect/Constructor<TT;>;",
-
- "F|C|T[]|[TT;",
-
- "F|C|java.util.Hashtable<?, ?>|Ljava/util/Hashtable<**>;",
-
- "F|C|java.util.concurrent.atomic.AtomicReferenceFieldUpdater<java.io.BufferedInputStream, byte[]>"
- + "|Ljava/util/concurrent/atomic/AtomicReferenceFieldUpdater<Ljava/io/BufferedInputStream;[B>;",
-
- "F|C|AA<byte[][]>|LAA<[[B>;",
-
- "F|C|AA<java.util.Map<java.lang.String, java.lang.String>[][]>"
- + "|LAA<[[Ljava/util/Map<Ljava/lang/String;Ljava/lang/String;>;>;",
-
- "F|C|java.util.Hashtable<java.lang.Object, java.lang.String>"
- + "|Ljava/util/Hashtable<Ljava/lang/Object;Ljava/lang/String;>;",
-
- "M|C|void(boolean, byte, char, short, int, float, long, double)"
- + "|(ZBCSIFJD)V",
-
- "M|C|void()E, F|()V^TE;^TF;",
-
- "M|C|java.lang.Class<? extends E><E extends java.lang.Class>()"
- + "|<E:Ljava/lang/Class;>()Ljava/lang/Class<+TE;>;",
-
- "M|C|java.lang.Class<? super E><E extends java.lang.Class>()"
- + "|<E:Ljava/lang/Class;>()Ljava/lang/Class<-TE;>;",
-
- "M|C|void(A<E>.B)|(LA<TE;>.B;)V",
-
- "M|C|void(A<E>.B<F>)|(LA<TE;>.B<TF;>;)V",
-
- "M|C|void(java.lang.String, java.lang.Class<?>, java.lang.reflect.Method[], java.lang.reflect.Method, java.lang.reflect.Method)"
- + "|(Ljava/lang/String;Ljava/lang/Class<*>;[Ljava/lang/reflect/Method;Ljava/lang/reflect/Method;Ljava/lang/reflect/Method;)V",
-
- "M|C|java.util.Map<java.lang.Object, java.lang.String>(java.lang.Object, java.util.Map<java.lang.Object, java.lang.String>)"
- + "|(Ljava/lang/Object;Ljava/util/Map<Ljava/lang/Object;Ljava/lang/String;>;)Ljava/util/Map<Ljava/lang/Object;Ljava/lang/String;>;",
-
- "M|C|java.util.Map<java.lang.Object, java.lang.String><T>(java.lang.Object, java.util.Map<java.lang.Object, java.lang.String>, T)"
- + "|<T:Ljava/lang/Object;>(Ljava/lang/Object;Ljava/util/Map<Ljava/lang/Object;Ljava/lang/String;>;TT;)Ljava/util/Map<Ljava/lang/Object;Ljava/lang/String;>;",
-
- "M|C|java.util.Map<java.lang.Object, java.lang.String><E, T extends java.lang.Comparable<E>>(java.lang.Object, java.util.Map<java.lang.Object, java.lang.String>, T)"
- + "|<E:Ljava/lang/Object;T::Ljava/lang/Comparable<TE;>;>(Ljava/lang/Object;Ljava/util/Map<Ljava/lang/Object;Ljava/lang/String;>;TT;)Ljava/util/Map<Ljava/lang/Object;Ljava/lang/String;>;", };
-
- public static TestSuite suite() {
- TestSuite suite = new TestSuite(
- TraceSignatureVisitorUnitTest.class.getName());
- for (int i = 0; i < DATA.length; i++) {
- suite.addTest(new TraceSignatureVisitorUnitTest(new TestData(
- DATA[i])));
- }
- return suite;
- }
-
- private TestData data;
-
- private TraceSignatureVisitorUnitTest(final TestData data) {
- super("testSignature");
- this.data = data;
- }
-
- public void testSignature() {
- TraceSignatureVisitor d = new TraceSignatureVisitor(data.access);
- SignatureReader r = new SignatureReader(data.signature);
-
- switch (data.type) {
- case 'C':
- r.accept(d);
- assertEquals(data.declaration, d.getDeclaration());
- break;
- case 'F':
- r.acceptType(d);
- assertEquals(data.declaration, d.getDeclaration());
- break;
- case 'M':
- r.accept(d);
- String fullMethodDeclaration = d.getReturnType()
- + d.getDeclaration()
- + (d.getExceptions() != null ? d.getExceptions() : "");
- assertEquals(data.declaration, fullMethodDeclaration);
- break;
- }
- }
-
- @Override
- public String getName() {
- return super.getName() + " " + data.signature;
- }
-
- public static class TestData {
-
- public final char type;
-
- public final int access;
-
- public final String declaration;
-
- public final String signature;
-
- public TestData(final String data) {
- StringTokenizer st = new StringTokenizer(data, "|");
- this.type = st.nextToken().charAt(0);
-
- String acc = st.nextToken();
- switch (acc.charAt(0)) {
- case 'E':
- this.access = Opcodes.ACC_ENUM;
- break;
- case 'I':
- this.access = Opcodes.ACC_INTERFACE;
- break;
- case 'A':
- this.access = Opcodes.ACC_ANNOTATION;
- break;
- default:
- this.access = 0;
- }
-
- this.declaration = st.nextToken();
- this.signature = st.nextToken();
- }
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/util/VerifyClassTest.java b/asm4/test/conform/org/objectweb/asm/util/VerifyClassTest.java
deleted file mode 100644
index b8a8684..0000000
--- a/asm4/test/conform/org/objectweb/asm/util/VerifyClassTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.util;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-
-import junit.framework.TestSuite;
-
-import org.objectweb.asm.AbstractTest;
-import org.objectweb.asm.ClassReader;
-
-/**
- * CheckClassAdapter tests.
- *
- * @author Eric Bruneton
- */
-public class VerifyClassTest extends AbstractTest {
-
- public static TestSuite suite() throws Exception {
- return new VerifyClassTest().getSuite();
- }
-
- @Override
- public void test() throws Exception {
- if (n.startsWith("pkg.")) {
- return;
- }
- ClassReader cr = new ClassReader(is);
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- CheckClassAdapter.verify(cr, false, pw);
- pw.close();
- String s = sw.toString();
- if (!s.isEmpty()) {
- System.out.println("In class: " + n);
- System.out.println(s);
- }
- assertTrue(s.isEmpty());
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/xml/ASMContentHandlerUnitTest.java b/asm4/test/conform/org/objectweb/asm/xml/ASMContentHandlerUnitTest.java
deleted file mode 100644
index 9d76f9d..0000000
--- a/asm4/test/conform/org/objectweb/asm/xml/ASMContentHandlerUnitTest.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.xml;
-
-import junit.framework.TestCase;
-
-import org.objectweb.asm.AnnotationVisitor;
-import org.objectweb.asm.ClassVisitor;
-import org.objectweb.asm.FieldVisitor;
-import org.objectweb.asm.MethodVisitor;
-import org.objectweb.asm.Opcodes;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.AttributesImpl;
-
-/**
- * ASMContentHandler unit tests
- *
- * @author Eric Bruneton
- */
-public class ASMContentHandlerUnitTest extends TestCase implements Opcodes {
-
- ASMContentHandler h;
-
- ClassVisitor cv;
-
- MethodVisitor mv;
-
- @Override
- protected void setUp() throws Exception {
- h = new ASMContentHandler(new ClassVisitor(Opcodes.ASM4) {
-
- AnnotationVisitor av = new AnnotationVisitor(Opcodes.ASM4) {
-
- @Override
- public AnnotationVisitor visitAnnotation(String name,
- String desc) {
- return this;
- }
-
- @Override
- public AnnotationVisitor visitArray(String name) {
- return this;
- }
- };
-
- @Override
- public AnnotationVisitor visitAnnotation(String desc,
- boolean visible) {
- return av;
- }
-
- @Override
- public FieldVisitor visitField(int access, String name,
- String desc, String signature, Object value) {
- return new FieldVisitor(Opcodes.ASM4) {
-
- @Override
- public AnnotationVisitor visitAnnotation(String desc,
- boolean visible) {
- return av;
- }
- };
- }
-
- @Override
- public MethodVisitor visitMethod(int access, String name,
- String desc, String signature, String[] exceptions) {
- return new MethodVisitor(Opcodes.ASM4) {
-
- @Override
- public AnnotationVisitor visitAnnotationDefault() {
- return av;
- }
-
- @Override
- public AnnotationVisitor visitAnnotation(String desc,
- boolean visible) {
- return av;
- }
-
- @Override
- public AnnotationVisitor visitParameterAnnotation(
- int parameter, String desc, boolean visible) {
- return av;
- }
- };
- }
- });
- cv = new SAXClassAdapter(h, true);
- cv.visit(V1_5, ACC_PUBLIC, "C", null, "java/lang/Object", null);
- }
-
- protected void methodSetUp() {
- mv = cv.visitMethod(0, "<init>", "()V", null, null);
- mv.visitCode();
- mv.visitVarInsn(ALOAD, 0);
- mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V");
- }
-
- public void testInvalidOpcode() {
- methodSetUp();
- AttributesImpl attrs = new AttributesImpl();
- try {
- h.startElement("", "opcode", "", attrs);
- h.endElement("", "opcode", "");
- fail();
- } catch (SAXException e) {
- }
- }
-
- public void testInvalidValueDescriptor() {
- methodSetUp();
- AttributesImpl attrs = new AttributesImpl();
- attrs.addAttribute("", "desc", "desc", "", "desc");
- attrs.addAttribute("", "cst", "cst", "", "");
- try {
- h.startElement("", "LDC", "", attrs);
- h.endElement("", "LDC", "");
- fail();
- } catch (SAXException e) {
- }
- }
-
- public void testInvalidValue() {
- methodSetUp();
- AttributesImpl attrs = new AttributesImpl();
- attrs.addAttribute("", "desc", "desc", "", "Ljava/lang/String;");
- attrs.addAttribute("", "cst", "cst", "", "\\");
- try {
- h.startElement("", "LDC", "", attrs);
- h.endElement("", "LDC", "");
- fail();
- } catch (SAXException e) {
- }
- }
-
- public void testEndDocument() {
- cv.visitEnd();
- try {
- h.endDocument();
- } catch (SAXException e) {
- }
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/xml/SAXAdapterTest.java b/asm4/test/conform/org/objectweb/asm/xml/SAXAdapterTest.java
deleted file mode 100644
index 3955a36..0000000
--- a/asm4/test/conform/org/objectweb/asm/xml/SAXAdapterTest.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/***
- * ASM XML Adapter
- * Copyright (c) 2004-2011, Eugene Kuleshov
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.xml;
-
-import java.io.ByteArrayOutputStream;
-
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.sax.SAXResult;
-import javax.xml.transform.sax.SAXTransformerFactory;
-import javax.xml.transform.sax.TransformerHandler;
-
-import junit.framework.TestSuite;
-
-import org.objectweb.asm.AbstractTest;
-import org.objectweb.asm.Attribute;
-import org.objectweb.asm.ClassReader;
-import org.objectweb.asm.ClassWriter;
-import org.objectweb.asm.Label;
-
-/**
- * SAXAdapter tests
- *
- * @author Eugene Kuleshov
- */
-public class SAXAdapterTest extends AbstractTest {
-
- public static TestSuite suite() throws Exception {
- return new SAXAdapterTest().getSuite();
- }
-
- @Override
- public void test() throws Exception {
- ClassReader cr = new ClassReader(is);
- ClassWriter cw = new ClassWriter(0);
-
- SAXTransformerFactory saxtf = (SAXTransformerFactory) TransformerFactory
- .newInstance();
- TransformerHandler handler = saxtf.newTransformerHandler();
- handler.setResult(new SAXResult(new ASMContentHandler(cw)));
- handler.startDocument();
- cr.accept(new SAXClassAdapter(handler, false), 0);
- handler.endDocument();
-
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- bos.write(cw.toByteArray());
-
- ClassWriter cw2 = new ClassWriter(0);
- cr.accept(cw2, new Attribute[] { new Attribute("Comment") {
- @Override
- protected Attribute read(final ClassReader cr, final int off,
- final int len, final char[] buf, final int codeOff,
- final Label[] labels) {
- return null; // skip these attributes
- }
- }, new Attribute("CodeComment") {
- @Override
- protected Attribute read(final ClassReader cr, final int off,
- final int len, final char[] buf, final int codeOff,
- final Label[] labels) {
- return null; // skip these attributes
- }
- } }, 0);
-
- assertEquals(new ClassReader(cw2.toByteArray()),
- new ClassReader(bos.toByteArray()));
- }
-}
diff --git a/asm4/test/conform/org/objectweb/asm/xml/SAXAdapterUnitTest.java b/asm4/test/conform/org/objectweb/asm/xml/SAXAdapterUnitTest.java
deleted file mode 100644
index 52703d5..0000000
--- a/asm4/test/conform/org/objectweb/asm/xml/SAXAdapterUnitTest.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/***
- * ASM tests
- * Copyright (c) 2000-2011 INRIA, France Telecom
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.objectweb.asm.xml;
-
-import junit.framework.TestCase;
-
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.DefaultHandler;
-
-/**
- * SAXAdapter unit tests
- *
- * @author Eric Bruneton
- */
-public class SAXAdapterUnitTest extends TestCase {
-
- SAXAdapter sa;
-
- @Override
- protected void setUp() {
- sa = new SAXAdapter(new DefaultHandler() {
-
- @Override
- public void startDocument() throws SAXException {
- throw new SAXException();
- }
-
- @Override
- public void endDocument() throws SAXException {
- throw new SAXException();
- }
-
- @Override
- public void startElement(final String arg0, final String arg1,
- final String arg2, final Attributes arg3)
- throws SAXException {
- throw new SAXException();
- }
-
- @Override
- public void endElement(final String arg0, final String arg1,
- final String arg2) throws SAXException {
- throw new SAXException();
- }
- }) {
- };
- }
-
- public void testInvalidAddDocumentStart() {
- try {
- sa.addDocumentStart();
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testInvalidAddDocumentEnd() {
- try {
- sa.addDocumentEnd();
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testInvalidAddStart() {
- try {
- sa.addStart("name", null);
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testInvalidAddEnd() {
- try {
- sa.addEnd("name");
- fail();
- } catch (Exception e) {
- }
- }
-}