aboutsummaryrefslogtreecommitdiff
path: root/libjava/java
diff options
context:
space:
mode:
authorRobert Schuster <robertschuster@fsfe.org>2006-02-01 13:40:05 +0000
committerRobert Schuster <rschuster@gcc.gnu.org>2006-02-01 13:40:05 +0000
commitc1a9321f29f76325f6fcf278c60678dcf9c71cde (patch)
tree331725f44321f544a0c7d62882b65627f0e43522 /libjava/java
parent168b93e9e32b3b6e95b7e3f149889298a051a935 (diff)
downloadgcc-c1a9321f29f76325f6fcf278c60678dcf9c71cde.zip
gcc-c1a9321f29f76325f6fcf278c60678dcf9c71cde.tar.gz
gcc-c1a9321f29f76325f6fcf278c60678dcf9c71cde.tar.bz2
2006-02-01 Robert Schuster <robertschuster@fsfe.org>
* link.cc: (_Jv_Linker::find_field_helper): Added checks. (_Jv_Linker::find_field): Use exception swallowing class resolution and added early return. (_Jv_ThrowNoClassDefFoundErrorTrampoline): New function. (_Jv_Linker::link_symbol_table): Use exception swallowing class resolution, added ffi_closure installation routine, use _Jv_ThrowNoClassDefFoundError for missing static method. (_Jv_Linker::ensure_class_linked): Added string check which does not trigger class resolution. * java/lang/natClassLoader.cc: (_Jv_FindClassNoException): New method. * java/lang/Class.h: (_Jv_FindClassNoException): New method declaration. * include/jvm.h: (_Jv_FindClassNoException): New method declaration. (_Jv_FindClassFromSignatureNoException): New method declaration. * prims.cc: (_Jv_FindClassFromSignatureNoException): New method. * gcj/javaprims.h: (_Jv_equalsUtf8Classname): New method declaration. (_Jv_isPrimitiveOrDerived): Dito. * prims.cc: (_Jv_equalsUtf8Classnames): New method. (_Jv_isPrimitiveOrDerived): New method. * verify.cc: (ref_intersection::equals): Use new classname comparison method. (type::compatible): Use new classname comparison method. Added check whether LHS' type is java.lang.Object . (type::resolve): Added new optional debug message and simplified if-expression. (type::to_array): Added codepath that generates an array type without resolving the element type. From-SVN: r110474
Diffstat (limited to 'libjava/java')
-rw-r--r--libjava/java/lang/Class.h16
-rw-r--r--libjava/java/lang/natClass.cc5
-rw-r--r--libjava/java/lang/natClassLoader.cc24
3 files changed, 42 insertions, 3 deletions
diff --git a/libjava/java/lang/Class.h b/libjava/java/lang/Class.h
index fe31fa2..2ddc8e1 100644
--- a/libjava/java/lang/Class.h
+++ b/libjava/java/lang/Class.h
@@ -69,7 +69,13 @@ enum
JV_STATE_ERROR = 12,
- JV_STATE_DONE = 14 // Must be last.
+ JV_STATE_PHANTOM = 13, // Bytecode is missing. In many cases we can
+ // work around that. If not, throw a
+ // NoClassDefFoundError.
+
+ JV_STATE_DONE = 14, // Must be last.
+
+
};
struct _Jv_Field;
@@ -240,6 +246,8 @@ void _Jv_RegisterClassHookDefault (jclass klass);
void _Jv_RegisterInitiatingLoader (jclass,java::lang::ClassLoader*);
void _Jv_UnregisterInitiatingLoader (jclass,java::lang::ClassLoader*);
void _Jv_UnregisterClass (jclass);
+jclass _Jv_FindClassNoException (_Jv_Utf8Const *name,
+ java::lang::ClassLoader *loader);
jclass _Jv_FindClass (_Jv_Utf8Const *name,
java::lang::ClassLoader *loader);
jclass _Jv_FindClassInCache (_Jv_Utf8Const *name);
@@ -263,6 +271,8 @@ jclass _Jv_GetArrayClass (jclass klass, java::lang::ClassLoader *loader);
jboolean _Jv_IsInterpretedClass (jclass);
jboolean _Jv_IsBinaryCompatibilityABI (jclass);
+jboolean _Jv_IsPhantomClass (jclass);
+
void _Jv_CopyClassesToSystemLoader (gnu::gcj::runtime::SystemClassLoader *);
#ifdef INTERPRETER
@@ -469,6 +479,8 @@ private:
friend void ::_Jv_RegisterInitiatingLoader (jclass,java::lang::ClassLoader*);
friend void ::_Jv_UnregisterInitiatingLoader (jclass,java::lang::ClassLoader*);
friend void ::_Jv_UnregisterClass (jclass);
+ friend jclass (::_Jv_FindClassNoException) (_Jv_Utf8Const *name,
+ java::lang::ClassLoader *loader);
friend jclass (::_Jv_FindClass) (_Jv_Utf8Const *name,
java::lang::ClassLoader *loader);
friend jclass (::_Jv_FindClassInCache) (_Jv_Utf8Const *name);
@@ -499,6 +511,8 @@ private:
friend jboolean (::_Jv_IsInterpretedClass) (jclass);
friend jboolean (::_Jv_IsBinaryCompatibilityABI) (jclass);
+ friend jboolean (::_Jv_IsPhantomClass) (jclass);
+
#ifdef INTERPRETER
friend void ::_Jv_InitField (jobject, jclass, int);
diff --git a/libjava/java/lang/natClass.cc b/libjava/java/lang/natClass.cc
index 951bab9..04a5bc4 100644
--- a/libjava/java/lang/natClass.cc
+++ b/libjava/java/lang/natClass.cc
@@ -668,8 +668,9 @@ java::lang::Class::finalize (void)
void
java::lang::Class::initializeClass (void)
{
- // Short-circuit to avoid needless locking.
- if (state == JV_STATE_DONE)
+ // Short-circuit to avoid needless locking (expression includes
+ // JV_STATE_PHANTOM and JV_STATE_DONE).
+ if (state >= JV_STATE_PHANTOM)
return;
// Step 1. We introduce a new scope so we can synchronize more
diff --git a/libjava/java/lang/natClassLoader.cc b/libjava/java/lang/natClassLoader.cc
index 797005b..5f4d957 100644
--- a/libjava/java/lang/natClassLoader.cc
+++ b/libjava/java/lang/natClassLoader.cc
@@ -266,6 +266,30 @@ _Jv_CopyClassesToSystemLoader (gnu::gcj::runtime::SystemClassLoader *loader)
system_class_list = SYSTEM_LOADER_INITIALIZED;
}
+// An internal variant of _Jv_FindClass which simply swallows a
+// NoClassDefFoundError or a ClassNotFoundException. This gives the
+// caller a chance to evaluate the situation and behave accordingly.
+jclass
+_Jv_FindClassNoException (_Jv_Utf8Const *name, java::lang::ClassLoader *loader)
+{
+ jclass klass;
+
+ try
+ {
+ klass = _Jv_FindClass(name, loader);
+ }
+ catch ( java::lang::NoClassDefFoundError *ncdfe )
+ {
+ return NULL;
+ }
+ catch ( java::lang::ClassNotFoundException *cnfe )
+ {
+ return NULL;
+ }
+
+ return klass;
+}
+
jclass
_Jv_FindClass (_Jv_Utf8Const *name, java::lang::ClassLoader *loader)
{