diff options
Diffstat (limited to 'libjava/java/lang/reflect')
-rw-r--r-- | libjava/java/lang/reflect/natArray.cc | 18 | ||||
-rw-r--r-- | libjava/java/lang/reflect/natConstructor.cc | 16 | ||||
-rw-r--r-- | libjava/java/lang/reflect/natField.cc | 14 | ||||
-rw-r--r-- | libjava/java/lang/reflect/natMethod.cc | 16 |
4 files changed, 10 insertions, 54 deletions
diff --git a/libjava/java/lang/reflect/natArray.cc b/libjava/java/lang/reflect/natArray.cc index ce76b9c..b7bc8be 100644 --- a/libjava/java/lang/reflect/natArray.cc +++ b/libjava/java/lang/reflect/natArray.cc @@ -14,6 +14,7 @@ details. */ #include <jvm.h> #include <gcj/cni.h> +#include <java-stack.h> #include <java/lang/reflect/Array.h> #include <java/lang/ArrayIndexOutOfBoundsException.h> #include <java/lang/IllegalArgumentException.h> @@ -54,21 +55,10 @@ java::lang::reflect::Array::newInstance (jclass componentType, if (ndims == 1) return newInstance (componentType, dims[0]); - gnu::gcj::runtime::StackTrace *t - = new gnu::gcj::runtime::StackTrace(4); - Class *caller = NULL; + Class *caller = _Jv_StackTrace::GetCallingClass (&Array::class$); ClassLoader *caller_loader = NULL; - try - { - for (int i = 1; !caller; i++) - { - caller = t->classAt (i); - } - caller_loader = caller->getClassLoaderInternal(); - } - catch (::java::lang::ArrayIndexOutOfBoundsException *e) - { - } + if (caller) + caller_loader = caller->getClassLoaderInternal(); jclass arrayType = componentType; for (int i = 0; i < ndims; i++) diff --git a/libjava/java/lang/reflect/natConstructor.cc b/libjava/java/lang/reflect/natConstructor.cc index 3697332..f4d9590 100644 --- a/libjava/java/lang/reflect/natConstructor.cc +++ b/libjava/java/lang/reflect/natConstructor.cc @@ -12,6 +12,7 @@ details. */ #include <gcj/cni.h> #include <jvm.h> +#include <java-stack.h> #include <java/lang/ArrayIndexOutOfBoundsException.h> #include <java/lang/IllegalAccessException.h> @@ -55,20 +56,7 @@ java::lang::reflect::Constructor::newInstance (jobjectArray args) // Check accessibility, if required. if (! (Modifier::isPublic (meth->accflags) || this->isAccessible())) { - gnu::gcj::runtime::StackTrace *t - = new gnu::gcj::runtime::StackTrace(4); - Class *caller = NULL; - try - { - for (int i = 1; !caller; i++) - { - caller = t->classAt (i); - } - } - catch (::java::lang::ArrayIndexOutOfBoundsException *e) - { - } - + Class *caller = _Jv_StackTrace::GetCallingClass (&Constructor::class$); if (! _Jv_CheckAccess(caller, declaringClass, meth->accflags)) throw new IllegalAccessException; } diff --git a/libjava/java/lang/reflect/natField.cc b/libjava/java/lang/reflect/natField.cc index 9a8107b..33a5717 100644 --- a/libjava/java/lang/reflect/natField.cc +++ b/libjava/java/lang/reflect/natField.cc @@ -13,6 +13,7 @@ details. */ #include <stdlib.h> #include <jvm.h> +#include <java-stack.h> #include <java/lang/reflect/Field.h> #include <java/lang/reflect/Modifier.h> #include <java/lang/ArrayIndexOutOfBoundsException.h> @@ -78,18 +79,7 @@ getAddr (java::lang::reflect::Field* field, jclass caller, jobject obj, // Check accessibility, if required. if (! (Modifier::isPublic (flags) || field->isAccessible())) { - gnu::gcj::runtime::StackTrace *t - = new gnu::gcj::runtime::StackTrace(7); - try - { - // We want to skip all the frames on the stack from this class. - for (int i = 1; !caller || caller == &Field::class$; i++) - caller = t->classAt (i); - } - catch (::java::lang::ArrayIndexOutOfBoundsException *e) - { - } - + caller = _Jv_StackTrace::GetCallingClass (&Field::class$); if (! _Jv_CheckAccess (caller, field->getDeclaringClass(), flags)) throw new java::lang::IllegalAccessException; } diff --git a/libjava/java/lang/reflect/natMethod.cc b/libjava/java/lang/reflect/natMethod.cc index 27c26e1..4329443 100644 --- a/libjava/java/lang/reflect/natMethod.cc +++ b/libjava/java/lang/reflect/natMethod.cc @@ -13,6 +13,7 @@ details. */ #include <gcj/cni.h> #include <jvm.h> #include <jni.h> +#include <java-stack.h> #include <java/lang/reflect/Method.h> #include <java/lang/reflect/Constructor.h> @@ -168,20 +169,7 @@ java::lang::reflect::Method::invoke (jobject obj, jobjectArray args) // Check accessibility, if required. if (! (Modifier::isPublic (meth->accflags) || this->isAccessible())) { - gnu::gcj::runtime::StackTrace *t - = new gnu::gcj::runtime::StackTrace(4); - Class *caller = NULL; - try - { - for (int i = 1; !caller; i++) - { - caller = t->classAt (i); - } - } - catch (::java::lang::ArrayIndexOutOfBoundsException *e) - { - } - + Class *caller = _Jv_StackTrace::GetCallingClass (&Method::class$); if (! _Jv_CheckAccess(caller, declaringClass, meth->accflags)) throw new IllegalAccessException; } |