Reputation: 437
In Java 6, is it possible to inject some value into a (@Target(ElementType.PARAMETER)
and @Retention(RetentionPolicy.RUNTIME)
-meta-annotated) method parameter?
It's entirely possible to find the annotation at runtime using reflection, it's just that there seems to be no way of actually modifying the parameter's value.
Or is that strictly Java 7 (or some yet-to-be-finalized JSR)? I can't see how it would be possible (other than perhaps using bytecode manipulation) in Java 6.
Upvotes: 1
Views: 1067
Reputation: 34014
If your Method is declared in an interface you could also look into java.lang.reflect.Proxy and InvocationHandler.
Upvotes: 0
Reputation: 45324
Rather than doing the bytecode manipulation yourself, it's less work to use something like AspectJ with an annotation pointcut.
Upvotes: 1