Imported GNU Classpath 0.92

2006-08-14  Mark Wielaard  <mark@klomp.org>

       Imported GNU Classpath 0.92
       * HACKING: Add more importing hints. Update automake version
       requirement.

       * configure.ac (gconf-peer): New enable AC argument.
       Add --disable-gconf-peer and --enable-default-preferences-peer
       to classpath configure when gconf is disabled.
       * scripts/makemake.tcl: Set gnu/java/util/prefs/gconf and
       gnu/java/awt/dnd/peer/gtk to bc. Classify
       gnu/java/security/Configuration.java as generated source file.

       * gnu/java/lang/management/VMGarbageCollectorMXBeanImpl.java,
       gnu/java/lang/management/VMMemoryPoolMXBeanImpl.java,
       gnu/java/lang/management/VMClassLoadingMXBeanImpl.java,
       gnu/java/lang/management/VMRuntimeMXBeanImpl.java,
       gnu/java/lang/management/VMMemoryManagerMXBeanImpl.java,
       gnu/java/lang/management/VMThreadMXBeanImpl.java,
       gnu/java/lang/management/VMMemoryMXBeanImpl.java,
       gnu/java/lang/management/VMCompilationMXBeanImpl.java: New VM stub
       classes.
       * java/lang/management/VMManagementFactory.java: Likewise.
       * java/net/VMURLConnection.java: Likewise.
       * gnu/java/nio/VMChannel.java: Likewise.

       * java/lang/Thread.java (getState): Add stub implementation.
       * java/lang/Class.java (isEnum): Likewise.
       * java/lang/Class.h (isEnum): Likewise.

       * gnu/awt/xlib/XToolkit.java (getClasspathTextLayoutPeer): Removed.

       * javax/naming/spi/NamingManager.java: New override for StackWalker
       functionality.

       * configure, sources.am, Makefile.in, gcj/Makefile.in,
       include/Makefile.in, testsuite/Makefile.in: Regenerated.

From-SVN: r116139
This commit is contained in:
Mark Wielaard 2006-08-14 23:12:35 +00:00
parent abab460491
commit ac1ed908de
1294 changed files with 99479 additions and 35933 deletions

View file

@ -0,0 +1,84 @@
/* BeanImpl.java - A common superclass for bean implementations.
Copyright (C) 2006 Free Software Foundation
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package gnu.java.lang.management;
import java.lang.management.ManagementPermission;
import javax.management.NotCompliantMBeanException;
import javax.management.StandardMBean;
/**
* A common superclass for bean implementations.
*
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
* @since 1.5
*/
public class BeanImpl
extends StandardMBean
{
/**
* Constructs a new <code>BeanImpl</code>.
*
* @param iface the bean interface being implemented.
* @throws NotCompliantMBeanException if this class doesn't implement
* the interface or a method appears
* in the interface that doesn't comply
* with the naming conventions.
*/
protected BeanImpl(Class iface)
throws NotCompliantMBeanException
{
super(iface);
}
protected void checkMonitorPermissions()
{
SecurityManager sm = System.getSecurityManager();
if (sm != null)
sm.checkPermission(new ManagementPermission("monitor"));
}
protected void checkControlPermissions()
{
SecurityManager sm = System.getSecurityManager();
if (sm != null)
sm.checkPermission(new ManagementPermission("control"));
}
}

View file

@ -0,0 +1,99 @@
/* ClassLoadingMXBeanImpl.java - Implementation of a class loading bean
Copyright (C) 2006 Free Software Foundation
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package gnu.java.lang.management;
import java.lang.management.ClassLoadingMXBean;
import javax.management.NotCompliantMBeanException;
/**
* Provides access to information about the class loading
* behaviour of the current invocation of the virtual
* machine. Instances of this bean are obtained by calling
* {@link ManagementFactory#getClassLoadingMXBean()}.
*
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
* @since 1.5
*/
public final class ClassLoadingMXBeanImpl
extends BeanImpl
implements ClassLoadingMXBean
{
/**
* Constructs a new <code>ClassLoadingMXBeanImpl</code>.
*
* @throws NotCompliantMBeanException if this class doesn't implement
* the interface or a method appears
* in the interface that doesn't comply
* with the naming conventions.
*/
public ClassLoadingMXBeanImpl()
throws NotCompliantMBeanException
{
super(ClassLoadingMXBean.class);
}
public int getLoadedClassCount()
{
return VMClassLoadingMXBeanImpl.getLoadedClassCount();
}
public long getTotalLoadedClassCount()
{
return getLoadedClassCount() + getUnloadedClassCount();
}
public long getUnloadedClassCount()
{
return VMClassLoadingMXBeanImpl.getUnloadedClassCount();
}
public boolean isVerbose()
{
return VMClassLoadingMXBeanImpl.isVerbose();
}
public void setVerbose(boolean verbose)
{
checkControlPermissions();
VMClassLoadingMXBeanImpl.setVerbose(verbose);
}
}

View file

@ -0,0 +1,105 @@
/* CompilationMXBeanImpl.java - Implementation of a compilation bean
Copyright (C) 2006 Free Software Foundation
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package gnu.java.lang.management;
import gnu.classpath.SystemProperties;
import java.lang.management.CompilationMXBean;
import javax.management.NotCompliantMBeanException;
/**
* Provides access to information about the JIT
* compiler of the virtual machine, if one exists.
* Instances of this bean are obtained by calling
* {@link ManagementFactory#getCompilationMXBean()},
* if this is the case.
*
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
* @since 1.5
*/
public final class CompilationMXBeanImpl
extends BeanImpl
implements CompilationMXBean
{
/**
* Constant for compiler name.
*/
private static final String COMPILER_NAME = "gnu.java.compiler.name";
/**
* Constant for compilation time support.
*/
private static final String COMPILATION_TIME_SUPPORT =
"gnu.java.lang.management.CompilationTimeSupport";
/**
* Constructs a new <code>CompilationMXBeanImpl</code>.
*
* @throws NotCompliantMBeanException if this class doesn't implement
* the interface or a method appears
* in the interface that doesn't comply
* with the naming conventions.
*/
public CompilationMXBeanImpl()
throws NotCompliantMBeanException
{
super(CompilationMXBean.class);
}
public String getName()
{
return SystemProperties.getProperty(COMPILER_NAME);
}
public boolean isCompilationTimeMonitoringSupported()
{
return SystemProperties.getProperty(COMPILATION_TIME_SUPPORT) != null;
}
public long getTotalCompilationTime()
{
if (isCompilationTimeMonitoringSupported())
return VMCompilationMXBeanImpl.getTotalCompilationTime();
else
throw new UnsupportedOperationException("Compilation time monitoring "
+ "is not supported");
}
}

View file

@ -0,0 +1,84 @@
/* GarbageCollectorMXBeanImpl.java - Implementation of a GC bean
Copyright (C) 2006 Free Software Foundation
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package gnu.java.lang.management;
import java.lang.management.GarbageCollectorMXBean;
import javax.management.NotCompliantMBeanException;
/**
* Provides access to information about one of the garbage
* collectors used by the current invocation of the
* virtual machine. An instance of this bean for each garbage
* collector is obtained by calling
* {@link ManagementFactory#getGarbageCollectorMXBeans()}.
*
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
* @since 1.5
*/
public final class GarbageCollectorMXBeanImpl
extends MemoryManagerMXBeanImpl
implements GarbageCollectorMXBean
{
/**
* Constructs a new <code>GarbageCollectorMXBeanImpl</code>.
*
* @param name the name of the garbage collector this bean represents.
* @throws NotCompliantMBeanException if this class doesn't implement
* the interface or a method appears
* in the interface that doesn't comply
* with the naming conventions.
*/
public GarbageCollectorMXBeanImpl(String name)
throws NotCompliantMBeanException
{
super(name, GarbageCollectorMXBean.class);
}
public long getCollectionCount()
{
return VMGarbageCollectorMXBeanImpl.getCollectionCount(name);
}
public long getCollectionTime()
{
return VMGarbageCollectorMXBeanImpl.getCollectionTime(name);
}
}

View file

@ -0,0 +1,322 @@
/* MemoryMXBeanImpl.java - Implementation of a memory bean
Copyright (C) 2006 Free Software Foundation
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package gnu.java.lang.management;
import java.lang.management.MemoryMXBean;
import java.lang.management.MemoryNotificationInfo;
import java.lang.management.MemoryUsage;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.management.ListenerNotFoundException;
import javax.management.MBeanNotificationInfo;
import javax.management.NotCompliantMBeanException;
import javax.management.Notification;
import javax.management.NotificationEmitter;
import javax.management.NotificationFilter;
import javax.management.NotificationListener;
import javax.management.openmbean.CompositeData;
import javax.management.openmbean.CompositeDataSupport;
import javax.management.openmbean.CompositeType;
import javax.management.openmbean.OpenDataException;
import javax.management.openmbean.OpenType;
import javax.management.openmbean.SimpleType;
/**
* Provides access to information about the memory
* management of the current invocation of the virtual
* machine. Instances of this bean are obtained by calling
* {@link ManagementFactory#getMemoryMXBean()}.
*
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
* @since 1.5
*/
public final class MemoryMXBeanImpl
extends BeanImpl
implements MemoryMXBean, NotificationEmitter
{
private List listeners;
private long notificationCount;
public static CompositeType notifType;
public static CompositeType usageType;
static
{
try
{
CompositeType usageType =
new CompositeType(MemoryUsage.class.getName(),
"Describes the usage levels of a pool",
new String[] { "init", "used",
"committed", "max"
},
new String[] { "Initial level",
"Used level",
"Committed level",
"Maximum level"
},
new OpenType[] {
SimpleType.LONG, SimpleType.LONG,
SimpleType.LONG, SimpleType.LONG
});
CompositeType notifType =
new CompositeType(MemoryNotificationInfo.class.getName(),
"Provides the notification info on memory usage",
new String[] { "poolName", "usage", "count" },
new String[] { "Name of the memory pool",
"Usage level of the memory pool",
"Number of times the threshold " +
"has been crossed"
},
new OpenType[] {
SimpleType.STRING, usageType, SimpleType.LONG
});
}
catch (OpenDataException e)
{
throw new IllegalStateException("Something went wrong in creating " +
"the composite data types.", e);
}
}
/**
* Constructs a new <code>MemoryMXBeanImpl</code>.
*
* @throws NotCompliantMBeanException if this class doesn't implement
* the interface or a method appears
* in the interface that doesn't comply
* with the naming conventions.
*/
public MemoryMXBeanImpl()
throws NotCompliantMBeanException
{
super(MemoryMXBean.class);
listeners = new ArrayList();
notificationCount = 0;
}
public void gc()
{
System.gc();
}
public MemoryUsage getHeapMemoryUsage()
{
return VMMemoryMXBeanImpl.getHeapMemoryUsage();
}
public MemoryUsage getNonHeapMemoryUsage()
{
return VMMemoryMXBeanImpl.getNonHeapMemoryUsage();
}
public int getObjectPendingFinalizationCount()
{
return VMMemoryMXBeanImpl.getObjectPendingFinalizationCount();
}
public boolean isVerbose()
{
return VMMemoryMXBeanImpl.isVerbose();
}
public void setVerbose(boolean verbose)
{
checkControlPermissions();
VMMemoryMXBeanImpl.setVerbose(verbose);
}
private class ListenerData
{
private NotificationListener listener;
private NotificationFilter filter;
private Object passback;
public ListenerData(NotificationListener listener,
NotificationFilter filter, Object passback)
{
this.listener = listener;
this.filter = filter;
this.passback = passback;
}
public NotificationListener getListener()
{
return listener;
}
public NotificationFilter getFilter()
{
return filter;
}
public Object getPassback()
{
return passback;
}
public boolean equals(Object obj)
{
if (obj instanceof ListenerData)
{
ListenerData data = (ListenerData) obj;
return (data.getListener() == listener &&
data.getFilter() == filter &&
data.getPassback() == passback);
}
return false;
}
}
public void addNotificationListener(NotificationListener listener,
NotificationFilter filter,
Object passback)
{
if (listener == null)
throw new IllegalArgumentException("Null listener added to bean.");
listeners.add(new ListenerData(listener, filter, passback));
}
public MBeanNotificationInfo[] getNotificationInfo()
{
return new MBeanNotificationInfo[]
{
new MBeanNotificationInfo(new String[]
{
MemoryNotificationInfo.MEMORY_COLLECTION_THRESHOLD_EXCEEDED,
MemoryNotificationInfo.MEMORY_THRESHOLD_EXCEEDED
},
Notification.class.getName(),
"Memory Usage Notifications")
};
}
public void removeNotificationListener(NotificationListener listener)
throws ListenerNotFoundException
{
Iterator it = listeners.iterator();
boolean foundOne = false;
while (it.hasNext())
{
ListenerData data = (ListenerData) it.next();
if (data.getListener() == listener)
{
it.remove();
foundOne = true;
}
}
if (!foundOne)
throw new ListenerNotFoundException("The specified listener, " + listener +
"is not registered with this bean.");
}
public void removeNotificationListener(NotificationListener listener,
NotificationFilter filter,
Object passback)
throws ListenerNotFoundException
{
if (!(listeners.remove(new ListenerData(listener, filter, passback))))
{
throw new ListenerNotFoundException("The specified listener, " + listener +
" with filter " + filter +
"and passback " + passback +
", is not registered with this bean.");
}
}
void fireNotification(String type, String poolName, long init, long used,
long committed, long max, long count)
{
Notification notif = new Notification(type, this, notificationCount);
MemoryUsage usage = new MemoryUsage(init, used, committed, max);
CompositeData data;
try
{
data = new CompositeDataSupport(notifType,
new String[] {
"poolName", "usage", "count"
},
new Object[] {
poolName, usage, Long.valueOf(count)
});
}
catch (OpenDataException e)
{
throw new IllegalStateException("Something went wrong in creating " +
"the composite data instance.", e);
}
notif.setUserData(data);
Iterator it = listeners.iterator();
while (it.hasNext())
{
ListenerData ldata = (ListenerData) it.next();
NotificationFilter filter = ldata.getFilter();
if (filter == null || filter.isNotificationEnabled(notif))
ldata.getListener().handleNotification(notif, ldata.getPassback());
}
++notificationCount;
}
void fireThresholdExceededNotification(String poolName, long init,
long used, long committed,
long max, long count)
{
fireNotification(MemoryNotificationInfo.MEMORY_THRESHOLD_EXCEEDED,
poolName, init, used, committed, max, count);
}
void fireCollectionThresholdExceededNotification(String poolName,
long init,
long used,
long committed,
long max,
long count)
{
fireNotification(MemoryNotificationInfo.MEMORY_COLLECTION_THRESHOLD_EXCEEDED,
poolName, init, used, committed, max, count);
}
}

View file

@ -0,0 +1,112 @@
/* MemoryManagerMXBeanImpl.java - Implementation of a memory manager bean
Copyright (C) 2006 Free Software Foundation
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package gnu.java.lang.management;
import java.lang.management.MemoryManagerMXBean;
import javax.management.NotCompliantMBeanException;
/**
* Provides access to information about one of the memory
* managers used by the current invocation of the
* virtual machine. An instance of this bean for each memory
* manager is obtained by calling
* {@link ManagementFactory#getMemoryPoolMXBeans()}.
*
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
* @since 1.5
*/
public class MemoryManagerMXBeanImpl
extends BeanImpl
implements MemoryManagerMXBean
{
/**
* The name of the memory manager.
*/
protected String name;
/**
* Constructs a new <code>MemoryManagerMXBeanImpl</code>.
*
* @param name the name of the manager this bean represents.
* @throws NotCompliantMBeanException if this class doesn't implement
* the interface or a method appears
* in the interface that doesn't comply
* with the naming conventions.
*/
public MemoryManagerMXBeanImpl(String name)
throws NotCompliantMBeanException
{
this(name, MemoryManagerMXBean.class);
}
/**
* Constructs a new <code>MemoryManagerMXBeanImpl</code>
* implementing the specified bean interface.
*
* @param name the name of the manager this bean represents.
* @param iface the bean interface being implemented.
* @throws NotCompliantMBeanException if this class doesn't implement
* the interface or a method appears
* in the interface that doesn't comply
* with the naming conventions.
*/
protected MemoryManagerMXBeanImpl(String name, Class iface)
throws NotCompliantMBeanException
{
super(iface);
this.name = name;
}
public String[] getMemoryPoolNames()
{
return VMMemoryManagerMXBeanImpl.getMemoryPoolNames(name);
}
public String getName()
{
return name;
}
public boolean isValid()
{
return VMMemoryManagerMXBeanImpl.isValid(name);
}
}

View file

@ -0,0 +1,225 @@
/* MemoryPoolMXBeanImpl.java - Implementation of a memory pool bean
Copyright (C) 2006 Free Software Foundation
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package gnu.java.lang.management;
import gnu.classpath.SystemProperties;
import java.lang.management.MemoryPoolMXBean;
import java.lang.management.MemoryUsage;
import javax.management.NotCompliantMBeanException;
/**
* Provides access to information about one of the memory
* resources or pools used by the current invocation of the
* virtual machine. An instance of this bean for each memory
* pool is obtained by calling
* {@link ManagementFactory#getMemoryPoolMXBeans()}.
*
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
* @since 1.5
*/
public final class MemoryPoolMXBeanImpl
extends BeanImpl
implements MemoryPoolMXBean
{
/**
* The name of the pool.
*/
private String name;
/**
* Constant for collection usage threshold.
*/
private static final String COLLECTION_USAGE_THRESHOLD =
"gnu.java.lang.management.CollectionUsageThresholdSupport";
/**
* Constant for thread time support.
*/
private static final String USAGE_THRESHOLD =
"gnu.java.lang.management.UsageThresholdSupport";
/**
* Constructs a new <code>MemoryPoolMXBeanImpl</code>.
*
* @param name the name of the pool this bean represents.
* @throws NotCompliantMBeanException if this class doesn't implement
* the interface or a method appears
* in the interface that doesn't comply
* with the naming conventions.
*/
public MemoryPoolMXBeanImpl(String name)
throws NotCompliantMBeanException
{
super(MemoryPoolMXBean.class);
this.name = name;
}
public MemoryUsage getCollectionUsage()
{
return VMMemoryPoolMXBeanImpl.getCollectionUsage(name);
}
public long getCollectionUsageThreshold()
{
if (isCollectionUsageThresholdSupported())
return VMMemoryPoolMXBeanImpl.getCollectionUsageThreshold(name);
else
throw new UnsupportedOperationException("A collection usage "+
"threshold is not supported.");
}
public long getCollectionUsageThresholdCount()
{
if (isCollectionUsageThresholdSupported())
return VMMemoryPoolMXBeanImpl.getCollectionUsageThresholdCount(name);
else
throw new UnsupportedOperationException("A collection usage "+
"threshold is not supported.");
}
public String[] getMemoryManagerNames()
{
return VMMemoryPoolMXBeanImpl.getMemoryManagerNames(name);
}
public String getName()
{
return name;
}
public MemoryUsage getPeakUsage()
{
if (isValid())
return VMMemoryPoolMXBeanImpl.getPeakUsage(name);
else
return null;
}
public String getType()
{
return VMMemoryPoolMXBeanImpl.getType(name);
}
public MemoryUsage getUsage()
{
if (isValid())
return VMMemoryPoolMXBeanImpl.getUsage(name);
else
return null;
}
public long getUsageThreshold()
{
if (isUsageThresholdSupported())
return VMMemoryPoolMXBeanImpl.getUsageThreshold(name);
else
throw new UnsupportedOperationException("A usage threshold " +
"is not supported.");
}
public long getUsageThresholdCount()
{
if (isUsageThresholdSupported())
return VMMemoryPoolMXBeanImpl.getUsageThresholdCount(name);
else
throw new UnsupportedOperationException("A usage threshold " +
"is not supported.");
}
public boolean isCollectionUsageThresholdExceeded()
{
return getCollectionUsage().getUsed() >= getCollectionUsageThreshold();
}
public boolean isCollectionUsageThresholdSupported()
{
return SystemProperties.getProperty(COLLECTION_USAGE_THRESHOLD) != null;
}
public boolean isUsageThresholdExceeded()
{
return getUsage().getUsed() >= getUsageThreshold();
}
public boolean isUsageThresholdSupported()
{
return SystemProperties.getProperty(USAGE_THRESHOLD) != null;
}
public boolean isValid()
{
return VMMemoryPoolMXBeanImpl.isValid(name);
}
public void resetPeakUsage()
{
checkControlPermissions();
VMMemoryPoolMXBeanImpl.resetPeakUsage(name);
}
public void setCollectionUsageThreshold(long threshold)
{
checkControlPermissions();
if (threshold < 0)
throw new IllegalArgumentException("Threshold of " + threshold +
"is less than zero.");
if (isCollectionUsageThresholdSupported())
VMMemoryPoolMXBeanImpl.setCollectionUsageThreshold(name, threshold);
else
throw new UnsupportedOperationException("A collection usage "+
"threshold is not supported.");
}
public void setUsageThreshold(long threshold)
{
checkControlPermissions();
if (threshold < 0)
throw new IllegalArgumentException("Threshold of " + threshold +
"is less than zero.");
if (isUsageThresholdSupported())
VMMemoryPoolMXBeanImpl.setUsageThreshold(name, threshold);
else
throw new UnsupportedOperationException("A usage threshold " +
"is not supported.");
}
}

View file

@ -0,0 +1,90 @@
/* OperatingSystemMXBeanImpl.java - Implementation of an operating system bean
Copyright (C) 2006 Free Software Foundation
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package gnu.java.lang.management;
import java.lang.management.OperatingSystemMXBean;
import javax.management.NotCompliantMBeanException;
/**
* Provides access to information about the underlying operating
* system.
*
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
* @since 1.5
*/
public final class OperatingSystemMXBeanImpl
extends BeanImpl
implements OperatingSystemMXBean
{
/**
* Constructs a new <code>OperatingSystemMXBeanImpl</code>.
*
* @throws NotCompliantMBeanException if this class doesn't implement
* the interface or a method appears
* in the interface that doesn't comply
* with the naming conventions.
*/
public OperatingSystemMXBeanImpl()
throws NotCompliantMBeanException
{
super(OperatingSystemMXBean.class);
}
public String getArch()
{
return System.getProperty("os.arch");
}
public int getAvailableProcessors()
{
return Runtime.getRuntime().availableProcessors();
}
public String getName()
{
return System.getProperty("os.name");
}
public String getVersion()
{
return System.getProperty("os.version");
}
}

View file

@ -0,0 +1,197 @@
/* RuntimeMXBeanImpl.java - Implementation of an runtime bean
Copyright (C) 2006 Free Software Foundation
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package gnu.java.lang.management;
import gnu.classpath.SystemProperties;
import java.lang.management.RuntimeMXBean;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import javax.management.NotCompliantMBeanException;
/**
* Provides access to information about the virtual machine.
*
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
* @since 1.5
*/
public final class RuntimeMXBeanImpl
extends BeanImpl
implements RuntimeMXBean
{
private static final String SUN_BOOT_CLASS_PATH = "sun.boot.class.path";
private static final String JAVA_BOOT_CLASS_PATH = "java.boot.class.path";
private long startTime = -1;
private String bootClassPath = null;
private boolean bootClassPathSupported = true;
/**
* Constructs a new <code>RuntimeMXBeanImpl</code>.
*
* @throws NotCompliantMBeanException if this class doesn't implement
* the interface or a method appears
* in the interface that doesn't comply
* with the naming conventions.
*/
public RuntimeMXBeanImpl()
throws NotCompliantMBeanException
{
super(RuntimeMXBean.class);
}
public String getBootClassPath()
{
checkMonitorPermissions();
if (isBootClassPathSupported())
return bootClassPath;
else
throw
new UnsupportedOperationException("Retrieving the boot " +
"classpath is not supported.");
}
public String getClassPath()
{
return System.getProperty("java.class.path");
}
public List getInputArguments()
{
checkMonitorPermissions();
return Arrays.asList(VMRuntimeMXBeanImpl.getInputArguments());
}
public String getLibraryPath()
{
return System.getProperty("java.library.path");
}
public String getManagementSpecVersion()
{
return "1.0";
}
public String getName()
{
return VMRuntimeMXBeanImpl.getName();
}
public String getSpecName()
{
return System.getProperty("java.vm.specification.name");
}
public String getSpecVendor()
{
return System.getProperty("java.vm.specification.vendor");
}
public String getSpecVersion()
{
return System.getProperty("java.vm.specification.version");
}
public long getStartTime()
{
if (startTime == -1)
startTime = VMRuntimeMXBeanImpl.getStartTime();
return startTime;
}
public Map getSystemProperties()
{
Map map = new HashMap();
Properties props = System.getProperties();
Iterator entries = props.entrySet().iterator();
while (entries.hasNext())
{
Map.Entry next = (Map.Entry) entries.next();
Object key = next.getKey();
Object value = next.getValue();
if (key instanceof String &&
value instanceof String)
map.put(key, value);
}
return map;
}
public long getUptime()
{
return new Date().getTime() - getStartTime();
}
public String getVmName()
{
return System.getProperty("java.vm.name");
}
public String getVmVendor()
{
return System.getProperty("java.vm.vendor");
}
public String getVmVersion()
{
return System.getProperty("java.vm.version");
}
public boolean isBootClassPathSupported()
{
if (bootClassPath == null)
{
bootClassPath = SystemProperties.getProperty(JAVA_BOOT_CLASS_PATH);
if (bootClassPath == null)
bootClassPath = SystemProperties.getProperty(SUN_BOOT_CLASS_PATH);
if (bootClassPath == null)
bootClassPathSupported = false;
}
return bootClassPathSupported;
}
}

View file

@ -0,0 +1,291 @@
/* ThreadMXBeanImpl.java - Implementation of a thread bean
Copyright (C) 2006 Free Software Foundation
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package gnu.java.lang.management;
import gnu.classpath.SystemProperties;
import java.lang.management.ThreadInfo;
import java.lang.management.ThreadMXBean;
import javax.management.NotCompliantMBeanException;
/**
* Provides access to information about the threads
* of the virtual machine. An instance of this bean is
* obtained by calling
* {@link ManagementFactory#getThreadMXBean()}.
* See {@link java.lang.management.ThreadMXBean} for
* full documentation.
*
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
* @since 1.5
*/
public final class ThreadMXBeanImpl
extends BeanImpl
implements ThreadMXBean
{
/**
* Constant for current thread time support.
*/
private static final String CURRENT_THREAD_TIME_SUPPORT =
"gnu.java.lang.management.CurrentThreadTimeSupport";
/**
* Constant for thread time support.
*/
private static final String THREAD_TIME_SUPPORT =
"gnu.java.lang.management.ThreadTimeSupport";
/**
* Constant for thread contention support.
*/
private static final String CONTENTION_SUPPORT =
"gnu.java.lang.management.ThreadContentionSupport";
/**
* Constant for initial value of thread time support.
*/
private static final String TIME_ENABLED =
"gnu.java.lang.management.ThreadTimeInitallyEnabled";
/**
* Flag to indicate whether time monitoring is enabled or not.
*/
private boolean timeEnabled;
/**
* Flag to indicate whether contention monitoring is enabled or not.
*/
private boolean contentionEnabled;
/**
* Default constructor to set up flag states. The
* VM has to specify whether time monitoring is initially
* enabled or not.
*
* @throws NotCompliantMBeanException if this class doesn't implement
* the interface or a method appears
* in the interface that doesn't comply
* with the naming conventions.
*/
public ThreadMXBeanImpl()
throws NotCompliantMBeanException
{
super(ThreadMXBean.class);
timeEnabled = Boolean.parseBoolean(SystemProperties.getProperty(TIME_ENABLED));
contentionEnabled = false;
}
public long[] findMonitorDeadlockedThreads()
{
checkMonitorPermissions();
return VMThreadMXBeanImpl.findMonitorDeadlockedThreads();
}
public long[] getAllThreadIds()
{
checkMonitorPermissions();
return VMThreadMXBeanImpl.getAllThreadIds();
}
public long getCurrentThreadCpuTime()
{
if (!isCurrentThreadCpuTimeSupported())
throw new UnsupportedOperationException("Current thread CPU " +
"time not supported.");
if (!timeEnabled)
return -1;
return VMThreadMXBeanImpl.getCurrentThreadCpuTime();
}
public long getCurrentThreadUserTime()
{
if (!isCurrentThreadCpuTimeSupported())
throw new UnsupportedOperationException("Current thread user " +
"time not supported.");
if (!timeEnabled)
return -1;
return VMThreadMXBeanImpl.getCurrentThreadUserTime();
}
public int getDaemonThreadCount()
{
return VMThreadMXBeanImpl.getDaemonThreadCount();
}
public int getPeakThreadCount()
{
return VMThreadMXBeanImpl.getPeakThreadCount();
}
public int getThreadCount()
{
return VMThreadMXBeanImpl.getThreadCount();
}
public long getThreadCpuTime(long id)
{
if (!isThreadCpuTimeSupported())
throw new UnsupportedOperationException("Thread CPU time not " +
"supported.");
if (id <= 0)
throw new IllegalArgumentException("Invalid thread id: " + id);
if (!timeEnabled)
return -1;
return VMThreadMXBeanImpl.getThreadCpuTime(id);
}
public ThreadInfo getThreadInfo(long id)
{
return getThreadInfo(id, 0);
}
public ThreadInfo[] getThreadInfo(long[] ids)
{
return getThreadInfo(ids, 0);
}
public ThreadInfo getThreadInfo(long id, int maxDepth)
{
checkMonitorPermissions();
if (id <= 0)
throw new IllegalArgumentException("Invalid thread id: " + id);
if (maxDepth < 0)
throw new IllegalArgumentException("Invalid depth: " + maxDepth);
return VMThreadMXBeanImpl.getThreadInfoForId(id, maxDepth);
}
public ThreadInfo[] getThreadInfo(long[] ids, int maxDepth)
{
checkMonitorPermissions();
if (maxDepth < 0)
throw new IllegalArgumentException("Invalid depth: " + maxDepth);
ThreadInfo[] infos = new ThreadInfo[ids.length];
for (int a = 0; a < ids.length; ++a)
{
if (ids[a] <= 0)
throw new IllegalArgumentException("Invalid thread id " + a +
": " + ids[a]);
infos[a] = VMThreadMXBeanImpl.getThreadInfoForId(ids[a], maxDepth);
}
return infos;
}
public long getThreadUserTime(long id)
{
if (!isThreadCpuTimeSupported())
throw new UnsupportedOperationException("Thread user time not " +
"supported.");
if (id <= 0)
throw new IllegalArgumentException("Invalid thread id: " + id);
if (!timeEnabled)
return -1;
return VMThreadMXBeanImpl.getThreadUserTime(id);
}
public long getTotalStartedThreadCount()
{
return VMThreadMXBeanImpl.getTotalStartedThreadCount();
}
public boolean isCurrentThreadCpuTimeSupported()
{
if (isThreadCpuTimeSupported())
return true;
return SystemProperties.getProperty(CURRENT_THREAD_TIME_SUPPORT) != null;
}
public boolean isThreadContentionMonitoringEnabled()
{
if (isThreadContentionMonitoringSupported())
return contentionEnabled;
else
throw new UnsupportedOperationException("Contention monitoring " +
"not supported.");
}
public boolean isThreadContentionMonitoringSupported()
{
return SystemProperties.getProperty(CONTENTION_SUPPORT) != null;
}
public boolean isThreadCpuTimeEnabled()
{
if (isThreadCpuTimeSupported() ||
isCurrentThreadCpuTimeSupported())
return timeEnabled;
else
throw new UnsupportedOperationException("Thread time not " +
"supported.");
}
public boolean isThreadCpuTimeSupported()
{
return SystemProperties.getProperty(THREAD_TIME_SUPPORT) != null;
}
public void resetPeakThreadCount()
{
checkControlPermissions();
VMThreadMXBeanImpl.resetPeakThreadCount();
}
public void setThreadContentionMonitoringEnabled(boolean enable)
{
checkControlPermissions();
if (isThreadContentionMonitoringSupported())
contentionEnabled = enable;
else
throw new UnsupportedOperationException("Contention monitoring " +
"not supported.");
}
public void setThreadCpuTimeEnabled(boolean enable)
{
checkControlPermissions();
if (isThreadCpuTimeSupported() ||
isCurrentThreadCpuTimeSupported())
timeEnabled = enable;
else
throw new UnsupportedOperationException("Thread time not " +
"supported.");
}
}

View file

@ -0,0 +1,46 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<!-- package.html - describes classes in gnu.java.lang.management package.
Copyright (C) 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. -->
<html>
<head><title>GNU Classpath - gnu.java.lang.management</title></head>
<body>
<p>GNU implementations of the Java system management beans.</p>
</body>
</html>