Accessing Annotations

Sebastian Sickelmann sebastian.sickelmann at gmx.de
Thu Nov 10 06:14:23 PST 2011


Hi,

i actually explore how i could implement
"Removing public fields without breaking binary compatibility"[0][1][2] 
inside of the vm.

In [0] i made an early prototype with annotations and 
class-weaving(changing) at load-time.
Now i want to shift this prototype to an inside-the-vm implementation.

The first place i ran into is the verifier. Here i need to return true 
if there is are methods
annotated with the new AccessorMethod-Annotation (which i made part of 
java/lang in my
private openjdk clone). Just for completeness: the methods parameters 
and return value must
fit to the expected field (said in other words "one get and one set 
method").

I tried to hack on Reflection::verify_field_access and added something 
like this[3] to access the
methods and their annotations. I tried it in various ways (and after 
some errors on my side) i
get an typeArrayOop/typeArrayKlass which i think i can access the 
annotations. Asking the
typeArrayKlass for its name/external-name/dimensions answers [B/[B/1 
which seems to be an
one-dimensional byte-array. Is this the structure of the 
RuntimeVisibleAnnotation described in
class-file-spec[4]?


Must i access its byte content and parse it, or have i missed an 
"annotationKlass" impl?

If i first must implement such a annotationKlass-implementation. Is 
there a good starting for this?


Some hints to get me working on this again would be fine.

Kind regards
Sebastian

[0] http://mail.openjdk.java.net/pipermail/jdk8-dev/2011-October/000199.html
[1] 
http://mail.openjdk.java.net/pipermail/core-libs-dev/2011-September/007676.html 

[2] http://codingwizard.wordpress.com/2011/09/13/remove-flaws-in-java-apis/
[3] 
http://dl.dropbox.com/u/43692695/oss-patches/openjdk8/compatiblefieldaccess/question1-2011-11-10/index.html
[4] 
http://java.sun.com/docs/books/jvms/second_edition/ClassFileFormat-Java5.pdf


More information about the hotspot-compiler-dev mailing list