* configure.ac: New switch for disabling -O2 (--disable-optimizations).
[cacao.git] / doc / annotations.tex
1 \documentclass[a4paper, 10pt, titlepage]{scrartcl} %{article}
2
3 \usepackage[english]{babel}
4 \usepackage[utf-8]{inputenc}
5 \usepackage{graphics}
6 \usepackage{url}
7 \usepackage[colorlinks=true,linkcolor=black,bookmarks=true,bookmarksopen=true]{hyperref}
8 \usepackage{listings}
9 \lstloadlanguages{Java,C}
10 \lstset{basicstyle=\scriptsize, numbers=left, tabsize=4, frame=single, breaklines=true}
11
12 \makeindex
13 %\pagestyle{plain}
14 \pagestyle{headings}
15 \setlength{\textwidth}{16cm}
16 \setlength{\textheight}{23cm}
17 \setlength{\topmargin}{0mm} 
18 \setlength{\oddsidemargin}{0cm} 
19 \setlength{\evensidemargin}{0cm}
20
21
22 \parskip\medskipamount
23
24
25 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
26
27 \begin{document}
28
29 \bibliographystyle{plain}
30
31 \title{Annotation Support\\
32 for the CACAO Java Virtual Machine}
33
34 \author{Mathias Stephan Panzenbök\\
35 0427417 033 534\\
36 \href{mailto:panzi@complang.tuwien.ac.at}{panzi@complang.tuwien.ac.at}}
37 \date{\today{}, Kottingbrunn/Wien}
38
39 \maketitle
40 \tableofcontents
41 \pagebreak
42
43 %% CONTENT BEGIN %%
44
45 \section{A short Introduction to Annotations in Java}
46 \label{sec:annotations-java-intro}
47 Since JDK 5.0 there is the possibility to annotate certain elements. This can
48 be used to supply some kind of documentation to the annotated elements
49 (=metadata), to influence compiler behaviour (e.g. the all known
50 \begin{scriptsize}\verb||\hspace{0.0pt}\verb|@|\hspace{0.0pt}\verb|SuppressWarnings|\hspace{0.0pt}\verb|(|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|"|\hspace{0.0pt}\verb|unchecked|\hspace{0.0pt}\verb|"|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|)|\hspace{0.0pt}\verb||\end{scriptsize}), or to do nifty tricks like some frameworks do (e.g. like
51 \href{http://www.hibernate.org/hib_docs/v3/reference/en/html/mapping.html#mapping-annotations}{Hibernate}\footnote{\url{http://www.hibernate.org/hib\_docs/v3/reference/en/html/mapping.html\#mapping-annotations}}
52 uses annotations for object relational mapping; or for really easy
53 \href{http://twoday.tuwien.ac.at/pub/stories/305002/}{command line option parsing}\footnote{\url{http://twoday.tuwien.ac.at/pub/stories/305002/}}).
54
55 Annotations can be defined for classes and all that can be represented by an
56 instance of \begin{scriptsize}\verb|java|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|lang|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|Class|\end{scriptsize} (=\begin{scriptsize}\verb|class|\end{scriptsize}, \begin{scriptsize}\verb|interface|\end{scriptsize},
57 \begin{scriptsize}\verb||\hspace{0.0pt}\verb|@|\hspace{0.0pt}\verb|interface|\end{scriptsize} (annotation type), \begin{scriptsize}\verb|enum|\end{scriptsize}, \begin{scriptsize}\verb|package|\end{scriptsize}), for fields, for
58 methods, for constructors and for parameters. Local variables can also be
59 annotated, but the annotations cannot be accessed at runtime and are simply
60 discarded by the compiler.
61
62 Annotations are stored as attributes in the classfile. There are several
63 annotation attributes defined:
64 \begin{itemize}
65  \item \begin{scriptsize}\verb|RuntimeVisibleAnnotations|\end{scriptsize} for classes, methods and fields
66  \item \begin{scriptsize}\verb|RuntimeInvisibleAnnotations|\end{scriptsize} for classes, methods and fields
67  \item \begin{scriptsize}\verb|RuntimeVisibleParameterAnnotations|\end{scriptsize} for parameters
68  \item \begin{scriptsize}\verb|RuntimeInvisibleParameterAnnotations|\end{scriptsize} for parameters
69  \item \begin{scriptsize}\verb|AnnotationDefault|\end{scriptsize} for methods
70 \end{itemize}
71
72 These attributes are loaded when the classfile is read, but will only be parsed
73 when the corresponding annotation is accessed.
74
75 Depending on its usage an annotation might not be needed at runtime. E.g. the
76 \begin{scriptsize}\verb|SuppressWarnings|\end{scriptsize} annotation is only needed by the compiler. To tell the
77 compiler that an annotation should be visible at runtime, the annotation itself
78 has to have the annotation \begin{scriptsize}\verb||\hspace{0.0pt}\verb|@|\hspace{0.0pt}\verb|Retention|\hspace{0.0pt}\verb|(|\hspace{0.0pt}\verb|RetentionPolicy|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|RUNTIME|\hspace{0.0pt}\verb|)|\hspace{0.0pt}\verb||\end{scriptsize} declared.
79
80 Runtime invisible annotations usually aren't even included in the classfile,
81 but that depends on the compiler (or on compiler flags). If they are included
82 in the classfile, the virtual machine should not load them, unless an
83 implementation specific flag is set, which tells the JVM to do so. CACAO
84 doesn't have such a flag right now and therefore runtime invisible annotations
85 are simply discarded.
86
87 You declare annotations like this:
88 \begin{lstlisting}[language=Java]
89 public @interface MyAnnotation {
90                 int              intValue();
91                 String           stringValue()     default "foo bar";
92                 Class<?>[]       classArray()      default {Foo.class, Class.class};
93                 SuppressWarnings annotationValue() default @SuppressWarnings("unused");
94 }
95 \end{lstlisting}
96
97 All methods defined in annotations have zero parameters and their return type
98 must be one of the following:
99 \begin{itemize}
100  \item a primitive type: \begin{scriptsize}\verb|boolean|\end{scriptsize}, \begin{scriptsize}\verb|byte|\end{scriptsize}, \begin{scriptsize}\verb|short|\end{scriptsize}, \begin{scriptsize}\verb|char|\end{scriptsize}, \begin{scriptsize}\verb|int|\end{scriptsize}, \begin{scriptsize}\verb|long|\end{scriptsize}, \begin{scriptsize}\verb|float|\end{scriptsize} or \begin{scriptsize}\verb|double|\end{scriptsize}
101  \item \begin{scriptsize}\verb|java|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|lang|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|String|\end{scriptsize}
102  \item \begin{scriptsize}\verb|java|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|lang|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|Class|\hspace{0.0pt}\verb|<|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|?|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|>|\hspace{0.0pt}\verb||\end{scriptsize}
103  \item an \begin{scriptsize}\verb|enum|\end{scriptsize} type
104  \item an annotation type (e.g. \begin{scriptsize}\verb|SuppressWarnings|\end{scriptsize})
105  \item or an one-dimensional array thereof
106 \end{itemize}
107
108 You use annotations like this:
109 \begin{lstlisting}[language=Java]
110 import java.util.Map;
111
112 @MyAnnotation(intValue=42)
113 class MyClass {
114                 @MyAnnotation(intValue=23, stringValue="hello world")
115                 public int aField;
116
117                 @Deprecated
118                 public void aDeprecatedMethod(
119                         @MyAnnotation(intValue=5, classArray=void.class)
120                         int a) {
121                 }
122
123                 @SuppressWarnings({"unchecked", "unused"})
124                 public MyClass() {
125                         Map<String,String>[] map = new Map[16];
126                 }
127 }
128 \end{lstlisting}
129
130 The annotations \begin{scriptsize}\verb||\hspace{0.0pt}\verb|@|\hspace{0.0pt}\verb|SuppressWarnings|\end{scriptsize} and \begin{scriptsize}\verb||\hspace{0.0pt}\verb|@|\hspace{0.0pt}\verb|Deprecated|\end{scriptsize} are defined by the
131 Java library (amongst many others).
132
133 You can then access the annotations of an annotated element by the reflection
134 API. There are several methods to do so. Each annotated element can have an
135 arbitrary number of annotations, but only one per annotation type.
136
137 The annotated element interface looks like this:
138 \begin{lstlisting}[language=Java]
139 package java.lang.reflect;
140
141 import java.lang.annotation.Annotation;
142
143 public interface AnnotatedElement
144 {
145   <T extends Annotation> T getAnnotation(Class<T> annotationClass);
146
147   Annotation[] getAnnotations();
148
149   Annotation[] getDeclaredAnnotations();
150
151   boolean isAnnotationPresent(Class<? extends Annotation> annotationClass);
152 }
153 \end{lstlisting}
154
155 Some classes offer more than this basic set of methods.
156
157 \begin{scriptsize}\verb|java|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|lang|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|Class|\end{scriptsize} has the method \begin{scriptsize}\verb|public|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|boolean|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|isAnnotation|\hspace{0.0pt}\verb|(|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|)|\hspace{0.0pt}\verb||\end{scriptsize} which
158 tells you if the referred class is an annotation.
159
160 \begin{scriptsize}\verb|java|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|lang|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|Constructor|\end{scriptsize} and \begin{scriptsize}\verb|java|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|lang|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|Method|\end{scriptsize} have the
161 method \begin{scriptsize}\verb|public|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|Annotation|\hspace{0.0pt}\verb|[|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|]|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|[|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|]|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|getParameterAnnotations|\hspace{0.0pt}\verb|(|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|)|\hspace{0.0pt}\verb||\end{scriptsize} which returns the
162 annotations for each parameter as a two-dimensional array.
163
164 \begin{scriptsize}\verb|java|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|lang|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|Method|\end{scriptsize} has the method \begin{scriptsize}\verb|public|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|Object|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|getDefaultValue|\hspace{0.0pt}\verb|(|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|)|\hspace{0.0pt}\verb||\end{scriptsize}
165 which returns the default value of a method of an annotation.
166
167 Annotations in Java are interfaces. Therefore there has to be an implementing
168 class for each annotation type. But the Java compiler does not generate such an
169 implementation, this actually happens at runtime. The Java runtime has to
170 create an implementation for an annotation type the first time an annotation of
171 a specific annotation type is requested. It then remembers this on the fly
172 generated class and uses it for each further instance of the same annotation
173 type.
174
175 \section{Overview of Annotation Support in CACAO}
176 \label{sec:annotations-cacao-overview}
177 Even though annotations in Java exist since JDK 5.0 I used the classfile
178 specification of JDK 6.0~\cite{JSR202}
179 to implement the annotations support. However, there where no changes between
180 this versions.
181
182 Because OpenJDK does a lot concerning annotation support in it's J2SE library
183 I started with annotations support for CACAO + OpenJDK. I thought this would be
184 easier and I would be able to gather some experience for working on the
185 annotation support for CACAO + GNU Classpath. OpenJDK does the annotation
186 parsing in Java code.
187
188 What had to be done:
189 \begin{itemize}
190  \item Loading of annotations from the classfile to the \begin{scriptsize}\verb|classinfo|\end{scriptsize} struct
191  \item Implementing the \begin{scriptsize}\verb|JVM_|\hspace{0.0pt}\verb|*|\hspace{0.0pt}\verb||\end{scriptsize} functions for getting the unparsed annotations for each annotated element as a byte array.
192  \item Implementing the \begin{scriptsize}\verb|sun|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|ConstantPool|\end{scriptsize} class which is used by OpenJDKs annotation parser to get access to constants that have to be loaded.
193 \end{itemize}
194
195 The code for the annotation loading is placed in the files
196 \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|vmcore|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|annotation|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|h|\end{scriptsize} (see section \ref{sec:src/vmcore/annotation.h}) and
197 \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|vmcore|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|annotation|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|c|\end{scriptsize} (see section \ref{sec:src/vmcore/annotation.c}).
198
199 This code is called by the loader functions:
200 \begin{itemize}
201  \item \begin{scriptsize}\verb|bool|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|class_load_attributes|\hspace{0.0pt}\verb|(|\hspace{0.0pt}\verb|classbuffer|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|*|\hspace{0.0pt}\verb|cb|\hspace{0.0pt}\verb|)|\hspace{0.0pt}\verb||\end{scriptsize}
202  \item \begin{scriptsize}\verb|bool|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|method_load|\hspace{0.0pt}\verb|(|\hspace{0.0pt}\verb|classbuffer|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|*|\hspace{0.0pt}\verb|cb|\hspace{0.0pt}\verb|,|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|methodinfo|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|*|\hspace{0.0pt}\verb|m|\hspace{0.0pt}\verb|,|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|descriptor_pool|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|*|\hspace{0.0pt}\verb|descpool|\hspace{0.0pt}\verb|)|\hspace{0.0pt}\verb||\end{scriptsize}
203  \item \begin{scriptsize}\verb|bool|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|field_load|\hspace{0.0pt}\verb|(|\hspace{0.0pt}\verb|classbuffer|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|*|\hspace{0.0pt}\verb|cb|\hspace{0.0pt}\verb|,|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|fieldinfo|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|*|\hspace{0.0pt}\verb|f|\hspace{0.0pt}\verb|,|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|descriptor_pool|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|*|\hspace{0.0pt}\verb|descpool|\hspace{0.0pt}\verb|)|\hspace{0.0pt}\verb||\end{scriptsize}
204 \end{itemize}
205 See: \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|vmcore|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|class|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|c|\end{scriptsize} (see section \ref{sec:src/vmcore/class.c}),
206 \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|vmcore|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|method|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|c|\end{scriptsize} (see section \ref{sec:src/vmcore/method.c}),
207 \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|vmcore|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|field|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|c|\end{scriptsize} (see section \ref{sec:src/vmcore/field.c})
208
209 All annotations and also the annotation default values are stored in the
210 \begin{scriptsize}\verb|classinfo|\end{scriptsize} struct as unparsed byte arrays:
211 \begin{lstlisting}[language=C,firstnumber=147]
212 #if defined(ENABLE_ANNOTATIONS)
213         java_object_t *annotations;
214         
215         java_object_t *method_annotations;
216         java_object_t *method_parameterannotations;
217         java_object_t *method_annotationdefaults;
218
219         java_object_t *field_annotations;
220 #endif
221 \end{lstlisting}
222 See: \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|vmcore|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|class|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|h|\end{scriptsize} (see section \ref{sec:src/vmcore/class.h})
223
224 I decided to use Java objects (\begin{scriptsize}\verb|java_bytearray_t|\end{scriptsize} and \begin{scriptsize}\verb|java_objectarray_t|\end{scriptsize})
225 rather than implementing my own array structs, because the annotation
226 parser, that is written in Java, needs Java bytearrays anyway. I would have had
227 to copy the whole unparsed annotation when they are parsed, which would had
228 reduced speed and increased memory usage.
229
230 For this to be possible twisti had to adapt CACAOs bootstrap process, so that
231 the primitive table already exists when classes will be loaded (because I use
232 \begin{scriptsize}\verb|builtin_newarray_byte|\end{scriptsize}, \begin{scriptsize}\verb|bultin_anewarray|\end{scriptsize} and
233 \begin{scriptsize}\verb|primitive_arrayclass_get_by_type|\end{scriptsize} during loading of the annotation
234 attributes).
235
236 Futher I added functions to access the unparsed annotations as Java byte arrays:
237 \begin{itemize}
238  \item \begin{scriptsize}\verb|class_get_annotations|\end{scriptsize}
239  \item \begin{scriptsize}\verb|method_get_annotations|\end{scriptsize}
240  \item \begin{scriptsize}\verb|method_get_parameterannotations|\end{scriptsize}
241  \item \begin{scriptsize}\verb|method_get_annotationdefault|\end{scriptsize}
242  \item \begin{scriptsize}\verb|field_get_annotations|\end{scriptsize}
243 \end{itemize}
244 See: \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|vmcore|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|class|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|h|\end{scriptsize} (see section \ref{sec:src/vmcore/class.h}),
245 \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|vmcore|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|field|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|h|\end{scriptsize} (see section \ref{sec:src/vmcore/field.h}),
246 \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|vmcore|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|method|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|h|\end{scriptsize} (see section \ref{sec:src/vmcore/method.h})
247
248 And used them in \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|native|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|vm|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|sun|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|jvm|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|c|\end{scriptsize} (see section \ref{sec:src/native/vm/sun/jvm.c}) to
249 implement these functions:
250 \begin{itemize}
251  \item \begin{scriptsize}\verb|JVM_GetClassAnnotations|\end{scriptsize}
252  \item \begin{scriptsize}\verb|JVM_GetFieldAnnotations|\end{scriptsize}
253  \item \begin{scriptsize}\verb|JVM_GetMethodAnnotations|\end{scriptsize}
254  \item \begin{scriptsize}\verb|JVM_GetMethodDefaultAnnotationValue|\end{scriptsize}
255  \item \begin{scriptsize}\verb|JVM_GetMethodParameterAnnotations|\end{scriptsize}
256 \end{itemize}
257
258 Then I had to add an implementation for OpenJDKs \begin{scriptsize}\verb|ConstantPool|\end{scriptsize} class by
259 filling in these functions (not all of them are used in the annotations support):
260 \begin{itemize}
261  \item \begin{scriptsize}\verb|JVM_GetClassConstantPool|\end{scriptsize}
262  \item \begin{scriptsize}\verb|JVM_ConstantPoolGetSize|\end{scriptsize}
263  \item \begin{scriptsize}\verb|JVM_ConstantPoolGetClassAt|\end{scriptsize}
264  \item \begin{scriptsize}\verb|JVM_ConstantPoolGetClassAtIfLoaded|\end{scriptsize}
265  \item \begin{scriptsize}\verb|JVM_ConstantPoolGetMethodAt|\end{scriptsize}
266  \item \begin{scriptsize}\verb|JVM_ConstantPoolGetMethodAtIfLoaded|\end{scriptsize}
267  \item \begin{scriptsize}\verb|JVM_ConstantPoolGetFieldAt|\end{scriptsize}
268  \item \begin{scriptsize}\verb|JVM_ConstantPoolGetFieldAtIfLoaded|\end{scriptsize}
269  \item \begin{scriptsize}\verb|JVM_ConstantPoolGetMemberRefInfoAt|\end{scriptsize}
270  \item \begin{scriptsize}\verb|JVM_ConstantPoolGetIntAt|\end{scriptsize}
271  \item \begin{scriptsize}\verb|JVM_ConstantPoolGetLongAt|\end{scriptsize}
272  \item \begin{scriptsize}\verb|JVM_ConstantPoolGetFloatAt|\end{scriptsize}
273  \item \begin{scriptsize}\verb|JVM_ConstantPoolGetDoubleAt|\end{scriptsize}
274  \item \begin{scriptsize}\verb|JVM_ConstantPoolGetStringAt|\end{scriptsize}
275  \item \begin{scriptsize}\verb|JVM_ConstantPoolGetUTF8At|\end{scriptsize}
276 \end{itemize}
277
278 In the annotation attributes in the classfile are no values stored, but indices
279 of members of the constant pool of the annotated class. The values at these
280 indices represent the values of the annotations' field. Therefore the
281 \begin{scriptsize}\verb|ConstantPool|\end{scriptsize} class is needed by the annotation parser to access those
282 constants.
283
284 This was roughly all that what was needed for annotation support for CACAO +
285 OpenJDK. For GNU Classpath much more had to be done. First there is no
286 annotations parser in GNU Classpath, but because of the GPL I just imported the
287 one from OpenJDK. So far so good, but GNU Classpath did not do anything about
288 annotations except in \begin{scriptsize}\verb|java|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|lang|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|Class|\end{scriptsize}. I had to implement the "high
289 level" annotations interface:
290 \begin{itemize}
291  \item \begin{scriptsize}\verb|Annotation|\hspace{0.0pt}\verb|[|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|]|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|java|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|lang|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|VMClass|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|getDeclaredAnnotations|\hspace{0.0pt}\verb|(|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|)|\hspace{0.0pt}\verb||\end{scriptsize}
292  \item \begin{scriptsize}\verb|Annotation|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|java|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|lang|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|Constructor|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|getAnnotation|\hspace{0.0pt}\verb|(|\hspace{0.0pt}\verb|Class|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|annotationClass|\hspace{0.0pt}\verb|)|\hspace{0.0pt}\verb||\end{scriptsize}
293  \item \begin{scriptsize}\verb|Annotation|\hspace{0.0pt}\verb|[|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|]|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|java|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|lang|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|Constructor|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|getDeclaredAnnotations|\hspace{0.0pt}\verb|(|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|)|\hspace{0.0pt}\verb||\end{scriptsize}
294  \item \begin{scriptsize}\verb|Annotation|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|java|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|lang|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|Field|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|getAnnotation|\hspace{0.0pt}\verb|(|\hspace{0.0pt}\verb|Class|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|annotationClass|\hspace{0.0pt}\verb|)|\hspace{0.0pt}\verb||\end{scriptsize}
295  \item \begin{scriptsize}\verb|Annotation|\hspace{0.0pt}\verb|[|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|]|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|java|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|lang|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|Field|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|getDeclaredAnnotations|\hspace{0.0pt}\verb|(|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|)|\hspace{0.0pt}\verb||\end{scriptsize}
296  \item \begin{scriptsize}\verb|Annotation|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|java|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|lang|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|Method|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|getAnnotation|\hspace{0.0pt}\verb|(|\hspace{0.0pt}\verb|Class|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|annotationClass|\hspace{0.0pt}\verb|)|\hspace{0.0pt}\verb||\end{scriptsize}
297  \item \begin{scriptsize}\verb|Annotation|\hspace{0.0pt}\verb|[|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|]|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|java|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|lang|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|Method|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|getDeclaredAnnotations|\hspace{0.0pt}\verb|(|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|)|\hspace{0.0pt}\verb||\end{scriptsize}
298 \end{itemize}
299 See: \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|native|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|vm|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|gnu|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|java_lang_VMClass|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|c|\end{scriptsize} (see section \ref{sec:src/native/vm/gnu/java_lang_VMClass.c}),
300 \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|lib|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|gnu|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|java|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|lang|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|Constructor|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|java|\end{scriptsize} (see section \ref{sec:src/lib/gnu/java/lang/reflect/Constructor.java}),
301 \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|native|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|vm|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|gnu|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|java_lang_reflect_Constructor|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|c|\end{scriptsize} (see section \ref{sec:src/native/vm/gnu/java_lang_reflect_Constructor.c}),
302 \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|lib|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|gnu|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|java|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|lang|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|Field|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|java|\end{scriptsize} (see section \ref{sec:src/lib/gnu/java/lang/reflect/Field.java}),
303 \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|native|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|vm|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|gnu|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|java_lang_reflect_Field|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|c|\end{scriptsize} (see section \ref{sec:src/native/vm/gnu/java_lang_reflect_Field.c}),
304 \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|lib|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|gnu|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|java|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|lang|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|Method|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|java|\end{scriptsize} (see section \ref{sec:src/lib/gnu/java/lang/reflect/Method.java}),
305 \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|native|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|vm|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|gnu|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|java_lang_reflect_Method|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|c|\end{scriptsize} (see section \ref{sec:src/native/vm/gnu/java_lang_reflect_Method.c})
306
307 I implementined caching of the parsed annotations almost identical to OpenJDK,
308 except for \begin{scriptsize}\verb|java|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|lang|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|Class|\end{scriptsize}, because that class already had the annotation
309 interface implemented (without caching). So I would have had to import this class
310 from GNU Classpath, change it and keep it up to date. Twisti said that's not
311 worth the effort and that OpenJDK is the future.
312
313 Because I used the annotation parser from OpenJDK I had to implement the
314 \begin{scriptsize}\verb|sun|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|ConstantPool|\end{scriptsize} class for GNU Classpath, too.
315
316 See: \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|lib|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|gnu|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|sun|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|ConstantPool|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|java|\end{scriptsize} (see section \ref{sec:src/lib/gnu/sun/reflect/ConstantPool.java}),
317 \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|native|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|vm|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|gnu|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|sun_reflect_ConstantPool|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|c|\end{scriptsize} (see section \ref{sec:src/native/vm/gnu/sun_reflect_ConstantPool.c})
318
319 The ugly bit there is the redundant implementation of this class. It is still
320 under discussion what we do in such a case. We agreed that until a better
321 solution is found, we will just keep the redundant implementations.
322
323 \section{Imported Files}
324 \label{sec:imported-files}
325
326 Following files where imported from GNU Classpath or OpenJDK and have to be
327 kept up to date. Files marked with * where changed or extended a bit to be
328 useable with CACAO. All this imported files are used with GNU Classpath only.
329
330 \begin{bfseries}Importet from GNU Classpath:\end{bfseries}
331 \begin{itemize}
332  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|lib|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|gnu|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|java|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|lang|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|Constructor|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|java|\end{scriptsize} (see section \ref{sec:src/lib/gnu/java/lang/reflect/Constructor.java})*
333 \end{itemize}
334
335 \begin{bfseries}Imported from OpenJDK:\end{bfseries}
336 \begin{itemize}
337  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|lib|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|gnu|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|sun|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|ConstantPool|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|java|\end{scriptsize} (see section \ref{sec:src/lib/gnu/sun/reflect/ConstantPool.java})*
338  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|lib|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|gnu|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|sun|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|annotation|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|AnnotationParser|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|java|\end{scriptsize} (see section \ref{sec:src/lib/gnu/sun/reflect/annotation/AnnotationParser.java})*
339  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|lib|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|gnu|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|sun|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|annotation|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|AnnotationType|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|java|\end{scriptsize} (see section \ref{sec:src/lib/gnu/sun/reflect/annotation/AnnotationType.java})*
340  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|lib|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|gnu|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|sun|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|annotation|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|AnnotationTypeMismatchExceptionProxy|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|java|\end{scriptsize} (see section \ref{sec:src/lib/gnu/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java})
341  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|lib|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|gnu|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|sun|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|annotation|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|EnumConstantNotPresentExceptionProxy|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|java|\end{scriptsize} (see section \ref{sec:src/lib/gnu/sun/reflect/annotation/EnumConstantNotPresentExceptionProxy.java})
342  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|lib|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|gnu|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|sun|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|annotation|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|ExceptionProxy|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|java|\end{scriptsize} (see section \ref{sec:src/lib/gnu/sun/reflect/annotation/ExceptionProxy.java})
343  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|lib|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|gnu|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|sun|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|annotation|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|TypeNotPresentExceptionProxy|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|java|\end{scriptsize} (see section \ref{sec:src/lib/gnu/sun/reflect/annotation/TypeNotPresentExceptionProxy.java})
344 \end{itemize}
345
346 \paragraph{TODO:}
347 \label{par:TODO/keep-imported-files-up-to-date}Keep these imported files up to date with OpenJDK/GNU Classpath.
348
349 \section{Files I touched and what I did to them}
350 \label{sec:touched-files}
351
352 \begin{bfseries}List of touched files:\end{bfseries}
353 \begin{itemize}
354  \item \begin{scriptsize}\verb|THIRDPARTY|\end{scriptsize} (see section \ref{sec:THIRDPARTY})
355  \item \begin{scriptsize}\verb|configure|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|ac|\end{scriptsize} (see section \ref{sec:configure.ac})
356  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|cacaoh|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|dummy|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|c|\end{scriptsize} (see section \ref{sec:src/cacaoh/dummy.c})
357  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|lib|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|Makefile|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|am|\end{scriptsize} (see section \ref{sec:src/lib/Makefile.am})
358  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|lib|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|gnu|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|java|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|lang|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|Constructor|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|java|\end{scriptsize} (see section \ref{sec:src/lib/gnu/java/lang/reflect/Constructor.java})
359  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|lib|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|gnu|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|java|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|lang|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|Field|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|java|\end{scriptsize} (see section \ref{sec:src/lib/gnu/java/lang/reflect/Field.java})
360  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|lib|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|gnu|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|java|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|lang|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|Method|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|java|\end{scriptsize} (see section \ref{sec:src/lib/gnu/java/lang/reflect/Method.java})
361  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|lib|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|gnu|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|sun|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|ConstantPool|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|java|\end{scriptsize} (see section \ref{sec:src/lib/gnu/sun/reflect/ConstantPool.java})
362  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|lib|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|gnu|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|sun|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|annotation|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|AnnotationParser|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|java|\end{scriptsize} (see section \ref{sec:src/lib/gnu/sun/reflect/annotation/AnnotationParser.java})
363  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|lib|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|gnu|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|sun|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|annotation|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|AnnotationType|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|java|\end{scriptsize} (see section \ref{sec:src/lib/gnu/sun/reflect/annotation/AnnotationType.java})
364  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|lib|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|gnu|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|sun|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|annotation|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|AnnotationTypeMismatchExceptionProxy|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|java|\end{scriptsize} (see section \ref{sec:src/lib/gnu/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java})
365  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|lib|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|gnu|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|sun|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|annotation|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|EnumConstantNotPresentExceptionProxy|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|java|\end{scriptsize} (see section \ref{sec:src/lib/gnu/sun/reflect/annotation/EnumConstantNotPresentExceptionProxy.java})
366  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|lib|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|gnu|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|sun|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|annotation|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|ExceptionProxy|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|java|\end{scriptsize} (see section \ref{sec:src/lib/gnu/sun/reflect/annotation/ExceptionProxy.java})
367  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|lib|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|gnu|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|sun|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|annotation|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|TypeNotPresentExceptionProxy|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|java|\end{scriptsize} (see section \ref{sec:src/lib/gnu/sun/reflect/annotation/TypeNotPresentExceptionProxy.java})
368  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|native|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|include|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|Makefile|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|am|\end{scriptsize} (see section \ref{sec:src/native/include/Makefile.am})
369  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|native|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|llni|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|h|\end{scriptsize} (see section \ref{sec:src/native/llni.h})
370  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|native|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|vm|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|gnu|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|Makefile|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|am|\end{scriptsize} (see section \ref{sec:src/native/vm/gnu/Makefile.am})
371  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|native|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|vm|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|gnu|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|java_lang_VMClass|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|c|\end{scriptsize} (see section \ref{sec:src/native/vm/gnu/java_lang_VMClass.c})
372  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|native|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|vm|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|gnu|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|java_lang_reflect_Constructor|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|c|\end{scriptsize} (see section \ref{sec:src/native/vm/gnu/java_lang_reflect_Constructor.c})
373  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|native|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|vm|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|gnu|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|java_lang_reflect_Field|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|c|\end{scriptsize} (see section \ref{sec:src/native/vm/gnu/java_lang_reflect_Field.c})
374  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|native|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|vm|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|gnu|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|java_lang_reflect_Method|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|c|\end{scriptsize} (see section \ref{sec:src/native/vm/gnu/java_lang_reflect_Method.c})
375  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|native|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|vm|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|gnu|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|sun_reflect_ConstantPool|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|c|\end{scriptsize} (see section \ref{sec:src/native/vm/gnu/sun_reflect_ConstantPool.c})
376  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|native|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|vm|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|java_lang_Class|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|c|\end{scriptsize} (see section \ref{sec:src/native/vm/java_lang_Class.c})
377  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|native|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|vm|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|java_lang_Class|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|h|\end{scriptsize} (see section \ref{sec:src/native/vm/java_lang_Class.h})
378  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|native|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|vm|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|nativevm|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|c|\end{scriptsize} (see section \ref{sec:src/native/vm/nativevm.c})
379  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|native|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|vm|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|nativevm|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|h|\end{scriptsize} (see section \ref{sec:src/native/vm/nativevm.h})
380  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|native|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|vm|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|c|\end{scriptsize} (see section \ref{sec:src/native/vm/reflect.c})
381  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|native|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|vm|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|h|\end{scriptsize} (see section \ref{sec:src/native/vm/reflect.h})
382  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|native|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|vm|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|sun|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|jvm|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|c|\end{scriptsize} (see section \ref{sec:src/native/vm/sun/jvm.c})
383  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|vmcore|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|Makefile|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|am|\end{scriptsize} (see section \ref{sec:src/vmcore/Makefile.am})
384  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|vmcore|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|annotation|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|c|\end{scriptsize} (see section \ref{sec:src/vmcore/annotation.c})
385  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|vmcore|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|annotation|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|h|\end{scriptsize} (see section \ref{sec:src/vmcore/annotation.h})
386  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|vmcore|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|class|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|c|\end{scriptsize} (see section \ref{sec:src/vmcore/class.c})
387  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|vmcore|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|class|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|h|\end{scriptsize} (see section \ref{sec:src/vmcore/class.h})
388  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|vmcore|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|field|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|c|\end{scriptsize} (see section \ref{sec:src/vmcore/field.c})
389  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|vmcore|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|field|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|h|\end{scriptsize} (see section \ref{sec:src/vmcore/field.h})
390  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|vmcore|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|linker|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|h|\end{scriptsize} (see section \ref{sec:src/vmcore/linker.h})
391  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|vmcore|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|loader|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|c|\end{scriptsize} (see section \ref{sec:src/vmcore/loader.c})
392  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|vmcore|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|method|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|c|\end{scriptsize} (see section \ref{sec:src/vmcore/method.c})
393  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|vmcore|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|method|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|h|\end{scriptsize} (see section \ref{sec:src/vmcore/method.h})
394  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|vmcore|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|utf8|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|c|\end{scriptsize} (see section \ref{sec:src/vmcore/utf8.c})
395  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|vmcore|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|utf8|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|h|\end{scriptsize} (see section \ref{sec:src/vmcore/utf8.h})
396  \item \begin{scriptsize}\verb|tests|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|regression|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|Makefile|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|am|\end{scriptsize} (see section \ref{sec:tests/regression/Makefile.am})
397  \item \begin{scriptsize}\verb|tests|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|regression|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|MinimalClassReflection|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|java|\end{scriptsize} (see section \ref{sec:tests/regression/MinimalClassReflection.java})
398  \item \begin{scriptsize}\verb|tests|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|regression|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|MinimalClassReflection|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|output|\end{scriptsize} (see section \ref{sec:tests/regression/MinimalClassReflection.output})
399  \item \begin{scriptsize}\verb|tests|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|regression|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|TestAnnotations|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|java|\end{scriptsize} (see section \ref{sec:tests/regression/TestAnnotations.java})
400  \item \begin{scriptsize}\verb|tests|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|regression|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|TestAnnotations|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|output|\end{scriptsize} (see section \ref{sec:tests/regression/TestAnnotations.output})
401 \end{itemize}
402
403 \subsection{THIRDPARTY}
404 \label{sec:THIRDPARTY}
405
406 Added copyright notice for this imported OpenJDK files:
407 \begin{itemize}
408  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|lib|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|gnu|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|sun|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|ConstantPool|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|java|\end{scriptsize} (see section \ref{sec:src/lib/gnu/sun/reflect/ConstantPool.java})
409  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|lib|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|gnu|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|sun|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|annotation|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|AnnotationParser|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|java|\end{scriptsize} (see section \ref{sec:src/lib/gnu/sun/reflect/annotation/AnnotationParser.java})
410  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|lib|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|gnu|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|sun|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|annotation|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|AnnotationType|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|java|\end{scriptsize} (see section \ref{sec:src/lib/gnu/sun/reflect/annotation/AnnotationType.java})
411  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|lib|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|gnu|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|sun|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|annotation|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|AnnotationTypeMismatchExceptionProxy|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|java|\end{scriptsize} (see section \ref{sec:src/lib/gnu/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java})
412  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|lib|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|gnu|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|sun|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|annotation|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|EnumConstantNotPresentExceptionProxy|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|java|\end{scriptsize} (see section \ref{sec:src/lib/gnu/sun/reflect/annotation/EnumConstantNotPresentExceptionProxy.java})
413  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|lib|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|gnu|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|sun|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|annotation|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|ExceptionProxy|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|java|\end{scriptsize} (see section \ref{sec:src/lib/gnu/sun/reflect/annotation/ExceptionProxy.java})
414  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|lib|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|gnu|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|sun|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|annotation|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|TypeNotPresentExceptionProxy|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|java|\end{scriptsize} (see section \ref{sec:src/lib/gnu/sun/reflect/annotation/TypeNotPresentExceptionProxy.java})
415 \end{itemize}
416
417 \subsection{configure.ac}
418 \label{sec:configure.ac}
419
420 Annotations Support will be built if the configure option \begin{scriptsize}\verb||\hspace{0.0pt}\verb|-|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|-|\hspace{0.0pt}\verb|enable|\hspace{0.0pt}\verb|-|\hspace{0.0pt}\verb|annotations|\end{scriptsize}
421 is supplied. As of the next release after the summer of 2007 this option will be
422 enabled by default.
423
424 Twisti later moved this option to the file
425 \href{http://mips.complang.tuwien.ac.at/hg/cacao/file/tip/m4/annotations.m4}{m4/annotations.m4}\footnote{\url{http://mips.complang.tuwien.ac.at/hg/cacao/file/tip/m4/annotations.m4}}.
426
427 If possible, all annotations support code is \begin{scriptsize}\verb||\hspace{0.0pt}\verb|#|\hspace{0.0pt}\verb|ifdef|\end{scriptsize}-ed with the
428 \begin{scriptsize}\verb|ENABLE_ANNOTATIONS|\end{scriptsize} macro.
429
430 \subsection{src/cacaoh/dummy.c}
431 \label{sec:src/cacaoh/dummy.c}
432
433 Simple/dummy implementations of following functions where added:
434 \begin{itemize}
435  \item \begin{scriptsize}\verb|builtin_newarray_byte|\end{scriptsize}
436  \item \begin{scriptsize}\verb|array_objectarray_element_get|\end{scriptsize}
437  \item \begin{scriptsize}\verb|array_objectarray_element_set|\end{scriptsize}
438  \item \begin{scriptsize}\verb|array_length_get|\end{scriptsize}
439  \item \begin{scriptsize}\verb|builtin_anewarray|\end{scriptsize}
440  \item \begin{scriptsize}\verb|primitive_arrayclass_get_by_type|\end{scriptsize}
441 \end{itemize}
442
443 \subsection{src/lib/Makefile.am}
444 \label{sec:src/lib/Makefile.am}
445
446 I added \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|lib|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|gnu|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|java|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|lang|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|Constructor|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|java|\end{scriptsize} to
447 \begin{scriptsize}\verb|VM_JAVA_FILES|\end{scriptsize} in this file.
448
449 Following files are only added to \begin{scriptsize}\verb|VM_JAVA_FILES|\end{scriptsize} if
450 \begin{scriptsize}\verb|ENABLE_ANNOTATIONS|\end{scriptsize} is defined:
451 \begin{itemize}
452  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|lib|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|gnu|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|sun|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|ConstantPool|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|java|\end{scriptsize}
453  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|lib|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|gnu|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|sun|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|annotation|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|AnnotationParser|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|java|\end{scriptsize}
454  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|lib|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|gnu|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|sun|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|annotation|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|AnnotationType|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|java|\end{scriptsize}
455  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|lib|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|gnu|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|sun|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|annotation|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|AnnotationTypeMismatchExceptionProxy|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|java|\end{scriptsize}
456  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|lib|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|gnu|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|sun|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|annotation|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|EnumConstantNotPresentExceptionProxy|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|java|\end{scriptsize}
457  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|lib|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|gnu|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|sun|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|annotation|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|ExceptionProxy|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|java|\end{scriptsize}
458  \item \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|lib|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|gnu|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|sun|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|annotation|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|TypeNotPresentExceptionProxy|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|java|\end{scriptsize}
459 \end{itemize}
460
461 \subsection{src/lib/gnu/java/lang/reflect/Constructor.java}
462 \label{sec:src/lib/gnu/java/lang/reflect/Constructor.java}
463
464 This file was imported from GNU Classpath because I needed to add some methods.
465
466 The additions to this class are inspired by OpenJDK (the private interface
467 looks and works the same but is implemented differently).
468
469 Following fields where added:
470 \begin{lstlisting}[language=Java,firstnumber=92]
471   private byte[] annotations = null;
472 \end{lstlisting}
473 This field holds the unparsed annotations.
474
475 \begin{lstlisting}[language=Java,firstnumber=97]
476   private byte[] parameterAnnotations = null;
477 \end{lstlisting}
478 This field holds the unparsed parameter annotations.
479
480 \begin{lstlisting}[language=Java,firstnumber=103]
481   private transient Map<Class<? extends Annotation>, Annotation> declaredAnnotations = null;
482 \end{lstlisting}
483 This field holds the parsed annotations.
484
485 \begin{lstlisting}[language=Java,firstnumber=111]
486   private static final Annotation[] EMPTY_ANNOTATIONS_ARRAY =
487     new Annotation[0];
488 \end{lstlisting}
489 Used in \begin{scriptsize}\verb|getDeclaredAnnotations|\hspace{0.0pt}\verb|(|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|)|\hspace{0.0pt}\verb||\end{scriptsize}. Look there for a description.
490
491 Following methods where added/implemented:
492 \begin{lstlisting}[language=Java,firstnumber=443]
493   private synchronized native Map<Class<? extends Annotation>, Annotation> declaredAnnotations();
494 \end{lstlisting}
495 When called the first time, this method will parse the declared annotations,
496 which are stored unparsed in the field \begin{scriptsize}\verb|annotations|\end{scriptsize} and then stores the
497 result in the field \begin{scriptsize}\verb|declaredAnnotations|\end{scriptsize} as a \begin{scriptsize}\verb|HashMap|\end{scriptsize}. Each successive
498 call will just return this field.
499
500 \begin{lstlisting}[language=Java,firstnumber=425]
501   public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
502     if (annotationClass == null)
503       throw new NullPointerException();
504
505     return (T)declaredAnnotations().get(annotationClass);
506   }
507 \end{lstlisting}
508 This method gets the annotation of the constructor of the type specified by
509 \begin{scriptsize}\verb|annotationClass|\end{scriptsize}, or \begin{scriptsize}\verb|null|\end{scriptsize}, if there is no such annotation present.
510
511 \begin{lstlisting}[language=Java,firstnumber=435]
512   public Annotation[] getDeclaredAnnotations() {
513     return declaredAnnotations().values().toArray(EMPTY_ANNOTATIONS_ARRAY);
514   }
515 \end{lstlisting}
516 This method gets all the declared annotations in an array. Because the generic
517 type \begin{scriptsize}\verb|java|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|util|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|Collection|\hspace{0.0pt}\verb|<|\hspace{0.0pt}\verb|Annotation|\hspace{0.0pt}\verb|>|\hspace{0.0pt}\verb||\end{scriptsize} cannot create an array of type
518 \begin{scriptsize}\verb|Annotation|\hspace{0.0pt}\verb|[|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|]|\hspace{0.0pt}\verb||\end{scriptsize} (because of type erasure) the \begin{scriptsize}\verb|toArray|\hspace{0.0pt}\verb|(|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|)|\hspace{0.0pt}\verb||\end{scriptsize} method must get a
519 zero length \begin{itshape}template\end{itshape} array passed, with which an annotation array can be
520 created.
521
522 \begin{lstlisting}[language=Java,firstnumber=461]
523   public native Annotation[][] getParameterAnnotations();
524 \end{lstlisting}
525 This method parses and returns all the parameter annotations in a
526 two-dimensional Annotation array.
527
528 \paragraph{TODO:}
529 \label{par:TODO/cache-parameter-annotations}Maybe also cache parsed parameter annotations? However, the
530 API specification does not specify an annotation lookup method like
531 \begin{scriptsize}\verb|getAnnotation|\hspace{0.0pt}\verb|(|\hspace{0.0pt}\verb|Class|\hspace{0.0pt}\verb|<|\hspace{0.0pt}\verb|T|\hspace{0.0pt}\verb|>|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|annotationClass|\hspace{0.0pt}\verb|)|\hspace{0.0pt}\verb||\end{scriptsize} for parameter annotations,
532 and so no Map has to be stored for this. The question is: Is caching the
533 parsed parameter annotation worth it? (OpenJDk does not do it.)
534
535 \subsection{src/lib/gnu/java/lang/reflect/Field.java}
536 \label{sec:src/lib/gnu/java/lang/reflect/Field.java}
537
538 Following fields where added:
539 \begin{lstlisting}[language=Java]
540   private byte[] annotations = null;
541   private transient Map<Class<? extends Annotation>, Annotation> declaredAnnotations = null;
542   private static final Annotation[] EMPTY_ANNOTATIONS_ARRAY =
543     new Annotation[0];
544 \end{lstlisting}
545 See: \begin{scriptsize}\verb|Constructor|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|java|\end{scriptsize} (see section \ref{sec:src/lib/gnu/java/lang/reflect/Constructor.java})
546
547 Following methods where added/implemented:
548 \begin{lstlisting}[language=Java]
549   public <T extends Annotation> T getAnnotation(Class<T> annotationClass)
550   public Annotation[] getDeclaredAnnotations()
551   private synchronized native Map<Class<? extends Annotation>, Annotation> declaredAnnotations();
552 \end{lstlisting}
553 See: \begin{scriptsize}\verb|Constructor|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|java|\end{scriptsize} (see section \ref{sec:src/lib/gnu/java/lang/reflect/Constructor.java})
554
555 \subsection{src/lib/gnu/java/lang/reflect/Method.java}
556 \label{sec:src/lib/gnu/java/lang/reflect/Method.java}
557
558 Following fields where added:
559 \begin{lstlisting}[language=Java]
560   private byte[] annotations          = null;
561   private byte[] parameterAnnotations = null;
562   private transient Map<Class<? extends Annotation>, Annotation> declaredAnnotations = null;
563   private static final Annotation[] EMPTY_ANNOTATIONS_ARRAY =
564     new Annotation[0];
565 \end{lstlisting}
566 See: \begin{scriptsize}\verb|Constructor|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|java|\end{scriptsize} (see section \ref{sec:src/lib/gnu/java/lang/reflect/Constructor.java})
567
568 \begin{lstlisting}[language=Java]
569   private byte[] annotationDefault    = null;
570 \end{lstlisting}
571 This field stores the unparsed annotation default value, if this method belongs
572 to an annotation interface. Otherwise, or if there is no default value, it
573 points to \begin{scriptsize}\verb|null|\end{scriptsize}.
574
575 Following methods where added/implemented:
576 \begin{lstlisting}[language=Java]
577   public <T extends Annotation> T getAnnotation(Class<T> annotationClass)
578   public Annotation[] getDeclaredAnnotations()
579   private synchronized native Map<Class<? extends Annotation>, Annotation> declaredAnnotations();
580   public native Annotation[][] getParameterAnnotations();
581 \end{lstlisting}
582 See: \begin{scriptsize}\verb|Constructor|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|java|\end{scriptsize} (see section \ref{sec:src/lib/gnu/java/lang/reflect/Constructor.java})
583
584 \begin{lstlisting}[language=Java]
585   public native Object getDefaultValue();
586 \end{lstlisting}
587 This method returns the parsed annotation default value of this method, if this
588 method belongs to an annotation interface. Otherwise, or if there is no default
589 value, it returns \begin{scriptsize}\verb|null|\end{scriptsize}.
590
591 \subsection{src/lib/gnu/sun/reflect/ConstantPool.java}
592 \label{sec:src/lib/gnu/sun/reflect/ConstantPool.java}
593
594 I imported this class from OpenJDk, where it is used to access the constant
595 pool entries of a class. This is needed when parsing annotations (and at the
596 moment only then).
597
598 I guess because it could be a security risk to grant normal Java code access to
599 this class, certain measures where taken to prevent that. First of all, there
600 is no obvious way to get a \begin{scriptsize}\verb|ConstantPool|\end{scriptsize} object in normal Java code.
601 Further the field \begin{scriptsize}\verb|constantPoolOop|\end{scriptsize} of the class \begin{scriptsize}\verb|ConstantPool|\end{scriptsize} is
602 hidden from the reflection API by this code:
603 \begin{lstlisting}[language=Java,firstnumber=61]
604   static {
605       Reflection.registerFieldsToFilter(ConstantPool.class, new String[] { "constantPoolOop" });
606   }
607 \end{lstlisting}
608 However, this is OpenJDK specific and I imported this class for usage with
609 GNU Classpath. I just out commented this static block, because I could not find
610 a similar mechanism in GNU Classpath. I'm not sure if this is even necessary
611 because there is no way to get a \begin{scriptsize}\verb|ConstantPool|\end{scriptsize} object in normal java code.
612
613 However, the field \begin{scriptsize}\verb|constantPoolOop|\end{scriptsize} is just the class object for which the
614 constant pool was requested. I figured this is the easiest way, because in
615 CACAO the access to the constant pool entries takes place by the function
616 \begin{scriptsize}\verb|voidptr|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|class_getconstant|\hspace{0.0pt}\verb|(|\hspace{0.0pt}\verb|classinfo|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|*|\hspace{0.0pt}\verb|class|\hspace{0.0pt}\verb|,|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|u4|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|pos|\hspace{0.0pt}\verb|,|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|u4|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|ctype|\hspace{0.0pt}\verb|)|\hspace{0.0pt}\verb||\end{scriptsize}.
617
618 \subsection{src/lib/gnu/sun/reflect/annotation/AnnotationParser.java}
619 \label{sec:src/lib/gnu/sun/reflect/annotation/AnnotationParser.java}
620
621 Like all classes in \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|lib|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|gnu|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|sun|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|annotation|\end{scriptsize} this class was
622 imported from OpenJDK.
623
624 \begin{lstlisting}[language=Java,firstnumber=59]
625     public static Annotation[] parseAnnotationsIntoArray(
626                 byte[] rawAnnotations,
627                 ConstantPool constPool,
628                 Class container)
629 \end{lstlisting}
630 This method is only used by \begin{scriptsize}\verb|java|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|lang|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|Class|\end{scriptsize}.
631
632 \begin{lstlisting}[language=Java,firstnumber=79]
633     public static Annotation[][] parseParameterAnnotations(
634                     byte[] parameterAnnotations,
635                     ConstantPool constPool,
636                     Class container,
637                     int numParameters)
638 \end{lstlisting}
639 This method is a wrapper around
640 \begin{scriptsize}\verb|public|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|static|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|Annotation|\hspace{0.0pt}\verb|[|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|]|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|[|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|]|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|parseParameterAnnotations|\hspace{0.0pt}\verb|(|\hspace{0.0pt}\verb|byte|\hspace{0.0pt}\verb|[|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|]|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|rawAnnotations|\hspace{0.0pt}\verb|,|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|ConstantPool|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|constPool|\hspace{0.0pt}\verb|,|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|Class|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|container|\hspace{0.0pt}\verb|)|\hspace{0.0pt}\verb||\end{scriptsize}
641 which basically adds a check if \begin{scriptsize}\verb|parameterAnnotations|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|=|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|=|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|null|\end{scriptsize} (= no parameter
642 annotations at all) and a check for the parameter count and throws appropriate
643 exceptions.
644
645 \begin{lstlisting}[language=Java,firstnumber=111]
646     public static Object parseAnnotationDefault(Method method,
647                                                 byte[] annotationDefault,
648                                                 ConstantPool constPool)
649 \end{lstlisting}
650 This is basically a copy from OpenJDKs
651 \begin{scriptsize}\verb|java|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|lang|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|Method|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|getAnnotationDefault|\hspace{0.0pt}\verb|(|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|)|\hspace{0.0pt}\verb||\end{scriptsize} method because I wanted
652 to change as less as possible in the Classpath code and there this method is
653 declared as \begin{scriptsize}\verb|native|\end{scriptsize}. However, I would have to write a method to get a
654 \begin{scriptsize}\verb|ConstantPool|\end{scriptsize} object in java code from which I rather stay away. My policy
655 is: You can't get a \begin{scriptsize}\verb|ConstantPool|\end{scriptsize}, but the VM can give one to "you" (to the
656 right method).
657
658 \begin{lstlisting}[language=Java,firstnumber=465]
659     private static Class<?> parseSig(String sig, Class container) {
660         if (sig.equals("V")) {
661             return void.class;
662         }
663         else {
664             return toClass(new FieldSignatureParser(container, sig).getFieldType());
665         }
666     }
667 \end{lstlisting}
668 I had to rewrite this method. It was much more complex and used a lot of
669 classes from OpenJDK I would have had to import. But GNU Classpath has it's own
670 signature parser (\begin{scriptsize}\verb|gnu|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|java|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|lang|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|FieldSignatureParser|\end{scriptsize}) which I
671 rather used instead. The \begin{scriptsize}\verb|sig|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|equals|\hspace{0.0pt}\verb|(|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|"|\hspace{0.0pt}\verb|V|\hspace{0.0pt}\verb|"|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|)|\hspace{0.0pt}\verb||\end{scriptsize} comparison was already in
672 OpenJDKs version. It seems that neither GNU Classpath nor OpenJDK has a return
673 type signature parser, but looking at the specs one can see that a field type
674 signature parser plus this check for void does the same.
675
676 \subsection{src/lib/gnu/sun/reflect/annotation/AnnotationType.java}
677 \label{sec:src/lib/gnu/sun/reflect/annotation/AnnotationType.java}
678
679 Imported from OpenJDK. Needed by \begin{scriptsize}\verb|AnnotationParser|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|java|\end{scriptsize} (see section \ref{sec:src/lib/gnu/sun/reflect/annotation/AnnotationParser.java}).
680
681 This class used OpenJDks \begin{scriptsize}\verb|sun|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|misc|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|SharedSecrets|\end{scriptsize} feature to keep an
682 annotation \begin{scriptsize}\verb|Class|\end{scriptsize} to \begin{scriptsize}\verb|AnnotationType|\end{scriptsize} mapping at a shared but secrete
683 place. In particular the methods
684 \begin{scriptsize}\verb|void|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|sun|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|misc|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|SharedSecrets|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|getJavaLangAccess|\hspace{0.0pt}\verb|(|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|)|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|setAnnotationType|\hspace{0.0pt}\verb|(|\hspace{0.0pt}\verb|Class|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|annotationClass|\hspace{0.0pt}\verb|,|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|AnnotationType|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|annotationType|\hspace{0.0pt}\verb|)|\hspace{0.0pt}\verb||\end{scriptsize}
685 and \begin{scriptsize}\verb|AnnotationType|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|sun|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|misc|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|SharedSecrets|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|getJavaLangAccess|\hspace{0.0pt}\verb|(|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|)|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|getAnnotationType|\hspace{0.0pt}\verb|(|\hspace{0.0pt}\verb|Class|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|annotationClass|\hspace{0.0pt}\verb|)|\hspace{0.0pt}\verb||\end{scriptsize}
686 where used.
687
688 GNU Classpath does not have such a feature and therefore I simply added a
689 \begin{scriptsize}\verb|Map|\end{scriptsize} to maintain the mapping:
690 \begin{lstlisting}[language=Java,firstnumber=50]
691     private static Map<Class, AnnotationType> annotationTypes =
692         new HashMap<Class, AnnotationType>();
693 \end{lstlisting}
694
695 This map is accessed in the methods
696 \begin{scriptsize}\verb|public|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|static|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|synchronized|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|AnnotationType|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|getInstance|\hspace{0.0pt}\verb|(|\hspace{0.0pt}\verb|Class|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|annotationClass|\hspace{0.0pt}\verb|)|\hspace{0.0pt}\verb||\end{scriptsize}
697 and \begin{scriptsize}\verb|private|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|AnnotationType|\hspace{0.0pt}\verb|(|\hspace{0.0pt}\verb|final|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|Class|\hspace{0.0pt}\verb|<|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|?|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|>|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|annotationClass|\hspace{0.0pt}\verb|)|\hspace{0.0pt}\verb||\end{scriptsize}.
698
699 \subsection{src/lib/gnu/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java}
700 \label{sec:src/lib/gnu/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java}
701
702 Imported from OpenJDK. Needed by \begin{scriptsize}\verb|AnnotationParser|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|java|\end{scriptsize} (see section \ref{sec:src/lib/gnu/sun/reflect/annotation/AnnotationParser.java}).
703
704 \subsection{src/lib/gnu/sun/reflect/annotation/EnumConstantNotPresentExceptionProxy.java}
705 \label{sec:src/lib/gnu/sun/reflect/annotation/EnumConstantNotPresentExceptionProxy.java}
706
707 Imported from OpenJDK. Needed by \begin{scriptsize}\verb|AnnotationParser|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|java|\end{scriptsize} (see section \ref{sec:src/lib/gnu/sun/reflect/annotation/AnnotationParser.java}).
708
709 \subsection{src/lib/gnu/sun/reflect/annotation/ExceptionProxy.java}
710 \label{sec:src/lib/gnu/sun/reflect/annotation/ExceptionProxy.java}
711
712 Imported from OpenJDK. Needed by \begin{scriptsize}\verb|AnnotationParser|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|java|\end{scriptsize} (see section \ref{sec:src/lib/gnu/sun/reflect/annotation/AnnotationParser.java}).
713
714 \subsection{src/lib/gnu/sun/reflect/annotation/TypeNotPresentExceptionProxy.java}
715 \label{sec:src/lib/gnu/sun/reflect/annotation/TypeNotPresentExceptionProxy.java}
716
717 Imported from OpenJDK. Needed by \begin{scriptsize}\verb|AnnotationParser|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|java|\end{scriptsize} (see section \ref{sec:src/lib/gnu/sun/reflect/annotation/AnnotationParser.java}).
718
719 \subsection{src/native/include/Makefile.am}
720 \label{sec:src/native/include/Makefile.am}
721
722 Added \begin{scriptsize}\verb|sun_reflect_ConstantPool|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|h|\end{scriptsize} to \begin{scriptsize}\verb|JAVASE_HEADER_FILES|\end{scriptsize}.
723
724 \subsection{src/native/llni.h}
725 \label{sec:src/native/llni.h}
726
727 Added two macros for accessing fields of the \begin{scriptsize}\verb|classinfo|\end{scriptsize} struct which are Java
728 objects:
729 \begin{lstlisting}[language=C,firstnumber=88]
730 /* LLNI_classinfo_field_get ***************************************************
731  
732    Get a field from classinfo that is a java object.
733
734 ******************************************************************************/
735
736 #define LLNI_classinfo_field_get(cls, field, variable) \
737         LLNI_CRITICAL_START; \
738         (variable) = LLNI_WRAP((cls)->field); \
739         LLNI_CRITICAL_END
740
741
742 /* LLNI_classinfo_field_set ***************************************************
743  
744    Set a field from classinfo that is a java object.
745
746 ******************************************************************************/
747
748 #define LLNI_classinfo_field_set(cls, field, variable) \
749         LLNI_CRITICAL_START; \
750         (cls)->field = LLNI_UNWRAP(variable); \
751         LLNI_CRITICAL_END
752 \end{lstlisting}
753
754 For implementing class unloading the \begin{scriptsize}\verb|classinfo|\end{scriptsize} struct has to be placed onto the
755 Java heap. When this will happen and handles are enabled, accessing members of
756 \begin{scriptsize}\verb|classinfo|\end{scriptsize} will become more difficult (basically like accessing members of other
757 Java objects). To wrap this access I added these macros. It is still not clear
758 how exactly the access will work, but when using these macros one has only to
759 change them instead all code that access Java object fields of \begin{scriptsize}\verb|classinfo|\end{scriptsize}.
760
761 \subsection{src/native/vm/gnu/Makefile.am}
762 \label{sec:src/native/vm/gnu/Makefile.am}
763
764 Added \begin{scriptsize}\verb|sun_reflect_ConstantPool|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|c|\end{scriptsize} to \begin{scriptsize}\verb|SUN_REFLECT_SOURCES|\end{scriptsize}.
765 Added \begin{scriptsize}\verb|java_lang_reflect_Constructor|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|c|\end{scriptsize} to \begin{scriptsize}\verb|libnativevmcore_la_SOURCES|\end{scriptsize}.
766
767 \subsection{src/native/vm/gnu/java\_lang\_VMClass.c}
768 \label{sec:src/native/vm/gnu/java_lang_VMClass.c}
769
770 If \begin{scriptsize}\verb|ENABLE_ANNOTATIONS|\end{scriptsize} is defined, the method
771 \begin{scriptsize}\verb|getDeclaredAnnotations|\end{scriptsize} will be defined.
772
773 \subsection{src/native/vm/gnu/java\_lang\_reflect\_Constructor.c}
774 \label{sec:src/native/vm/gnu/java_lang_reflect_Constructor.c}
775
776 If \begin{scriptsize}\verb|ENABLE_ANNOTATIONS|\end{scriptsize} is defined, the methods
777 \begin{scriptsize}\verb|declaredAnnotations|\end{scriptsize} and \begin{scriptsize}\verb|getParameterAnnotations|\end{scriptsize} will be
778 defined.
779
780 Following functions where added:
781 \begin{itemize}
782  \item \begin{scriptsize}\verb|Java_java_lang_reflect_Constructor_declaredAnnotations|\end{scriptsize}
783 \end{itemize}
784 This function implements
785 \begin{scriptsize}\verb|java|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|lang|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|Constructor|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|declaredAnnotations|\end{scriptsize}. It uses the
786 function \begin{scriptsize}\verb|struct|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|java_util_Map|\hspace{0.0pt}\verb|*|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|reflect_get_declaredannotatios|\hspace{0.0pt}\verb|(|\hspace{0.0pt}\verb|java_handle_bytearray_t|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|*|\hspace{0.0pt}\verb|annotations|\hspace{0.0pt}\verb|,|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|java_lang_Class|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|*|\hspace{0.0pt}\verb|declaringClass|\hspace{0.0pt}\verb|,|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|classinfo|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|*|\hspace{0.0pt}\verb|referrer|\hspace{0.0pt}\verb|)|\hspace{0.0pt}\verb||\end{scriptsize} to do so.
787
788 \begin{itemize}
789  \item \begin{scriptsize}\verb|Java_java_lang_reflect_Constructor_getParameterAnnotations|\end{scriptsize}
790 \end{itemize}
791 This function implements
792 \begin{scriptsize}\verb|java|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|lang|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|Constructor|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|getParameterAnnotations|\end{scriptsize}. It uses the
793 function \begin{scriptsize}\verb|java_handle_objectarray_t|\hspace{0.0pt}\verb|*|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|reflect_get_parameterannotations|\hspace{0.0pt}\verb|(|\hspace{0.0pt}\verb|java_handle_t|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|*|\hspace{0.0pt}\verb|parameterAnnotations|\hspace{0.0pt}\verb|,|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|int32_t|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|slot|\hspace{0.0pt}\verb|,|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|java_lang_Class|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|*|\hspace{0.0pt}\verb|declaringClass|\hspace{0.0pt}\verb|,|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|classinfo|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|*|\hspace{0.0pt}\verb|referrer|\hspace{0.0pt}\verb|)|\hspace{0.0pt}\verb||\end{scriptsize} to do so.
794
795 \subsection{src/native/vm/gnu/java\_lang\_reflect\_Field.c}
796 \label{sec:src/native/vm/gnu/java_lang_reflect_Field.c}
797
798 If \begin{scriptsize}\verb|ENABLE_ANNOTATIONS|\end{scriptsize} is defined, the method
799 \begin{scriptsize}\verb|declaredAnnotations|\end{scriptsize} will be defined.
800
801 Following function was added:
802 \begin{itemize}
803  \item \begin{scriptsize}\verb|Java_java_lang_reflect_Field_declaredAnnotations|\end{scriptsize}
804 \end{itemize}
805 This function implements
806 \begin{scriptsize}\verb|java|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|lang|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|Field|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|declaredAnnotations|\end{scriptsize}. It uses the
807 function \begin{scriptsize}\verb|struct|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|java_util_Map|\hspace{0.0pt}\verb|*|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|reflect_get_declaredannotatios|\hspace{0.0pt}\verb|(|\hspace{0.0pt}\verb|java_handle_bytearray_t|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|*|\hspace{0.0pt}\verb|annotations|\hspace{0.0pt}\verb|,|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|java_lang_Class|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|*|\hspace{0.0pt}\verb|declaringClass|\hspace{0.0pt}\verb|,|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|classinfo|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|*|\hspace{0.0pt}\verb|referrer|\hspace{0.0pt}\verb|)|\hspace{0.0pt}\verb||\end{scriptsize} to do so.
808
809 \subsection{src/native/vm/gnu/java\_lang\_reflect\_Method.c}
810 \label{sec:src/native/vm/gnu/java_lang_reflect_Method.c}
811
812 If \begin{scriptsize}\verb|ENABLE_ANNOTATIONS|\end{scriptsize} is defined, the methods \begin{scriptsize}\verb|getDefaultValue|\end{scriptsize},
813 \begin{scriptsize}\verb|declaredAnnotations|\end{scriptsize} and \begin{scriptsize}\verb|getParameterAnnotations|\end{scriptsize} will be
814 defined.
815
816 Following functions where added:
817 \begin{itemize}
818  \item \begin{scriptsize}\verb|Java_java_lang_reflect_Method_getDefaultValue|\end{scriptsize}
819 \end{itemize}
820 This function implements \begin{scriptsize}\verb|java|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|lang|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|Method|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|getDefaultValue|\end{scriptsize}. It
821 uses the static method \begin{scriptsize}\verb|sun|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|annotation|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|AnnotationParser|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|parseAnnotationDefault|\hspace{0.0pt}\verb|(|\hspace{0.0pt}\verb|Method|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|m|\hspace{0.0pt}\verb|,|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|ConstantPoop|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|cpool|\hspace{0.0pt}\verb|)|\hspace{0.0pt}\verb||\end{scriptsize} to do so.
822 Because this static method is only used here, I thought it makes sense to cache
823 it's \begin{scriptsize}\verb|methodinfo|\end{scriptsize} here, so I don't have to resolve this method every time
824 \begin{scriptsize}\verb|getDefaultValue|\end{scriptsize} is called. For this purpose I made the
825 \begin{scriptsize}\verb|m_parseAnnotationDefault|\end{scriptsize} pointer \begin{scriptsize}\verb|static|\end{scriptsize}.
826
827 \begin{itemize}
828  \item \begin{scriptsize}\verb|Java_java_lang_reflect_Constructor_declaredAnnotations|\end{scriptsize}
829 \end{itemize}
830 This function implements
831 \begin{scriptsize}\verb|java|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|lang|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|Method|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|declaredAnnotations|\end{scriptsize}. It uses the
832 function \begin{scriptsize}\verb|struct|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|java_util_Map|\hspace{0.0pt}\verb|*|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|reflect_get_declaredannotatios|\hspace{0.0pt}\verb|(|\hspace{0.0pt}\verb|java_handle_bytearray_t|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|*|\hspace{0.0pt}\verb|annotations|\hspace{0.0pt}\verb|,|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|java_lang_Class|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|*|\hspace{0.0pt}\verb|declaringClass|\hspace{0.0pt}\verb|,|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|classinfo|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|*|\hspace{0.0pt}\verb|referrer|\hspace{0.0pt}\verb|)|\hspace{0.0pt}\verb||\end{scriptsize} to do so.
833
834 \begin{itemize}
835  \item \begin{scriptsize}\verb|Java_java_lang_reflect_Constructor_getParameterAnnotations|\end{scriptsize}
836 \end{itemize}
837 This function implements
838 \begin{scriptsize}\verb|java|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|lang|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|Method|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|getParameterAnnotations|\end{scriptsize}. It uses the
839 function \begin{scriptsize}\verb|java_handle_objectarray_t|\hspace{0.0pt}\verb|*|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|reflect_get_parameterannotations|\hspace{0.0pt}\verb|(|\hspace{0.0pt}\verb|java_handle_t|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|*|\hspace{0.0pt}\verb|parameterAnnotations|\hspace{0.0pt}\verb|,|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|int32_t|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|slot|\hspace{0.0pt}\verb|,|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|java_lang_Class|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|*|\hspace{0.0pt}\verb|declaringClass|\hspace{0.0pt}\verb|,|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|classinfo|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|*|\hspace{0.0pt}\verb|referrer|\hspace{0.0pt}\verb|)|\hspace{0.0pt}\verb||\end{scriptsize} to do so.
840
841 \subsection{src/native/vm/gnu/sun\_reflect\_ConstantPool.c}
842 \label{sec:src/native/vm/gnu/sun_reflect_ConstantPool.c}
843
844 This file is one of two almost 100% identical implementations of the class
845 \begin{scriptsize}\verb|sun|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|ConstantPool|\end{scriptsize}. The other one can be found in
846 \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|native|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|vm|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|sun|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|jvm|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|c|\end{scriptsize} (see section \ref{sec:src/native/vm/sun/jvm.c}). The thing is, this class is
847 needed for OpenJDK and GNU Classpath (because I also use OpenJDKs
848 \begin{scriptsize}\verb|AnnotationParser|\end{scriptsize} with GNU Classpath) and even though it does the same
849 thing in both cases, it has to be implemented in different files with different
850 method names. This is a common problem which is discussed on the mailing list.
851 Until we find a proper solution, twisti said I just should implement it twice,
852 no matter the redundancy.
853
854 Actually not all methods of this class are used in the annotations support
855 (and therefore in whole OpenJDK, because annotations support still is the only
856 thing which uses this class).
857
858 The used methods are:
859 \begin{itemize}
860  \item \begin{scriptsize}\verb|getIntAt0|\end{scriptsize}
861  \item \begin{scriptsize}\verb|getLongAt0|\end{scriptsize}
862  \item \begin{scriptsize}\verb|getFloatAt0|\end{scriptsize}
863  \item \begin{scriptsize}\verb|getDoubleAt0|\end{scriptsize}
864  \item \begin{scriptsize}\verb|getUTF8At0|\end{scriptsize}
865 \end{itemize}
866
867 Not used methods, which I implemented anyway because of their triviality are:
868 \begin{itemize}
869  \item \begin{scriptsize}\verb|getSize0|\end{scriptsize}
870  \item \begin{scriptsize}\verb|getClassAt0|\end{scriptsize}
871  \item \begin{scriptsize}\verb|getClassAtIfLoaded0|\end{scriptsize}
872  \item \begin{scriptsize}\verb|getMethodAt0|\end{scriptsize}
873  \item \begin{scriptsize}\verb|getMethodAtIfLoaded0|\end{scriptsize}
874  \item \begin{scriptsize}\verb|getFieldAt0|\end{scriptsize}
875  \item \begin{scriptsize}\verb|getFieldAtIfLoaded0|\end{scriptsize}
876  \item \begin{scriptsize}\verb|getStringAt0|\end{scriptsize}
877 \end{itemize}
878
879 Methods, which I didn't implement because what they do wasn't clear to me:
880 \begin{itemize}
881  \item \begin{scriptsize}\verb|getMemberRefInfoAt0|\end{scriptsize}
882 \end{itemize}
883
884 Almost all the implemented functions basically are implemented by calling
885 \begin{scriptsize}\verb|voidptr|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|class_getconstant|\hspace{0.0pt}\verb|(|\hspace{0.0pt}\verb|classinfo|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|*|\hspace{0.0pt}\verb|class|\hspace{0.0pt}\verb|,|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|u4|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|pos|\hspace{0.0pt}\verb|,|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|u4|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|ctype|\hspace{0.0pt}\verb|)|\hspace{0.0pt}\verb||\end{scriptsize}.
886
887 \paragraph{TODO:}
888 \label{par:TODO/ConstantPool.getStringAt0}In the implementations for \begin{scriptsize}\verb|getStringAt0|\end{scriptsize} and \begin{scriptsize}\verb|getUTF8At0|\end{scriptsize}
889 I'm not sure if I used the right \begin{scriptsize}\verb|string_new|\end{scriptsize}-function. I used
890 \begin{scriptsize}\verb|java_object_t|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|*|\hspace{0.0pt}\verb|literalstring_new|\hspace{0.0pt}\verb|(|\hspace{0.0pt}\verb|utf|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|*|\hspace{0.0pt}\verb|u|\hspace{0.0pt}\verb|)|\hspace{0.0pt}\verb||\end{scriptsize} where maybe
891 \begin{scriptsize}\verb|java_handle_t|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|*|\hspace{0.0pt}\verb|javastring_new|\hspace{0.0pt}\verb|(|\hspace{0.0pt}\verb|utf|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|*|\hspace{0.0pt}\verb|text|\hspace{0.0pt}\verb|)|\hspace{0.0pt}\verb||\end{scriptsize} would have been the correct
892 function. Maybe this has to be changed.
893
894 I'm not sure if the implementation of \begin{scriptsize}\verb|getMethodAt0|\end{scriptsize} is 100% right. (See
895 comment in the source.) But this method is not used anyway.
896
897 \paragraph{TODO:}
898 \label{par:TODO/join-constantpool-implementations}Join the two redundant \begin{scriptsize}\verb|sun|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|ConstantPool|\end{scriptsize}
899 implementations. It has to be discussed how that has to be done and where this
900 implementation has to be placed.
901
902 \subsection{src/native/vm/java\_lang\_Class.c}
903 \label{sec:src/native/vm/java_lang_Class.c}
904
905 Here I had to implement the \begin{scriptsize}\verb|getDeclaredAnnotations|\end{scriptsize} method, but only for
906 GNU Classpath. OpenJDK does that in the J2SE implementation. The method is
907 implemented in the function \begin{scriptsize}\verb|java_handle_objectarray_t|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|*|\hspace{0.0pt}\verb|_Jv_java_lang_Class_getDeclaredAnnotations|\hspace{0.0pt}\verb|(|\hspace{0.0pt}\verb|java_lang_Class|\hspace{0.0pt}\verb|*|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|klass|\hspace{0.0pt}\verb|)|\hspace{0.0pt}\verb||\end{scriptsize}.
908 This function has to call the static method \begin{scriptsize}\verb|Annotation|\hspace{0.0pt}\verb|[|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|]|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|sun|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|annotation|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|AnnotationParser|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|parseAnnotationsIntoArray|\hspace{0.0pt}\verb|(|\hspace{0.0pt}\verb|ConstantPool|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|cpool|\hspace{0.0pt}\verb|,|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|Class|\hspace{0.0pt}\verb|<|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|?|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|>|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|cls|\hspace{0.0pt}\verb|)|\hspace{0.0pt}\verb||\end{scriptsize}.
909 The \begin{scriptsize}\verb|methodinfo|\end{scriptsize} for this method is cached like it's done in \begin{scriptsize}\verb|Java_java_lang_reflect_Method_getDefaultValue|\end{scriptsize}.
910
911 \subsection{src/native/vm/java\_lang\_Class.h}
912 \label{sec:src/native/vm/java_lang_Class.h}
913
914 Added declaration: \begin{scriptsize}\verb|java_handle_objectarray_t|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|*|\hspace{0.0pt}\verb|_Jv_java_lang_Class_getDeclaredAnnotations|\hspace{0.0pt}\verb|(|\hspace{0.0pt}\verb|java_lang_Class|\hspace{0.0pt}\verb|*|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|klass|\hspace{0.0pt}\verb|)|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|;|\hspace{0.0pt}\verb||\end{scriptsize}
915
916 \subsection{src/native/vm/nativevm.c}
917 \label{sec:src/native/vm/nativevm.c}
918
919 Added to GNU Classpath section:
920 \begin{lstlisting}[language=C,firstnumber=90]
921 #if defined(ENABLE_ANNOTATIONS)
922         _Jv_sun_reflect_ConstantPool_init();
923 #endif
924 \end{lstlisting}
925
926 \subsection{src/native/vm/nativevm.h}
927 \label{sec:src/native/vm/nativevm.h}
928
929 Added to GNU Classpath section:
930 \begin{lstlisting}[language=C,firstnumber=69]
931 #if defined(ENABLE_ANNOTATIONS)
932 void _Jv_sun_reflect_ConstantPool_init();
933 #endif
934 \end{lstlisting}
935
936 \subsection{src/native/vm/reflect.c}
937 \label{sec:src/native/vm/reflect.c}
938
939 In the \begin{scriptsize}\verb|reflect_|\hspace{0.0pt}\verb|*|\hspace{0.0pt}\verb|_new|\end{scriptsize}-functions for the reflective types, I added the
940 calls to the \begin{scriptsize}\verb||\hspace{0.0pt}\verb|*|\hspace{0.0pt}\verb|_get_annotations|\end{scriptsize} functions.
941
942 Following functions were added:
943 \begin{itemize}
944  \item \begin{scriptsize}\verb|reflect_get_declaredannotatios|\end{scriptsize}
945 \end{itemize}
946 This function creates a \begin{scriptsize}\verb|ConstantPool|\end{scriptsize} instance for the given
947 \begin{scriptsize}\verb|declaringClass|\end{scriptsize} and calls the static method
948 \begin{scriptsize}\verb|Map|\hspace{0.0pt}\verb|<|\hspace{0.0pt}\verb|Class|\hspace{0.0pt}\verb|,|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|Annotation|\hspace{0.0pt}\verb|>|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|sun|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|annotation|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|AnnotationParser|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|parseAnnotation|\hspace{0.0pt}\verb|(|\hspace{0.0pt}\verb|ConstantPool|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|cpool|\hspace{0.0pt}\verb|,|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|Class|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|cls|\hspace{0.0pt}\verb|)|\hspace{0.0pt}\verb||\end{scriptsize}
949 in order to parse the annotations. The \begin{scriptsize}\verb|methodinfo|\end{scriptsize} for this static method is
950 cached as a \begin{scriptsize}\verb|static|\end{scriptsize} variable.
951
952 \begin{itemize}
953  \item \begin{scriptsize}\verb|reflect_get_parameterannotations|\end{scriptsize}
954 \end{itemize}
955 This function creates a \begin{scriptsize}\verb|ConstantPool|\end{scriptsize} instance for the given
956 \begin{scriptsize}\verb|declaringClass|\end{scriptsize} and calls the static method
957 \begin{scriptsize}\verb|Annotation|\hspace{0.0pt}\verb|[|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|]|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|[|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|]|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|sun|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|annotation|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|AnnotationParser|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|parseAnnotation|\hspace{0.0pt}\verb|(|\hspace{0.0pt}\verb|ConstantPool|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|cpool|\hspace{0.0pt}\verb|,|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|Class|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|cls|\hspace{0.0pt}\verb|,|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|int|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb|paramcount|\hspace{0.0pt}\verb|)|\hspace{0.0pt}\verb||\end{scriptsize}
958 in order to parse the parameter annotations. The \begin{scriptsize}\verb|methodinfo|\end{scriptsize} for this static
959 method is cached as a \begin{scriptsize}\verb|static|\end{scriptsize} variable.
960
961 \subsection{src/native/vm/reflect.h}
962 \label{sec:src/native/vm/reflect.h}
963
964 Following declarations were added:
965 \begin{lstlisting}[language=C,firstnumber=65]
966 #if defined(WITH_CLASSPATH_GNU) && defined(ENABLE_ANNOTATIONS)
967 struct java_util_Map* reflect_get_declaredannotatios(
968         java_handle_bytearray_t *annotations,
969         java_lang_Class         *declaringClass,
970         classinfo               *referrer);
971
972 java_handle_objectarray_t* reflect_get_parameterannotations(
973         java_handle_t   *parameterAnnotations,
974         int32_t          slot,
975         java_lang_Class *declaringClass,
976         classinfo       *referrer);
977 #endif
978 \end{lstlisting}
979
980 \subsection{src/native/vm/sun/jvm.c}
981 \label{sec:src/native/vm/sun/jvm.c}
982
983 Following functions where implemented:
984 \begin{itemize}
985  \item \begin{scriptsize}\verb|JVM_GetClassAnnotations|\end{scriptsize}
986  \item \begin{scriptsize}\verb|JVM_GetFieldAnnotations|\end{scriptsize}
987  \item \begin{scriptsize}\verb|JVM_GetMethodAnnotations|\end{scriptsize}
988  \item \begin{scriptsize}\verb|JVM_GetMethodDefaultAnnotationValue|\end{scriptsize}
989  \item \begin{scriptsize}\verb|JVM_GetMethodParameterAnnotations|\end{scriptsize}
990  \item \begin{scriptsize}\verb|JVM_GetClassConstantPool|\end{scriptsize}
991  \item \begin{scriptsize}\verb|JVM_ConstantPoolGetSize|\end{scriptsize}
992  \item \begin{scriptsize}\verb|JVM_ConstantPoolGetClassAt|\end{scriptsize}
993  \item \begin{scriptsize}\verb|JVM_ConstantPoolGetClassAtIfLoaded|\end{scriptsize}
994  \item \begin{scriptsize}\verb|JVM_ConstantPoolGetMethodAt|\end{scriptsize}
995  \item \begin{scriptsize}\verb|JVM_ConstantPoolGetMethodAtIfLoaded|\end{scriptsize}
996  \item \begin{scriptsize}\verb|JVM_ConstantPoolGetFieldAt|\end{scriptsize}
997  \item \begin{scriptsize}\verb|JVM_ConstantPoolGetFieldAtIfLoaded|\end{scriptsize}
998  \item \begin{scriptsize}\verb|JVM_ConstantPoolGetMemberRefInfoAt|\end{scriptsize}
999  \item \begin{scriptsize}\verb|JVM_ConstantPoolGetIntAt|\end{scriptsize}
1000  \item \begin{scriptsize}\verb|JVM_ConstantPoolGetLongAt|\end{scriptsize}
1001  \item \begin{scriptsize}\verb|JVM_ConstantPoolGetFloatAt|\end{scriptsize}
1002  \item \begin{scriptsize}\verb|JVM_ConstantPoolGetDoubleAt|\end{scriptsize}
1003  \item \begin{scriptsize}\verb|JVM_ConstantPoolGetStringAt|\end{scriptsize}
1004  \item \begin{scriptsize}\verb|JVM_ConstantPoolGetUTF8At|\end{scriptsize}
1005 \end{itemize}
1006
1007 The \begin{scriptsize}\verb|JVM_Get|\hspace{0.0pt}\verb|*|\hspace{0.0pt}\verb|Annotations|\end{scriptsize} functions just call the corresponding \begin{scriptsize}\verb||\hspace{0.0pt}\verb|*|\hspace{0.0pt}\verb|_get_annotations|\end{scriptsize}
1008 functions.
1009
1010 The \begin{scriptsize}\verb|JVM_ConstantPool|\hspace{0.0pt}\verb|*|\hspace{0.0pt}\verb||\end{scriptsize} functions are implementing the methods of the
1011 \begin{scriptsize}\verb|sun|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|ConstantPool|\end{scriptsize} class.
1012
1013 See: \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|native|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|vm|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|gnu|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|sun_reflect_ConstantPool|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|c|\end{scriptsize} (see section \ref{sec:src/native/vm/gnu/sun_reflect_ConstantPool.c})
1014
1015 The function \begin{scriptsize}\verb|JVM_GetClassConstantPool|\end{scriptsize} returns a \begin{scriptsize}\verb|sun|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|reflect|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|ConstantPool|\end{scriptsize}
1016 instance for the given \begin{scriptsize}\verb|java|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|lang|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|Class|\end{scriptsize} object.
1017
1018 \subsection{src/vmcore/Makefile.am}
1019 \label{sec:src/vmcore/Makefile.am}
1020
1021 \begin{scriptsize}\verb|ANNOTATION_SOURCES|\end{scriptsize} is only defined if \begin{scriptsize}\verb|ENABLE_ANNOTATIONS|\end{scriptsize} is.
1022
1023 \subsection{src/vmcore/annotation.c}
1024 \label{sec:src/vmcore/annotation.c}
1025
1026 This file implements the annotation attribute loading.
1027
1028 The \begin{scriptsize}\verb|annotation_load_|\hspace{0.0pt}\verb|*|\hspace{0.0pt}\verb||\end{scriptsize} functions are used to load the corresponding
1029 annotations and store them into the corresponding \begin{scriptsize}\verb|classinfo|\end{scriptsize} struct.
1030
1031 The unparsed annotations, parameter annotations and annotation default values
1032 for methods and fields are also stored in the \begin{scriptsize}\verb|classinfo|\end{scriptsize}, in order to reduce
1033 the overhead to the \begin{scriptsize}\verb|methodinfo|\end{scriptsize} and \begin{scriptsize}\verb|fieldinfo|\end{scriptsize} structs. This data is
1034 stored in arrays, where you can access the data at the members slot. These arrays
1035 are only as big as they need to be, meaning if there are e.g. 10 methods, but only
1036 the first one is annotated, the \begin{scriptsize}\verb|method_annotations|\end{scriptsize} array is only one
1037 element in size. If there aren't any method annotations at all,
1038 \begin{scriptsize}\verb|method_annotations|\end{scriptsize} is \begin{scriptsize}\verb|NULL|\end{scriptsize}.
1039
1040 During the classloading process I can't know which one's the highest slot with
1041 annotations, so I first allocate an array that is just big enough for the first
1042 annotated slot I parse. If during further loading higher annotated slots occur,
1043 a bigger array is allocated and the old elements are copied to it.
1044
1045 Maybe this could be made more efficient by first allocating an array that is as
1046 big as the method-/field-count and after loading all methods/fields, the array
1047 will be packed (the elements get copied into a smaller but big enough array).
1048
1049 I used \begin{scriptsize}\verb|java_bytearray_t|\end{scriptsize} to store the unparsed annotations and
1050 \begin{scriptsize}\verb|java_objectarray_t|\end{scriptsize} when I needed an array of byte-arrays.
1051
1052 See: \begin{scriptsize}\verb|src|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|vmcore|\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|class|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|h|\end{scriptsize} (see section \ref{sec:src/vmcore/class.h})
1053
1054 \subsection{src/vmcore/annotation.h}
1055 \label{sec:src/vmcore/annotation.h}
1056
1057 Following declarations where added:
1058 \begin{lstlisting}[language=C,firstnumber=43]
1059 /* function prototypes ********************************************************/
1060
1061 bool annotation_load_class_attribute_runtimevisibleannotations(
1062         classbuffer *cb);
1063
1064 bool annotation_load_class_attribute_runtimeinvisibleannotations(
1065         classbuffer *cb);
1066
1067 bool annotation_load_method_attribute_runtimevisibleannotations(
1068         classbuffer *cb, methodinfo *m);
1069
1070 bool annotation_load_method_attribute_runtimeinvisibleannotations(
1071         classbuffer *cb, methodinfo *m);
1072
1073 bool annotation_load_field_attribute_runtimevisibleannotations(
1074         classbuffer *cb, fieldinfo *f);
1075
1076 bool annotation_load_field_attribute_runtimeinvisibleannotations(
1077         classbuffer *cb, fieldinfo *f);
1078
1079 bool annotation_load_method_attribute_annotationdefault(
1080         classbuffer *cb, methodinfo *m);
1081
1082 bool annotation_load_method_attribute_runtimevisibleparameterannotations(
1083         classbuffer *cb, methodinfo *m);
1084
1085 bool annotation_load_method_attribute_runtimeinvisibleparameterannotations(
1086         classbuffer *cb, methodinfo *m);
1087 \end{lstlisting}
1088
1089 These functions load the respective attributes from a \begin{scriptsize}\verb|classbuffer|\end{scriptsize}.
1090 They return \begin{scriptsize}\verb|true|\end{scriptsize} on success or \begin{scriptsize}\verb|false|\end{scriptsize} if an error has occured.
1091
1092 \subsection{src/vmcore/class.c}
1093 \label{sec:src/vmcore/class.c}
1094
1095 \begin{itemize}
1096  \item \begin{scriptsize}\verb|classinfo|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|*|\hspace{0.0pt}\verb|class_sun_reflect_ConstantPool|\hspace{0.0pt}\verb|;|\hspace{0.0pt}\verb||\end{scriptsize}
1097  \item \begin{scriptsize}\verb|classinfo|\hspace{0.0pt}\verb| |\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|*|\hspace{0.0pt}\verb|class_sun_reflect_annotation_AnnotationParser|\hspace{0.0pt}\verb|;|\hspace{0.0pt}\verb||\end{scriptsize}
1098 \end{itemize}
1099 Declared \begin{scriptsize}\verb|classinfo|\end{scriptsize}s for preloading for these two classes if
1100 \begin{scriptsize}\verb|ENABLE_ANNOTATIONS|\end{scriptsize} is defined.
1101
1102 \begin{scriptsize}\verb|class_sun_reflect_annotation_AnnotationParser|\end{scriptsize} is only defined if
1103 \begin{scriptsize}\verb|WITH_CLASSPATH_GNU|\end{scriptsize} is defined.
1104
1105 \begin{itemize}
1106  \item \begin{scriptsize}\verb|class_load_attributes|\end{scriptsize}
1107 \end{itemize}
1108 Added loading of annotations if \begin{scriptsize}\verb|ENABLE_ANNOTATIONS|\end{scriptsize} is defined.
1109
1110 \begin{itemize}
1111  \item \begin{scriptsize}\verb|class_get_annotations|\end{scriptsize}
1112 \end{itemize}
1113 This function returns the unparsed annotations as a Java byte array.
1114
1115 \subsection{src/vmcore/class.h}
1116 \label{sec:src/vmcore/class.h}
1117
1118 Following fields where added to the \begin{scriptsize}\verb|classinfo|\end{scriptsize} struct:
1119 \begin{lstlisting}[language=C,firstnumber=147]
1120 #if defined(ENABLE_ANNOTATIONS)
1121         /* All the annotation attributes are NULL (and not a zero length array)   */
1122         /* if there is nothing.                                                   */
1123         java_object_t *annotations;   /* annotations of this class                */
1124         
1125         java_object_t *method_annotations; /* array of annotations of the methods */
1126         java_object_t *method_parameterannotations; /* array of parameter         */
1127                                       /* annotations of the methods               */
1128         java_object_t *method_annotationdefaults; /* array of annotation default  */
1129                                       /* values of the methods                    */
1130
1131         java_object_t *field_annotations; /* array of annotations of the fields   */
1132 #endif
1133 \end{lstlisting}
1134
1135 Following declarations where added:
1136 \begin{lstlisting}[language=C,firstnumber=246]
1137 #if defined(ENABLE_ANNOTATIONS)
1138 extern classinfo *class_sun_reflect_ConstantPool;
1139 #if defined(WITH_CLASSPATH_GNU)
1140 extern classinfo *class_sun_reflect_annotation_AnnotationParser;
1141 #endif
1142 #endif
1143 \end{lstlisting}
1144 \begin{lstlisting}[language=C,firstnumber=385]
1145 java_handle_bytearray_t   *class_get_annotations(classinfo *c);
1146 \end{lstlisting}
1147
1148 \subsection{src/vmcore/field.c}
1149 \label{sec:src/vmcore/field.c}
1150
1151 Added implementation of newly defined functions in \begin{scriptsize}\verb|field|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|h|\end{scriptsize} (see section \ref{sec:src/vmcore/field.h}).
1152
1153 \subsection{src/vmcore/field.h}
1154 \label{sec:src/vmcore/field.h}
1155
1156 \begin{itemize}
1157  \item \begin{scriptsize}\verb|field_get_annotations|\end{scriptsize}
1158 \end{itemize}
1159 Returns the unparsed annotations as a Java byte array.
1160
1161 \subsection{src/vmcore/linker.h}
1162 \label{sec:src/vmcore/linker.h}
1163
1164 Fixed formatting of a comment.
1165
1166 \subsection{src/vmcore/loader.c}
1167 \label{sec:src/vmcore/loader.c}
1168
1169 \begin{itemize}
1170  \item \begin{scriptsize}\verb|loader_init|\end{scriptsize}
1171 \end{itemize}
1172 Added loading of the \begin{scriptsize}\verb|class_sun_reflect_ConstantPool|\end{scriptsize} and the
1173 \begin{scriptsize}\verb|class_sun_reflect_annotation_AnnotationParser|\end{scriptsize} \begin{scriptsize}\verb|classinfo|\end{scriptsize} structs.
1174
1175 \paragraph{TODO:}
1176 \label{par:TODO/dont-load-extra-classinfos}This is maybe a tiny bit of a memory waste. Not much but still, if no
1177 annotation support is used, this \begin{scriptsize}\verb|classinfo|\end{scriptsize}s are needlessly loaded.
1178
1179 \subsection{src/vmcore/method.c}
1180 \label{sec:src/vmcore/method.c}
1181
1182 Added implementation of newly defined functions in \begin{scriptsize}\verb|method|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|h|\end{scriptsize} (see section \ref{sec:src/vmcore/method.h}).
1183
1184 \subsection{src/vmcore/method.h}
1185 \label{sec:src/vmcore/method.h}
1186
1187 \begin{itemize}
1188  \item \begin{scriptsize}\verb|method_get_annotations|\end{scriptsize}
1189 \end{itemize}
1190 Returns the unparsed annotations as a Java byte array.
1191
1192 \begin{itemize}
1193  \item \begin{scriptsize}\verb|method_get_parameterannotations|\end{scriptsize}
1194 \end{itemize}
1195 Returns the unparsed parameter annotations as a Java byte array.
1196
1197 \begin{itemize}
1198  \item \begin{scriptsize}\verb|method_get_annotationdefault|\end{scriptsize}
1199 \end{itemize}
1200 Returns the unparsed annotation default value as a Java byte array.
1201
1202 \begin{itemize}
1203  \item \begin{scriptsize}\verb|method_get_parametercount|\end{scriptsize}
1204 \end{itemize}
1205 Returns the number of parameters of the referred method. The \begin{scriptsize}\verb|this|\end{scriptsize} pointer
1206 of non-static methods is \begin{bfseries}not\end{bfseries} counted.
1207
1208 \subsection{src/vmcore/utf8.c}
1209 \label{sec:src/vmcore/utf8.c}
1210
1211 Implemented loading of annotation attribute names into the according \begin{scriptsize}\verb|utf|\end{scriptsize}
1212 constants:
1213 \begin{itemize}
1214  \item \begin{scriptsize}\verb|utf_RuntimeVisibleAnnotations|\end{scriptsize}
1215  \item \begin{scriptsize}\verb|utf_RuntimeInvisibleAnnotations|\end{scriptsize}
1216  \item \begin{scriptsize}\verb|utf_RuntimeVisibleParameterAnnotations|\end{scriptsize}
1217  \item \begin{scriptsize}\verb|utf_RuntimeInvisibleParameterAnnotations|\end{scriptsize}
1218  \item \begin{scriptsize}\verb|utf_AnnotationDefault|\end{scriptsize}
1219 \end{itemize}
1220
1221 \subsection{src/vmcore/utf8.h}
1222 \label{sec:src/vmcore/utf8.h}
1223
1224 Following declarations where added:
1225 \begin{lstlisting}[language=C,firstnumber=151]
1226 #if defined(ENABLE_ANNOTATIONS)
1227 extern utf *utf_RuntimeVisibleAnnotations;
1228 extern utf *utf_RuntimeInvisibleAnnotations;
1229 extern utf *utf_RuntimeVisibleParameterAnnotations;
1230 extern utf *utf_RuntimeInvisibleParameterAnnotations;
1231 extern utf *utf_AnnotationDefault;
1232 #endif
1233 \end{lstlisting}
1234
1235 \subsection{tests/regression/Makefile.am}
1236 \label{sec:tests/regression/Makefile.am}
1237
1238 Added \begin{scriptsize}\verb||\hspace{0.0pt}\verb|$|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|(|\hspace{0.0pt}\verb|srcdir|\hspace{0.0pt}\verb|)|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|MinimalClassReflection|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|java|\end{scriptsize} and
1239 \begin{scriptsize}\verb||\hspace{0.0pt}\verb|$|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|(|\hspace{0.0pt}\verb|srcdir|\hspace{0.0pt}\verb|)|\hspace{0.0pt}\verb||\hspace{0.0pt}\verb|/|\hspace{0.0pt}\verb|TestAnnotations|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|java|\end{scriptsize} to \begin{scriptsize}\verb|SOURCE_FILES|\end{scriptsize}.
1240
1241 Added \begin{scriptsize}\verb|MinimalClassReflection|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|output|\end{scriptsize} and \begin{scriptsize}\verb|TestAnnotations|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|output|\end{scriptsize} to
1242 \begin{scriptsize}\verb|EXTRA_DIST|\end{scriptsize}.
1243
1244 Added \begin{scriptsize}\verb|MinimalClassReflection|\end{scriptsize} and \begin{scriptsize}\verb|TestAnnotations|\end{scriptsize} to
1245 \begin{scriptsize}\verb|OUTPUT_JAVA_TESTS|\end{scriptsize}.
1246
1247 \subsection{tests/regression/MinimalClassReflection.java}
1248 \label{sec:tests/regression/MinimalClassReflection.java}
1249
1250 Testcases for a few methods of \begin{scriptsize}\verb|java|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|lang|\hspace{0.0pt}\verb|.|\hspace{0.0pt}\verb|Class|\end{scriptsize}. This is already obsolete
1251 because I ported this test to the \href{http://www.sourceware.org/mauve/}{Mauve}\footnote{\url{http://www.sourceware.org/mauve/}}
1252 test framework and continued working on that test.
1253
1254 I wrote this testcase because I mentioned some odd/wrong behaviours of this
1255 methods while testing the annotations support.
1256
1257 Download Mauve testcase: \href{http://twoday.tuwien.ac.at/pub/files/MinimalClassReflection}{MinimalClassReflection.zip}\footnote{\url{http://twoday.tuwien.ac.at/pub/files/MinimalClassReflection}} (ZIP, 2 KB)
1258
1259 \subsection{tests/regression/MinimalClassReflection.output}
1260 \label{sec:tests/regression/MinimalClassReflection.output}
1261
1262 Correct output for the minimal class reflection test.
1263
1264 \subsection{tests/regression/TestAnnotations.java}
1265 \label{sec:tests/regression/TestAnnotations.java}
1266
1267 Testcases for the annotations support. This is already obsolete because I
1268 ported this test to the \href{http://www.sourceware.org/mauve/}{Mauve} test framework
1269 and continued working on that test.
1270
1271 Download Mauve testcase: \href{http://twoday.tuwien.ac.at/pub/files/TestAnnotations}{TestAnnotations.zip}\footnote{\url{http://twoday.tuwien.ac.at/pub/files/TestAnnotations}} (ZIP, 9 KB)
1272
1273 \subsection{tests/regression/TestAnnotations.output}
1274 \label{sec:tests/regression/TestAnnotations.output}
1275
1276 Correct output for the annotations test.
1277
1278 \section{TODOs}
1279 \label{sec:todos}
1280 \begin{itemize}
1281  \item Keep imported files up to date. (see section \ref{par:TODO/keep-imported-files-up-to-date})
1282  \item Maybe cache parsed parameter annotations. (see section \ref{par:TODO/cache-parameter-annotations})
1283  \item Check methods \begin{scriptsize}\verb|getStringAt0|\end{scriptsize} and \begin{scriptsize}\verb|getUTF8At0|\end{scriptsize} of \begin{scriptsize}\verb|sun.reflect.ConstantPool|\end{scriptsize}. (see section \ref{par:TODO/ConstantPool.getStringAt0})
1284  \item Join \begin{scriptsize}\verb|sun.reflect.ConstantPool|\end{scriptsize} implementations. (see section \ref{par:TODO/join-constantpool-implementations})
1285  \item Maybe don't load \begin{scriptsize}\verb|class_sun_reflect_ConstantPool|\end{scriptsize} and \begin{scriptsize}\verb|class_sun_reflect_annotation_AnnotationParser|\end{scriptsize} \begin{scriptsize}\verb|classinfo|\end{scriptsize} structs in \begin{scriptsize}\verb|loader_init()|\end{scriptsize}. (see section \ref{par:TODO/dont-load-extra-classinfos})
1286  \item Do something with \begin{scriptsize}\verb|RuntimeInvisible|\hspace{0.0pt}\verb|*|\hspace{0.0pt}\verb|Annotations|\end{scriptsize}?
1287 \end{itemize}
1288
1289 %% CONTENT END %%
1290
1291 \bibliography{jsr}
1292
1293 \end{document}