[multiple changes]
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. From-SVN: r122041
This commit is contained in:
parent
421076b552
commit
24d8ce15e2
20 changed files with 188 additions and 185 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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"));
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue