summaryrefslogtreecommitdiff
path: root/libjava/java
diff options
context:
space:
mode:
authoraph <aph@138bc75d-0d04-0410-961f-82ee72b054a4>2007-02-16 13:51:04 +0000
committeraph <aph@138bc75d-0d04-0410-961f-82ee72b054a4>2007-02-16 13:51:04 +0000
commitbe2aabc47f21ac8b023b257f0aa73bbc4b7bdc06 (patch)
tree959c3c9976841825636b5dad2623a5818c7188d3 /libjava/java
parentd1d2495d53f8f05317f62241f1064f7d076f8f74 (diff)
downloadgcc-be2aabc47f21ac8b023b257f0aa73bbc4b7bdc06.tar.gz
2007-02-15 Andrew Haley <aph@redhat.com>
* Makefile.am (nat_source_files): Remove java/lang/management/natVMManagementFactory.cc. * java/lang/Thread.java (getStackTrace): Use reflection to call the ManagementFactory. * java/lang/management/VMManagementFactory.java: Remove native methods. * java/lang/management/natVMManagementFactory.cc: Deleted. * sources.am: Regnerate. * scripts/makemake.tcl: Add new "bcheaders" type. Move java/lang/management and gnu/classpath/management to "bc". Move gnu/java/lang/management to "bcheaders". 2007-02-16 Andrew Haley <aph@redhat.com> * gnu/java/lang/management/MemoryMXBeanImpl.java, javax/management/MBeanServerDelegate.java: Use gnu.javax.management.ListenerData rather than gnu.classpath.ListenerData. * gnu/javax/management/ListenerData.java: Move here from gnu/classpath/ListenerData.java. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@122041 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/java')
-rw-r--r--libjava/java/lang/Thread.java45
-rw-r--r--libjava/java/lang/management/VMManagementFactory.java20
-rw-r--r--libjava/java/lang/management/natVMManagementFactory.cc44
3 files changed, 57 insertions, 52 deletions
diff --git a/libjava/java/lang/Thread.java b/libjava/java/lang/Thread.java
index 7216512530d..84682f3fb83 100644
--- a/libjava/java/lang/Thread.java
+++ b/libjava/java/lang/Thread.java
@@ -50,6 +50,9 @@ import java.lang.management.ThreadMXBean;
import java.util.HashMap;
import java.util.Map;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
* "The Java Language Specification", ISBN 0-201-63451-1
* plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
@@ -1291,9 +1294,43 @@ public class Thread implements Runnable
SecurityManager sm = SecurityManager.current; // Be thread-safe.
if (sm != null)
sm.checkPermission(new RuntimePermission("getStackTrace"));
- ThreadMXBean bean = ManagementFactory.getThreadMXBean();
- ThreadInfo info = bean.getThreadInfo(getId(), Integer.MAX_VALUE);
- return info.getStackTrace();
- }
+ // Calling java.lang.management via reflection means that
+ // javax.management be overridden in the endorsed directory.
+
+ // This is the equivalent code:
+ //
+ // ThreadMXBean bean = ManagementFactory.getThreadMXBean();
+ // ThreadInfo info = bean.getThreadInfo(getId(), Integer.MAX_VALUE);
+ // return info.getStackTrace();
+
+ try
+ {
+ try
+ {
+ Object bean
+ = (Class.forName("java.lang.management.ManagementFactory")
+ .getDeclaredMethod("getThreadMXBean")
+ .invoke(null));
+ Object info = bean.getClass()
+ .getDeclaredMethod("getThreadInfo", long.class, int.class)
+ .invoke(bean, new Long(getId()), new Integer(Integer.MAX_VALUE));
+ Object trace = info.getClass()
+ .getDeclaredMethod("getStackTrace").invoke(info);
+ return (StackTraceElement[])trace;
+ }
+ catch (InvocationTargetException e)
+ {
+ throw (Exception)e.getTargetException();
+ }
+ }
+ catch (UnsupportedOperationException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ throw new UnsupportedOperationException(e);
+ }
+ }
}
diff --git a/libjava/java/lang/management/VMManagementFactory.java b/libjava/java/lang/management/VMManagementFactory.java
index f10497014b4..35b15e360f1 100644
--- a/libjava/java/lang/management/VMManagementFactory.java
+++ b/libjava/java/lang/management/VMManagementFactory.java
@@ -1,5 +1,5 @@
/* VMManagementFactory.java - VM interface for obtaining system beans.
- Copyright (C) 2006 Free Software Foundation
+ Copyright (C) 2006, 2007 Free Software Foundation
This file is part of GNU Classpath.
@@ -54,7 +54,11 @@ final class VMManagementFactory
*
* @return a list of memory pool names.
*/
- static native String[] getMemoryPoolNames();
+ static String[] getMemoryPoolNames()
+ {
+ String[] result = {"Heap"};
+ return result;
+ }
/**
* Return a list of the names of the currently available
@@ -63,7 +67,11 @@ final class VMManagementFactory
*
* @return a list of memory manager names.
*/
- static native String[] getMemoryManagerNames();
+ static String[] getMemoryManagerNames()
+ {
+ String[] result = {};
+ return result;
+ }
/**
* Return a list of the names of the currently available
@@ -71,5 +79,9 @@ final class VMManagementFactory
*
* @return a list of garbage collector names.
*/
- static native String[] getGarbageCollectorNames();
+ static String[] getGarbageCollectorNames()
+ {
+ String[] result = {"BoehmGC"};
+ return result;
+ }
}
diff --git a/libjava/java/lang/management/natVMManagementFactory.cc b/libjava/java/lang/management/natVMManagementFactory.cc
deleted file mode 100644
index 35a418bb338..00000000000
--- a/libjava/java/lang/management/natVMManagementFactory.cc
+++ /dev/null
@@ -1,44 +0,0 @@
-/* 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 <gcj/cni.h>
-#include <java/lang/String.h>
-#include <java/lang/management/VMManagementFactory.h>
-
-JArray< ::java::lang::String *> *
-java::lang::management::VMManagementFactory::getMemoryPoolNames ()
-{
- return (JArray<jstring>*)
- JvNewObjectArray(1, &java::lang::String::class$, JvNewStringLatin1("Heap"));
-}
-
-
-JArray< ::java::lang::String *> *
-java::lang::management::VMManagementFactory::getMemoryManagerNames ()
-{
- return (JArray<jstring>*)
- JvNewObjectArray(0, &java::lang::String::class$, NULL);
-}
-
-
-JArray< ::java::lang::String *> *
-java::lang::management::VMManagementFactory::getGarbageCollectorNames ()
-{
- return (JArray<jstring>*)
- JvNewObjectArray(1, &java::lang::String::class$, JvNewStringLatin1("BoehmGC"));
-}