From 83d9978859a871cd0b3bd1d06ba01942afc88d5d Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Fri, 21 Dec 2001 19:47:50 +0000 Subject: re PR libgcj/2428 (Classloader is not set) Fix for PR libgcj/2428: * java/lang/natClass.cc: Include RuntimePermission.h. (getClassLoader): Define. * java/lang/Class.h (Class.getClassLoader): Only declare. From-SVN: r48253 --- libjava/ChangeLog | 7 +++++++ libjava/java/lang/Class.h | 5 +---- libjava/java/lang/natClass.cc | 28 ++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 4 deletions(-) (limited to 'libjava') diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 3513b27..a9ce352 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,10 @@ +2001-12-21 Tom Tromey + + Fix for PR libgcj/2428: + * java/lang/natClass.cc: Include RuntimePermission.h. + (getClassLoader): Define. + * java/lang/Class.h (Class.getClassLoader): Only declare. + 2001-12-19 Tom Tromey * java/awt/FlowLayout.java (FlowLayout(), FlowLayout(int)): Set diff --git a/libjava/java/lang/Class.h b/libjava/java/lang/Class.h index 73d81da..0f36f25 100644 --- a/libjava/java/lang/Class.h +++ b/libjava/java/lang/Class.h @@ -134,10 +134,7 @@ public: static jclass forName (jstring className); JArray *getClasses (void); - java::lang::ClassLoader *getClassLoader (void) - { - return loader; - } + java::lang::ClassLoader *getClassLoader (void); java::lang::reflect::Constructor *getConstructor (JArray *); JArray *getConstructors (void); diff --git a/libjava/java/lang/natClass.cc b/libjava/java/lang/natClass.cc index 6dfe14b..0e34f32 100644 --- a/libjava/java/lang/natClass.cc +++ b/libjava/java/lang/natClass.cc @@ -43,6 +43,7 @@ details. */ #include #include #include +#include #include #include #include @@ -102,6 +103,29 @@ java::lang::Class::forName (jstring className) return forName (className, true, NULL); } +java::lang::ClassLoader * +java::lang::Class::getClassLoader (void) +{ +#if 0 + // FIXME: the checks we need to do are more complex. See the spec. + // Currently we can't implement them. + java::lang::SecurityManager *s = java::lang::System::getSecurityManager(); + if (s != NULL) + s->checkPermission (new RuntimePermission (JvNewStringLatin1 ("getClassLoader"))); +#endif + + // The spec requires us to return `null' for primitive classes. In + // other cases we have the option of returning `null' for classes + // loaded with the bootstrap loader. All gcj-compiled classes which + // are linked into the application used to return `null' here, but + // that confuses some poorly-written applications. It is a useful + // and apparently harmless compatibility hack to simply never return + // `null' instead. + if (isPrimitive ()) + return NULL; + return loader ? loader : ClassLoader::getSystemClassLoader (); +} + java::lang::reflect::Constructor * java::lang::Class::getConstructor (JArray *param_types) { @@ -373,6 +397,8 @@ java::lang::Class::getName (void) JArray * java::lang::Class::getClasses (void) { + // FIXME: security checking. + // Until we have inner classes, it always makes sense to return an // empty array. JArray *result @@ -440,6 +466,8 @@ java::lang::Class::_getFields (JArray *result, JArray * java::lang::Class::getFields (void) { + // FIXME: security checking. + using namespace java::lang::reflect; int count = _getFields (NULL, 0); -- cgit v1.1