* src/vmcore/class.c (class_get_enclosingmethod): New function.
* src/vmcore/class.h: Likewise.
jobjectArray JVM_GetEnclosingMethodInfo(JNIEnv *env, jclass ofClass)
{
- log_println("JVM_GetEnclosingMethodInfo: IMPLEMENT ME!");
+ classinfo *c;
+ methodinfo *m;
+ java_handle_objectarray_t *oa;
+
+ TRACEJVMCALLS("JVM_GetEnclosingMethodInfo(env=%p, ofClass=%p)", env, ofClass);
+
+ c = LLNI_classinfo_unwrap(ofClass);
+
+ if ((c == NULL) || class_is_primitive(c))
+ return NULL;
+
+ m = class_get_enclosingmethod(c);
+
+ if (m == NULL)
+ return NULL;
+
+ oa = builtin_anewarray(3, class_java_lang_Object);
+
+ if (oa == NULL)
+ return NULL;
+
+ array_objectarray_element_set(oa, 0, (java_handle_t *) LLNI_classinfo_wrap(m->class));
+ array_objectarray_element_set(oa, 1, javastring_new(m->name));
+ array_objectarray_element_set(oa, 2, javastring_new(m->descriptor));
+
+ return (jobjectArray) oa;
}
}
+/* class_get_enclosingmethod ***************************************************
+
+ Return the enclosing method for the given class.
+
+ IN:
+ c ... class to return the enclosing method for
+
+ RETURN:
+ methodinfo of the enclosing method
+
+*******************************************************************************/
+
+methodinfo *class_get_enclosingmethod(classinfo *c)
+{
+ constant_nameandtype *cn;
+ classinfo *ec;
+ methodinfo *m;
+
+ /* get enclosing class and method */
+
+ ec = class_get_enclosingclass(c);
+ cn = c->enclosingmethod;
+
+ /* check for enclosing class and method */
+
+ if (ec == NULL)
+ return NULL;
+
+ if (cn == NULL)
+ return NULL;
+
+ /* find method in enclosing class */
+
+ m = class_findmethod(ec, cn->name, cn->descriptor);
+
+ if (m == NULL) {
+ exceptions_throw_internalerror("Enclosing method doesn't exist");
+ return NULL;
+ }
+
+ return m;
+}
+
+
/* class_get_interfaces ********************************************************
Return an array of interfaces of the given class.
java_handle_objectarray_t *class_get_declaredclasses(classinfo *c, bool publicOnly);
classinfo *class_get_declaringclass(classinfo *c);
classinfo *class_get_enclosingclass(classinfo *c);
+methodinfo *class_get_enclosingmethod(classinfo *c);
java_handle_objectarray_t *class_get_interfaces(classinfo *c);
java_handle_bytearray_t *class_get_annotations(classinfo *c);
int32_t class_get_modifiers(classinfo *c, bool ignoreInnerClassesAttrib);