]> source.dussan.org Git - aspectj.git/commitdiff
Fix 486612: Can lose a super type bound when weaving a type using generics in its...
authorAndy Clement <aclement@pivotal.io>
Wed, 27 Jan 2016 19:49:38 +0000 (11:49 -0800)
committerAndy Clement <aclement@pivotal.io>
Wed, 27 Jan 2016 19:49:38 +0000 (11:49 -0800)
org.aspectj.matcher/src/org/aspectj/weaver/TypeVariable.java
tests/bugs189/486612/Azpect.java [new file with mode: 0644]
tests/bugs189/486612/Code.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc189/Ajc189Tests.java
tests/src/org/aspectj/systemtest/ajc189/ajc189.out.xml [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc189/ajc189.xml

index 2e0409bc90888bb5b25c25683045c9ddc8f26c7f..d67bbd8dca3c156c32283e233ee1f0f3ac5072bd 100644 (file)
@@ -151,9 +151,9 @@ public class TypeVariable {
 
                if (superclass != null) {
                        ResolvedType rt = superclass.resolve(world);
-                       // if (!superclass.isTypeVariableReference() && rt.isInterface()) {
-                       // throw new IllegalStateException("Why is the type an interface? " + rt);
-                       // }
+//                      if (!superclass.isTypeVariableReference() && rt.isInterface()) {
+//                              throw new IllegalStateException("Why is the type an interface? " + rt);
+//                      }
                        superclass = rt;
                }
                firstbound = getFirstBound().resolve(world);
@@ -254,7 +254,9 @@ public class TypeVariable {
                StringBuffer sb = new StringBuffer();
                sb.append(name);
                sb.append(":");
-               sb.append(superclass.getSignature());
+               if (superInterfaces.length == 0 || !superclass.getSignature().equals(UnresolvedType.OBJECT.getSignature())) {
+                       sb.append(superclass.getSignature());
+               }
                if (superInterfaces.length != 0) {
                        for (int i = 0; i < superInterfaces.length; i++) {
                                sb.append(":");
@@ -272,8 +274,8 @@ public class TypeVariable {
                StringBuffer sb = new StringBuffer();
                sb.append(name);
                sb.append(":");
-               if (superInterfaces.length == 0) {
-                       sb.append(((ResolvedType) superclass).getSignatureForAttribute());
+               if (superInterfaces.length == 0 || !superclass.getSignature().equals(UnresolvedType.OBJECT.getSignature())) {
+                       sb.append(((ReferenceType)superclass).getSignatureForAttribute());
                }
                if (superInterfaces.length != 0) {
                        for (int i = 0; i < superInterfaces.length; i++) {
diff --git a/tests/bugs189/486612/Azpect.java b/tests/bugs189/486612/Azpect.java
new file mode 100644 (file)
index 0000000..e5a1ba3
--- /dev/null
@@ -0,0 +1,7 @@
+aspect Azpect {
+ declare parents: B implements I;
+ declare parents: D implements I;
+  before(): staticinitialization(!Azpect){}
+}
+
+interface I {}
diff --git a/tests/bugs189/486612/Code.java b/tests/bugs189/486612/Code.java
new file mode 100644 (file)
index 0000000..089d932
--- /dev/null
@@ -0,0 +1,17 @@
+import java.io.*;
+
+public class Code {
+  public static void main(String []argv) {
+  }
+}
+
+class B<T extends SomeClass & SomeInterface> extends C<T> implements Serializable {
+}
+
+class C<T> {}
+
+class SomeClass {}
+interface SomeInterface {}
+interface SomeOtherInterface {}
+
+class D<T extends SomeInterface&SomeOtherInterface> {}
index 9d5206c4be91d3f31ea72f985d84f9cfe2b61679..138787853b69619c3c8e245a0b3f62b2098cbf2d 100644 (file)
@@ -14,6 +14,7 @@ import java.io.File;
 
 import junit.framework.Test;
 
+import org.aspectj.apache.bcel.classfile.JavaClass;
 import org.aspectj.testing.XMLBasedAjcTestCase;
 
 /**
@@ -21,13 +22,22 @@ import org.aspectj.testing.XMLBasedAjcTestCase;
  */
 public class Ajc189Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
 
+       public void testLostBounds() throws Exception {
+               runTest("lost bounds");
+               // This type has I added via declare parents
+               JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), "B");
+               assertEquals("<T:LSomeClass;:LSomeInterface;>LC<TT;>;Ljava/io/Serializable;LI;",jc.getGenericSignature());
+               jc = getClassFrom(ajc.getSandboxDirectory(), "D");
+               assertEquals("<T::LSomeInterface;:LSomeOtherInterface;>Ljava/lang/Object;LI;",jc.getGenericSignature());
+       }
+       
        public void testWhileNPE_486203() throws Exception {
                runTest("while npe");
        }
        
-       public void testOverweaving_352389() throws Exception {
-               runTest("overweaving");
-       }
+//     public void testOverweaving_352389() throws Exception {
+//             runTest("overweaving");
+//     }
        
        // ---
 
diff --git a/tests/src/org/aspectj/systemtest/ajc189/ajc189.out.xml b/tests/src/org/aspectj/systemtest/ajc189/ajc189.out.xml
new file mode 100644 (file)
index 0000000..e69de29
index d9b2b42263297a8da89e3282475982ecaddbfb0a..594f7f11d8794b92c556f6c921f4bcc3b3969dfa 100644 (file)
@@ -2,6 +2,11 @@
 
 <suite>
 
+<ajc-test dir="bugs189/486612" title="lost bounds">
+  <compile files="Code.java Azpect.java" options="-1.8"/>
+</ajc-test>
+
+
 <ajc-test dir="bugs189/486203" title="while npe">
 <compile files="While.java" options="-1.8"/>
 </ajc-test>