diff options
author | Tom Tromey <tromey@redhat.com> | 2002-09-03 21:33:46 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2002-09-03 21:33:46 +0000 |
commit | f4701961145138742997ead9600196211450c9d9 (patch) | |
tree | b89c68832aa1f41f6cad7d80d73b8ae5813779c8 /libjava/java/lang/Class.java | |
parent | 57016b4723d40263c4765d0c94ab20a0e3c2335f (diff) | |
download | gcc-f4701961145138742997ead9600196211450c9d9.zip gcc-f4701961145138742997ead9600196211450c9d9.tar.gz gcc-f4701961145138742997ead9600196211450c9d9.tar.bz2 |
Class.h (_getDeclaredMethod): Declare.
* java/lang/Class.h (_getDeclaredMethod): Declare.
(_getMethod): Now private.
* java/lang/natClass.cc (_getDeclaredMethod): Renamed from
getDeclaredMethod. Now returns NULL on failure.
* java/lang/Class.java (_getDeclaredMethod): Declare.
(getDeclaredMethod): No longer native; implements access checks.
From-SVN: r56772
Diffstat (limited to 'libjava/java/lang/Class.java')
-rw-r--r-- | libjava/java/lang/Class.java | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/libjava/java/lang/Class.java b/libjava/java/lang/Class.java index 12306da..cc1cc40 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. |