diff options
author | aclement <aclement> | 2005-06-14 15:17:16 +0000 |
---|---|---|
committer | aclement <aclement> | 2005-06-14 15:17:16 +0000 |
commit | d494f7fd436543dc3cf052f289220a9d2156f110 (patch) | |
tree | 917ba8a4e5f9fb2a138fc5f8dcd4819bcc940173 | |
parent | bdfe1316585fb6697eba3beeef0095bc9039371a (diff) | |
download | aspectj-d494f7fd436543dc3cf052f289220a9d2156f110.tar.gz aspectj-d494f7fd436543dc3cf052f289220a9d2156f110.zip |
Updated with a simple erasure test case - will need more later!
-rw-r--r-- | bcel-builder/testdata/ErasureTestData.java | 7 | ||||
-rw-r--r-- | bcel-builder/testdata/testcode.jar | bin | 16370 -> 16210 bytes | |||
-rw-r--r-- | bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/AllTests.java | 1 | ||||
-rw-r--r-- | bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/GenericsErasureTesting.java | 50 |
4 files changed, 58 insertions, 0 deletions
diff --git a/bcel-builder/testdata/ErasureTestData.java b/bcel-builder/testdata/ErasureTestData.java new file mode 100644 index 000000000..493f59a14 --- /dev/null +++ b/bcel-builder/testdata/ErasureTestData.java @@ -0,0 +1,7 @@ +import java.util.*; + +public class ErasureTestData { + + public Vector<String> getData() { return null; } + +} diff --git a/bcel-builder/testdata/testcode.jar b/bcel-builder/testdata/testcode.jar Binary files differindex d954f728a..884ed866f 100644 --- a/bcel-builder/testdata/testcode.jar +++ b/bcel-builder/testdata/testcode.jar diff --git a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/AllTests.java b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/AllTests.java index ff170ab07..f7ef2ab46 100644 --- a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/AllTests.java +++ b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/AllTests.java @@ -50,6 +50,7 @@ public class AllTests { suite.addTestSuite(TypeAnnotationsTest.class); suite.addTestSuite(UtilTests.class); suite.addTestSuite(GenericSignatureParsingTest.class); + suite.addTestSuite(GenericsErasureTesting.class); //$JUnit-END$ return suite; } diff --git a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/GenericsErasureTesting.java b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/GenericsErasureTesting.java new file mode 100644 index 000000000..37883221d --- /dev/null +++ b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/GenericsErasureTesting.java @@ -0,0 +1,50 @@ +/* ******************************************************************* + * Copyright (c) 2005 Contributors + * All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Common Public License v1.0 + * which accompanies this distribution and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * Andy Clement (IBM) initial implementation + * ******************************************************************/ +package org.aspectj.apache.bcel.classfile.tests; + +import org.aspectj.apache.bcel.classfile.Attribute; +import org.aspectj.apache.bcel.classfile.JavaClass; +import org.aspectj.apache.bcel.classfile.Method; +import org.aspectj.apache.bcel.classfile.Signature; + +/** + * Should be possible to recover original declared signatures after erasure by using + * the signature attribute. + */ +public class GenericsErasureTesting extends BcelTestCase { + + + public void testLoadingGenerics() throws ClassNotFoundException { + JavaClass clazz = getClassFromJar("ErasureTestData"); + Method m = getMethod(clazz,"getData"); + String sig = m.getDeclaredSignature(); + System.err.println(getSignatureAttribute(clazz,"getData")); + System.err.println(sig); + assertTrue("Incorrect: "+sig,sig.equals("()Ljava/util/Vector<Ljava/lang/String;>;")); + } + + + // helper methods below + + public Signature getSignatureAttribute(JavaClass clazz,String name) { + Method m = getMethod(clazz,name); + Attribute[] as = m.getAttributes(); + for (int i = 0; i < as.length; i++) { + Attribute attribute = as[i]; + if (attribute.getName().equals("Signature")) { + return (Signature)attribute; + } + } + return null; + } + +} |