]> source.dussan.org Git - aspectj.git/commitdiff
Updated with a simple erasure test case - will need more later!
authoraclement <aclement>
Tue, 14 Jun 2005 15:17:16 +0000 (15:17 +0000)
committeraclement <aclement>
Tue, 14 Jun 2005 15:17:16 +0000 (15:17 +0000)
bcel-builder/testdata/ErasureTestData.java [new file with mode: 0644]
bcel-builder/testdata/testcode.jar
bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/AllTests.java
bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/GenericsErasureTesting.java [new file with mode: 0644]

diff --git a/bcel-builder/testdata/ErasureTestData.java b/bcel-builder/testdata/ErasureTestData.java
new file mode 100644 (file)
index 0000000..493f59a
--- /dev/null
@@ -0,0 +1,7 @@
+import java.util.*;
+
+public class ErasureTestData {
+
+  public Vector<String> getData() { return null; }
+
+}
index d954f728a1d02c0dd032735e74982b863ec87c3b..884ed866fd65ab5421e60f4962affe8275db6fa9 100644 (file)
Binary files a/bcel-builder/testdata/testcode.jar and b/bcel-builder/testdata/testcode.jar differ
index ff170ab07239d14dcd8934ac1602cd770a00ce09..f7ef2ab46edaa8fb0f7798adf0216eed1a4a1c45 100644 (file)
@@ -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 (file)
index 0000000..3788322
--- /dev/null
@@ -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;
+       }
+       
+}