* [ecj] Add implementations of a few beans
@ 2006-08-26 18:10 Andrew John Hughes
0 siblings, 0 replies; only message in thread
From: Andrew John Hughes @ 2006-08-26 18:10 UTC (permalink / raw)
To: java-patches
[-- Attachment #1.1: Type: text/plain, Size: 1154 bytes --]
The attached patch implements a few of the beans at the native
level in GCJ.
Changelog:
2006-08-26 Andrew John Hughes <gnu_andrew@member.fsf.org>
* link.cc:
Increment loaded classes when printing verbose output.
* gnu/java/lang/management/natVMMemoryMXBeanImpl.cc:
Added comments.
* gnu/java/lang/management/natVMMemoryPoolMXBeanImpl.cc:
(getMemoryManagerNames(jstring)): Implemented.
(isValid(jstring)): Implemented.
* gnu/java/lang/management/natVMClassLoadingMXBeanImpl.cc:
(getLoadedClassCount()): Implemented.
(getUnloadedClassCount()): Likewise.
(isVerbose()): Likewise.
(setVerbose(jboolean)): Likewise.
* java/lang/management/natVMManagementFactory.cc:
(getMemoryPoolNames()): Implemented.
(getMemoryManagerNames()): Likewise.
(getGarbageCollectorNames()): Likewise.
* include/jvm.h:
Add loaded and unloaded class counts.
* defineclasses.c:
Increment loaded classes count.
* prims.cc:
Add loaded and unloaded class counts.
--
Andrew :-)
Escape the Java Trap with GNU Classpath!
http://www.gnu.org/philosophy/java-trap.html
public class gcj extends Freedom implements Java { ... }
[-- Attachment #1.2: classloading.diff --]
[-- Type: text/plain, Size: 10196 bytes --]
Index: libjava/link.cc
===================================================================
--- libjava/link.cc (revision 116257)
+++ libjava/link.cc (working copy)
@@ -1932,11 +1932,14 @@ _Jv_Linker::wait_for_state (jclass klass
// Print some debugging info if requested. Interpreted classes are
// handled in defineclass, so we only need to handle the two
// pre-compiled cases here.
- if (gcj::verbose_class_flag
- && (klass->state == JV_STATE_COMPILED
+ if ((klass->state == JV_STATE_COMPILED
|| klass->state == JV_STATE_PRELOADING)
&& ! _Jv_IsInterpretedClass (klass))
- print_class_loaded (klass);
+ {
+ if (gcj::verbose_class_flag)
+ print_class_loaded (klass);
+ ++gcj::loadedClasses;
+ }
try
{
Index: libjava/gnu/java/lang/management/natVMMemoryMXBeanImpl.cc
===================================================================
--- libjava/gnu/java/lang/management/natVMMemoryMXBeanImpl.cc (revision 116257)
+++ libjava/gnu/java/lang/management/natVMMemoryMXBeanImpl.cc (working copy)
@@ -1,7 +1,22 @@
+/* Copyright (C) 2006 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+/**
+ * @author Andrew John Hughes <gnu_andrew@member.fsf.org>
+ * @date Tue 08 Aug 2006 */
+/*
+ * Status: Stubbed.
+ */
+
#include <config.h>
-#include <gnu/java/lang/management/VMMemoryMXBeanImpl.h>
#include <gcj/cni.h>
+#include <gnu/java/lang/management/VMMemoryMXBeanImpl.h>
#include <java/lang/UnsupportedOperationException.h>
::java::lang::management::MemoryUsage *
Index: libjava/gnu/java/lang/management/natVMMemoryPoolMXBeanImpl.cc
===================================================================
--- libjava/gnu/java/lang/management/natVMMemoryPoolMXBeanImpl.cc (revision 116257)
+++ libjava/gnu/java/lang/management/natVMMemoryPoolMXBeanImpl.cc (working copy)
@@ -1,11 +1,26 @@
+/* Copyright (C) 2006 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+/**
+ * @author Andrew John Hughes <gnu_andrew@member.fsf.org>
+ * @date Tue 08 Aug 2006 */
+/* Implemented for our sole pool, the heap (we ignore the name input).
+ * Status: Stubbed.
+ */
+
#include <config.h>
-#include <gnu/java/lang/management/VMMemoryPoolMXBeanImpl.h>
#include <gcj/cni.h>
+#include <gnu/java/lang/management/VMMemoryPoolMXBeanImpl.h>
#include <java/lang/UnsupportedOperationException.h>
::java::lang::management::MemoryUsage *
-gnu::java::lang::management::VMMemoryPoolMXBeanImpl::getCollectionUsage (::java::lang::String *)
+gnu::java::lang::management::VMMemoryPoolMXBeanImpl::getCollectionUsage(jstring n)
{
throw new ::java::lang::UnsupportedOperationException (JvNewStringLatin1 ("gnu::java::lang::management::VMMemoryPoolMXBeanImpl::getCollectionUsage (::java::lang::String *) not implemented"));
}
@@ -26,9 +41,10 @@ gnu::java::lang::management::VMMemoryPoo
JArray< ::java::lang::String *> *
-gnu::java::lang::management::VMMemoryPoolMXBeanImpl::getMemoryManagerNames (::java::lang::String *)
+gnu::java::lang::management::VMMemoryPoolMXBeanImpl::getMemoryManagerNames(jstring n)
{
- throw new ::java::lang::UnsupportedOperationException (JvNewStringLatin1 ("gnu::java::lang::management::VMMemoryPoolMXBeanImpl::getMemoryManagerNames (::java::lang::String *) not implemented"));
+ return (JArray<jstring>*)
+ JvNewObjectArray(1, &::java::lang::String::class$, JvNewStringLatin1("BoehmGC"));
}
@@ -70,7 +86,7 @@ gnu::java::lang::management::VMMemoryPoo
jboolean
gnu::java::lang::management::VMMemoryPoolMXBeanImpl::isValid (::java::lang::String *)
{
- throw new ::java::lang::UnsupportedOperationException (JvNewStringLatin1 ("gnu::java::lang::management::VMMemoryPoolMXBeanImpl::isValid (::java::lang::String *) not implemented"));
+ return true;
}
Index: libjava/gnu/java/lang/management/natVMClassLoadingMXBeanImpl.cc
===================================================================
--- libjava/gnu/java/lang/management/natVMClassLoadingMXBeanImpl.cc (revision 116257)
+++ libjava/gnu/java/lang/management/natVMClassLoadingMXBeanImpl.cc (working copy)
@@ -1,32 +1,49 @@
+/* Copyright (C) 2006 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+/**
+ * @author Andrew John Hughes <gnu_andrew@member.fsf.org>
+ * @date Sun 20 Aug 2006 */
+/* Written using online API docs for JDK 1.5 beta from http://java.sun.com.
+ * Status: Believed complete and correct.
+ */
+
#include <config.h>
+#include <jvm.h>
+
#include <gnu/java/lang/management/VMClassLoadingMXBeanImpl.h>
-#include <gcj/cni.h>
-#include <java/lang/UnsupportedOperationException.h>
jint
gnu::java::lang::management::VMClassLoadingMXBeanImpl::getLoadedClassCount ()
{
- throw new ::java::lang::UnsupportedOperationException (JvNewStringLatin1 ("gnu::java::lang::management::VMClassLoadingMXBeanImpl::getLoadedClassCount () not implemented"));
+ /* FIXME: We never unload, so this never goes down again */
+ return ::gcj::loadedClasses;
}
jlong
gnu::java::lang::management::VMClassLoadingMXBeanImpl::getUnloadedClassCount ()
{
- throw new ::java::lang::UnsupportedOperationException (JvNewStringLatin1 ("gnu::java::lang::management::VMClassLoadingMXBeanImpl::getUnloadedClassCount () not implemented"));
+ /* FIXME: We never unload, so this always == 0 */
+ return ::gcj::unloadedClasses;
}
jboolean
gnu::java::lang::management::VMClassLoadingMXBeanImpl::isVerbose ()
{
- throw new ::java::lang::UnsupportedOperationException (JvNewStringLatin1 ("gnu::java::lang::management::VMClassLoadingMXBeanImpl::isVerbose () not implemented"));
+ return ::gcj::verbose_class_flag;
}
void
-gnu::java::lang::management::VMClassLoadingMXBeanImpl::setVerbose (jboolean)
+gnu::java::lang::management::VMClassLoadingMXBeanImpl::setVerbose (jboolean b)
{
- throw new ::java::lang::UnsupportedOperationException (JvNewStringLatin1 ("gnu::java::lang::management::VMClassLoadingMXBeanImpl::setVerbose (jboolean) not implemented"));
+ ::gcj::verbose_class_flag = b;
}
Index: libjava/java/lang/management/natVMManagementFactory.cc
===================================================================
--- libjava/java/lang/management/natVMManagementFactory.cc (revision 116257)
+++ libjava/java/lang/management/natVMManagementFactory.cc (working copy)
@@ -1,25 +1,44 @@
+/* Copyright (C) 2006 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+/**
+ * @author Andrew John Hughes <gnu_andrew@member.fsf.org>
+ * @date Tue 08 Aug 2006 */
+/* Implemented for our sole pool, the heap, and our sole memory
+ * manager/garbage collector, Boehm GC.
+ * Status: Believed complete and correct.
+ */
+
#include <config.h>
-#include <java/lang/management/VMManagementFactory.h>
#include <gcj/cni.h>
-#include <java/lang/UnsupportedOperationException.h>
+#include <java/lang/String.h>
+#include <java/lang/management/VMManagementFactory.h>
JArray< ::java::lang::String *> *
java::lang::management::VMManagementFactory::getMemoryPoolNames ()
{
- throw new ::java::lang::UnsupportedOperationException (JvNewStringLatin1 ("java::lang::management::VMManagementFactory::getMemoryPoolNames () not implemented"));
+ return (JArray<jstring>*)
+ JvNewObjectArray(1, &java::lang::String::class$, JvNewStringLatin1("Heap"));
}
JArray< ::java::lang::String *> *
java::lang::management::VMManagementFactory::getMemoryManagerNames ()
{
- throw new ::java::lang::UnsupportedOperationException (JvNewStringLatin1 ("java::lang::management::VMManagementFactory::getMemoryManagerNames () not implemented"));
+ return (JArray<jstring>*)
+ JvNewObjectArray(0, &java::lang::String::class$, NULL);
}
JArray< ::java::lang::String *> *
java::lang::management::VMManagementFactory::getGarbageCollectorNames ()
{
- throw new ::java::lang::UnsupportedOperationException (JvNewStringLatin1 ("java::lang::management::VMManagementFactory::getGarbageCollectorNames () not implemented"));
+ return (JArray<jstring>*)
+ JvNewObjectArray(1, &java::lang::String::class$, JvNewStringLatin1("BoehmGC"));
}
Index: libjava/include/jvm.h
===================================================================
--- libjava/include/jvm.h (revision 116257)
+++ libjava/include/jvm.h (working copy)
@@ -242,6 +242,11 @@ namespace gcj
/* The VM arguments */
extern JArray<jstring>* vmArgs;
+ // Currently loaded classes
+ extern jint loadedClasses;
+
+ // Unloaded classes
+ extern jlong unloadedClasses;
}
// This class handles all aspects of class preparation and linking.
Index: libjava/defineclass.cc
===================================================================
--- libjava/defineclass.cc (revision 116257)
+++ libjava/defineclass.cc (working copy)
@@ -417,6 +417,7 @@ _Jv_ClassReader::parse ()
def->state = JV_STATE_READ;
if (gcj::verbose_class_flag)
_Jv_Linker::print_class_loaded (def);
+ ++gcj::loadedClasses;
def->notifyAll ();
}
Index: libjava/prims.cc
===================================================================
--- libjava/prims.cc (revision 116257)
+++ libjava/prims.cc (working copy)
@@ -1121,6 +1121,12 @@ namespace gcj
// Arguments passed to the VM
JArray<jstring>* vmArgs;
+
+ // Currently loaded classes
+ jint loadedClasses = 0;
+
+ // Unloaded classes
+ jlong unloadedClasses = 0;
}
// We accept all non-standard options accepted by Sun's java command,
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2006-08-26 18:10 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-26 18:10 [ecj] Add implementations of a few beans Andrew John Hughes
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).