{
private Class<T> clazz;
private int slot;
+
+ /**
+ * Unparsed annotations.
+ */
private byte[] annotations = null;
+
+ /**
+ * Unparsed parameter annotations.
+ */
private byte[] parameterAnnotations = null;
+
+ /**
+ * Annotations get parsed the first time they are
+ * accessed and are then cached it this map.
+ */
private transient Map<Class<? extends Annotation>, Annotation> declaredAnnotations = null;
private static final int CONSTRUCTOR_MODIFIERS
= Modifier.PRIVATE | Modifier.PROTECTED | Modifier.PUBLIC;
-
+
+ /**
+ * Helper array for creating a new array from a java.util.Container.
+ */
private static final Annotation[] EMPTY_ANNOTATIONS_ARRAY =
new Annotation[0];
return declaredAnnotations().values().toArray(EMPTY_ANNOTATIONS_ARRAY);
}
+ /**
+ * Parses the annotations if they aren't parsed yet and stores them into
+ * the declaredAnnotations map and return this map.
+ */
private synchronized native Map<Class<? extends Annotation>, Annotation> declaredAnnotations();
/**
private Class clazz;
private String name;
private int slot;
+
+ /**
+ * Unparsed annotations.
+ */
private byte[] annotations = null;
+
+ /**
+ * Annotations get parsed the first time they are
+ * accessed and are then cached it this map.
+ */
private transient Map<Class<? extends Annotation>, Annotation> declaredAnnotations = null;
private static final int FIELD_MODIFIERS
| Modifier.PUBLIC | Modifier.STATIC | Modifier.TRANSIENT
| Modifier.VOLATILE;
+ /**
+ * Helper array for creating a new array from a java.util.Container.
+ */
private static final Annotation[] EMPTY_ANNOTATIONS_ARRAY =
new Annotation[0];
return declaredAnnotations().values().toArray(EMPTY_ANNOTATIONS_ARRAY);
}
+ /**
+ * Parses the annotations if they aren't parsed yet and stores them into
+ * the declaredAnnotations map and return this map.
+ */
private synchronized native Map<Class<? extends Annotation>, Annotation> declaredAnnotations();
}
Class clazz;
String name;
int slot;
+
+ /**
+ * Unparsed annotations.
+ */
private byte[] annotations = null;
+
+ /**
+ * Unparsed parameter annotations.
+ */
private byte[] parameterAnnotations = null;
+
+ /**
+ * Unparsed annotation default value.
+ */
private byte[] annotationDefault = null;
+
+ /**
+ * Annotations get parsed the first time they are
+ * accessed and are then cached it this map.
+ */
private transient Map<Class<? extends Annotation>, Annotation> declaredAnnotations = null;
private static final int METHOD_MODIFIERS
| Modifier.PRIVATE | Modifier.PROTECTED | Modifier.PUBLIC
| Modifier.STATIC | Modifier.STRICT | Modifier.SYNCHRONIZED;
+ /**
+ * Helper array for creating a new array from a java.util.Container.
+ */
private static final Annotation[] EMPTY_ANNOTATIONS_ARRAY =
new Annotation[0];
return declaredAnnotations().values().toArray(EMPTY_ANNOTATIONS_ARRAY);
}
+ /**
+ * Parses the annotations if they aren't parsed yet and stores them into
+ * the declaredAnnotations map and return this map.
+ */
private synchronized native Map<Class<? extends Annotation>, Annotation> declaredAnnotations();
/**
*/
public class AnnotationParser {
/**
- * Parses the annotations described by the passed byte array.
- * But return Annotation[] so I don't have to do this in C.
+ * Parses the annotations described by the passed byte array,
+ * but returns Annotation[] so I don't have to do this in C.
*
* @author Mathias Panzenböck
*
+ * @param rawAnnotations are the unparsed annotations
+ * @param constPool is the constant pool of the declaring class
+ * @param container is the containing class
+ * @return the parsed annotations in an array
* @throws AnnotationFormatError if an annotation is found to be
* malformed.
*/
*
* @author Mathias Panzenböck
*
+ * @param parameterAnnotations are the unparsed parameter annotations
+ * @param constPool is the constant pool of the declaring class
+ * @param container is the containing class
+ * @return the parsed parameter annotations in an array 2 dimensional array
* @throws AnnotationFormatError if an annotation is found to be
* malformed.
*/
*
* @author Mathias Panzenböck
*
+ * @param method represents the method for which the annotation default value has to be parsed
+ * @param annotationDefault is the unparsed annotation default value
+ * @param constPool is the constant pool of the declaring class
+ * @return the parsed annotation default value (boxed, if it's a primitive type)
* @throws AnnotationFormatError if an annotation is found to be
* malformed.
*/
AnnotationType result = sun.misc.SharedSecrets.getJavaLangAccess().
getAnnotationType(annotationClass);
*/
+ // emulating OpenJDKs SharedSecrets in GNU Classpath:
AnnotationType result = annotationTypes.get(annotationClass);
if (result == null)
result = new AnnotationType((Class<?>) annotationClass);
sun.misc.SharedSecrets.getJavaLangAccess().
setAnnotationType(annotationClass, this);
*/
-
+ // emulating OpenJDKs SharedSecrets in GNU Classpath:
annotationTypes.put(annotationClass, this);
// Initialize retention, & inherited fields. Special treatment
* Class: java/lang/reflect/Constructor
* Method: declaredAnnotations
* Signature: ()Ljava/util/Map;
+ *
+ * Parses the annotations (if they aren't parsed yet) and stores them into
+ * the declaredAnnotations map and return this map.
*/
JNIEXPORT struct java_util_Map* JNICALL Java_java_lang_reflect_Constructor_declaredAnnotations(JNIEnv *env, java_lang_reflect_Constructor *this)
{
- java_util_Map *declaredAnnotations = NULL;
- java_handle_bytearray_t *annotations = NULL;
- java_lang_Class *declaringClass = NULL;
- classinfo *referer = NULL;
+ java_util_Map *declaredAnnotations = NULL; /* parsed annotations */
+ java_handle_bytearray_t *annotations = NULL; /* unparsed annotations */
+ java_lang_Class *declaringClass = NULL; /* the constant pool of this class is used */
+ classinfo *referer = NULL; /* class, which calles the annotation parser */
+ /* (for the parameter 'referer' of vm_call_method()) */
LLNI_field_get_ref(this, declaredAnnotations, declaredAnnotations);
+ /* are the annotations parsed yet? */
if (declaredAnnotations == NULL) {
LLNI_field_get_ref(this, annotations, annotations);
LLNI_field_get_ref(this, clazz, declaringClass);
* Class: java/lang/reflect/Constructor
* Method: getParameterAnnotations
* Signature: ()[[Ljava/lang/annotation/Annotation;
+ *
+ * Parses the parameter annotations and returns them in an 2 dimensional array.
*/
JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_reflect_Constructor_getParameterAnnotations(JNIEnv *env, java_lang_reflect_Constructor *this)
{
- java_handle_bytearray_t *parameterAnnotations = NULL;
- int32_t slot = -1;
- java_lang_Class *declaringClass = NULL;
- classinfo *referer = NULL;
+ java_handle_bytearray_t *parameterAnnotations = NULL; /* unparsed parameter annotations */
+ int32_t slot = -1; /* slot of the method */
+ java_lang_Class *declaringClass = NULL; /* the constant pool of this class is used */
+ classinfo *referer = NULL; /* class, which calles the annotation parser */
+ /* (for the parameter 'referer' of vm_call_method()) */
LLNI_field_get_ref(this, parameterAnnotations, parameterAnnotations);
LLNI_field_get_val(this, slot, slot);
*/
JNIEXPORT struct java_util_Map* JNICALL Java_java_lang_reflect_Field_declaredAnnotations(JNIEnv *env, java_lang_reflect_Field *this)
{
- java_util_Map *declaredAnnotations = NULL;
- java_handle_bytearray_t *annotations = NULL;
- java_lang_Class *declaringClass = NULL;
- classinfo *referer = NULL;
+ java_util_Map *declaredAnnotations = NULL; /* parsed annotations */
+ java_handle_bytearray_t *annotations = NULL; /* unparsed annotations */
+ java_lang_Class *declaringClass = NULL; /* the constant pool of this class is used */
+ classinfo *referer = NULL; /* class, which calles the annotation parser */
+ /* (for the parameter 'referer' of vm_call_method()) */
LLNI_field_get_ref(this, declaredAnnotations, declaredAnnotations);
+ /* are the annotations parsed yet? */
if (declaredAnnotations == NULL) {
LLNI_field_get_ref(this, annotations, annotations);
LLNI_field_get_ref(this, clazz, declaringClass);
* Class: java/lang/reflect/Method
* Method: getDefaultValue
* Signature: ()Ljava/lang/Object;
+ *
+ * Parses the annotation default value and returnes it (boxed, if it's a primitive).
*/
JNIEXPORT struct java_lang_Object* JNICALL Java_java_lang_reflect_Method_getDefaultValue(JNIEnv *env, struct java_lang_reflect_Method* this)
{
- java_handle_bytearray_t *annotationDefault = NULL;
- static methodinfo *m_parseAnnotationDefault = NULL;
- utf *utf_parseAnnotationDefault = NULL;
- utf *utf_desc = NULL;
- sun_reflect_ConstantPool *constantPool = NULL;
- java_lang_Class *constantPoolOop = NULL;
- classinfo *referer = NULL;
+ java_handle_bytearray_t *annotationDefault = NULL; /* unparsed annotation default value */
+ static methodinfo *m_parseAnnotationDefault = NULL; /* parser method (will be chached, therefore static) */
+ utf *utf_parseAnnotationDefault = NULL; /* parser method name */
+ utf *utf_desc = NULL; /* parser method descriptor (signature) */
+ sun_reflect_ConstantPool *constantPool = NULL; /* constant pool object to use */
+ java_lang_Class *constantPoolOop = NULL; /* methods declaring class */
+ classinfo *referer = NULL; /* class, which calles the annotation parser */
+ /* (for the parameter 'referer' of vm_call_method()) */
if (this == NULL) {
exceptions_throw_nullpointerexception();
(sun_reflect_ConstantPool*)native_new_and_init(
class_sun_reflect_ConstantPool);
- if(constantPool == NULL) {
+ if (constantPool == NULL) {
/* out of memory */
return NULL;
}
LLNI_field_get_ref(this, clazz, constantPoolOop);
LLNI_field_set_ref(constantPool, constantPoolOop, (java_lang_Object*)constantPoolOop);
- /* only resolve the method the first time */
+ /* only resolve the parser method the first time */
if (m_parseAnnotationDefault == NULL) {
utf_parseAnnotationDefault = utf_new_char("parseAnnotationDefault");
utf_desc = utf_new_char(
* Class: java/lang/reflect/Method
* Method: declaredAnnotations
* Signature: ()Ljava/util/Map;
+ *
+ * Parses the annotations (if they aren't parsed yet) and stores them into
+ * the declaredAnnotations map and return this map.
*/
JNIEXPORT struct java_util_Map* JNICALL Java_java_lang_reflect_Method_declaredAnnotations(JNIEnv *env, java_lang_reflect_Method *this)
{
- java_util_Map *declaredAnnotations = NULL;
- java_handle_bytearray_t *annotations = NULL;
- java_lang_Class *declaringClass = NULL;
- classinfo *referer = NULL;
+ java_util_Map *declaredAnnotations = NULL; /* parsed annotations */
+ java_handle_bytearray_t *annotations = NULL; /* unparsed annotations */
+ java_lang_Class *declaringClass = NULL; /* the constant pool of this class is used */
+ classinfo *referer = NULL; /* class, which calles the annotation parser */
+ /* (for the parameter 'referer' of vm_call_method()) */
LLNI_field_get_ref(this, declaredAnnotations, declaredAnnotations);
+ /* are the annotations parsed yet? */
if (declaredAnnotations == NULL) {
LLNI_field_get_ref(this, annotations, annotations);
LLNI_field_get_ref(this, clazz, declaringClass);
* Class: java/lang/reflect/Method
* Method: getParameterAnnotations
* Signature: ()[[Ljava/lang/annotation/Annotation;
+ *
+ * Parses the parameter annotations and returns them in an 2 dimensional array.
*/
JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_reflect_Method_getParameterAnnotations(JNIEnv *env, java_lang_reflect_Method *this)
{
- java_handle_bytearray_t *parameterAnnotations = NULL;
- int32_t slot = -1;
- java_lang_Class *declaringClass = NULL;
- classinfo *referer = NULL;
+ java_handle_bytearray_t *parameterAnnotations = NULL; /* unparsed parameter annotations */
+ int32_t slot = -1; /* slot of the method */
+ java_lang_Class *declaringClass = NULL; /* the constant pool of this class is used */
+ classinfo *referer = NULL; /* class, which calles the annotation parser */
+ /* (for the parameter 'referer' of vm_call_method()) */
LLNI_field_get_ref(this, parameterAnnotations, parameterAnnotations);
LLNI_field_get_val(this, slot, slot);
XXX: The Methods in this file are very redundant to thouse in
src/native/vm/sun/jvm.c Unless someone has a good idea how to cover
- such redundancy I leave it how it is.
+ such redundancy I leave it how it is.
+
+ The ConstantPool class represents an interface to the constant pool of a
+ class and is used by the annotations parser (sun.reflect.annotation.
+ AnnotationParser) to get the values of the constants refered by the
+ annotations.
*******************************************************************************/
};
-/* _Jv_sun_reflect_ConstantPool_init ********************************************
+/* _Jv_sun_reflect_ConstantPool_init ******************************************
Register native functions.
*/
java_handle_objectarray_t *_Jv_java_lang_Class_getDeclaredAnnotations(java_lang_Class* klass)
{
- classinfo *c = NULL;
- static methodinfo *m_parseAnnotationsIntoArray = NULL;
- utf *utf_parseAnnotationsIntoArray = NULL;
- utf *utf_desc = NULL;
- java_handle_bytearray_t *annotations = NULL;
- sun_reflect_ConstantPool *constantPool = NULL;
- java_lang_Object *constantPoolOop = (java_lang_Object*)klass;
+ classinfo *c = NULL; /* classinfo for the java.lang.Class object 'klass' */
+ static methodinfo *m_parseAnnotationsIntoArray = NULL; /* parser method (cached, therefore static) */
+ utf *utf_parseAnnotationsIntoArray = NULL; /* parser method name */
+ utf *utf_desc = NULL; /* parser method descriptor (signature) */
+ java_handle_bytearray_t *annotations = NULL; /* unparsed annotations */
+ sun_reflect_ConstantPool *constantPool = NULL; /* constant pool of klass */
+ java_lang_Object *constantPoolOop = (java_lang_Object*)klass; /* constantPoolOop field of */
+ /* sun.reflect.ConstantPool */
if (klass == NULL) {
exceptions_throw_nullpointerexception();
(sun_reflect_ConstantPool*)native_new_and_init(
class_sun_reflect_ConstantPool);
- if(constantPool == NULL) {
+ if (constantPool == NULL) {
/* out of memory */
return NULL;
}
LLNI_field_set_ref(constantPool, constantPoolOop, constantPoolOop);
- /* only resolve the method the first time */
+ /* only resolve the parser method the first time */
if (m_parseAnnotationsIntoArray == NULL) {
utf_parseAnnotationsIntoArray = utf_new_char("parseAnnotationsIntoArray");
utf_desc = utf_new_char(
#if defined(WITH_CLASSPATH_GNU) && defined(ENABLE_ANNOTATIONS)
/* reflect_get_declaredannotatios *********************************************
- Returns a java.util.Map<Class<? extends Annotation>, Annotation>
- of the declared annotations.
+ Calls the annotation parser with the unparsed annotations and returnes
+ the parsed annotations as a map.
+
+ IN:
+ annotations........the unparsed annotations
+ declaringClass.....the class in which the annotated element is declared
+ referer............the calling class (for the 'referer' parameter of
+ vm_call_method())
+
+ RETURN VALUE:
+ The parsed annotations as a
+ java.util.Map<Class<? extends Annotation>, Annotation>.
*******************************************************************************/
classinfo *referer)
{
static methodinfo *m_parseAnnotations = NULL;
+ /* parser method (chached, therefore static) */
utf *utf_parseAnnotations = NULL;
+ /* parser method name */
utf *utf_desc = NULL;
+ /* parser method descriptor (signature) */
sun_reflect_ConstantPool *constantPool = NULL;
+ /* constant pool of the declaring class */
java_lang_Object *constantPoolOop = (java_lang_Object*)declaringClass;
+ /* constantPoolOop field of the constant pool */
+ /* object (sun.reflect.ConstantPool) */
constantPool =
(sun_reflect_ConstantPool*)native_new_and_init(
LLNI_field_set_ref(constantPool, constantPoolOop, constantPoolOop);
- /* only resolve the method the first time */
+ /* only resolve the parser method the first time */
if (m_parseAnnotations == NULL) {
utf_parseAnnotations = utf_new_char("parseAnnotations");
utf_desc = utf_new_char(
/* reflect_get_parameterannotations *******************************************
- Parses and returns the parameter annotations of a method.
+ Calls the annotation parser with the unparsed parameter annotations of
+ a method and returnes the parsed parameter annotations in a 2 dimensional
+ array.
+
+ IN:
+ parameterAnnotations....the unparsed parameter annotations
+ slot....................the slot of the method
+ declaringClass..........the class in which the annotated element is
+ declared
+ referer.................the calling class (for the 'referer' parameter
+ of vm_call_method())
+
+ RETURN VALUE:
+ The parsed parameter annotations in a 2 dimensional array.
*******************************************************************************/
* ones).
*
* ConstantPool constPool = new ConstantPool();
- * constPool.constantPoolOop = getDeclaringClass();
+ * constPool.constantPoolOop = method.getDeclaringClass();
* return sun.reflect.AnnotationParser.parseParameterAnnotations(
- * parameterAnnotations,
- * constPool,
- * getDeclaringClass(),
- * getParameterTypes().length);
+ * parameterAnnotations,
+ * constPool,
+ * method.getDeclaringClass(),
+ * method.getParameterTypes().length);
*/
static methodinfo *m_parseParameterAnnotations = NULL;
+ /* parser method (cached, therefore static) */
utf *utf_parseParameterAnnotations = NULL;
+ /* parser method name */
utf *utf_desc = NULL;
+ /* parser method descriptor (signature) */
sun_reflect_ConstantPool *constantPool = NULL;
+ /* constant pool of the declaring class */
java_lang_Object *constantPoolOop = (java_lang_Object*)declaringClass;
+ /* constantPoolOop field of the constant pool object */
classinfo *c = NULL;
+ /* classinfo of the decaring class */
methodinfo *m = NULL;
+ /* method info of the annotated method */
int32_t numParameters = -1;
+ /* parameter count of the annotated method */
/* get parameter count */
LLNI_field_set_ref(constantPool, constantPoolOop, constantPoolOop);
- /* only resolve the method the first time */
+ /* only resolve the parser method the first time */
if (m_parseParameterAnnotations == NULL) {
utf_parseParameterAnnotations = utf_new_char("parseParameterAnnotations");
utf_desc = utf_new_char(
jbyteArray JVM_GetClassAnnotations(JNIEnv *env, jclass cls)
{
- classinfo *c = NULL;
- java_handle_bytearray_t *annotations = NULL;
+ classinfo *c = NULL; /* classinfo for 'cls' */
+ java_handle_bytearray_t *annotations = NULL; /* unparsed annotations */
TRACEJVMCALLS("JVM_GetClassAnnotations: cls=%p", cls);
jbyteArray JVM_GetFieldAnnotations(JNIEnv *env, jobject field)
{
- java_lang_reflect_Field *rf = (java_lang_reflect_Field*)field;
- java_handle_bytearray_t *ba = NULL;
+ java_lang_reflect_Field *rf = NULL; /* java.lang.reflect.Field for 'field' */
+ java_handle_bytearray_t *ba = NULL; /* unparsed annotations */
TRACEJVMCALLS("JVM_GetFieldAnnotations: field=%p", field);
return NULL;
}
+ rf = (java_lang_reflect_Field*)field;
+
LLNI_field_get_ref(rf, annotations, ba);
return (jbyteArray)ba;
jbyteArray JVM_GetMethodAnnotations(JNIEnv *env, jobject method)
{
- java_lang_reflect_Method *rm = (java_lang_reflect_Method*)method;
- java_handle_bytearray_t *ba = NULL;
+ java_lang_reflect_Method *rm = NULL; /* java.lang.reflect.Method for 'method' */
+ java_handle_bytearray_t *ba = NULL; /* unparsed annotations */
TRACEJVMCALLS("JVM_GetMethodAnnotations: method=%p", method);
return NULL;
}
+ rm = (java_lang_reflect_Method*)method;
+
LLNI_field_get_ref(rm, annotations, ba);
return (jbyteArray)ba;
jbyteArray JVM_GetMethodDefaultAnnotationValue(JNIEnv *env, jobject method)
{
- java_lang_reflect_Method *rm = (java_lang_reflect_Method*)method;
- java_handle_bytearray_t *ba = NULL;
+ java_lang_reflect_Method *rm = NULL; /* java.lang.reflect.Method for 'method' */
+ java_handle_bytearray_t *ba = NULL; /* unparsed annotation default value */
TRACEJVMCALLS("JVM_GetMethodDefaultAnnotationValue: method=%p", method);
return NULL;
}
+ rm = (java_lang_reflect_Method*)method;
+
LLNI_field_get_ref(rm, annotationDefault, ba);
return (jbyteArray)ba;
jbyteArray JVM_GetMethodParameterAnnotations(JNIEnv *env, jobject method)
{
- java_lang_reflect_Method *rm = (java_lang_reflect_Method*)method;
- java_handle_bytearray_t *ba = NULL;
+ java_lang_reflect_Method *rm = NULL; /* java.lang.reflect.Method for 'method' */
+ java_handle_bytearray_t *ba = NULL; /* unparsed parameter annotations */
TRACEJVMCALLS("JVM_GetMethodParameterAnnotations: method=%p", method);
return NULL;
}
+ rm = (java_lang_reflect_Method*)method;
+
LLNI_field_get_ref(rm, parameterAnnotations, ba);
return (jbyteArray)ba;
{
#if defined(ENABLE_ANNOTATIONS)
sun_reflect_ConstantPool *constantPool = NULL;
+ /* constant pool object for the class refered by 'cls' */
java_lang_Object *constantPoolOop = (java_lang_Object*)cls;
-
+ /* constantPoolOop field of the constant pool object */
+
TRACEJVMCALLS("JVM_GetClassConstantPool(env=%p, cls=%p)", env, cls);
constantPool =
jint JVM_ConstantPoolGetSize(JNIEnv *env, jobject unused, jobject jcpool)
{
- classinfo *c;
+ classinfo *c; /* classinfo of the class for which 'this' is the constant pool */
TRACEJVMCALLS("JVM_ConstantPoolGetSize(env=%p, unused=%p, jcpool=%p)", env, unused, jcpool);
jclass JVM_ConstantPoolGetClassAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
{
- constant_classref *ref;
- classinfo *c;
- classinfo *result;
+ constant_classref *ref; /* classref to the class at constant pool index 'index' */
+ classinfo *c; /* classinfo of the class for which 'this' is the constant pool */
+ classinfo *result; /* classinfo of the class at constant pool index 'index' */
TRACEJVMCALLS("JVM_ConstantPoolGetClassAt(env=%p, jcpool=%p, index=%d)", env, jcpool, index);
jclass JVM_ConstantPoolGetClassAtIfLoaded(JNIEnv *env, jobject unused, jobject jcpool, jint index)
{
- constant_classref *ref;
- classinfo *c;
- classinfo *result;
+ constant_classref *ref; /* classref to the class at constant pool index 'index' */
+ classinfo *c; /* classinfo of the class for which 'this' is the constant pool */
+ classinfo *result; /* classinfo of the class at constant pool index 'index' */
TRACEJVMCALLS("JVM_ConstantPoolGetClassAtIfLoaded(env=%p, unused=%p, jcpool=%p, index=%d)", env, unused, jcpool, index);
jobject JVM_ConstantPoolGetMethodAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
{
- constant_FMIref *ref;
- classinfo *cls = LLNI_classinfo_unwrap(jcpool);
+ constant_FMIref *ref; /* reference to the method in constant pool at index 'index' */
+ classinfo *cls; /* classinfo of the class for which 'this' is the constant pool */
TRACEJVMCALLS("JVM_ConstantPoolGetMethodAt: jcpool=%p, index=%d", jcpool, index);
-
+
+ cls = LLNI_classinfo_unwrap(jcpool);
ref = (constant_FMIref*)class_getconstant(cls, index, CONSTANT_Methodref);
if (ref == NULL) {
jobject JVM_ConstantPoolGetMethodAtIfLoaded(JNIEnv *env, jobject unused, jobject jcpool, jint index)
{
- constant_FMIref *ref;
- classinfo *c = NULL;
- classinfo *cls = LLNI_classinfo_unwrap(jcpool);
+ constant_FMIref *ref; /* reference to the method in constant pool at index 'index' */
+ classinfo *c = NULL; /* resolved declaring class of the method */
+ classinfo *cls; /* classinfo of the class for which 'this' is the constant pool */
TRACEJVMCALLS("JVM_ConstantPoolGetMethodAtIfLoaded: jcpool=%p, index=%d", jcpool, index);
+ cls = LLNI_classinfo_unwrap(jcpool);
ref = (constant_FMIref*)class_getconstant(cls, index, CONSTANT_Methodref);
if (ref == NULL) {
jobject JVM_ConstantPoolGetFieldAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
{
- constant_FMIref *ref;
- classinfo *cls = LLNI_classinfo_unwrap(jcpool);
+ constant_FMIref *ref; /* reference to the field in constant pool at index 'index' */
+ classinfo *cls; /* classinfo of the class for which 'this' is the constant pool */
TRACEJVMCALLS("JVM_ConstantPoolGetFieldAt: jcpool=%p, index=%d", jcpool, index);
+ cls = LLNI_classinfo_unwrap(jcpool);
ref = (constant_FMIref*)class_getconstant(cls, index, CONSTANT_Fieldref);
if (ref == NULL) {
jobject JVM_ConstantPoolGetFieldAtIfLoaded(JNIEnv *env, jobject unused, jobject jcpool, jint index)
{
- constant_FMIref *ref;
- classinfo *c;
- classinfo *cls = LLNI_classinfo_unwrap(jcpool);
+ constant_FMIref *ref; /* reference to the field in constant pool at index 'index' */
+ classinfo *c; /* resolved declaring class for the field */
+ classinfo *cls; /* classinfo of the class for which 'this' is the constant pool */
TRACEJVMCALLS("JVM_ConstantPoolGetFieldAtIfLoaded: jcpool=%p, index=%d", jcpool, index);
+ cls = LLNI_classinfo_unwrap(jcpool);
ref = (constant_FMIref*)class_getconstant(cls, index, CONSTANT_Fieldref);
if (ref == NULL) {
jobjectArray JVM_ConstantPoolGetMemberRefInfoAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
{
log_println("JVM_ConstantPoolGetMemberRefInfoAt: jcpool=%p, index=%d, IMPLEMENT ME!", jcpool, index);
+
+ /* TODO: implement. (this is yet unused be OpenJDK but, so very low priority) */
+
return NULL;
}
jint JVM_ConstantPoolGetIntAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
{
- constant_integer *ref;
- classinfo *cls = LLNI_classinfo_unwrap(jcpool);
+ constant_integer *ref; /* reference to the int value in constant pool at index 'index' */
+ classinfo *cls; /* classinfo of the class for which 'this' is the constant pool */
TRACEJVMCALLS("JVM_ConstantPoolGetIntAt: jcpool=%p, index=%d", jcpool, index);
+ cls = LLNI_classinfo_unwrap(jcpool);
ref = (constant_integer*)class_getconstant(cls, index, CONSTANT_Integer);
if (ref == NULL) {
jlong JVM_ConstantPoolGetLongAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
{
- constant_long *ref;
- classinfo *cls = LLNI_classinfo_unwrap(jcpool);
+ constant_long *ref; /* reference to the long value in constant pool at index 'index' */
+ classinfo *cls; /* classinfo of the class for which 'this' is the constant pool */
TRACEJVMCALLS("JVM_ConstantPoolGetLongAt: jcpool=%p, index=%d", jcpool, index);
+ cls = LLNI_classinfo_unwrap(jcpool);
ref = (constant_long*)class_getconstant(cls, index, CONSTANT_Long);
if (ref == NULL) {
jfloat JVM_ConstantPoolGetFloatAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
{
- constant_float *ref;
- classinfo *cls = LLNI_classinfo_unwrap(jcpool);
+ constant_float *ref; /* reference to the float value in constant pool at index 'index' */
+ classinfo *cls; /* classinfo of the class for which 'this' is the constant pool */
TRACEJVMCALLS("JVM_ConstantPoolGetFloatAt: jcpool=%p, index=%d", jcpool, index);
+ cls = LLNI_classinfo_unwrap(jcpool);
ref = (constant_float*)class_getconstant(cls, index, CONSTANT_Float);
if (ref == NULL) {
jdouble JVM_ConstantPoolGetDoubleAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
{
- constant_double *ref;
- classinfo *cls = LLNI_classinfo_unwrap(jcpool);
+ constant_double *ref; /* reference to the double value in constant pool at index 'index' */
+ classinfo *cls; /* classinfo of the class for which 'this' is the constant pool */
TRACEJVMCALLS("JVM_ConstantPoolGetDoubleAt: jcpool=%p, index=%d", jcpool, index);
+ cls = LLNI_classinfo_unwrap(jcpool);
ref = (constant_double*)class_getconstant(cls, index, CONSTANT_Double);
if (ref == NULL) {
jstring JVM_ConstantPoolGetStringAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
{
- utf *ref;
- classinfo *cls = LLNI_classinfo_unwrap(jcpool);
+ utf *ref; /* utf object for the string in constant pool at index 'index' */
+ classinfo *cls; /* classinfo of the class for which 'this' is the constant pool */
TRACEJVMCALLS("JVM_ConstantPoolGetStringAt: jcpool=%p, index=%d", jcpool, index);
+ cls = LLNI_classinfo_unwrap(jcpool);
ref = (utf*)class_getconstant(cls, index, CONSTANT_String);
if (ref == NULL) {
jstring JVM_ConstantPoolGetUTF8At(JNIEnv *env, jobject unused, jobject jcpool, jint index)
{
- utf *ref;
- classinfo *cls = LLNI_classinfo_unwrap(jcpool);
+ utf *ref; /* utf object for the utf8 data in constant pool at index 'index' */
+ classinfo *cls; /* classinfo of the class for which 'this' is the constant pool */
TRACEJVMCALLS("JVM_ConstantPoolGetUTF8At: jcpool=%p, index=%d", jcpool, index);
+ cls = LLNI_classinfo_unwrap(jcpool);
ref = (utf*)class_getconstant(cls, index, CONSTANT_Utf8);
if (ref == NULL) {
Resize an array of bytearrays.
+ IN:
+ bas.....array of bytearrays (bas is short for 'bytearrays')
+ size....new size of the refered array
+
+ RETURN VALUE:
+ The new array if a resize was neccessarry, the old if the given size
+ equals the current size or NULL if an error occured.
+
*******************************************************************************/
-static bool annotation_bytearrays_resize(java_handle_objectarray_t **bas,
- uint32_t size)
+static java_handle_objectarray_t *annotation_bytearrays_resize(
+ java_handle_objectarray_t *bas, uint32_t size)
{
- java_handle_objectarray_t *newbas = NULL;
- uint32_t minsize;
- uint32_t oldsize;
+ java_handle_objectarray_t *newbas = NULL; /* new array */
+ uint32_t minsize = 0; /* count of object refs to copy */
+ uint32_t oldsize = 0; /* size of old array */
- assert(bas != NULL);
-
- if (*bas != NULL) {
- oldsize = array_length_get((java_handle_t*)*bas);
-
+ if (bas != NULL) {
+ oldsize = array_length_get((java_handle_t*)bas);
+
/* if the size already fits do nothing */
if (size == oldsize) {
- return true;
+ return bas;
}
}
-
+
newbas = builtin_anewarray(size,
primitive_arrayclass_get_by_type(PRIMITIVETYPE_BYTE));
- if (newbas == NULL) {
- /* out of memory */
- return false;
- }
-
/* is there a old byte array array? */
- if (*bas != NULL) {
+ if (newbas != NULL && bas != NULL) {
minsize = size < oldsize ? size : oldsize;
- MCOPY(LLNI_array_data(newbas), LLNI_array_data(*bas),
+ MCOPY(LLNI_array_data(newbas), LLNI_array_data(bas),
java_object_t*, minsize);
}
- *bas = newbas;
-
- return true;
+ return newbas;
}
Insert a bytearray into an array of bytearrays.
+ IN:
+ bas........array of bytearrays where 'ba' has to be insertet into at
+ position 'index'.
+ index......position where 'ba' has to be inserted into 'bas'.
+ ba.........byte array which has to be inserted into 'bas'.
+
+ RETURN VALUE:
+ The new array if a resize was neccessarry, the old if the given size
+ equals the current size or NULL if an error occured.
+
*******************************************************************************/
-static bool annotation_bytearrays_insert(java_handle_objectarray_t **bas,
- uint32_t index, java_handle_bytearray_t *ba)
+static java_handle_objectarray_t *annotation_bytearrays_insert(
+ java_handle_objectarray_t *bas, uint32_t index, java_handle_bytearray_t *ba)
{
- uint32_t size = 0;
-
- assert(bas != NULL);
+ uint32_t size = 0; /* current size of the array */
/* do nothing if NULL is inserted but no array exists */
- if (ba == NULL && *bas == NULL) {
- return true;
+ if (ba == NULL && bas == NULL) {
+ return bas;
}
/* get lengths if array exists */
- if (*bas != NULL) {
- size = array_length_get((java_handle_t*)*bas);
+ if (bas != NULL) {
+ size = array_length_get((java_handle_t*)bas);
}
if (ba == NULL) {
/* insert NULL only if array is big enough */
if (size > index) {
- array_objectarray_element_set(*bas, index, NULL);
+ array_objectarray_element_set(bas, index, NULL);
}
}
else {
/* resize array if it's not enough for inserted value */
if (size <= index) {
- if (!annotation_bytearrays_resize(bas, index + 1)) {
+ bas = annotation_bytearrays_resize(bas, index + 1);
+
+ if (bas == NULL) {
/* out of memory */
- return false;
+ return NULL;
}
}
- array_objectarray_element_set(*bas, index, (java_handle_t*)ba);
+ array_objectarray_element_set(bas, index, (java_handle_t*)ba);
}
- return true;
+ return bas;
}
static bool annotation_load_attribute_body(classbuffer *cb,
java_handle_bytearray_t **attribute, const char *errormsg_prefix)
{
- uint32_t size = 0;
- java_handle_bytearray_t *ba = NULL;
+ uint32_t size = 0; /* size of the attribute */
+ java_handle_bytearray_t *ba = NULL; /* the raw attributes' bytes */
assert(cb != NULL);
assert(attribute != NULL);
bool annotation_load_method_attribute_annotationdefault(
classbuffer *cb, methodinfo *m)
{
- int slot = 0;
- java_handle_bytearray_t *annotationdefault = NULL;
- java_handle_objectarray_t **annotationdefaults = NULL;
+ int slot = 0;
+ /* the slot of the method */
+ java_handle_bytearray_t *annotationdefault = NULL;
+ /* unparsed annotation defalut value */
+ java_handle_objectarray_t *annotationdefaults = NULL;
+ /* array of unparsed annotation default values */
assert(cb != NULL);
assert(m != NULL);
- annotationdefaults = &(m->class->method_annotationdefaults);
+ /* XXX: Wait for michis reply if it should be:
+ * LLNI_field_get_ref(m->class, method_annotations, annotationdefaults);
+ */
+ annotationdefaults = m->class->method_annotationdefaults;
if (!annotation_load_attribute_body(
cb, &annotationdefault,
if (annotationdefault != NULL) {
slot = m - m->class->methods;
+ annotationdefaults = annotation_bytearrays_insert(
+ annotationdefaults, slot, annotationdefault);
- if (!annotation_bytearrays_insert(
- annotationdefaults, slot, annotationdefault)) {
+ if (annotationdefaults == NULL) {
return false;
}
+
+ /* XXX: Wait for michis reply if it should be:
+ * LLNI_field_set_ref(m->class, method_annotations, annotationdefaults);
+ */
+ m->class->method_annotationdefaults = annotationdefaults;
}
return true;
bool annotation_load_method_attribute_runtimevisibleparameterannotations(
classbuffer *cb, methodinfo *m)
{
- int slot = 0;
- java_handle_bytearray_t *annotations = NULL;
- java_handle_objectarray_t **parameterannotations = NULL;
+ int slot = 0;
+ /* the slot of the method */
+ java_handle_bytearray_t *annotations = NULL;
+ /* unparsed parameter annotations */
+ java_handle_objectarray_t *parameterannotations = NULL;
+ /* array of unparsed parameter annotations */
assert(cb != NULL);
assert(m != NULL);
- parameterannotations = &(m->class->method_parameterannotations);
+ /* XXX: Wait for michis reply if it should be:
+ * LLNI_field_get_ref(m->class, method_parameterannotations, parameterannotations);
+ */
+ parameterannotations = m->class->method_parameterannotations;
if (!annotation_load_attribute_body(
cb, &annotations,
if (annotations != NULL) {
slot = m - m->class->methods;
+ parameterannotations = annotation_bytearrays_insert(
+ parameterannotations, slot, annotations);
- if (!annotation_bytearrays_insert(
- parameterannotations, slot, annotations)) {
+ if (parameterannotations == NULL) {
return false;
}
+
+ /* XXX: Wait for michis reply if it should be:
+ * LLNI_field_set_ref(m->class, method_parameterannotations, parameterannotations);
+ */
+ m->class->method_parameterannotations = parameterannotations;
}
return true;
Hotspot loads them into the same bytearray as the runtime visible parameter
annotations (after the runtime visible parameter annotations). But in J2SE
- the bytearray will only be parsed as if ther is only one annotation
+ the bytearray will only be parsed as if there is only one annotation
structure in it, so the runtime invisible parameter annotatios will be
ignored.
Load runtime visible annotations of a class.
+ IN:
+ cb........the classbuffer from which the attribute has to be loaded.
+
+ RETURN VALUE:
+ true if all went good. false otherwhise.
+
*******************************************************************************/
bool annotation_load_class_attribute_runtimevisibleannotations(
classbuffer *cb)
{
- return annotation_load_attribute_body(
- cb, &(cb->class->annotations),
- "invalid runtime visible annotations class attribute");
+ java_handle_bytearray_t *annotations = NULL; /* unparsed annotations */
+
+ if (!annotation_load_attribute_body(
+ cb, &annotations,
+ "invalid runtime visible annotations class attribute")) {
+ return false;
+ }
+
+ /* XXX: Wait for michis reply if it should be:
+ * LLNI_field_set_ref(cb->class, annotations, annotations);
+ */
+ cb->class->annotations = annotations;
+
+ return true;
}
Load runtime invisible annotations of a class (just skip them).
+ IN:
+ cb........the classbuffer from which the attribute has to be loaded.
+
+ RETURN VALUE:
+ true if all went good. false otherwhise.
+
*******************************************************************************/
bool annotation_load_class_attribute_runtimeinvisibleannotations(
/* annotation_load_method_attribute_runtimevisibleannotations *****************
Load runtime visible annotations of a method.
-
+
+ IN:
+ cb........the classbuffer from which the attribute has to be loaded.
+ m.........the method of which the runtime visible annotations have
+ to be loaded.
+
+ RETURN VALUE:
+ true if all went good. false otherwhise.
+
*******************************************************************************/
bool annotation_load_method_attribute_runtimevisibleannotations(
classbuffer *cb, methodinfo *m)
{
- int slot = 0;
- java_handle_bytearray_t *annotations = NULL;
- java_handle_objectarray_t **method_annotations = NULL;
+ int slot = 0;
+ /* slot of the method */
+ java_handle_bytearray_t *annotations = NULL;
+ /* unparsed annotations */
+ java_handle_objectarray_t *method_annotations = NULL;
+ /* array of unparsed method annotations */
assert(cb != NULL);
assert(m != NULL);
- method_annotations = &(m->class->method_annotations);
+ /* XXX: Wait for michis reply if it should be:
+ * LLNI_field_get_ref(m->class, method_annotations, method_annotations);
+ */
+ method_annotations = m->class->method_annotations;
if (!annotation_load_attribute_body(
cb, &annotations,
if (annotations != NULL) {
slot = m - m->class->methods;
+ method_annotations = annotation_bytearrays_insert(
+ method_annotations, slot, annotations);
- if (!annotation_bytearrays_insert(
- method_annotations, slot, annotations)) {
+ if (method_annotations == NULL) {
return false;
}
+
+ /* XXX: Wait for michis reply if it should be:
+ * LLNI_field_set_ref(m->class, method_annotations, method_annotations);
+ */
+ m->class->method_annotations = method_annotations;
}
return true;
Load runtime invisible annotations of a method (just skip them).
+ IN:
+ cb........the classbuffer from which the attribute has to be loaded.
+ m.........the method of which the runtime invisible annotations have
+ to be loaded.
+
+ RETURN VALUE:
+ true if all went good. false otherwhise.
+
*******************************************************************************/
bool annotation_load_method_attribute_runtimeinvisibleannotations(
Load runtime visible annotations of a field.
+ IN:
+ cb........the classbuffer from which the attribute has to be loaded.
+ f.........the field of which the runtime visible annotations have
+ to be loaded.
+
+ RETURN VALUE:
+ true if all went good. false otherwhise.
+
*******************************************************************************/
bool annotation_load_field_attribute_runtimevisibleannotations(
classbuffer *cb, fieldinfo *f)
{
- int slot = 0;
- java_handle_bytearray_t *annotations = NULL;
- java_handle_objectarray_t **field_annotations = NULL;
+ int slot = 0;
+ /* slot of the field */
+ java_handle_bytearray_t *annotations = NULL;
+ /* unparsed annotations */
+ java_handle_objectarray_t *field_annotations = NULL;
+ /* array of unparsed field annotations */
assert(cb != NULL);
assert(f != NULL);
- field_annotations = &(f->class->field_annotations);
+ /* XXX: Wait for michis reply if it should be:
+ * LLNI_field_get_ref(f->class, method_annotations, method_annotations);
+ */
+ field_annotations = f->class->field_annotations;
if (!annotation_load_attribute_body(
cb, &annotations,
if (annotations != NULL) {
slot = f - f->class->fields;
+ field_annotations = annotation_bytearrays_insert(
+ field_annotations, slot, annotations);
- if (!annotation_bytearrays_insert(
- field_annotations, slot, annotations)) {
+ if (field_annotations == NULL) {
return false;
}
+
+ /* XXX: Wait for michis reply if it should be:
+ * LLNI_field_set_ref(f->class, method_annotations, method_annotations);
+ */
+ f->class->field_annotations = field_annotations;
}
return true;
Load runtime invisible annotations of a field (just skip them).
+ IN:
+ cb........the classbuffer from which the attribute has to be loaded.
+ f.........the field of which the runtime invisible annotations have
+ to be loaded.
+
+ RETURN VALUE:
+ true if all went good. false otherwhise.
+
*******************************************************************************/
bool annotation_load_field_attribute_runtimeinvisibleannotations(
#endif
#if defined(ENABLE_ANNOTATIONS)
- /* XXX We can't do a release with that enabled */
-
else if (attribute_name == utf_RuntimeVisibleAnnotations) {
/* RuntimeVisibleAnnotations */
if (!annotation_load_class_attribute_runtimevisibleannotations(cb))
return false;
}
- /* XXX RuntimeInvisibleAnnotations should only be loaded
- * (or returned to Java) if some commandline options says so.
- * Currently there is no such option available in cacao,
- * therefore I load them allways (for testing purpose).
- * Anyway, bytecode for RuntimeInvisibleAnnotations is only
- * generated if you tell javac to do so. So in most cases
- * there won't be any.
- */
else if (attribute_name == utf_RuntimeInvisibleAnnotations) {
/* RuntimeInvisibleAnnotations */
if (!annotation_load_class_attribute_runtimeinvisibleannotations(cb))
/* class_get_annotations *******************************************************
- Return the unparsed declared annotations in an byte array
- of the given class (or NULL if there aren't any).
+ Get the unparsed declared annotations in a byte array
+ of the given class.
+
+ IN:
+ c........the class of which the annotations should be returned
+
+ RETURN VALUE:
+ The unparsed declared annotations in a byte array
+ (or NULL if there aren't any).
*******************************************************************************/
/* field_get_annotations ******************************************************
- Gets a fields' annotations (or NULL if none).
+ Gat a fields' unparsed annotations in a byte array.
+
+ IN:
+ f........the field of which the annotations should be returned
+
+ RETURN VALUE:
+ The unparsed annotations in a byte array (or NULL if there aren't any).
*******************************************************************************/
java_handle_bytearray_t *field_get_annotations(fieldinfo *f)
{
#if defined(ENABLE_ANNOTATIONS)
- classinfo *c;
- int slot;
- java_handle_bytearray_t *annotations;
- java_handle_t *a;
+ classinfo *c; /* declaring class */
+ int slot; /* slot of this field */
+ java_handle_bytearray_t *annotations; /* unparsed annotations */
+ java_handle_t *a; /* unparsed annotations cast */
+ /* into java_handle_t* */
c = f->class;
slot = f - c->fields;
annotations = NULL;
a = (java_handle_t*)c->field_annotations;
+ /* the field_annotations array might be shorter then the field
+ * count if the fields above a certain index have no annotations.
+ */
if (c->field_annotations != NULL && array_length_get(a) > slot) {
annotations = (java_handle_bytearray_t*)
array_objectarray_element_get(
Use the descriptor of a method to determine the number of parameters
of the method. The this pointer of non-static methods is not counted.
- Returns -1 on error.
+ IN:
+ m........the method of which the parameters should be counted
+
+ RETURN VALUE:
+ The parameter count or -1 on error.
*******************************************************************************/
int32_t method_get_parametercount(methodinfo *m)
{
- methoddesc *md;
- int32_t paramcount = 0;
+ methoddesc *md; /* method descriptor of m */
+ int32_t paramcount = 0; /* the parameter count of m */
md = m->parseddesc;
/* is the descriptor fully parsed? */
- if (m->parseddesc->params == NULL) {
+ if (md->params == NULL) {
if (!descriptor_params_from_paramtypes(md, m->flags)) {
return -1;
}
/* method_get_annotations ******************************************************
- Gets a methods' annotations (or NULL if none).
+ Get a methods' unparsed annotations in a byte array.
+
+ IN:
+ m........the method of which the annotations should be returned
+
+ RETURN VALUE:
+ The unparsed annotations in a byte array (or NULL if there aren't any).
*******************************************************************************/
java_handle_bytearray_t *method_get_annotations(methodinfo *m)
{
#if defined(ENABLE_ANNOTATIONS)
- classinfo *c;
- int slot;
- java_handle_bytearray_t *annotations;
- java_handle_t *a;
+ classinfo *c; /* methods' declaring class */
+ int slot; /* methods' slot */
+ java_handle_bytearray_t *annotations; /* methods' unparsed annotations */
+ java_handle_t *a; /* methods' unparsed annotations */
+ /* cast into a java_handle_t* */
c = m->class;
slot = m - c->methods;
annotations = NULL;
a = (java_handle_t*)c->method_annotations;
-
+
+ /* the method_annotations array might be shorter then the method
+ * count if the methods above a certain index have no annotations.
+ */
if (c->method_annotations != NULL && array_length_get(a) > slot) {
annotations = (java_handle_bytearray_t*)array_objectarray_element_get(
c->method_annotations, slot);
/* method_get_parameterannotations ********************************************
- Gets a methods' parameter annotations (or NULL if none).
+ Get a methods' unparsed parameter annotations in an array of byte
+ arrays.
+
+ IN:
+ m........the method of which the parameter annotations should be
+ returned
+
+ RETURN VALUE:
+ The unparsed parameter annotations in a byte array (or NULL if
+ there aren't any).
*******************************************************************************/
java_handle_bytearray_t *method_get_parameterannotations(methodinfo *m)
{
#if defined(ENABLE_ANNOTATIONS)
- classinfo *c;
- int slot;
- java_handle_bytearray_t *parameterAnnotations;
- java_handle_t *a;
+ classinfo *c; /* methods' declaring class */
+ int slot; /* methods' slot */
+ java_handle_bytearray_t *parameterAnnotations; /* methods' unparsed */
+ /* parameter annotations */
+ java_handle_t *a; /* methods' unparsed */
+ /* parameter annotations */
+ /* cast into java_handle_t* */
c = m->class;
slot = m - c->methods;
/* method_get_annotationdefault ***********************************************
- Gets a methods' annotation default value (or NULL if none).
+ Get a methods' unparsed annotation default value in a byte array.
+
+ IN:
+ m........the method of which the annotation default value should be
+ returned
+
+ RETURN VALUE:
+ The unparsed annotation default value in a byte array (or NULL if
+ there isn't one).
*******************************************************************************/
java_handle_bytearray_t *method_get_annotationdefault(methodinfo *m)
{
#if defined(ENABLE_ANNOTATIONS)
- classinfo *c;
- int slot;
- java_handle_bytearray_t *annotationDefault;
- java_handle_t *a;
+ classinfo *c; /* methods' declaring class */
+ int slot; /* methods' slot */
+ java_handle_bytearray_t *annotationDefault; /* methods' unparsed */
+ /* annotation default value */
+ java_handle_t *a; /* methods' unparsed */
+ /* annotation default value */
+ /* cast into java_handle_t* */
c = m->class;
slot = m - c->methods;
utf *utf_StackMapTable;
#if defined(ENABLE_ANNOTATIONS)
-utf *utf_RuntimeVisibleAnnotations;
-utf *utf_RuntimeInvisibleAnnotations;
-utf *utf_RuntimeVisibleParameterAnnotations;
-utf *utf_RuntimeInvisibleParameterAnnotations;
-utf *utf_AnnotationDefault;
+utf *utf_RuntimeVisibleAnnotations; /* RuntimeVisibleAnnotations */
+utf *utf_RuntimeInvisibleAnnotations; /* RuntimeInvisibleAnnotations */
+utf *utf_RuntimeVisibleParameterAnnotations; /* RuntimeVisibleParameterAnnotations */
+utf *utf_RuntimeInvisibleParameterAnnotations; /* RuntimeInvisibleParameterAnnotations */
+utf *utf_AnnotationDefault; /* AnnotationDefault */
#endif
#endif
*/
+/**
+ * Test following methos of java.lang.Class for proper function:
+ * getSuperclass()
+ * getDeclaringClass()
+ * getEnclosingClass()
+ * getEnclosingConstructor()
+ * getEnclosingMethod()
+ *
+ * I wrote this because getSuperclass() sometimes made problems.
+ */
import java.lang.reflect.Method;
import java.lang.reflect.Constructor;