Community
Participate
Working Groups
When I compile the following code examples with the spring-aspect aspect, compile fails: github project is at: https://github.com/michaelwiles/aspectj-bug Fail example: public class FailsApectJ { private <T> Function<String, Collection<String>> ASpectJFailWithWildCardAndVarArgeMethodReference() { Function<T, ? extends Object> x = a -> a; // the wild card fails the compile x.andThen(this::get); return null; } private <T> List<T> get(T... args) { return Arrays.asList(args); } } Pass Example: private <T> Function<String, Collection<String>> noWildCardWithVarArgsMethodReference() { Function<T, Object> x = a -> a; // no wild card - passes x.andThen(this::get); return null; } private <T> List<T> get(T... args) { return Arrays.asList(args); } private <T> Function<String, Collection<String>> wildCardWithVarArgsNoMethodReference() { Function<T, ? extends Object> x = a -> a; // no wild card - passes x.andThen(t -> get(t)); return null; } Fails when there is a wild card, a var args and a method reference. You can checkout the github project to replicate the issue. Comments: The only aspect that I've found that exhibits the behaviour is the spring-aspect - I run a few others but none of them have the issue. So I'm not entirely sure exactly what pointcut or other exposes it. The stack trace I get is: [ERROR] abort trouble in: [ERROR] com.afrozaar.aspectj.test.FailsApectJ -- (IllegalStateException) Expecting [,L, or T, but found !Ljava while unpacking (!+Ljava/lang/Object;)Ljava/util/List<!+Ljava/lang/Object;>; [ERROR] Expecting [,L, or T, but found !Ljava while unpacking (!+Ljava/lang/Object;)Ljava/util/List<!+Ljava/lang/Object;>; [ERROR] java.lang.IllegalStateException: Expecting [,L, or T, but found !Ljava while unpacking (!+Ljava/lang/Object;)Ljava/util/List<!+Ljava/lang/Object;>; [ERROR] at org.aspectj.util.GenericSignatureParser.parseFieldTypeSignature(GenericSignatureParser.java:159) [ERROR] at org.aspectj.util.GenericSignatureParser.parseTypeArgument(GenericSignatureParser.java:251) [ERROR] at org.aspectj.util.GenericSignatureParser.maybeParseTypeArguments(GenericSignatureParser.java:259) [ERROR] at org.aspectj.util.GenericSignatureParser.parseClassTypeSignature(GenericSignatureParser.java:204) [ERROR] at org.aspectj.util.GenericSignatureParser.parseFieldTypeSignature(GenericSignatureParser.java:155) [ERROR] at org.aspectj.util.GenericSignatureParser.parseAsMethodSignature(GenericSignatureParser.java:99) [ERROR] at org.aspectj.weaver.bcel.BcelMethod.unpackGenericSignature(BcelMethod.java:565) [ERROR] at org.aspectj.weaver.bcel.BcelMethod.getGenericReturnType(BcelMethod.java:544) [ERROR] at org.aspectj.weaver.JoinPointSignature.getGenericReturnType(JoinPointSignature.java:191) [ERROR] at org.aspectj.weaver.patterns.SignaturePattern.matchesExactlyMethod(SignaturePattern.java:507) [ERROR] at org.aspectj.weaver.patterns.SignaturePattern.matchesExactly(SignaturePattern.java:360) [ERROR] at org.aspectj.weaver.patterns.SignaturePattern.matches(SignaturePattern.java:320) [ERROR] at org.aspectj.weaver.patterns.KindedPointcut.matchInternal(KindedPointcut.java:197) [ERROR] at org.aspectj.weaver.patterns.Pointcut.match(Pointcut.java:137) [ERROR] at org.aspectj.weaver.patterns.AndPointcut.matchInternal(AndPointcut.java:56) [ERROR] at org.aspectj.weaver.patterns.Pointcut.match(Pointcut.java:137) [ERROR] at org.aspectj.weaver.patterns.OrPointcut.matchInternal(OrPointcut.java:56) [ERROR] at org.aspectj.weaver.patterns.Pointcut.match(Pointcut.java:137) [ERROR] at org.aspectj.weaver.ShadowMunger.match(ShadowMunger.java:113) [ERROR] at org.aspectj.weaver.Advice.match(Advice.java:109) [ERROR] at org.aspectj.weaver.bcel.BcelAdvice.match(BcelAdvice.java:152) [ERROR] at org.aspectj.weaver.bcel.BcelClassWeaver.match(BcelClassWeaver.java:3304) Now I understand that it display an error - though the code compiles and runs fine. The interesting thing is the original code which is a bit more complex failed did not fail with this error. It failed with this error: java.lang.StringIndexOutOfBoundsException: String index out of range: 0 [ERROR] at java.lang.String.charAt(String.java:658) [ERROR] at org.aspectj.weaver.UnresolvedType.forSignature(UnresolvedType.java:383) [ERROR] at org.aspectj.weaver.TypeFactory.convertSigToType(TypeFactory.java:84) [ERROR] at org.aspectj.weaver.TypeFactory.createTypeFromSignature(TypeFactory.java:159) [ERROR] at org.aspectj.weaver.UnresolvedType.forSignature(UnresolvedType.java:409) [ERROR] at org.aspectj.weaver.bcel.BcelGenericSignatureToTypeXConverter.typeSignature2TypeX(BcelGenericSignatureToTypeXConverter.java:199) [ERROR] at org.aspectj.weaver.bcel.BcelGenericSignatureToTypeXConverter.typeSignature2TypeX(BcelGenericSignatureToTypeXConverter.java:189) [ERROR] at org.aspectj.weaver.bcel.BcelMethod.unpackGenericSignature(BcelMethod.java:609) [ERROR] at org.aspectj.weaver.bcel.BcelMethod.getGenericReturnType(BcelMethod.java:542) [ERROR] at org.aspectj.weaver.JoinPointSignature.getGenericReturnType(JoinPointSignature.java:191) [ERROR] at org.aspectj.weaver.patterns.SignaturePattern.matchesExactlyMethod(SignaturePattern.java:507) [ERROR] at org.aspectj.weaver.patterns.SignaturePattern.matchesExactly(SignaturePattern.java:360) [ERROR] at org.aspectj.weaver.patterns.SignaturePattern.matches(SignaturePattern.java:320) If I remove the method reference from the original code it compiles successfully. 1.9.0.BETA-6 of aspectj also has the problem. The work around of course, is obvious - don't use the method reference, or the var args or the wildcard.
My Apologies - I made a mistake with the second passing example: Should read wild card but passes when you remove the method reference.