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:
@@ -199,7 +199,7 @@ public class VMVirtualMachine
|
||||
* @return an array of virtual machine methods
|
||||
*/
|
||||
public static native VMMethod[] getAllClassMethods (Class klass)
|
||||
{ return null; }
|
||||
throws JdwpException;
|
||||
|
||||
/**
|
||||
* A factory method for getting valid virtual machine methods
|
||||
@@ -213,7 +213,7 @@ public class VMVirtualMachine
|
||||
* @throws JdwpException for any other error
|
||||
*/
|
||||
public static native VMMethod getClassMethod(Class klass, long id)
|
||||
{ return null; }
|
||||
throws JdwpException;
|
||||
|
||||
/**
|
||||
* Returns the thread's call stack
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
/* VMClassLoadingMXBeanImpl.java - VM impl. 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;
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
final class VMClassLoadingMXBeanImpl
|
||||
{
|
||||
|
||||
/**
|
||||
* Returns the number of classes currently loaded by
|
||||
* the virtual machine.
|
||||
*
|
||||
* @return the number of loaded classes.
|
||||
*/
|
||||
static native int getLoadedClassCount();
|
||||
|
||||
/**
|
||||
* Returns the number of classes that have been unloaded
|
||||
* by the virtual machine since it was started.
|
||||
*
|
||||
* @return the number of unloaded classes.
|
||||
*/
|
||||
static native long getUnloadedClassCount();
|
||||
|
||||
/**
|
||||
* Returns true if the virtual machine will emit additional
|
||||
* information when classes are loaded and unloaded. The
|
||||
* format of the output is left up to the virtual machine.
|
||||
*
|
||||
* @return true if verbose class loading output is on.
|
||||
*/
|
||||
static native boolean isVerbose();
|
||||
|
||||
/**
|
||||
* Turns on or off the emission of additional information
|
||||
* when classes are loaded and unloaded. The format of the
|
||||
* output is left up to the virtual machine. This method
|
||||
* may be called by multiple threads concurrently, but there
|
||||
* is only one global setting of verbosity that is affected.
|
||||
*
|
||||
* @param verbose the new setting for verbose class loading
|
||||
* output.
|
||||
*/
|
||||
static native void setVerbose(boolean verbose);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/* VMCompilationMXBeanImpl.java - VM 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;
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
final class VMCompilationMXBeanImpl
|
||||
{
|
||||
|
||||
/**
|
||||
* Returns the number of milliseconds the JIT
|
||||
* compiler has spent compiling Java bytecode
|
||||
* to native machine code. This is only called
|
||||
* if a JIT compiler exists and the
|
||||
* gnu.java.lang.management.CompilationTimeSupport
|
||||
* property has been set.
|
||||
*
|
||||
* @return the number of milliseconds spent
|
||||
* compiling.
|
||||
*/
|
||||
static native long getTotalCompilationTime();
|
||||
|
||||
}
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
/* VMGarbageCollectorMXBeanImpl.java - VM interface for 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;
|
||||
|
||||
/**
|
||||
* Provides access to information about the garbage collectors
|
||||
* of the virtual machine. Garbage collectors are responsible
|
||||
* for removing unreferenced objects from memory. A garbage
|
||||
* collector is a type of memory manager, so this interface
|
||||
* is combined with that of generic memory managers. 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
|
||||
*/
|
||||
final class VMGarbageCollectorMXBeanImpl
|
||||
{
|
||||
|
||||
/**
|
||||
* Returns the number of collections the garbage collector
|
||||
* represented by this bean has made. -1 is returned if the
|
||||
* collection count is undefined.
|
||||
*
|
||||
* @param name the name of the garbage collector.
|
||||
* @return the number of collections made, or -1 if this is
|
||||
* undefined.
|
||||
*/
|
||||
static native long getCollectionCount(String name);
|
||||
|
||||
/**
|
||||
* Returns the accumulated number of milliseconds this garbage
|
||||
* collector has spent freeing the memory used by unreferenced
|
||||
* objects. -1 is returned if the collection time is undefined.
|
||||
* Note that the accumulated time may not change, even when the
|
||||
* collection count increases, if the time taken is sufficiently
|
||||
* short; this depends on the resolution of the timer used.
|
||||
*
|
||||
* @param name the name of the garbage collector.
|
||||
* @return the accumulated number of milliseconds spent collecting,
|
||||
* or -1 if this is undefined.
|
||||
*/
|
||||
static native long getCollectionTime(String name);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
/* VMMemoryMXBeanImpl.java - VM impl. 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.MemoryUsage;
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
final class VMMemoryMXBeanImpl
|
||||
{
|
||||
|
||||
/**
|
||||
* Returns an instance of {@link java.lang.management.MemoryUsage}
|
||||
* with appropriate initial, used, committed and maximum values
|
||||
* for the heap. By default, this uses the methods of
|
||||
* {@link java.lang.Runtime} to provide some of the values.
|
||||
*
|
||||
* @return an {@link java.lang.management.MemoryUsage} instance
|
||||
* for the heap.
|
||||
*/
|
||||
static MemoryUsage getHeapMemoryUsage()
|
||||
{
|
||||
Runtime runtime = Runtime.getRuntime();
|
||||
long totalMem = runtime.totalMemory();
|
||||
return new MemoryUsage(-1, totalMem - runtime.freeMemory(),
|
||||
totalMem, runtime.maxMemory());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an instance of {@link java.lang.management.MemoryUsage}
|
||||
* with appropriate initial, used, committed and maximum values
|
||||
* for non-heap memory.
|
||||
*
|
||||
* @return an {@link java.lang.management.MemoryUsage} instance
|
||||
* for non-heap memory.
|
||||
*/
|
||||
static native MemoryUsage getNonHeapMemoryUsage();
|
||||
|
||||
/**
|
||||
* Returns the number of objects ready to be garbage collected.
|
||||
*
|
||||
* @return the number of finalizable objects.
|
||||
*/
|
||||
static native int getObjectPendingFinalizationCount();
|
||||
|
||||
/**
|
||||
* Returns true if the virtual machine will emit additional
|
||||
* information when memory is allocated and deallocated. The
|
||||
* format of the output is left up to the virtual machine.
|
||||
*
|
||||
* @return true if verbose class loading output is on.
|
||||
*/
|
||||
static native boolean isVerbose();
|
||||
|
||||
/**
|
||||
* Turns on or off the emission of additional information
|
||||
* when memory is allocated and deallocated. The format of the
|
||||
* output is left up to the virtual machine. This method
|
||||
* may be called by multiple threads concurrently, but there
|
||||
* is only one global setting of verbosity that is affected.
|
||||
*
|
||||
* @param verbose the new setting for verbose class loading
|
||||
* output.
|
||||
*/
|
||||
static native void setVerbose(boolean verbose);
|
||||
|
||||
}
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
/* VMMemoryManagerMXBeanImpl.java - VM interface for 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.ManagementFactory;
|
||||
import java.lang.management.MemoryPoolMXBean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Provides access to information about the memory managers
|
||||
* of the virtual machine. An instance of this bean for each
|
||||
* memory manager is obtained by calling
|
||||
* {@link ManagementFactory#getMemoryManagerMXBeans()}.
|
||||
*
|
||||
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
|
||||
* @since 1.5
|
||||
*/
|
||||
final class VMMemoryManagerMXBeanImpl
|
||||
{
|
||||
|
||||
/**
|
||||
* Returns an array containing the names of the memory pools
|
||||
* this memory manager manages.
|
||||
*
|
||||
* @param name the name of the memory manager.
|
||||
* @return an array containing the name of each memory pool
|
||||
* this manager is responsible for.
|
||||
*/
|
||||
static String[] getMemoryPoolNames(String name)
|
||||
{
|
||||
List managedPools = new ArrayList();
|
||||
Iterator beans = ManagementFactory.getMemoryPoolMXBeans().iterator();
|
||||
while (beans.hasNext())
|
||||
{
|
||||
MemoryPoolMXBean bean = (MemoryPoolMXBean) beans.next();
|
||||
String[] managers = bean.getMemoryManagerNames();
|
||||
for (int a = 0; a < managers.length; ++a)
|
||||
if (managers[a].equals(name))
|
||||
{
|
||||
managedPools.add(bean.getName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
return (String[]) managedPools.toArray(new String[managedPools.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this memory manager is still valid. A memory
|
||||
* manager becomes invalid when it is removed by the virtual machine
|
||||
* and no longer used.
|
||||
*
|
||||
* @param name the name of the memory manager.
|
||||
* @return true if this memory manager is valid.
|
||||
*/
|
||||
static native boolean isValid(String name);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
/* MemoryPoolMXBeanImpl.java - VM interface for memory pool beans
|
||||
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.MemoryUsage;
|
||||
|
||||
/**
|
||||
* Provides access to information on the memory resources or
|
||||
* pools used by the current invocation of the virtual machine.
|
||||
*
|
||||
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
|
||||
* @since 1.5
|
||||
*/
|
||||
final class VMMemoryPoolMXBeanImpl
|
||||
{
|
||||
|
||||
/**
|
||||
* Returns memory usage statistics for the specified pool
|
||||
* just after a best-effort attempt to free memory. This
|
||||
* is valid only for certain garbage collectors.
|
||||
*
|
||||
* @param name the name of the pool to obtain statistics on.
|
||||
* @return a {@link java.lang.management.MemoryUsage} object
|
||||
* containing the statistics or <code>null</code>
|
||||
* if this pool does not support such statistics.
|
||||
*/
|
||||
static native MemoryUsage getCollectionUsage(String name);
|
||||
|
||||
/**
|
||||
* Returns the collection usage threshold for the specified pool.
|
||||
* This is only called if this functionality is supported
|
||||
* by the virtual machine (i.e. the appropriate property,
|
||||
* <code>gnu.java.lang.management.CollectionUsageThresholdSupport</code>,
|
||||
* is defined). The value is initially zero.
|
||||
*
|
||||
* @param name the name of the pool to obtain statistics on.
|
||||
* @return the collection usage threshold.
|
||||
*/
|
||||
static native long getCollectionUsageThreshold(String name);
|
||||
|
||||
/**
|
||||
* Returns the number of times the collection usage threshold
|
||||
* has been met or exceeded by the specified pool.
|
||||
* This is only called if this functionality is supported
|
||||
* by the virtual machine (i.e. the appropriate property,
|
||||
* <code>gnu.java.lang.management.CollectionUsageThresholdSupport</code>,
|
||||
* is defined).
|
||||
*
|
||||
* @param name the name of the pool to obtain statistics on.
|
||||
* @return the collection usage threshold count.
|
||||
*/
|
||||
static native long getCollectionUsageThresholdCount(String name);
|
||||
|
||||
/**
|
||||
* Returns an array of names of memory managers which manage
|
||||
* the specified pool.
|
||||
*
|
||||
* @param name the name of the pool to obtain statistics on.
|
||||
* @return a list of memory managers for the pool.
|
||||
*/
|
||||
static native String[] getMemoryManagerNames(String name);
|
||||
|
||||
/**
|
||||
* Returns the peak usage level of the specified pool.
|
||||
* This is only called if the pool is valid.
|
||||
*
|
||||
* @param name the name of the pool to obtain statistics on.
|
||||
* @return a {@link java.lang.management.MemoryUsage} object
|
||||
* containing the statistics.
|
||||
*/
|
||||
static native MemoryUsage getPeakUsage(String name);
|
||||
|
||||
/**
|
||||
* Returns the type of memory used by the specified pool.
|
||||
* The value must be either "HEAP" or "NON_HEAP".
|
||||
*
|
||||
* @param name the name of the pool to obtain statistics on.
|
||||
* @return the type of the given pool.
|
||||
*/
|
||||
static native String getType(String name);
|
||||
|
||||
/**
|
||||
* Returns the current usage level of the specified pool.
|
||||
* This is only called if the pool is valid.
|
||||
*
|
||||
* @param name the name of the pool to obtain statistics on.
|
||||
* @return a {@link java.lang.management.MemoryUsage} object
|
||||
* containing the statistics.
|
||||
*/
|
||||
static native MemoryUsage getUsage(String name);
|
||||
|
||||
/**
|
||||
* Returns the usage threshold for the specified pool.
|
||||
* This is only called if this functionality is supported
|
||||
* by the virtual machine (i.e. the appropriate property,
|
||||
* <code>gnu.java.lang.management.UsageThresholdSupport</code>,
|
||||
* is defined). The value is initially defined by the
|
||||
* virtual machine.
|
||||
*
|
||||
* @param name the name of the pool to obtain statistics on.
|
||||
* @return the usage threshold.
|
||||
*/
|
||||
static native long getUsageThreshold(String name);
|
||||
|
||||
/**
|
||||
* Returns the number of times the usage threshold
|
||||
* has been met or exceeded by the specified pool.
|
||||
* This is only called if this functionality is supported
|
||||
* by the virtual machine (i.e. the appropriate property,
|
||||
* <code>gnu.java.lang.management.UsageThresholdSupport</code>,
|
||||
* is defined).
|
||||
*
|
||||
* @param name the name of the pool to obtain statistics on.
|
||||
* @return the usage threshold count.
|
||||
*/
|
||||
static native long getUsageThresholdCount(String name);
|
||||
|
||||
/**
|
||||
* Returns true if the specified pool is still valid i.e.
|
||||
* it is still in use by the virtual machine.
|
||||
*
|
||||
* @param name the name of the pool to check the validity of.
|
||||
* @return true if the pool is valid.
|
||||
*/
|
||||
static native boolean isValid(String name);
|
||||
|
||||
/**
|
||||
* Resets the peak usage level to the current usage level for
|
||||
* the specified pool.
|
||||
*
|
||||
* @param name the name of the pool to reset the peak usage of.
|
||||
*/
|
||||
static native void resetPeakUsage(String name);
|
||||
|
||||
/**
|
||||
* Sets the collection usage threshold for the specified
|
||||
* pool to the supplied value.
|
||||
* This is only called if this functionality is supported
|
||||
* by the virtual machine (i.e. the appropriate property,
|
||||
* <code>gnu.java.lang.management.CollectionUsageThresholdSupport</code>,
|
||||
* is defined).
|
||||
*
|
||||
* @param name the name of the pool to set the threshold of.
|
||||
* @param threshold the new threshold level.
|
||||
*/
|
||||
static native void setCollectionUsageThreshold(String name, long threshold);
|
||||
|
||||
/**
|
||||
* Sets the usage threshold for the specified pool to the supplied value.
|
||||
* This is only called if this functionality is supported
|
||||
* by the virtual machine (i.e. the appropriate property,
|
||||
* <code>gnu.java.lang.management.UsageThresholdSupport</code>,
|
||||
* is defined).
|
||||
*
|
||||
* @param name the name of the pool to set the threshold of.
|
||||
* @param threshold the new threshold level.
|
||||
*/
|
||||
static native void setUsageThreshold(String name, long threshold);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
/* VMRuntimeMXBeanImpl.java - VM 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;
|
||||
|
||||
/**
|
||||
* Provides access to information about the virtual machine.
|
||||
*
|
||||
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
|
||||
* @since 1.5
|
||||
*/
|
||||
final class VMRuntimeMXBeanImpl
|
||||
{
|
||||
|
||||
/**
|
||||
* Returns the command-line arguments supplied
|
||||
* to the virtual machine, excluding those supplied
|
||||
* to <code>main()</code>.
|
||||
*
|
||||
* @return the command-line arguments.
|
||||
*/
|
||||
static native String[] getInputArguments();
|
||||
|
||||
/**
|
||||
* Returns a developer-chosen name for the virtual
|
||||
* machine, which may differ over different running
|
||||
* instances of the same virtual machine binary.
|
||||
* For example, this may include the particular
|
||||
* process identifier used by this instance or
|
||||
* the host name of the machine on which it is
|
||||
* running. The intention is that this name refers
|
||||
* to the precise entity that the other data supplied
|
||||
* by the bean refers to, rather than the VM in general.
|
||||
*
|
||||
* @return the custom name of the VM.
|
||||
*/
|
||||
static String getName()
|
||||
{
|
||||
return SystemProperties.getProperty("java.vm.name") + " " +
|
||||
SystemProperties.getProperty("java.vm.version");
|
||||
}
|
||||
|
||||
/**
|
||||
* The time in milliseconds at which the virtual
|
||||
* machine was started. This method is only executed
|
||||
* once (for efficency), as the value is not expected
|
||||
* to change.
|
||||
*
|
||||
* @return the VM start time.
|
||||
*/
|
||||
static native long getStartTime();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,207 @@
|
||||
/* VMThreadMXBeanImpl.java - VM impl. 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 java.lang.management.ThreadInfo;
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
final class VMThreadMXBeanImpl
|
||||
{
|
||||
|
||||
/**
|
||||
* Cache of how many threads were found.
|
||||
*/
|
||||
private static int filled;
|
||||
|
||||
/**
|
||||
* Returns the ids of cycles of deadlocked threads, occurring
|
||||
* due to monitor ownership.
|
||||
*
|
||||
* @return the ids of the deadlocked threads.
|
||||
*/
|
||||
static native long[] findMonitorDeadlockedThreads();
|
||||
|
||||
/* This is the same as in Thread.getAllStackTraces() */
|
||||
static Thread[] getAllThreads()
|
||||
{
|
||||
ThreadGroup group = Thread.currentThread().getThreadGroup();
|
||||
while (group.getParent() != null)
|
||||
group = group.getParent();
|
||||
int arraySize = group.activeCount();
|
||||
Thread[] threadList = new Thread[arraySize];
|
||||
filled = group.enumerate(threadList);
|
||||
while (filled == arraySize)
|
||||
{
|
||||
arraySize *= 2;
|
||||
threadList = new Thread[arraySize];
|
||||
filled = group.enumerate(threadList);
|
||||
}
|
||||
return threadList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the id of all live threads at the time of execution.
|
||||
*
|
||||
* @return the live thread ids.
|
||||
*/
|
||||
static long[] getAllThreadIds()
|
||||
{
|
||||
Thread[] threadList = getAllThreads();
|
||||
long[] ids = new long[filled];
|
||||
for (int a = 0; a < filled; ++a)
|
||||
ids[a] = threadList[a].getId();
|
||||
return ids;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of nanoseconds of CPU time
|
||||
* the current thread has used in total. This is
|
||||
* only called if this feature is enabled and
|
||||
* supported.
|
||||
*
|
||||
* @return the nanoseconds of CPU time used by
|
||||
* the current thread.
|
||||
*/
|
||||
static native long getCurrentThreadCpuTime();
|
||||
|
||||
/**
|
||||
* Returns the number of nanoseconds of user time
|
||||
* the current thread has used in total. This is
|
||||
* only called if this feature is enabled and
|
||||
* supported.
|
||||
*
|
||||
* @return the nanoseconds of user time used by
|
||||
* the current thread.
|
||||
*/
|
||||
static native long getCurrentThreadUserTime();
|
||||
|
||||
/**
|
||||
* Returns the number of live daemon threads.
|
||||
*
|
||||
* @return the number of live daemon threads.
|
||||
*/
|
||||
static int getDaemonThreadCount()
|
||||
{
|
||||
Thread[] threadList = getAllThreads();
|
||||
int daemonCount = 0;
|
||||
for (int a = 0; a < filled; ++a)
|
||||
{
|
||||
if (threadList[a].isDaemon())
|
||||
++daemonCount;
|
||||
}
|
||||
return daemonCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current peak number of live threads.
|
||||
*
|
||||
* @return the peak number of live threads.
|
||||
*/
|
||||
static native int getPeakThreadCount();
|
||||
|
||||
/**
|
||||
* Returns the number of live threads.
|
||||
*
|
||||
* @return the number of live threads.
|
||||
*/
|
||||
static int getThreadCount()
|
||||
{
|
||||
getAllThreads();
|
||||
return filled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of nanoseconds of CPU time
|
||||
* the specified thread has used in total. This is
|
||||
* only called if this feature is enabled and
|
||||
* supported.
|
||||
*
|
||||
* @param id the thread to obtain statistics on.
|
||||
* @return the nanoseconds of CPU time used by
|
||||
* the thread.
|
||||
*/
|
||||
static native long getThreadCpuTime(long id);
|
||||
|
||||
/**
|
||||
* Returns the {@link java.lang.management.ThreadInfo}
|
||||
* which corresponds to the specified id.
|
||||
*
|
||||
* @param id the id of the thread.
|
||||
* @param maxDepth the depth of the stack trace.
|
||||
* @return the corresponding <code>ThreadInfo</code>.
|
||||
*/
|
||||
static native ThreadInfo getThreadInfoForId(long id, int maxDepth);
|
||||
|
||||
/**
|
||||
* Returns the number of nanoseconds of user time
|
||||
* the specified thread has used in total. This is
|
||||
* only called if this feature is enabled and
|
||||
* supported.
|
||||
*
|
||||
* @param id the thread to obtain statistics on.
|
||||
* @return the nanoseconds of user time used by
|
||||
* the thread.
|
||||
*/
|
||||
static native long getThreadUserTime(long id);
|
||||
|
||||
/**
|
||||
* Returns the total number of threads that have
|
||||
* been started over the lifetime of the virtual
|
||||
* machine.
|
||||
*
|
||||
* @return the total number of threads started.
|
||||
*/
|
||||
static native long getTotalStartedThreadCount();
|
||||
|
||||
/**
|
||||
* Resets the peak thread count to the current
|
||||
* number of live threads.
|
||||
*/
|
||||
static native void resetPeakThreadCount();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
/* VMChannel.java -- Native interface suppling channel operations.
|
||||
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. */
|
||||
|
||||
|
||||
package gnu.java.nio;
|
||||
|
||||
import gnu.classpath.Configuration;
|
||||
import gnu.java.net.PlainSocketImpl;
|
||||
import gnu.java.nio.PipeImpl.SinkChannelImpl;
|
||||
import gnu.java.nio.PipeImpl.SourceChannelImpl;
|
||||
import gnu.java.nio.channels.FileChannelImpl;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/**
|
||||
* Native interface to support configuring of channel to run in a non-blocking
|
||||
* manner and support scatter/gather io operations.
|
||||
*
|
||||
* @author Michael Barker <mike@middlesoft.co.uk>
|
||||
*
|
||||
*/
|
||||
public class VMChannel
|
||||
{
|
||||
private final int fd;
|
||||
|
||||
private VMChannel(int fd)
|
||||
{
|
||||
this.fd = fd;
|
||||
}
|
||||
|
||||
public static VMChannel getVMChannel(PlainSocketImpl socket)
|
||||
{
|
||||
return new VMChannel(socket.getNativeFD());
|
||||
}
|
||||
|
||||
public static VMChannel getVMChannel(SourceChannelImpl source)
|
||||
{
|
||||
return new VMChannel(source.getNativeFD());
|
||||
}
|
||||
|
||||
public static VMChannel getVMChannel(SinkChannelImpl sink)
|
||||
{
|
||||
return new VMChannel(sink.getNativeFD());
|
||||
}
|
||||
|
||||
public static VMChannel getVMChannel(FileChannelImpl file)
|
||||
{
|
||||
return new VMChannel(file.getNativeFD());
|
||||
}
|
||||
|
||||
static
|
||||
{
|
||||
// load the shared library needed for native methods.
|
||||
if (Configuration.INIT_LOAD_LIBRARY)
|
||||
{
|
||||
System.loadLibrary ("javanio");
|
||||
}
|
||||
initIDs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the file descriptor to have the required blocking
|
||||
* setting.
|
||||
*
|
||||
* @param fd
|
||||
* @param blocking
|
||||
*/
|
||||
public native void setBlocking(int fd, boolean blocking);
|
||||
|
||||
public void setBlocking(boolean blocking)
|
||||
{
|
||||
setBlocking(fd, blocking);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reads a byte buffer directly using the supplied file descriptor.
|
||||
* Assumes that the buffer is a DirectBuffer.
|
||||
*
|
||||
* @param fd Native file descriptor to read from.
|
||||
* @param dst Direct Byte Buffer to read to.
|
||||
* @return Number of bytes read.
|
||||
* @throws IOException If an error occurs or dst is not a direct buffers.
|
||||
*/
|
||||
native int read(int fd, ByteBuffer dst)
|
||||
throws IOException;
|
||||
|
||||
public int read(ByteBuffer dst)
|
||||
throws IOException
|
||||
{
|
||||
return read(fd, dst);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads into byte buffers directly using the supplied file descriptor.
|
||||
* Assumes that the buffer list contains DirectBuffers. Will perform a
|
||||
* scattering read.
|
||||
*
|
||||
* @param fd Native file descriptor to read from.
|
||||
* @param dsts An array direct byte buffers.
|
||||
* @param offset Index of the first buffer to read to.
|
||||
* @param length The number of buffers to read to.
|
||||
* @return Number of bytes read.
|
||||
* @throws IOException If an error occurs or the dsts are not direct buffers.
|
||||
*/
|
||||
native long readScattering(int fd, ByteBuffer[] dsts, int offset, int length)
|
||||
throws IOException;
|
||||
|
||||
public long readScattering(ByteBuffer[] dsts, int offset, int length)
|
||||
throws IOException
|
||||
{
|
||||
if (offset + length > dsts.length)
|
||||
throw new IndexOutOfBoundsException("offset + length > dsts.length");
|
||||
|
||||
return readScattering(fd, dsts, offset, length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes from a direct byte bufer using the supplied file descriptor.
|
||||
* Assumes the buffer is a DirectBuffer.
|
||||
*
|
||||
* @param fd
|
||||
* @param src
|
||||
* @return Number of bytes written.
|
||||
* @throws IOException
|
||||
*/
|
||||
native int write(int fd, ByteBuffer src)
|
||||
throws IOException;
|
||||
|
||||
public int write(ByteBuffer src)
|
||||
throws IOException
|
||||
{
|
||||
return write(fd, src);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes from byte buffers directly using the supplied file descriptor.
|
||||
* Assumes the that buffer list constains DirectBuffers. Will perform
|
||||
* as gathering write.
|
||||
*
|
||||
* @param fd
|
||||
* @param srcs
|
||||
* @param offset
|
||||
* @param length
|
||||
* @return Number of bytes written.
|
||||
* @throws IOException
|
||||
*/
|
||||
native long writeGathering(int fd, ByteBuffer[] srcs, int offset, int length)
|
||||
throws IOException;
|
||||
|
||||
public long writeGathering(ByteBuffer[] srcs, int offset, int length)
|
||||
throws IOException
|
||||
{
|
||||
if (offset + length > srcs.length)
|
||||
throw new IndexOutOfBoundsException("offset + length > srcs.length");
|
||||
|
||||
return writeGathering(fd, srcs, offset, length);
|
||||
}
|
||||
|
||||
private native static void initIDs();
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/* VMFile.java -- Class for methods natively accessing files
|
||||
Copyright (C) 2004 Free Software Foundation, Inc.
|
||||
Copyright (C) 2004, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
@@ -210,10 +210,10 @@ final class VMFile
|
||||
|
||||
/**
|
||||
* This method returns a canonical representation of the pathname of
|
||||
* the given path. The actual form of the canonical representation is
|
||||
* different. On the GNU system, the canonical form differs from the
|
||||
* absolute form in that all relative file references to "." and ".."
|
||||
* are resolved and removed.
|
||||
* this file. The actual form of the canonical representation is
|
||||
* system-dependent. On the GNU system, conversion to canonical
|
||||
* form involves the removal of redundant separators, references to
|
||||
* "." and "..", and symbolic links.
|
||||
* <p>
|
||||
* Note that this method, unlike the other methods which return path
|
||||
* names, can throw an IOException. This is because native method
|
||||
@@ -221,9 +221,5 @@ final class VMFile
|
||||
*
|
||||
* @exception IOException If an error occurs
|
||||
*/
|
||||
public static String toCanonicalForm(String path) throws IOException
|
||||
{
|
||||
// FIXME: this only works on UNIX
|
||||
return PlatformHelper.toCanonicalForm(path);
|
||||
}
|
||||
public static native String toCanonicalForm(String path) throws IOException;
|
||||
}
|
||||
|
||||
@@ -75,6 +75,10 @@ final class VMClassLoader
|
||||
/** packages loaded by the bootstrap class loader */
|
||||
static final HashMap definedPackages = new HashMap();
|
||||
|
||||
/** jars from property java.boot.class.path */
|
||||
static final HashMap bootjars = new HashMap();
|
||||
|
||||
|
||||
/**
|
||||
* Converts the array string of native package names to
|
||||
* Packages. The packages are then put into the
|
||||
@@ -168,10 +172,6 @@ final class VMClassLoader
|
||||
return (URL)e.nextElement();
|
||||
return null;
|
||||
}
|
||||
|
||||
/** jars from property java.boot.class.path */
|
||||
static final HashMap bootjars = new HashMap();
|
||||
|
||||
/**
|
||||
* Helper to get a list of resources from the bootstrap class loader.
|
||||
*
|
||||
|
||||
@@ -135,7 +135,10 @@ final class VMSystem
|
||||
* @return the current time
|
||||
* @see java.util.Date
|
||||
*/
|
||||
public static native long currentTimeMillis();
|
||||
public static long currentTimeMillis()
|
||||
{
|
||||
return nanoTime() / 1000000L;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -162,10 +165,7 @@ final class VMSystem
|
||||
* @return the time of a system timer in nanoseconds.
|
||||
* @since 1.5
|
||||
*/
|
||||
public static long nanoTime()
|
||||
{
|
||||
return currentTimeMillis() * 1000;
|
||||
}
|
||||
public static native long nanoTime();
|
||||
|
||||
/**
|
||||
* Returns a list of 'name=value' pairs representing the current environment
|
||||
|
||||
@@ -446,4 +446,16 @@ final class VMThread
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current state of the thread.
|
||||
* The value must be one of "BLOCKED", "NEW",
|
||||
* "RUNNABLE", "TERMINATED", "TIMED_WAITING" or
|
||||
* "WAITING".
|
||||
*
|
||||
* @return a string corresponding to one of the
|
||||
* thread enumeration states specified above.
|
||||
*/
|
||||
native String getState();
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
/* VMManagementFactory.java - VM interface for obtaining system beans.
|
||||
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 java.lang.management;
|
||||
|
||||
/**
|
||||
* Provides lists of resources required by the
|
||||
* {@link java.lang.management.ManagementFactory} for
|
||||
* creating beans.
|
||||
*
|
||||
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
|
||||
* @since 1.5
|
||||
*/
|
||||
final class VMManagementFactory
|
||||
{
|
||||
|
||||
/**
|
||||
* Return a list of the names of the currently available
|
||||
* memory pools within the virtual machine.
|
||||
*
|
||||
* @return a list of memory pool names.
|
||||
*/
|
||||
static native String[] getMemoryPoolNames();
|
||||
|
||||
/**
|
||||
* Return a list of the names of the currently available
|
||||
* memory managers within the virtual machine. This should
|
||||
* not include the garbage collectors listed below.
|
||||
*
|
||||
* @return a list of memory manager names.
|
||||
*/
|
||||
static native String[] getMemoryManagerNames();
|
||||
|
||||
/**
|
||||
* Return a list of the names of the currently available
|
||||
* garbage collectors within the virtual machine.
|
||||
*
|
||||
* @return a list of garbage collector names.
|
||||
*/
|
||||
static native String[] getGarbageCollectorNames();
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/* VMURLConnection - VM code for URLConnection
|
||||
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. */
|
||||
|
||||
|
||||
package java.net;
|
||||
|
||||
import gnu.classpath.Configuration;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
final class VMURLConnection
|
||||
{
|
||||
public static final int LENGTH = 1024;
|
||||
|
||||
static
|
||||
{
|
||||
if (Configuration.INIT_LOAD_LIBRARY)
|
||||
System.loadLibrary("javanet");
|
||||
init();
|
||||
}
|
||||
|
||||
private static native void init();
|
||||
|
||||
private static native String guessContentTypeFromBuffer(byte[] b, int valid);
|
||||
|
||||
/**
|
||||
* This is called from URLConnection to guess the mime type of a
|
||||
* stream. This method may return null to indicate that it could
|
||||
* not guess a type.
|
||||
*/
|
||||
static String guessContentTypeFromStream(InputStream is)
|
||||
throws IOException
|
||||
{
|
||||
if (! is.markSupported())
|
||||
return null;
|
||||
is.mark(LENGTH);
|
||||
byte[] bytes = new byte[LENGTH];
|
||||
int r = is.read(bytes);
|
||||
if (r < 0)
|
||||
return null;
|
||||
is.reset();
|
||||
return guessContentTypeFromBuffer(bytes, r);
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -35,7 +35,7 @@ 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.classpath;
|
||||
package sun.misc;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
@@ -48,7 +48,7 @@ import java.lang.reflect.Field;
|
||||
* @author Tom Tromey (tromey@redhat.com)
|
||||
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
|
||||
*/
|
||||
public final class Unsafe
|
||||
public class Unsafe
|
||||
{
|
||||
// Singleton class.
|
||||
private static Unsafe unsafe = new Unsafe();
|
||||
@@ -279,7 +279,7 @@ public final class Unsafe
|
||||
* @param arrayClass the class for which the first element's address should
|
||||
* be obtained.
|
||||
* @return the offset of the first element of the array class.
|
||||
* @see #arrayIndexScale(Class)
|
||||
* @see arrayIndexScale(Class)
|
||||
*/
|
||||
public native int arrayBaseOffset(Class arrayClass);
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/* Reflection.java - JSR 166 reflection hooks
|
||||
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 sun.reflect;
|
||||
|
||||
import gnu.classpath.VMStackWalker;
|
||||
|
||||
public class Reflection
|
||||
{
|
||||
/**
|
||||
* A stack-walking wrapper method used by the JSR 166 RI.
|
||||
*/
|
||||
public static Class getCallerClass(int depth)
|
||||
{
|
||||
return VMStackWalker.getClassContext()[depth];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
/* ReflectUtil.java - JSR 166 reflection hooks
|
||||
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 sun.reflect.misc;
|
||||
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
public class ReflectUtil
|
||||
{
|
||||
// We use this inaccessible inner class as an argument type
|
||||
// in verifyMemberAccess. All current users of this method
|
||||
// in the JSR 166 RI pass 'null' for this argument, and
|
||||
// consequently we don't know what it means. Using a funny
|
||||
// type like this for the argument means that if the RI changes,
|
||||
// we will see a compilation error.
|
||||
private static class MustBeNull
|
||||
{
|
||||
}
|
||||
|
||||
public static void checkPackageAccess(Class declaringClass)
|
||||
{
|
||||
// FIXME: not sure what to check here.
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform access checks on a member of a class. This API is
|
||||
* derived from the public domain code in the JSR 166 reference
|
||||
* implementation.
|
||||
* @param caller the class requesting access to the member
|
||||
* @param declarer the declaring class of the member
|
||||
* @param ignored unknown parameter; always null
|
||||
* @param modifiers the modifiers on the member
|
||||
*/
|
||||
public static void ensureMemberAccess(Class caller,
|
||||
Class declarer,
|
||||
MustBeNull ignored,
|
||||
int modifiers)
|
||||
{
|
||||
// Same class, always ok.
|
||||
if (caller == declarer)
|
||||
return;
|
||||
// Public access is ok.
|
||||
if ((modifiers & Modifier.PUBLIC) != 0)
|
||||
return;
|
||||
// Protected access and request comes from
|
||||
// a subclass of the declarer -- ok.
|
||||
if ((modifiers & Modifier.PROTECTED) != 0
|
||||
&& declarer.isAssignableFrom(caller))
|
||||
return;
|
||||
// Package-private access, or protected access,
|
||||
// and the packages are the same --ok.
|
||||
if ((modifiers & Modifier.PRIVATE) == 0
|
||||
&& caller.getPackage() == declarer.getPackage())
|
||||
return;
|
||||
// Otherwise, no.
|
||||
throw new IllegalAccessError();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user