This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
Index: java/lang/natClassLoader.cc
===================================================================
--- java/lang/natClassLoader.cc (revision 124192)
+++ java/lang/natClassLoader.cc (working copy)
@@ -380,6 +392,19 @@
void
_Jv_CopyClassesToSystemLoader (gnu::gcj::runtime::SystemClassLoader *loader)
{
+ using namespace ::java::lang;
+
+ // Add any classes loaded before this point to the loaded classes list for
+ // JVMTI. As this is done, the memory used by the list is freed.
+ for (struct _Jv_TempClassListElement *ptr = jvmti_class_list_head;
+ ptr;
+ ptr = ptr->next)
+ {
+ VMClassLoader::loaded_classes->add (new ref::WeakReference (ptr->klass));
+ _Jv_Free (jvmti_class_list_head);
+ jvmti_class_list_head = ptr;
+ }
+
for (jclass klass = system_class_list;
klass;
klass = klass->next_or_version)
@@ -655,6 +680,33 @@
_Jv_PushClass (jclass k)
{
JvSynchronize sync (&java::lang::Class::class$);
+ + using namespace ::java::lang;
+
+ // Build a list of loaded classes for JVMTI.
+ if (system_class_list == SYSTEM_LOADER_INITIALIZED)
+ VMClassLoader::loaded_classes->add (new ref::WeakReference (k));
+ else
+ {
+ if (!jvmti_class_list_head)
+ {
+ jvmti_class_list_head + = reinterpret_cast<struct _Jv_TempClassListElement *> + (_Jv_MallocUnchecked (sizeof (struct _Jv_TempClassListElement)));
+ jvmti_class_list_head->next = NULL;
+ }
+ else
+ {
+ struct _Jv_TempClassListElement *tmp + = reinterpret_cast<struct _Jv_TempClassListElement *> + (_Jv_MallocUnchecked (sizeof (struct _Jv_TempClassListElement)));
+ tmp->next = jvmti_class_list_head;
+ jvmti_class_list_head = tmp;
+ }
+
+ jvmti_class_list_head->klass = k;
+ }
+ jclass tmp = stack_head;
stack_head = k;
k->chain = tmp;
Index: java/lang/VMClassLoader.h =================================================================== --- java/lang/VMClassLoader.h (revision 124192) +++ java/lang/VMClassLoader.h (working copy)
Index: java/lang/VMClassLoader.java
===================================================================
--- java/lang/VMClassLoader.java (revision 124192)
+++ java/lang/VMClassLoader.java (working copy)
@@ -345,4 +350,24 @@
return default_sys;
}
+
+ /**
+ * First check if any of the classes in the list have been collected, and if
+ * they have, remove them from the list. It then returns the modified list.
+ *
+ * @return The <code>HashSet</code> of loaded classes.
+ */
+ public static HashSet getAllLoadedClasses()
+ {
+ Iterator it = loaded_classes.iterator();
+
+ while (it.hasNext())
+ {
+ WeakReference ref = (WeakReference) it.next();
+ if (ref.get() == null)
+ it.remove();
+ }
+
+ return loaded_classes;
+ }
}
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |