Commit f4701961 by Tom Tromey Committed by Tom Tromey

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
parent 57016b47
2002-09-03 Tom Tromey <tromey@redhat.com>
* 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.
2002-09-01 Mark Wielaard <mark@klomp.org> 2002-09-01 Mark Wielaard <mark@klomp.org>
* gnu/gcj/runtime/NameFinder.java (remove_interpreter): New field. * gnu/gcj/runtime/NameFinder.java (remove_interpreter): New field.
......
...@@ -160,6 +160,9 @@ private: ...@@ -160,6 +160,9 @@ private:
java::lang::reflect::Method *getPrivateMethod (jstring, JArray<jclass> *); java::lang::reflect::Method *getPrivateMethod (jstring, JArray<jclass> *);
java::security::ProtectionDomain *getProtectionDomain0 (); java::security::ProtectionDomain *getProtectionDomain0 ();
java::lang::reflect::Method *_getMethod (jstring, JArray<jclass> *);
java::lang::reflect::Method *_getDeclaredMethod (jstring, JArray<jclass> *);
public: public:
JArray<java::lang::reflect::Field *> *getFields (void); JArray<java::lang::reflect::Field *> *getFields (void);
...@@ -167,7 +170,6 @@ public: ...@@ -167,7 +170,6 @@ public:
void getSignature (java::lang::StringBuffer *buffer); void getSignature (java::lang::StringBuffer *buffer);
static jstring getSignature (JArray<jclass> *, jboolean is_constructor); static jstring getSignature (JArray<jclass> *, jboolean is_constructor);
java::lang::reflect::Method *_getMethod (jstring, JArray<jclass> *);
JArray<java::lang::reflect::Method *> *getMethods (void); JArray<java::lang::reflect::Method *> *getMethods (void);
inline jint getModifiers (void) inline jint getModifiers (void)
......
...@@ -65,9 +65,31 @@ public final class Class implements Serializable ...@@ -65,9 +65,31 @@ public final class Class implements Serializable
public native Field getDeclaredField (String fieldName) public native Field getDeclaredField (String fieldName)
throws NoSuchFieldException, SecurityException; throws NoSuchFieldException, SecurityException;
public native Field[] getDeclaredFields () throws SecurityException; public native Field[] getDeclaredFields () throws SecurityException;
public native Method getDeclaredMethod (String methodName,
Class[] parameterTypes) private native Method _getDeclaredMethod (String methodName,
throws NoSuchMethodException, SecurityException; 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; public native Method[] getDeclaredMethods () throws SecurityException;
// This is marked as unimplemented in the JCL book. // This is marked as unimplemented in the JCL book.
......
...@@ -315,8 +315,8 @@ java::lang::Class::getSignature (JArray<jclass> *param_types, ...@@ -315,8 +315,8 @@ java::lang::Class::getSignature (JArray<jclass> *param_types,
} }
java::lang::reflect::Method * java::lang::reflect::Method *
java::lang::Class::getDeclaredMethod (jstring name, java::lang::Class::_getDeclaredMethod (jstring name,
JArray<jclass> *param_types) JArray<jclass> *param_types)
{ {
jstring partial_sig = getSignature (param_types, false); jstring partial_sig = getSignature (param_types, false);
jint p_len = partial_sig->length(); jint p_len = partial_sig->length();
...@@ -324,7 +324,6 @@ java::lang::Class::getDeclaredMethod (jstring name, ...@@ -324,7 +324,6 @@ java::lang::Class::getDeclaredMethod (jstring name,
int i = isPrimitive () ? 0 : method_count; int i = isPrimitive () ? 0 : method_count;
while (--i >= 0) while (--i >= 0)
{ {
// FIXME: access checks.
if (_Jv_equalUtf8Consts (methods[i].name, utf_name) if (_Jv_equalUtf8Consts (methods[i].name, utf_name)
&& _Jv_equaln (methods[i].signature, partial_sig, p_len)) && _Jv_equaln (methods[i].signature, partial_sig, p_len))
{ {
...@@ -336,7 +335,7 @@ java::lang::Class::getDeclaredMethod (jstring name, ...@@ -336,7 +335,7 @@ java::lang::Class::getDeclaredMethod (jstring name,
return rmethod; return rmethod;
} }
} }
throw new java::lang::NoSuchMethodException; return NULL;
} }
JArray<java::lang::reflect::Method *> * JArray<java::lang::reflect::Method *> *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment