import java.util.List; | |||||
public interface A<T extends BaseT, I extends BaseI> { | |||||
public T setInputs(List<I> inputs); | |||||
} |
import java.util.List; | |||||
public class AlreadyImplementsA { | |||||
public ConcreteTImpl setInputs(List<ConcreteIImpl> inputs) { | |||||
return null; | |||||
} | |||||
} |
public interface BaseI { | |||||
} |
public interface BaseT { | |||||
} |
public aspect BindInterfaceA { | |||||
declare parents: AlreadyImplementsA implements A<ConcreteTImpl,ConcreteIImpl>; | |||||
} |
public class ConcreteIImpl implements BaseI { | |||||
} |
public class ConcreteTImpl implements BaseT { | |||||
} |
public class Runner { | |||||
public static void main(String[] argv) { | |||||
if (new AlreadyImplementsA() instanceof A) { | |||||
System.out.println("ok"); | |||||
} | |||||
} | |||||
} |
// public Outer<String>.Inner m2() { ... } | // public Outer<String>.Inner m2() { ... } | ||||
} | } | ||||
// | // | ||||
// public void testMultiArgs_509235() { | // public void testMultiArgs_509235() { | ||||
// runTest("multiargs"); | // runTest("multiargs"); | ||||
// runTest("multiargs - no ellipsis"); | // runTest("multiargs - no ellipsis"); | ||||
// } | // } | ||||
// 1.8.13: | |||||
public void testAjcGenerics() { | |||||
runTest("generics"); | |||||
} | |||||
// --- | // --- | ||||
public static Test suite() { | public static Test suite() { |
<compile options="-1.8" files="Code.java"/> | <compile options="-1.8" files="Code.java"/> | ||||
</ajc-test> | </ajc-test> | ||||
<ajc-test dir="bugs1813/generics" title="generics"> | |||||
<!-- this order works reliably --> | |||||
<compile options="-1.8 -showWeaveInfo" files="A.java AlreadyImplementsA.java BaseI.java BaseT.java BindInterfaceA.aj ConcreteIImpl.java ConcreteTImpl.java Runner.java"> | |||||
<message kind="weave" text="Extending interface set for type 'AlreadyImplementsA' (AlreadyImplementsA.java) to include 'A<ConcreteTImpl,ConcreteIImpl>' (BindInterfaceA.aj)"/> | |||||
</compile> | |||||
<!-- this order was failing --> | |||||
<compile options="-1.8 -showWeaveInfo" files="AlreadyImplementsA.java BaseI.java BaseT.java BindInterfaceA.aj ConcreteIImpl.java ConcreteTImpl.java A.java Runner.java "> | |||||
<message kind="weave" text="Extending interface set for type 'AlreadyImplementsA' (AlreadyImplementsA.java) to include 'A<ConcreteTImpl,ConcreteIImpl>' (BindInterfaceA.aj)"/> | |||||
</compile> | |||||
<run class="Runner"> | |||||
<stdout> | |||||
<line text="ok"/> | |||||
</stdout> | |||||
</run> | |||||
</ajc-test> | |||||
<ajc-test dir="bugs1811/509235" title="multiargs"> | <ajc-test dir="bugs1811/509235" title="multiargs"> | ||||
<compile options="-1.8" files="Code.java"/> | <compile options="-1.8" files="Code.java"/> | ||||
<run class="Code"> | <run class="Code"> |
&& targetMethod.getBackingGenericMember().getParameterSignature().equals(newParentMethodSig)) { | && targetMethod.getBackingGenericMember().getParameterSignature().equals(newParentMethodSig)) { | ||||
discoveredImpl = targetMethod; | discoveredImpl = targetMethod; | ||||
} else if (newParentMethod.hasBackingGenericMember()) { | } else if (newParentMethod.hasBackingGenericMember()) { | ||||
if (newParentMethod.getBackingGenericMember().getParameterSignature().equals(targetMethodSignature)) { | |||||
if (newParentMethod.getBackingGenericMember().getParameterSignature().equals(targetMethodSignature)) { // newParentMethod.getBackingGenericMember().getParameterSignature gives: (Pjava/util/List<TI;>;) targetMethodSignature= (Ljava/util/List;) | |||||
discoveredImpl = targetMethod; | discoveredImpl = targetMethod; | ||||
} else if (targetMethod instanceof BcelMethod) { | |||||
// BcelMethod does not have backing generic member set (need to investigate why). For now, special case here: | |||||
UnresolvedType[] targetMethodGenericParameterTypes = targetMethod.getGenericParameterTypes(); | |||||
if (targetMethodGenericParameterTypes !=null) { | |||||
StringBuilder b = new StringBuilder("("); | |||||
for (UnresolvedType p: targetMethodGenericParameterTypes) { | |||||
b.append(p.getSignature()); | |||||
} | |||||
b.append(')'); | |||||
if (b.toString().equals(newParentMethodSig)) { | |||||
discoveredImpl = targetMethod; | |||||
} | |||||
} | |||||
} | } | ||||
} | } | ||||
} | } |