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) 1999, 2000, 2001 Free Software Foundation
|
||||
/* Copyright (C) 1999, 2000, 2001, 2003 Free Software Foundation
|
||||
|
||||
This file is part of libgcj.
|
||||
|
||||
|
@ -15,6 +15,7 @@ details. */
|
|||
#include <jvm.h>
|
||||
#include <gcj/cni.h>
|
||||
#include <java/lang/reflect/Array.h>
|
||||
#include <java/lang/ArrayIndexOutOfBoundsException.h>
|
||||
#include <java/lang/IllegalArgumentException.h>
|
||||
#include <java/lang/Byte.h>
|
||||
#include <java/lang/Short.h>
|
||||
|
@ -38,8 +39,8 @@ java::lang::reflect::Array::newInstance (jclass componentType, jint length)
|
|||
return _Jv_NewPrimArray (componentType, length);
|
||||
}
|
||||
else
|
||||
// FIXME: class loader?
|
||||
return JvNewObjectArray (length, componentType, NULL);
|
||||
|
||||
}
|
||||
|
||||
jobject
|
||||
|
@ -52,10 +53,26 @@ java::lang::reflect::Array::newInstance (jclass componentType,
|
|||
jint* dims = elements (dimensions);
|
||||
if (ndims == 1)
|
||||
return newInstance (componentType, dims[0]);
|
||||
|
||||
gnu::gcj::runtime::StackTrace *t
|
||||
= new gnu::gcj::runtime::StackTrace(4);
|
||||
Class *caller = NULL;
|
||||
ClassLoader *caller_loader = NULL;
|
||||
try
|
||||
{
|
||||
for (int i = 1; !caller; i++)
|
||||
{
|
||||
caller = t->classAt (i);
|
||||
}
|
||||
caller_loader = caller->getClassLoaderInternal();
|
||||
}
|
||||
catch (::java::lang::ArrayIndexOutOfBoundsException *e)
|
||||
{
|
||||
}
|
||||
|
||||
jclass arrayType = componentType;
|
||||
for (int i = 0; i < ndims; i++) // FIXME 2nd arg should
|
||||
// be "current" loader
|
||||
arrayType = _Jv_GetArrayClass (arrayType, 0);
|
||||
for (int i = 0; i < ndims; i++)
|
||||
arrayType = _Jv_GetArrayClass (arrayType, caller_loader);
|
||||
|
||||
return _Jv_NewMultiArray (arrayType, ndims, dims);
|
||||
}
|
||||
|
@ -343,8 +360,10 @@ java::lang::reflect::Array::setBoolean (jobject array,
|
|||
|
||||
void
|
||||
java::lang::reflect::Array::set (jobject array, jint index,
|
||||
jobject value, jclass elType)
|
||||
jobject value, jclass elType)
|
||||
{
|
||||
// We don't have to call getElementType here, or check INDEX,
|
||||
// because it was already done in the Java wrapper.
|
||||
if (! _Jv_IsInstanceOf (value, elType))
|
||||
throw new java::lang::IllegalArgumentException;
|
||||
elements ((jobjectArray) array) [index] = value;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue