aboutsummaryrefslogtreecommitdiff
path: root/libjava/java/lang/Class.java
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/java/lang/Class.java')
-rw-r--r--libjava/java/lang/Class.java28
1 files changed, 25 insertions, 3 deletions
diff --git a/libjava/java/lang/Class.java b/libjava/java/lang/Class.java
index 12306da8061..cc1cc40f2a4 100644
--- a/libjava/java/lang/Class.java
+++ b/libjava/java/lang/Class.java
@@ -65,9 +65,31 @@ public final class Class implements Serializable
public native Field getDeclaredField (String fieldName)
throws NoSuchFieldException, SecurityException;
public native Field[] getDeclaredFields () throws SecurityException;
- public native Method getDeclaredMethod (String methodName,
- Class[] parameterTypes)
- throws NoSuchMethodException, SecurityException;
+
+ private native Method _getDeclaredMethod (String methodName,
+ Class[] parameterTypes);
+
+ 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());
+ }
+
+ if ("<init>".equals(methodName) || "<clinit>".equals(methodName))
+ throw new NoSuchMethodException(methodName);
+
+ Method m = _getDeclaredMethod(methodName, parameterTypes);
+ if (m == null)
+ throw new NoSuchMethodException (methodName);
+ return m;
+ }
+
public native Method[] getDeclaredMethods () throws SecurityException;
// This is marked as unimplemented in the JCL book.