Class.h (getSignature): Updated.
* java/lang/Class.h (getSignature): Updated. * java/lang/Class.java (getSignature): Updated. * java/lang/natClass.cc (getSignature): Added `is_constructor' argument. (getConstructor): Ensure constructor is public. (_getConstructors): Check for public-ness of constructor when `declared' is false, not when it is true. From-SVN: r31241
This commit is contained in:
parent
c0029be5f7
commit
95c6cc0ab5
4 changed files with 24 additions and 10 deletions
|
@ -1,3 +1,13 @@
|
||||||
|
2000-01-04 Tom Tromey <tromey@cygnus.com>
|
||||||
|
|
||||||
|
* java/lang/Class.h (getSignature): Updated.
|
||||||
|
* java/lang/Class.java (getSignature): Updated.
|
||||||
|
* java/lang/natClass.cc (getSignature): Added `is_constructor'
|
||||||
|
argument.
|
||||||
|
(getConstructor): Ensure constructor is public.
|
||||||
|
(_getConstructors): Check for public-ness of constructor when
|
||||||
|
`declared' is false, not when it is true.
|
||||||
|
|
||||||
2000-01-04 Warren Levy <warrenl@cygnus.com>
|
2000-01-04 Warren Levy <warrenl@cygnus.com>
|
||||||
|
|
||||||
* java/net/natPlainDatagramSocketImpl.cc (peek): Removed unnecesary
|
* java/net/natPlainDatagramSocketImpl.cc (peek): Removed unnecesary
|
||||||
|
|
|
@ -103,7 +103,7 @@ public:
|
||||||
JArray<jclass> *getInterfaces (void);
|
JArray<jclass> *getInterfaces (void);
|
||||||
|
|
||||||
void getSignature (java::lang::StringBuffer *buffer);
|
void getSignature (java::lang::StringBuffer *buffer);
|
||||||
static jstring getSignature (JArray<jclass> *);
|
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);
|
JArray<java::lang::reflect::Method *> *getMethods (void);
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,8 @@ public final class Class implements Serializable
|
||||||
public native Class[] getInterfaces ();
|
public native Class[] getInterfaces ();
|
||||||
|
|
||||||
private final native void getSignature (StringBuffer buffer);
|
private final native void getSignature (StringBuffer buffer);
|
||||||
private static final native String getSignature (Class[] parameterTypes);
|
private static final native String getSignature (Class[] parameterTypes,
|
||||||
|
boolean is_construtor);
|
||||||
|
|
||||||
public native Method getMethod (String methodName, Class[] parameterTypes)
|
public native Method getMethod (String methodName, Class[] parameterTypes)
|
||||||
throws NoSuchMethodException, SecurityException;
|
throws NoSuchMethodException, SecurityException;
|
||||||
|
|
|
@ -101,7 +101,7 @@ java::lang::Class::forName (jstring className)
|
||||||
java::lang::reflect::Constructor *
|
java::lang::reflect::Constructor *
|
||||||
java::lang::Class::getConstructor (JArray<jclass> *param_types)
|
java::lang::Class::getConstructor (JArray<jclass> *param_types)
|
||||||
{
|
{
|
||||||
jstring partial_sig = getSignature (param_types);
|
jstring partial_sig = getSignature (param_types, true);
|
||||||
jint hash = partial_sig->hashCode ();
|
jint hash = partial_sig->hashCode ();
|
||||||
|
|
||||||
int i = isPrimitive () ? 0 : method_count;
|
int i = isPrimitive () ? 0 : method_count;
|
||||||
|
@ -114,7 +114,7 @@ java::lang::Class::getConstructor (JArray<jclass> *param_types)
|
||||||
// Found it. For getConstructor, the constructor must be
|
// Found it. For getConstructor, the constructor must be
|
||||||
// public.
|
// public.
|
||||||
using namespace java::lang::reflect;
|
using namespace java::lang::reflect;
|
||||||
if (Modifier::isPublic(methods[i].accflags))
|
if (! Modifier::isPublic(methods[i].accflags))
|
||||||
break;
|
break;
|
||||||
Constructor *cons = new Constructor ();
|
Constructor *cons = new Constructor ();
|
||||||
cons->offset = (char *) (&methods[i]) - (char *) methods;
|
cons->offset = (char *) (&methods[i]) - (char *) methods;
|
||||||
|
@ -139,7 +139,7 @@ java::lang::Class::_getConstructors (jboolean declared)
|
||||||
if (method->name == NULL
|
if (method->name == NULL
|
||||||
&& ! _Jv_equalUtf8Consts (method->name, init_name))
|
&& ! _Jv_equalUtf8Consts (method->name, init_name))
|
||||||
continue;
|
continue;
|
||||||
if (declared
|
if (! declared
|
||||||
&& ! java::lang::reflect::Modifier::isPublic(method->accflags))
|
&& ! java::lang::reflect::Modifier::isPublic(method->accflags))
|
||||||
continue;
|
continue;
|
||||||
numConstructors++;
|
numConstructors++;
|
||||||
|
@ -154,7 +154,7 @@ java::lang::Class::_getConstructors (jboolean declared)
|
||||||
if (method->name == NULL
|
if (method->name == NULL
|
||||||
&& ! _Jv_equalUtf8Consts (method->name, init_name))
|
&& ! _Jv_equalUtf8Consts (method->name, init_name))
|
||||||
continue;
|
continue;
|
||||||
if (declared
|
if (! declared
|
||||||
&& ! java::lang::reflect::Modifier::isPublic(method->accflags))
|
&& ! java::lang::reflect::Modifier::isPublic(method->accflags))
|
||||||
continue;
|
continue;
|
||||||
java::lang::reflect::Constructor *cons
|
java::lang::reflect::Constructor *cons
|
||||||
|
@ -169,7 +169,7 @@ java::lang::Class::_getConstructors (jboolean declared)
|
||||||
java::lang::reflect::Constructor *
|
java::lang::reflect::Constructor *
|
||||||
java::lang::Class::getDeclaredConstructor (JArray<jclass> *param_types)
|
java::lang::Class::getDeclaredConstructor (JArray<jclass> *param_types)
|
||||||
{
|
{
|
||||||
jstring partial_sig = getSignature (param_types);
|
jstring partial_sig = getSignature (param_types, true);
|
||||||
jint hash = partial_sig->hashCode ();
|
jint hash = partial_sig->hashCode ();
|
||||||
|
|
||||||
int i = isPrimitive () ? 0 : method_count;
|
int i = isPrimitive () ? 0 : method_count;
|
||||||
|
@ -277,7 +277,8 @@ java::lang::Class::getSignature (java::lang::StringBuffer *buffer)
|
||||||
// This doesn't have to be native. It is an implementation detail
|
// This doesn't have to be native. It is an implementation detail
|
||||||
// only called from the C++ code, though, so maybe this is clearer.
|
// only called from the C++ code, though, so maybe this is clearer.
|
||||||
jstring
|
jstring
|
||||||
java::lang::Class::getSignature (JArray<jclass> *param_types)
|
java::lang::Class::getSignature (JArray<jclass> *param_types,
|
||||||
|
jboolean is_constructor)
|
||||||
{
|
{
|
||||||
java::lang::StringBuffer *buf = new java::lang::StringBuffer ();
|
java::lang::StringBuffer *buf = new java::lang::StringBuffer ();
|
||||||
buf->append((jchar) '(');
|
buf->append((jchar) '(');
|
||||||
|
@ -285,6 +286,8 @@ java::lang::Class::getSignature (JArray<jclass> *param_types)
|
||||||
for (int i = 0; i < param_types->length; ++i)
|
for (int i = 0; i < param_types->length; ++i)
|
||||||
v[i]->getSignature(buf);
|
v[i]->getSignature(buf);
|
||||||
buf->append((jchar) ')');
|
buf->append((jchar) ')');
|
||||||
|
if (is_constructor)
|
||||||
|
buf->append((jchar) 'V');
|
||||||
return buf->toString();
|
return buf->toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,7 +295,7 @@ 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);
|
jstring partial_sig = getSignature (param_types, false);
|
||||||
jint p_len = partial_sig->length();
|
jint p_len = partial_sig->length();
|
||||||
_Jv_Utf8Const *utf_name = _Jv_makeUtf8Const (name);
|
_Jv_Utf8Const *utf_name = _Jv_makeUtf8Const (name);
|
||||||
int i = isPrimitive () ? 0 : method_count;
|
int i = isPrimitive () ? 0 : method_count;
|
||||||
|
@ -446,7 +449,7 @@ java::lang::Class::getInterfaces (void)
|
||||||
java::lang::reflect::Method *
|
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);
|
jstring partial_sig = getSignature (param_types, false);
|
||||||
jint p_len = partial_sig->length();
|
jint p_len = partial_sig->length();
|
||||||
_Jv_Utf8Const *utf_name = _Jv_makeUtf8Const (name);
|
_Jv_Utf8Const *utf_name = _Jv_makeUtf8Const (name);
|
||||||
for (Class *klass = this; klass; klass = klass->getSuperclass())
|
for (Class *klass = this; klass; klass = klass->getSuperclass())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue