Tom Klug wrote:...To write the annotation is not the problem, the problem is to get the information of them at the Runtime.
I could only get some informations from annotated methods, but not from local variable or parameter.
SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Tom Klug wrote:Hi everybody,
I`d like to create my own annotations to annotate some parameter and/or some local variable.
To write the annotation is not the problem, the problem is to get the information of them at the Runtime.
I could only get some informations from annotated methods, but not from local variable or parameter.
Has anybody experience with such kind of annotation and could help me?
thanks a lot
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Vijitha Kumara wrote:
What kind of information you expect and what is the exact problem you are trying to solve? Please, TellTheDetails.
And welcome to JavaRanch
Rob Prime wrote:
You'll need method getParameterAnnotations(). This returns an Annotation[][]. The array is indexed with parameter order. So to get the annotations of the third parameter, you'll need getParamaterAnnotations()[2].
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Rob Prime wrote:There is one annotation that can make sense for local variables: @SuppressWarnings. But I do believe that any non-system annotations, that will not be treated specially by the compiler (like @SuppressWarnings, @Override, @Deprecated do), will make any sense for local variables. There is nothing that can inspect them afterwards.
Tom Klug wrote:Now the compiler should read this informations at run time.
It works with the parameter of the method m (which is a), but not with the local variable (which is b). So the question is: why it does not work
and is there another possibility to transport some information from source code to run time?
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Dinner will be steamed monkey heads with a side of tiny ads.
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|