summaryrefslogtreecommitdiff
path: root/libjava
diff options
context:
space:
mode:
authortromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2002-07-05 20:40:11 +0000
committertromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2002-07-05 20:40:11 +0000
commitf91ed2b141975d0deafba31bd2dec640610a0b4b (patch)
treed6831eedd78519f01123093a5f9a1b1695f7a3ea /libjava
parent13c773a754902f99f21c8926af690472242795a7 (diff)
downloadgcc-f91ed2b141975d0deafba31bd2dec640610a0b4b.tar.gz
2002-07-04 Tom Tromey <tromey@redhat.com>
Jeff Sturm <jsturm@one-point.com> Fix for PR libgcj/7060: * java/lang/Class.h (_getMethod): Renamed from getMethod. * java/lang/natClass.cc (_getMethod): Renamed from getMethod. Recurse into superinterfaces. Don't throw NoSuchMethodException. * java/lang/Class.java (getMethod): New Java implementation; complies with spec. (_getMethod): New native method. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@55266 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava')
-rw-r--r--libjava/ChangeLog11
-rw-r--r--libjava/java/lang/Class.h2
-rw-r--r--libjava/java/lang/Class.java25
-rw-r--r--libjava/java/lang/natClass.cc18
4 files changed, 51 insertions, 5 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index 24696fd1b87..d5f5fd826f2 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,3 +1,14 @@
+2002-07-04 Tom Tromey <tromey@redhat.com>
+ Jeff Sturm <jsturm@one-point.com>
+
+ Fix for PR libgcj/7060:
+ * java/lang/Class.h (_getMethod): Renamed from getMethod.
+ * java/lang/natClass.cc (_getMethod): Renamed from getMethod.
+ Recurse into superinterfaces. Don't throw NoSuchMethodException.
+ * java/lang/Class.java (getMethod): New Java implementation;
+ complies with spec.
+ (_getMethod): New native method.
+
2002-07-02 Tom Tromey <tromey@redhat.com>
David Hovemeyer <daveho@cs.umd.edu>
diff --git a/libjava/java/lang/Class.h b/libjava/java/lang/Class.h
index eb33c93a732..9eb1a5cac1a 100644
--- a/libjava/java/lang/Class.h
+++ b/libjava/java/lang/Class.h
@@ -166,7 +166,7 @@ public:
void getSignature (java::lang::StringBuffer *buffer);
static jstring getSignature (JArray<jclass> *, jboolean is_constructor);
- java::lang::reflect::Method *getMethod (jstring, JArray<jclass> *);
+ java::lang::reflect::Method *_getMethod (jstring, JArray<jclass> *);
JArray<java::lang::reflect::Method *> *getMethods (void);
inline jint getModifiers (void)
diff --git a/libjava/java/lang/Class.java b/libjava/java/lang/Class.java
index 7bd38dee01f..12306da8061 100644
--- a/libjava/java/lang/Class.java
+++ b/libjava/java/lang/Class.java
@@ -121,8 +121,29 @@ public final class Class implements Serializable
private static final native String getSignature (Class[] parameterTypes,
boolean is_construtor);
- public native Method getMethod (String methodName, Class[] parameterTypes)
- throws NoSuchMethodException, SecurityException;
+ public native Method _getMethod (String methodName, Class[] parameterTypes);
+
+ 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());
+ }
+
+ if ("<init>".equals(methodName) || "<clinit>".equals(methodName))
+ throw new NoSuchMethodException(methodName);
+
+ Method m = _getMethod(methodName, parameterTypes);
+ if (m == null)
+ throw new NoSuchMethodException (methodName);
+ return m;
+ }
+
private native int _getMethods (Method[] result, int offset);
public native Method[] getMethods () throws SecurityException;
diff --git a/libjava/java/lang/natClass.cc b/libjava/java/lang/natClass.cc
index 53990902566..43b79adc9b6 100644
--- a/libjava/java/lang/natClass.cc
+++ b/libjava/java/lang/natClass.cc
@@ -485,7 +485,7 @@ java::lang::Class::getInterfaces (void)
}
java::lang::reflect::Method *
-java::lang::Class::getMethod (jstring name, JArray<jclass> *param_types)
+java::lang::Class::_getMethod (jstring name, JArray<jclass> *param_types)
{
jstring partial_sig = getSignature (param_types, false);
jint p_len = partial_sig->length();
@@ -514,7 +514,21 @@ java::lang::Class::getMethod (jstring name, JArray<jclass> *param_types)
}
}
}
- throw new java::lang::NoSuchMethodException;
+
+ // If we haven't found a match, and this class is an interface, then
+ // check all the superinterfaces.
+ if (isInterface())
+ {
+ for (int i = 0; i < interface_count; ++i)
+ {
+ using namespace java::lang::reflect;
+ Method *rmethod = interfaces[i]->_getMethod (name, param_types);
+ if (rmethod != NULL)
+ return rmethod;
+ }
+ }
+
+ return NULL;
}
// This is a very slow implementation, since it re-scans all the