aboutsummaryrefslogtreecommitdiff
path: root/libjava/java/lang/Class.java
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2003-07-21 01:54:06 +0000
committerTom Tromey <tromey@gcc.gnu.org>2003-07-21 01:54:06 +0000
commitffd94572f43f8b2a3697c9718c34ac3275a48262 (patch)
treedceb21b9cf452ee4920e5a2a6465e98ae9cd868c /libjava/java/lang/Class.java
parent3c87bc22a96ca7029326ef7992f03382f0a22353 (diff)
downloadgcc-ffd94572f43f8b2a3697c9718c34ac3275a48262.zip
gcc-ffd94572f43f8b2a3697c9718c34ac3275a48262.tar.gz
gcc-ffd94572f43f8b2a3697c9718c34ac3275a48262.tar.bz2
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
Diffstat (limited to 'libjava/java/lang/Class.java')
-rw-r--r--libjava/java/lang/Class.java46
1 files changed, 19 insertions, 27 deletions
diff --git a/libjava/java/lang/Class.java b/libjava/java/lang/Class.java
index 44f5b5a..bd77691 100644
--- a/libjava/java/lang/Class.java
+++ b/libjava/java/lang/Class.java
@@ -72,14 +72,7 @@ public final class Class implements Serializable
public Method getDeclaredMethod (String methodName, Class[] parameterTypes)
throws NoSuchMethodException, SecurityException
{
- SecurityManager sm = System.getSecurityManager();
- if (sm != null)
- {
- sm.checkMemberAccess(this, Member.DECLARED);
- Package p = getPackage();
- if (p != null)
- sm.checkPackageAccess(p.getName());
- }
+ memberAccessCheck(Member.DECLARED);
if ("<init>".equals(methodName) || "<clinit>".equals(methodName))
throw new NoSuchMethodException(methodName);
@@ -101,9 +94,7 @@ public final class Class implements Serializable
public Field getField (String fieldName)
throws NoSuchFieldException, SecurityException
{
- SecurityManager s = System.getSecurityManager();
- if (s != null)
- s.checkMemberAccess (this, java.lang.reflect.Member.DECLARED);
+ memberAccessCheck (Member.PUBLIC);
Field fld = getField(fieldName, fieldName.hashCode());
if (fld == null)
throw new NoSuchFieldException(fieldName);
@@ -148,14 +139,7 @@ public final class Class implements Serializable
public Method getMethod (String methodName, Class[] parameterTypes)
throws NoSuchMethodException, SecurityException
{
- SecurityManager sm = System.getSecurityManager();
- if (sm != null)
- {
- sm.checkMemberAccess(this, Member.PUBLIC);
- Package p = getPackage();
- if (p != null)
- sm.checkPackageAccess(p.getName());
- }
+ memberAccessCheck(Member.PUBLIC);
if ("<init>".equals(methodName) || "<clinit>".equals(methodName))
throw new NoSuchMethodException(methodName);
@@ -334,14 +318,6 @@ public final class Class implements Serializable
{
}
- // Do a security check.
- private void checkMemberAccess (int flags)
- {
- SecurityManager sm = System.getSecurityManager();
- if (sm != null)
- sm.checkMemberAccess(this, flags);
- }
-
// Initialize the class.
private native void initializeClass ();
@@ -361,4 +337,20 @@ public final class Class implements Serializable
return "";
return name.substring(0, lastInd);
}
+
+ /**
+ * Perform security checks common to all of the methods that
+ * get members of this Class.
+ */
+ private void memberAccessCheck(int which)
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ {
+ sm.checkMemberAccess(this, which);
+ Package pkg = getPackage();
+ if (pkg != null)
+ sm.checkPackageAccess(pkg.getName());
+ }
+ }
}