]> source.dussan.org Git - aspectj.git/commitdiff
test and fix for first part of 126355
authoraclement <aclement>
Tue, 23 May 2006 10:37:22 +0000 (10:37 +0000)
committeraclement <aclement>
Tue, 23 May 2006 10:37:22 +0000 (10:37 +0000)
tests/bugs152/pr126355/Pair.java [new file with mode: 0644]
tests/bugs152/pr126355/Test.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc152/Ajc152Tests.java
tests/src/org/aspectj/systemtest/ajc152/ajc152.xml
weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java
weaver/src/org/aspectj/weaver/bcel/LazyClassGen.java

diff --git a/tests/bugs152/pr126355/Pair.java b/tests/bugs152/pr126355/Pair.java
new file mode 100644 (file)
index 0000000..385b403
--- /dev/null
@@ -0,0 +1,7 @@
+public class Pair<F, S> {
+    public Pair(F first, S second) { }
+}
+
+aspect IdempotentCache pertarget(cached()) {
+    pointcut cached(): execution(public * *(..)) && within(Pair);
+}
diff --git a/tests/bugs152/pr126355/Test.java b/tests/bugs152/pr126355/Test.java
new file mode 100644 (file)
index 0000000..a87128f
--- /dev/null
@@ -0,0 +1,5 @@
+public class Test {
+       public static void main (String args[]) {
+               Pair<String,String> pair = new Pair<String,String>("one","two");
+       }
+}
index 1105d823555142d217648c790b8545f23a7d1b66..230564f072a7fcc42c891d3de8941ede79f98cf2 100644 (file)
@@ -17,6 +17,7 @@ import org.aspectj.testing.XMLBasedAjcTestCase;
 
 public class Ajc152Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
 
+  public void testFunkyGenericErrorWithITDs_pr126355() { runTest("bizarre generic error with itds");}
   public void testConcretizingAbstractMethods_pr142466() { runTest("aop.xml aspect inheriting but not concretizing abstract method");}
   public void testConcretizingAbstractMethods_pr142466_2() { runTest("aop.xml aspect inheriting but not concretizing abstract method - 2");}
   public void testComplexGenericDecl_pr137568() { runTest("complicated generics declaration");}
@@ -69,6 +70,12 @@ public class Ajc152Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
   public void testJarChecking_pr137235_2() { runTest("directory with .jar extension"); }
   public void testMakePreMethodNPE_pr136393() { runTest("NPE in makePreMethod");}
 
+//  public void testFunkyGenericErrorWithITDs_pr126355_2() { 
+//       runTest("bizarre generic error with itds - 2");
+//       // public class Pair<F,S> affected by pertarget aspect
+//       GenericsTests.verifyClassSignature(ajc,"Pair","<F:Ljava/lang/Object;S:Ljava/lang/Object;>Ljava/lang/Object;LIdempotentCache$ajcMightHaveAspect;;");
+//  }
+
   // tests that can't be included for some reason
 
   // Not valid whilst the ajc compiler forces debug on (ignores -g:none) - it will be green but is invalid, trust me
index 64857100deab3804eaefcc29b04a22459cf71e1f..18111ec69b2ef63e35a13113898871e83b776327 100644 (file)
       </run>
     </ajc-test>
 
+       <ajc-test dir="bugs152/pr126355" title="bizarre generic error with itds">
+     <compile files="Pair.java" options="-1.5"/>
+     <compile files="Test.java" options="-1.5"/>
+    </ajc-test>
+    
+       <ajc-test dir="bugs152/pr126355" title="bizarre generic error with itds - 2">
+     <compile files="Pair.java" options="-1.5"/>
+     <compile files="Test.java" options="-1.5"/>
+    </ajc-test>
+
     <ajc-test dir="bugs152/pr132349" title="ITD on inner type of generic type">
      <compile files="TopLevelType.java" options="-1.5"/>
      <run class="TopLevelType"/>
index d48eaa8f834d57d354db24286f4ceca6a62c3388..d352731cda38a2f0c58770d66ae659d790c4e6cd 100644 (file)
@@ -480,12 +480,19 @@ public class BcelObjectType extends AbstractReferenceTypeDelegate {
                        superClass = newParent;
                } else {
                        ResolvedType[] oldInterfaceNames = getDeclaredInterfaces();
-                       int len = oldInterfaceNames.length;
-                       ResolvedType[] newInterfaceNames = new ResolvedType[len+1];
-                       System.arraycopy(oldInterfaceNames, 0, newInterfaceNames, 0, len);
-                       newInterfaceNames[len] = newParent;
-                       
-                       interfaces = newInterfaceNames;
+                       int exists = -1;
+                       for (int i = 0; i < oldInterfaceNames.length; i++) {
+                               ResolvedType type = oldInterfaceNames[i];
+                               if (type.equals(newParent)) {exists = i;break; }
+                       }
+                       if (exists==-1) {
+                               int len = oldInterfaceNames.length;
+                               ResolvedType[] newInterfaceNames = new ResolvedType[len+1];
+                               System.arraycopy(oldInterfaceNames, 0, newInterfaceNames, 0, len);
+                               newInterfaceNames[len] = newParent;
+                               
+                               interfaces = newInterfaceNames;
+                       }
                }
                //System.err.println("javaClass: " + Arrays.asList(javaClass.getInterfaceNames()) + " super " + superclassName);
                //if (lazyClassGen != null) lazyClassGen.print();
index 6533ea1312d19ef0605c64b23076a5a9d5783e9d..f03a1c835e068c275ed0a36cd52f6c677eddcd3c 100644 (file)
@@ -581,7 +581,6 @@ public final class LazyClassGen {
                                signature.append("<");
                                for (int i = 0; i < tVars.length; i++) {
                                        TypeVariable variable = tVars[i];
-                                       if (i!=0) signature.append(",");
                                        signature.append(variable.getSignature());
                                }
                                signature.append(">");