Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Matching a generic argument vs. type erasure

Turn that into a bug/enh request?  At the moment I’m trying to tie up some loose ends and get a 1.9.3 done - and help AJDT a little - this thread needs more concentrated brainpower :)


> On Feb 18, 2019, at 6:46 PM, Alexander Kriegisch <alexander@xxxxxxxxxxxxxx> wrote:
> Hi Andy.
> In my answer [1] to a StackOverflow question I tried to explain to the original poster why he cannot use a concrete type in order to limit method parameter matching for a method defined in a generic supertype. I also showed him a workaround using the concrete type in 'args()' because then he can utilise runtime information. I also pointed him to the AJ generics manual [2]. I am not a generics expert, but I do see with javap that, as I expected, the method in question actually has an Object parameter in the byte code. Anyway, the OP has a point there, saying that his derived type specifies the concrete type for the generic supertype, but of course he does not override the method from the generic superclass.
> If you compile my attached sample code (it is an Eclipse project) you see that my workaround pointcut works, but if you use javap on both abstract supertypes AbstractIntegerConverter and AbstractStringConverter you also see that aspect code for the around advice is generated for both of them because there is no way I know of to limit the pointcut any further.
> My question is: Do you think it would be possible to utilise the type information present in the subclasses IntegerToStringConverter and StringToIntegerConverter (javap shows there is information present) in order to limit bytecode weaving to what is actually the pointcut's target, i.e. extending generics functionality in AspectJ to utilise existing type information in order to enable more specific pointcuts and eliminate the need to use runtime types via args(), target() or this()?
> [1]
> [2]
> -- 
> Alexander Kriegisch
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> To change your delivery options, retrieve your password, or unsubscribe from this list, visit

Back to the top