Browse Source

Fix 486612: Can lose a super type bound when weaving a type using generics in its declaration

tags/V1_8_9
Andy Clement 8 years ago
parent
commit
4bee355d22

+ 8
- 6
org.aspectj.matcher/src/org/aspectj/weaver/TypeVariable.java View 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++) {

+ 7
- 0
tests/bugs189/486612/Azpect.java View File

@@ -0,0 +1,7 @@
aspect Azpect {
declare parents: B implements I;
declare parents: D implements I;
before(): staticinitialization(!Azpect){}
}

interface I {}

+ 17
- 0
tests/bugs189/486612/Code.java View File

@@ -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> {}

+ 13
- 3
tests/src/org/aspectj/systemtest/ajc189/Ajc189Tests.java View 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");
// }
// ---


+ 0
- 0
tests/src/org/aspectj/systemtest/ajc189/ajc189.out.xml View File


+ 5
- 0
tests/src/org/aspectj/systemtest/ajc189/ajc189.xml View 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>

Loading…
Cancel
Save