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
|
@ -166,15 +166,7 @@ _Jv_ResolvePoolEntry (jclass klass, int index)
|
|||
if (! _Jv_equalUtf8Consts (field->name, field_name))
|
||||
continue;
|
||||
|
||||
// now, check field access.
|
||||
|
||||
if ( (cls == klass)
|
||||
|| ((field->flags & Modifier::PUBLIC) != 0)
|
||||
|| (((field->flags & Modifier::PROTECTED) != 0)
|
||||
&& cls->isAssignableFrom (klass))
|
||||
|| (((field->flags & Modifier::PRIVATE) == 0)
|
||||
&& _Jv_ClassNameSamePackage (cls->name,
|
||||
klass->name)))
|
||||
if (_Jv_CheckAccess (klass, cls, field->flags))
|
||||
{
|
||||
/* resove the field using the class' own loader
|
||||
if necessary */
|
||||
|
@ -347,20 +339,10 @@ _Jv_SearchMethodInClass (jclass cls, jclass klass,
|
|||
method_signature)))
|
||||
continue;
|
||||
|
||||
if (cls == klass
|
||||
|| ((method->accflags & Modifier::PUBLIC) != 0)
|
||||
|| (((method->accflags & Modifier::PROTECTED) != 0)
|
||||
&& cls->isAssignableFrom (klass))
|
||||
|| (((method->accflags & Modifier::PRIVATE) == 0)
|
||||
&& _Jv_ClassNameSamePackage (cls->name,
|
||||
klass->name)))
|
||||
{
|
||||
return method;
|
||||
}
|
||||
if (_Jv_CheckAccess (klass, cls, method->accflags))
|
||||
return method;
|
||||
else
|
||||
{
|
||||
throw new java::lang::IllegalAccessError;
|
||||
}
|
||||
throw new java::lang::IllegalAccessError;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue