Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: java_lang_Class.c 8357 2007-08-19 22:59:43Z twisti $
+ $Id: java_lang_Class.c 8395 2007-08-22 13:12:46Z panzi $
*/
*/
java_handle_objectarray_t *_Jv_java_lang_Class_getDeclaredAnnotations(java_lang_Class* klass)
{
- classinfo *c = LLNI_classinfo_unwrap(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;
- uint32_t size = 0;
java_lang_Object *constantPoolOop = (java_lang_Object*)klass;
- if (c == NULL) {
+ if (klass == NULL) {
exceptions_throw_nullpointerexception();
return NULL;
}
- /* Return null for arrays and primitives: */
- if (class_is_primitive(c) || class_is_array(c)) {
- return NULL;
- }
+ c = LLNI_classinfo_unwrap(klass);
- if (c->annotations != NULL) {
- size = c->annotations->size;
- annotations = builtin_newarray_byte(size);
+ /* get annotations: */
+ annotations = class_get_annotations(c);
- if(annotations != NULL) {
- MCOPY(annotations->data, c->annotations->data, uint8_t, size);
- }
+ if (exceptions_get_exception() != NULL) {
+ /* the only exception possible here should be a out of memory exception
+ * raised by copying the annotations into a java bytearray */
+ return NULL;
}
constantPool =
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: jvm.c 8393 2007-08-22 01:10:09Z panzi $
+ $Id: jvm.c 8395 2007-08-22 13:12:46Z panzi $
*/
jbyteArray JVM_GetClassAnnotations(JNIEnv *env, jclass cls)
{
-#if defined(ENABLE_ANNOTATIONS)
- classinfo *c = LLNI_classinfo_unwrap(cls);
+ classinfo *c = NULL;
java_handle_bytearray_t *annotations = NULL;
TRACEJVMCALLS("JVM_GetClassAnnotations: cls=%p", cls);
exceptions_throw_nullpointerexception();
return NULL;
}
+
+ c = LLNI_classinfo_unwrap(cls);
- /* Return null for arrays and primitives: */
- if(class_is_primitive(c) || class_is_array(c))
- {
- return NULL;
- }
-
- if(c->annotations != NULL)
- {
- uint32_t size = c->annotations->size;
- annotations = builtin_newarray_byte(size);
-
- if(annotations != NULL)
- {
- MCOPY(annotations->data, c->annotations->data, uint8_t, size);
- }
- }
+ /* get annotations: */
+ annotations = class_get_annotations(c);
return (jbyteArray)annotations;
-#else
- log_println("JVM_GetClassAnnotations: cls=%p, not implemented in this configuration!", cls);
- return NULL;
-#endif
}
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: class.c 8387 2007-08-21 15:37:47Z twisti $
+ $Id: class.c 8395 2007-08-22 13:12:46Z panzi $
*/
}
+/* class_get_annotations *******************************************************
+
+ Return the unparsed declared annotations in an byte array
+ of the given class (or NULL if there aren't any).
+
+*******************************************************************************/
+
+java_handle_bytearray_t *class_get_annotations(classinfo *c)
+{
+#if defined(ENABLE_ANNOTATIONS)
+ java_handle_bytearray_t *annotations = NULL;
+ uint32_t size = 0;
+
+ /* Return null for arrays and primitives: */
+ if (class_is_primitive(c) || class_is_array(c)) {
+ return NULL;
+ }
+
+ /* copy the annotations into a java byte array: */
+ if (c->annotations != NULL) {
+ size = c->annotations->size;
+ annotations = builtin_newarray_byte(size);
+
+ if(annotations != NULL) {
+ MCOPY(annotations->data, c->annotations->data, uint8_t, size);
+ }
+ }
+
+ return annotations;
+#else
+ return NULL;
+#endif
+}
+
+
/* class_get_signature *********************************************************
Return the signature of the given class. For array and primitive
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: class.h 8393 2007-08-22 01:10:09Z panzi $
+ $Id: class.h 8395 2007-08-22 13:12:46Z panzi $
*/
classinfo *class_get_declaringclass(classinfo *c);
classinfo *class_get_enclosingclass(classinfo *c);
java_handle_objectarray_t *class_get_interfaces(classinfo *c);
+java_handle_bytearray_t *class_get_annotations(classinfo *c);
#if defined(ENABLE_JAVASE)
utf *class_get_signature(classinfo *c);