Runtime.java: Comment fix.
* java/lang/Runtime.java: Comment fix. * java/lang/ClassLoader.java (isAncestorOf): New method. (getParent): Uncommented security check. Use isAncestorOf. * include/jvm.h (_Jv_CheckAccess): Declare. * java/lang/reflect/natConstructor.cc (newInstance): Perform access check. Include IllegalAccessException.h, ArrayIndexOutOfBoundsException.h. * java/lang/reflect/natArray.cc (newInstance): Pass caller's class loader to _Jv_GetArrayClass. Include ArrayIndexOutOfBoundsException.h. * java/lang/reflect/Field.java: Update comment to reflect status. (equals): Fixed indentation. * java/lang/Class.h (Class): Declare memberAccessCheck, not checkMemberAccess. Make _Jv_CheckAccess a friend. * java/lang/Class.java (memberAccessCheck): New method from Classpath. (checkMemberAccess): Removed. (getDeclaredMethod): Use memberAccessCheck. (getField): Likewise. (getMethod): Likewise. * resolve.cc (_Jv_ResolvePoolEntry): Use _Jv_CheckAccess. (_Jv_SearchMethodInClass): Likewise. * prims.cc (_Jv_CheckAccess): New function. * jni.cc (_Jv_JNI_FindClass): Use getClassLoaderInternal. (_Jv_JNI_GetAnyFieldID): Likewise. * java/lang/natClass.cc (forName): Use getClassLoaderInternal. (getClassLoader): Added security check. (getConstructor): Call memberAccessCheck. (getDeclaredClasses): Likewise. (getDeclaredField): Likewise. (getDeclaredFields): Likewise. (_getConstructors): Likewise. (getDeclaredConstructor): Likewise. (getDeclaredMethods): Likewise. (getFields): Likewise. (getMethods): Likewise. (newInstance): Likewise. (_Jv_MakeVTable): Put method name in exception. * java/lang/reflect/natMethod.cc (getType): Use getClassLoaderInternal. (_Jv_GetTypesFromSignature): Likewise. (invoke): Perform access check. (_Jv_CallAnyMethodA): Removed old FIXME comments. Include ArrayIndexOutOfBoundsException.h. * java/lang/reflect/natField.cc (getType): Use getClassLoaderInternal. (_Jv_CheckFieldAccessibility): Removed. (getAddr): Use _Jv_CheckAccess; find caller. Include ArrayIndexOutOfBoundsException.h. From-SVN: r69621
This commit is contained in:
parent
3c87bc22a9
commit
ffd94572f4
15 changed files with 286 additions and 152 deletions
|
@ -1,6 +1,6 @@
|
|||
// natField.cc - Implementation of java.lang.reflect.Field native methods.
|
||||
|
||||
/* Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation
|
||||
/* Copyright (C) 1998, 1999, 2000, 2001, 2003 Free Software Foundation
|
||||
|
||||
This file is part of libgcj.
|
||||
|
||||
|
@ -15,6 +15,7 @@ details. */
|
|||
#include <jvm.h>
|
||||
#include <java/lang/reflect/Field.h>
|
||||
#include <java/lang/reflect/Modifier.h>
|
||||
#include <java/lang/ArrayIndexOutOfBoundsException.h>
|
||||
#include <java/lang/IllegalArgumentException.h>
|
||||
#include <java/lang/IllegalAccessException.h>
|
||||
#include <java/lang/NullPointerException.h>
|
||||
|
@ -46,31 +47,36 @@ java::lang::reflect::Field::getType ()
|
|||
{
|
||||
jfieldID fld = _Jv_FromReflectedField (this);
|
||||
JvSynchronize sync (declaringClass);
|
||||
_Jv_ResolveField (fld, declaringClass->getClassLoader ());
|
||||
_Jv_ResolveField (fld, declaringClass->getClassLoaderInternal ());
|
||||
return fld->type;
|
||||
}
|
||||
|
||||
static void
|
||||
_Jv_CheckFieldAccessibility (jfieldID /*fld*/, jclass /*caller*/)
|
||||
{
|
||||
#if 0
|
||||
if (caller == NULL)
|
||||
caller = getCaller();
|
||||
#endif
|
||||
#if 0
|
||||
_Jv_ushort flags = fld->getModifiers();
|
||||
check accesss;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void*
|
||||
getAddr (java::lang::reflect::Field* field, jclass caller, jobject obj)
|
||||
{
|
||||
// FIXME: we know CALLER is NULL here. At one point we planned to
|
||||
// have the compiler insert the caller as a hidden argument in some
|
||||
// calls. However, we never implemented that, so we have to find
|
||||
// the caller by hand instead.
|
||||
gnu::gcj::runtime::StackTrace *t
|
||||
= new gnu::gcj::runtime::StackTrace(4);
|
||||
try
|
||||
{
|
||||
for (int i = 1; !caller; i++)
|
||||
{
|
||||
caller = t->classAt (i);
|
||||
}
|
||||
}
|
||||
catch (::java::lang::ArrayIndexOutOfBoundsException *e)
|
||||
{
|
||||
}
|
||||
|
||||
jfieldID fld = _Jv_FromReflectedField (field);
|
||||
_Jv_ushort flags = fld->getModifiers();
|
||||
if (! (flags & java::lang::reflect::Modifier::PUBLIC)
|
||||
&& ! field->isAccessible ())
|
||||
_Jv_CheckFieldAccessibility (fld, caller);
|
||||
if (! field->isAccessible ()
|
||||
&& ! _Jv_CheckAccess (caller, field->getDeclaringClass(), flags))
|
||||
throw new java::lang::IllegalAccessException;
|
||||
|
||||
if (flags & java::lang::reflect::Modifier::STATIC)
|
||||
{
|
||||
jclass fldClass = field->getDeclaringClass ();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue