|
|
Re: Accessing Class annotation values from JvmDeclaredType? [message #1730854 is a reply to message #1730851] |
Fri, 29 April 2016 09:47 |
Larry LeBron Messages: 124 Registered: October 2015 |
Senior Member |
|
|
Right, JvmAnnotationReference lets me access the list of JvmAnnotationValue for the annotation, but this just gives me the name of the value and the operation it supports. I don't see a way to get the actual defined value, as specified by the annotated class.
For my example, I can get information like:
name: exampleVal
operation: JvmOperation: packageName.exampleVal() (visibility: PUBLIC, simpleName: exampleVal, identifier: packageName.exampleVal(), deprecated: false) (varArgs: false) (static: false, final: false, abstract: true, synchronized: false, default: false, native: false, strictFloatingPoint: false)
What I'm looking for is the equivalent of what I can invoke on the Foo.class object itself:
val fooAnnotation = Foo.class.getAnnotation(ExampleAnnotation.class)
System.out.println(fooAnnotation.exampleVal) // prints "hi"
I can get this class instance by calling: Class.forName(jvmDeclaredType.qualifiedName), but not sure this is a fully safe operation during inferral.
[Updated on: Fri, 29 April 2016 09:48] Report message to a moderator
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04704 seconds