OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-dev/] [fsf-gcc-snapshot-1-mar-12/] [or1k-gcc/] [libjava/] [classpath/] [doc/] [cp-vmintegration.texinfo] - Diff between revs 767 and 783

Only display areas with differences | Details | Blame | View Log

Rev 767 Rev 783
\input texinfo @c -*-texinfo-*-
\input texinfo @c -*-texinfo-*-
 
 
@c %**start of header
@c %**start of header
@setfilename cp-vmintegration.info
@setfilename cp-vmintegration.info
@settitle GNU Classpath VM Integration Guide
@settitle GNU Classpath VM Integration Guide
@c %**end of header
@c %**end of header
 
 
@setchapternewpage off
@setchapternewpage off
 
 
@ifinfo
@ifinfo
This file contains important information you will need to know if you
This file contains important information you will need to know if you
are going to write an interface between GNU Classpath and a Virtual
are going to write an interface between GNU Classpath and a Virtual
Machine.
Machine.
 
 
Copyright (C) 1998-2002, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
Copyright (C) 1998-2002, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
 
 
@ifnotplaintext
@ifnotplaintext
@dircategory GNU Libraries
@dircategory GNU Libraries
@direntry
@direntry
* VM Integration: (cp-vmintegration).  GNU Classpath VM Integration Guide
* VM Integration: (cp-vmintegration).  GNU Classpath VM Integration Guide
@end direntry
@end direntry
@end ifnotplaintext
@end ifnotplaintext
@end ifinfo
@end ifinfo
 
 
@titlepage
@titlepage
@title GNU Classpath VM Integration Guide
@title GNU Classpath VM Integration Guide
@author John Keiser
@author John Keiser
@author C. Brian Jones
@author C. Brian Jones
@author Mark Wielaard
@author Mark Wielaard
 
 
@page
@page
@vskip 0pt plus 1filll
@vskip 0pt plus 1filll
Copyright @copyright{} 1998-2002 Free Software Foundation, Inc.
Copyright @copyright{} 1998-2002 Free Software Foundation, Inc.
@sp 2
@sp 2
Permission is granted to make and distribute verbatim copies of
Permission is granted to make and distribute verbatim copies of
this document provided the copyright notice and this permission notice
this document provided the copyright notice and this permission notice
are preserved on all copies.
are preserved on all copies.
 
 
Permission is granted to copy and distribute modified versions of this
Permission is granted to copy and distribute modified versions of this
document under the conditions for verbatim copying, provided that the
document under the conditions for verbatim copying, provided that the
entire resulting derived work is distributed under the terms of a
entire resulting derived work is distributed under the terms of a
permission notice identical to this one.
permission notice identical to this one.
 
 
Permission is granted to copy and distribute translations of this manual
Permission is granted to copy and distribute translations of this manual
into another language, under the above conditions for modified versions,
into another language, under the above conditions for modified versions,
except that this permission notice may be stated in a translation
except that this permission notice may be stated in a translation
approved by the Free Software Foundation.
approved by the Free Software Foundation.
 
 
@end titlepage
@end titlepage
 
 
@ifinfo
@ifinfo
@node Top, Introduction, (dir), (dir)
@node Top, Introduction, (dir), (dir)
@top GNU Classpath Hacker's Guide
@top GNU Classpath Hacker's Guide
 
 
This file contains important information you will need to know if you
This file contains important information you will need to know if you
are going to write an interface between GNU Classpath and a Virtual
are going to write an interface between GNU Classpath and a Virtual
Machine.
Machine.
 
 
This document is incomplete, as we are still in alpha with the interface.
This document is incomplete, as we are still in alpha with the interface.
 
 
@end ifinfo
@end ifinfo
 
 
@menu
@menu
* Introduction::                An introduction to the Classpath project
* Introduction::                An introduction to the Classpath project
* Initialization::              Initializing the classes
* Initialization::              Initializing the classes
* Classpath Hooks::             Hooks from Classpath to the VM
* Classpath Hooks::             Hooks from Classpath to the VM
* VM Hooks::                    Hooks from the underlying VM to Classpath
* VM Hooks::                    Hooks from the underlying VM to Classpath
* JNI Implementation::          Hooking the VM to jni.h
* JNI Implementation::          Hooking the VM to jni.h
* JVMTI Implementation::        Hooking the VM to jvmti.h
* JVMTI Implementation::        Hooking the VM to jvmti.h
* Miscellaneous VM Requirements::
* Miscellaneous VM Requirements::
@end menu
@end menu
 
 
@node Introduction, Initialization, Top, Top
@node Introduction, Initialization, Top, Top
@comment node-name, next, previous, up
@comment node-name, next, previous, up
@chapter Introduction
@chapter Introduction
 
 
The Classpath Project's ambition to be a 100% clean room implementation
The Classpath Project's ambition to be a 100% clean room implementation
of the standard Java class libraries cannot be fulfilled without some
of the standard Java class libraries cannot be fulfilled without some
level of integration with the Virtual Machine, the underlying machinery
level of integration with the Virtual Machine, the underlying machinery
that actually runs Java.
that actually runs Java.
 
 
There are several VMs out there, here is a small list.
There are several VMs out there, here is a small list.
 
 
@itemize @bullet
@itemize @bullet
@item @uref{http://www.hungry.com/old-hungry/products/japhar/,Japhar}
@item @uref{http://www.hungry.com/old-hungry/products/japhar/,Japhar}
Japhar was the first VM to use GNU Classpath.  Today you can see that
Japhar was the first VM to use GNU Classpath.  Today you can see that
sort of relationship in the source tree which denotes several Japhar
sort of relationship in the source tree which denotes several Japhar
specific files as a reference implementation of those pieces.  This VM
specific files as a reference implementation of those pieces.  This VM
has been primarily tested against Linux and lacks garbage collections, a
has been primarily tested against Linux and lacks garbage collections, a
JIT, and suffers recently from slow development.
JIT, and suffers recently from slow development.
 
 
@item @uref{http://www.intel.com/research/mrl/orp/,Intel's Open Runtime Platform}
@item @uref{http://www.intel.com/research/mrl/orp/,Intel's Open Runtime Platform}
Intel surprised us not long ago with the release of this rather advanced
Intel surprised us not long ago with the release of this rather advanced
VM that uses GNU Classpath for a set of class libraries and works on
VM that uses GNU Classpath for a set of class libraries and works on
Linux and Windows 2000.  As of June, 2004, it does not appear that ORP
Linux and Windows 2000.  As of June, 2004, it does not appear that ORP
is under active development.
is under active development.
 
 
@item @uref{http://www.sablevm.org/,SableVM}
@item @uref{http://www.sablevm.org/,SableVM}
SableVM is a robust, extremely portable, efficient, and
SableVM is a robust, extremely portable, efficient, and
specifications-compliant Java Virtual Machine that aims to be easy to
specifications-compliant Java Virtual Machine that aims to be easy to
maintain and to extend. It features a state-of-the-art, efficient
maintain and to extend. It features a state-of-the-art, efficient
interpreter engine. Its source code is very accessible and easy to
interpreter engine. Its source code is very accessible and easy to
understand, and has many robustness features that have been the object
understand, and has many robustness features that have been the object
of careful design.
of careful design.
 
 
@item @uref{http://www.kaffe.org,Kaffe}
@item @uref{http://www.kaffe.org,Kaffe}
Kaffe is an advanced VM and together with its own class libraries
Kaffe is an advanced VM and together with its own class libraries
provides a Java 1.1 compatible environment.
provides a Java 1.1 compatible environment.
 
 
@item @uref{http://www.mozilla.org/projects/ef,Electrical Fire}
@item @uref{http://www.mozilla.org/projects/ef,Electrical Fire}
The Electrical File VM continues to be listed as a Mozilla project
The Electrical File VM continues to be listed as a Mozilla project
though development has been somewhat quiet.  A number of concepts from
though development has been somewhat quiet.  A number of concepts from
EF were expected at one point to be rolled into Japhar, but that
EF were expected at one point to be rolled into Japhar, but that
development has not occurred as of yet.
development has not occurred as of yet.
 
 
@item @uref{http://latte.snu.ac.kr/,LaTTe}
@item @uref{http://latte.snu.ac.kr/,LaTTe}
This VM project so far supports only Sun UltraSparc processors using the
This VM project so far supports only Sun UltraSparc processors using the
proprietary Solaris 2.5.1 or higher operating system.  LaTTe was derived
proprietary Solaris 2.5.1 or higher operating system.  LaTTe was derived
from Kaffe but claims a number of improvements.
from Kaffe but claims a number of improvements.
 
 
@item @uref{http://gcc.gnu.org/java/,GNU Compiler for Java (GCJ)}
@item @uref{http://gcc.gnu.org/java/,GNU Compiler for Java (GCJ)}
This is a portable, optimizing, ahead-of-time compiler for the Java
This is a portable, optimizing, ahead-of-time compiler for the Java
Programming Language. It can compile Java source code directly to native
Programming Language. It can compile Java source code directly to native
machine code, Java source code to Java bytecode (class files), and Java
machine code, Java source code to Java bytecode (class files), and Java
bytecode to native machine code. Compiled applications are linked with the
bytecode to native machine code. Compiled applications are linked with the
GCJ runtime, libgcj which is based on the GNU Classpath code, which provides
GCJ runtime, libgcj which is based on the GNU Classpath code, which provides
the core class libraries, a garbage collector, and a bytecode interpreter.
the core class libraries, a garbage collector, and a bytecode interpreter.
libgcj can dynamically load and interpret class files, resulting in mixed
libgcj can dynamically load and interpret class files, resulting in mixed
compiled/interpreted applications.
compiled/interpreted applications.
GCJ is part of the GNU Compiler Collection (@uref{http://gcc.gnu.org/,GCC}).
GCJ is part of the GNU Compiler Collection (@uref{http://gcc.gnu.org/,GCC}).
On March 6 2000 the libgcj and GNU Classpath projects were officially merged
On March 6 2000 the libgcj and GNU Classpath projects were officially merged
and there is active work on merging all the classes between the projects.
and there is active work on merging all the classes between the projects.
Licensed under GPL+exception, just as GNU Classpath is.
Licensed under GPL+exception, just as GNU Classpath is.
 
 
@item @uref{http://kissme.sourceforge.net/,Kissme}
@item @uref{http://kissme.sourceforge.net/,Kissme}
This is a free Java Virtual Machine that is being developed on GNU/Linux
This is a free Java Virtual Machine that is being developed on GNU/Linux
and can run console Java applications.  Kissme also provides support for
and can run console Java applications.  Kissme also provides support for
orthogonally persistent Java.
orthogonally persistent Java.
@c I don't know what ``orthogonally persistent Java'' is, and I bet
@c I don't know what ``orthogonally persistent Java'' is, and I bet
@c there are other people don't know either. -- Steve Augart, 4 June 2004
@c there are other people don't know either. -- Steve Augart, 4 June 2004
 
 
@item @uref{http://jamvm.sourceforge.net/,JamVM}
@item @uref{http://jamvm.sourceforge.net/,JamVM}
A simple, small bytecode interpreter that works out-of-the-box with
A simple, small bytecode interpreter that works out-of-the-box with
pure GNU Classpath; it is emerging as the preferred platform for
pure GNU Classpath; it is emerging as the preferred platform for
quickly testing a new build of GNU Classpath.  Licensed under the GPL.
quickly testing a new build of GNU Classpath.  Licensed under the GPL.
 
 
@item @uref{http://jikesrvm.sourceforge.net/,Jikes RVM}
@item @uref{http://jikesrvm.sourceforge.net/,Jikes RVM}
A free runtime environment for Java, written in Java.  Works
A free runtime environment for Java, written in Java.  Works
out-of-the-box with pure GNU Classpath.  Features an optimizing JIT.
out-of-the-box with pure GNU Classpath.  Features an optimizing JIT.
Runs on the x86 and PowerPC architectures, on the AIX, Linux, and Mac
Runs on the x86 and PowerPC architectures, on the AIX, Linux, and Mac
OS/X operating systems.  Licensed under the CPL (Common Public
OS/X operating systems.  Licensed under the CPL (Common Public
License).  Extensively documented.  Actively developed as of June,
License).  Extensively documented.  Actively developed as of June,
2004.
2004.
 
 
@end itemize
@end itemize
 
 
In the past integration efforts were focused mainly on Japhar with an eye
In the past integration efforts were focused mainly on Japhar with an eye
towards getting Electrical Fire to work.  Most information contained in
towards getting Electrical Fire to work.  Most information contained in
this document is gleaned from these efforts. Recently more work has been
this document is gleaned from these efforts. Recently more work has been
done on getting gcj, orp and kissme to work out of the box with GNU Classpath
done on getting gcj, orp and kissme to work out of the box with GNU Classpath
but there is much to do before that becomes a reality.
but there is much to do before that becomes a reality.
 
 
 
 
@node Initialization, Classpath Hooks, Introduction, Top
@node Initialization, Classpath Hooks, Introduction, Top
@comment node-name, next, previous, up
@comment node-name, next, previous, up
@chapter Initialization
@chapter Initialization
 
 
The order of initialization, as far as I can tell, doesn't matter just
The order of initialization, as far as I can tell, doesn't matter just
yet.  However, when we move to 1.2 support, it probably will matter, so
yet.  However, when we move to 1.2 support, it probably will matter, so
we'll have a note in here at that time.
we'll have a note in here at that time.
 
 
The initialization order is currently documented in the
The initialization order is currently documented in the
@file{Runtime.java} source file.
@file{Runtime.java} source file.
 
 
@node Classpath Hooks, VM Hooks, Initialization, Top
@node Classpath Hooks, VM Hooks, Initialization, Top
@comment node-name, next, previous, up
@comment node-name, next, previous, up
@chapter Classpath Hooks
@chapter Classpath Hooks
 
 
The primary method of interaction between Classpath and the VM is via
The primary method of interaction between Classpath and the VM is via
the helper classes, which are named after the relevant core library
the helper classes, which are named after the relevant core library
class, but include an additional `VM' prefix.  The library classes from
class, but include an additional `VM' prefix.  The library classes from
Classpath call out to these to get certain VM-specific dirty work done.
Classpath call out to these to get certain VM-specific dirty work done.
A reference copy of each VM class exists.  The majority consist of a
A reference copy of each VM class exists.  The majority consist of a
series of static methods, some of which are simply declared
series of static methods, some of which are simply declared
@code{native}, and some which provide a default implementation.  VMs may
@code{native}, and some which provide a default implementation.  VMs may
either use these as is, or create their own local variations.  When
either use these as is, or create their own local variations.  When
using the default implementations, the VM is responsible for
using the default implementations, the VM is responsible for
implementing any of the code marked as @code{native} which corresponds
implementing any of the code marked as @code{native} which corresponds
to functionality they wish their VM to provide.  When using their own
to functionality they wish their VM to provide.  When using their own
versions of the classes, VM implementors may choose to change the mix of
versions of the classes, VM implementors may choose to change the mix of
native and non-native methods from that below, so as to best suit their
native and non-native methods from that below, so as to best suit their
implementation.
implementation.
 
 
@menu
@menu
* java.lang::
* java.lang::
* gnu.classpath::
* gnu.classpath::
* java.util::
* java.util::
* java.io::
* java.io::
* java.security::
* java.security::
* java.net::
* java.net::
* java.nio::
* java.nio::
* java.nio.channels::
* java.nio.channels::
* gnu.java.nio::
* gnu.java.nio::
* java.lang.reflect::
* java.lang.reflect::
* gnu.java.lang::
* gnu.java.lang::
* gnu.java.lang.management::
* gnu.java.lang.management::
* java.lang.management::
* java.lang.management::
* Classpath Callbacks::
* Classpath Callbacks::
@end menu
@end menu
 
 
@node java.lang, gnu.classpath, Classpath Hooks, Classpath Hooks
@node java.lang, gnu.classpath, Classpath Hooks, Classpath Hooks
@comment  node-name,  next,  previous,  up
@comment  node-name,  next,  previous,  up
 
 
@section @code{java.lang}
@section @code{java.lang}
 
 
@code{java.lang} is the core Java package, being imported automatically by all
@code{java.lang} is the core Java package, being imported automatically by all
classes.  It includes basic classes as @code{Object} and @code{String}.
classes.  It includes basic classes as @code{Object} and @code{String}.
A VM must implement at least some parts of this package in order to
A VM must implement at least some parts of this package in order to
become operable.
become operable.
 
 
@menu
@menu
* java.lang.VMClass::
* java.lang.VMClass::
* java.lang.VMObject::
* java.lang.VMObject::
* java.lang.VMClassLoader::
* java.lang.VMClassLoader::
* java.lang.VMSystem::
* java.lang.VMSystem::
* java.lang.VMThrowable::
* java.lang.VMThrowable::
* java.lang.VMCompiler::
* java.lang.VMCompiler::
* java.lang.VMDouble::
* java.lang.VMDouble::
* java.lang.VMFloat::
* java.lang.VMFloat::
* java.lang.VMProcess::
* java.lang.VMProcess::
* java.lang.VMRuntime::
* java.lang.VMRuntime::
* java.lang.VMString::
* java.lang.VMString::
* java.lang.VMThread::
* java.lang.VMThread::
* java.lang.VMMath::
* java.lang.VMMath::
@end menu
@end menu
 
 
@node java.lang.VMClass, java.lang.VMObject ,java.lang,java.lang
@node java.lang.VMClass, java.lang.VMObject ,java.lang,java.lang
@subsection @code{java.lang.VMClass}
@subsection @code{java.lang.VMClass}
 
 
The core class, @code{java.lang.Class}, and the corresponding VM class,
The core class, @code{java.lang.Class}, and the corresponding VM class,
@code{java.lang.VMClass}, provide two main functions within GNU Classpath.
@code{java.lang.VMClass}, provide two main functions within GNU Classpath.
 
 
@enumerate
@enumerate
@item For basic VM operation, @code{java.lang.Class} provides the link between
@item For basic VM operation, @code{java.lang.Class} provides the link between
the Java-based representation of a class it embodies and the VM's own
the Java-based representation of a class it embodies and the VM's own
internal structure for a class.  @xref{VM Hooks}.
internal structure for a class.  @xref{VM Hooks}.
 
 
@item As far as the user is concerned, the main function of
@item As far as the user is concerned, the main function of
@code{java.lang.Class} is as an entry point to the reflection
@code{java.lang.Class} is as an entry point to the reflection
facilities, and so it also provides this functionality, backed by the
facilities, and so it also provides this functionality, backed by the
VM class.
VM class.
@end enumerate
@end enumerate
 
 
This VM class lists the following methods, organized by the version of the
This VM class lists the following methods, organized by the version of the
Java specification in which they occur.  All are @code{native}, unless
Java specification in which they occur.  All are @code{native}, unless
otherwise specified, and pertain to reflection.  As a result, the VM only
otherwise specified, and pertain to reflection.  As a result, the VM only
needs to implement these methods in order to provide reflection support,
needs to implement these methods in order to provide reflection support,
and then only to the degree required.
and then only to the degree required.
 
 
@itemize @bullet
@itemize @bullet
@item 1.0
@item 1.0
@itemize @bullet
@itemize @bullet
@item @code{isInterface(Class)} -- This is simply a property test, and matches
@item @code{isInterface(Class)} -- This is simply a property test, and matches
the presence of an appropriate flag within the class file.
the presence of an appropriate flag within the class file.
@item @code{getName(Class)} -- Returns the fully-qualified name of the class.
@item @code{getName(Class)} -- Returns the fully-qualified name of the class.
@item @code{getSuperclass(Class)} -- Returns a @code{Class} instance which
@item @code{getSuperclass(Class)} -- Returns a @code{Class} instance which
represents the superclass.  Again, the class file contains an element directly
represents the superclass.  Again, the class file contains an element directly
relating to this.  @code{null} is returned for primitives, interfaces and
relating to this.  @code{null} is returned for primitives, interfaces and
@code{Object}.
@code{Object}.
@item @code{getInterfaces(Class)} -- Same as the above, but the implemented
@item @code{getInterfaces(Class)} -- Same as the above, but the implemented
or extended interfaces rather than the superclass.  An empty array should
or extended interfaces rather than the superclass.  An empty array should
be returned, rather than @code{null}.
be returned, rather than @code{null}.
@item @code{getDeclaredClasses(Class,boolean)} -- Returns the internal classes
@item @code{getDeclaredClasses(Class,boolean)} -- Returns the internal classes
this instance declares directly.  The flag determines whether or not the
this instance declares directly.  The flag determines whether or not the
VM should filter out non-public classes.
VM should filter out non-public classes.
@item @code{getDeclaredFields(Class,boolean)} -- The same for fields.
@item @code{getDeclaredFields(Class,boolean)} -- The same for fields.
@item @code{getDeclaredMethods(Class,boolean)} -- And for methods.
@item @code{getDeclaredMethods(Class,boolean)} -- And for methods.
@item @code{getDeclaredConstructors(Class,boolean)} -- And constructors.
@item @code{getDeclaredConstructors(Class,boolean)} -- And constructors.
@item @code{getClassLoader(Class)} -- Returns the @code{ClassLoader} instance
@item @code{getClassLoader(Class)} -- Returns the @code{ClassLoader} instance
which is responsible for the specified class.
which is responsible for the specified class.
@item @code{forName(String, boolean, ClassLoader)} -- The VM should create a
@item @code{forName(String, boolean, ClassLoader)} -- The VM should create a
@code{Class} instance corresponding to the named class.  As noted in
@code{Class} instance corresponding to the named class.  As noted in
@ref{VM Hooks}, the internal content of the instance is the
@ref{VM Hooks}, the internal content of the instance is the
responsibility of the VM@.  The supplied class loader is recorded as that
responsibility of the VM@.  The supplied class loader is recorded as that
which loaded the class, and the boolean specifies whether or not to
which loaded the class, and the boolean specifies whether or not to
run the class initializer.
run the class initializer.
@item @code{isArray(Class)} -- Another property test, corresponding to a
@item @code{isArray(Class)} -- Another property test, corresponding to a
class file flag.
class file flag.
@item @code{initialize(Class)} -- The VM should initialize the class fully,
@item @code{initialize(Class)} -- The VM should initialize the class fully,
if it has not already done so.
if it has not already done so.
@item @code{loadArrayClass(String,ClassLoader)} -- This is called if
@item @code{loadArrayClass(String,ClassLoader)} -- This is called if
@code{forName} returns @code{null} and the string specifies an array class.
@code{forName} returns @code{null} and the string specifies an array class.
The specified array class should be loaded with the supplied class loader.
The specified array class should be loaded with the supplied class loader.
@item @code{throwException(Throwable)} -- The VM should throw the supplied
@item @code{throwException(Throwable)} -- The VM should throw the supplied
checked exception, without declaring it.
checked exception, without declaring it.
@end itemize
@end itemize
@item 1.1
@item 1.1
@itemize @bullet
@itemize @bullet
@item @code{isInstance(Class,Object)} -- This is a reflection-based equivalent
@item @code{isInstance(Class,Object)} -- This is a reflection-based equivalent
of the @code{instanceof} operator.
of the @code{instanceof} operator.
@item @code{isAssignableFrom(Class,Class)} -- Mainly a shorthand for the above,
@item @code{isAssignableFrom(Class,Class)} -- Mainly a shorthand for the above,
removing the need to create an instance to test assignability.
removing the need to create an instance to test assignability.
@item @code{isPrimitive(Class)} -- Returns true if this class is simply
@item @code{isPrimitive(Class)} -- Returns true if this class is simply
a representation of one of the primitive types: @code{boolean}, @code{byte},
a representation of one of the primitive types: @code{boolean}, @code{byte},
@code{char}, @code{short}, @code{int}, @code{long}, @code{float},
@code{char}, @code{short}, @code{int}, @code{long}, @code{float},
@code{double} and @code{void}.
@code{double} and @code{void}.
@item @code{getComponentType(Class)} -- Produces a @code{Class} instance which
@item @code{getComponentType(Class)} -- Produces a @code{Class} instance which
represents the type of the members of the array the class instance represents.
represents the type of the members of the array the class instance represents.
Classes which don't represent an array type return @code{null}.
Classes which don't represent an array type return @code{null}.
@item @code{getModifiers(Class,boolean)} -- Returns an integer which encodes
@item @code{getModifiers(Class,boolean)} -- Returns an integer which encodes
the class' modifiers, such as @code{public}.  Again, this relates to
the class' modifiers, such as @code{public}.  Again, this relates to
information stored in the class file.
information stored in the class file.
@item @code{getDeclaringClass(Class)} -- Returns the class that declared
@item @code{getDeclaringClass(Class)} -- Returns the class that declared
an inner or member class, or @code{null} if the instance refers to a top-level
an inner or member class, or @code{null} if the instance refers to a top-level
class.
class.
@end itemize
@end itemize
@item 1.5
@item 1.5
@itemize @bullet
@itemize @bullet
@item @code{isSynthetic(Class)} -- Returns true if the flags for this class
@item @code{isSynthetic(Class)} -- Returns true if the flags for this class
mark it as synthetic.
mark it as synthetic.
@item @code{isAnnotation(Class)} -- Returns true if the flags for this class
@item @code{isAnnotation(Class)} -- Returns true if the flags for this class
mark it as an annotation.
mark it as an annotation.
@item @code{isEnum(Class)} -- Returns true if the flags for this class
@item @code{isEnum(Class)} -- Returns true if the flags for this class
mark it as an enumeration.
mark it as an enumeration.
@item @code{getSimpleName(Class)} -- Returns the simple name of the class.
@item @code{getSimpleName(Class)} -- Returns the simple name of the class.
A default implementation is provided, but a more efficient version may instead
A default implementation is provided, but a more efficient version may instead
be provided by the VM.
be provided by the VM.
@item @code{getCanonicalName(Class)} -- Returns the canonical name of the
@item @code{getCanonicalName(Class)} -- Returns the canonical name of the
class.  A default implementation is provided, but a more efficient
class.  A default implementation is provided, but a more efficient
version may instead be provided by the VM.
version may instead be provided by the VM.
@item @code{getEnclosingClass(Class)} -- Returns the immediately enclosing
@item @code{getEnclosingClass(Class)} -- Returns the immediately enclosing
class (null for a top-level class).
class (null for a top-level class).
@item @code{getEnclosingConstructor(Class)} -- Returns the constructor
@item @code{getEnclosingConstructor(Class)} -- Returns the constructor
which immediately encloses the supplied class.
which immediately encloses the supplied class.
@item @code{getEnclosingMethod(Class)} -- Returns the method
@item @code{getEnclosingMethod(Class)} -- Returns the method
which immediately encloses the supplied class.
which immediately encloses the supplied class.
@item @code{getClassSignature(Class)} -- Returns the generic signature of
@item @code{getClassSignature(Class)} -- Returns the generic signature of
the class or null if there isn't one.
the class or null if there isn't one.
@item @code{isAnonymousClass(Class)} -- Returns true if the class is an
@item @code{isAnonymousClass(Class)} -- Returns true if the class is an
anonymous class.
anonymous class.
@item @code{isLocalClass(Class)} -- Returns true if the class is an
@item @code{isLocalClass(Class)} -- Returns true if the class is an
local class.
local class.
@item @code{isMemberClass(Class)} -- Returns true if the class is an
@item @code{isMemberClass(Class)} -- Returns true if the class is an
member class.
member class.
@end itemize
@end itemize
@end itemize
@end itemize
 
 
@node java.lang.VMObject, java.lang.VMClassLoader, java.lang.VMClass, java.lang
@node java.lang.VMObject, java.lang.VMClassLoader, java.lang.VMClass, java.lang
@subsection @code{java.lang.VMObject}
@subsection @code{java.lang.VMObject}
 
 
@code{VMObject} is the bridge between the low level @code{Object}
@code{VMObject} is the bridge between the low level @code{Object}
facilities such as making a clone, getting the class of the object and
facilities such as making a clone, getting the class of the object and
the wait/notify semantics.  This is accomplished using the following
the wait/notify semantics.  This is accomplished using the following
@code{native} methods.
@code{native} methods.
 
 
@itemize @bullet
@itemize @bullet
@item @code{getClass(Object)} -- Returns the @code{Class} instance for the
@item @code{getClass(Object)} -- Returns the @code{Class} instance for the
object.  @code{Class} objects are produced by the VM, as described in
object.  @code{Class} objects are produced by the VM, as described in
@ref{VM Hooks}.
@ref{VM Hooks}.
@item @code{clone(Cloneable)} -- The VM should produce a low-level clone of the
@item @code{clone(Cloneable)} -- The VM should produce a low-level clone of the
specified object, creating a field-by-field shallow copy of the original.
specified object, creating a field-by-field shallow copy of the original.
The only difference between the two is that the new object should still be
The only difference between the two is that the new object should still be
@code{finalizable}, even if the original is not.
@code{finalizable}, even if the original is not.
@item @code{notify(Object)} -- The VM should choose one of the threads waiting
@item @code{notify(Object)} -- The VM should choose one of the threads waiting
for a lock on the specified object arbitrarily, and wake it.  If the current
for a lock on the specified object arbitrarily, and wake it.  If the current
thread does not currently hold the lock on the object, then an
thread does not currently hold the lock on the object, then an
@code{IllegalMonitorStateException} should be thrown.
@code{IllegalMonitorStateException} should be thrown.
@item @code{notifyAll(Object)} -- Same as the above, but all threads are
@item @code{notifyAll(Object)} -- Same as the above, but all threads are
awakened.
awakened.
@item @code{wait(Object,long,int)} -- The VM should set the current thread
@item @code{wait(Object,long,int)} -- The VM should set the current thread
into a waiting state, which persists until it receives a notify signal or the
into a waiting state, which persists until it receives a notify signal or the
specified time (in milliseconds and nanoseconds) is exceeded.  The nanoseconds
specified time (in milliseconds and nanoseconds) is exceeded.  The nanoseconds
restriction may be ignored if such granularity is not available, and a
restriction may be ignored if such granularity is not available, and a
@code{IllegalMonitorStateException} should be thrown if the current thread
@code{IllegalMonitorStateException} should be thrown if the current thread
doesn't own the object.
doesn't own the object.
@end itemize
@end itemize
 
 
@node java.lang.VMClassLoader, java.lang.VMSystem, java.lang.VMObject, java.lang
@node java.lang.VMClassLoader, java.lang.VMSystem, java.lang.VMObject, java.lang
@subsection @code{java.lang.VMClassLoader}
@subsection @code{java.lang.VMClassLoader}
@code{VMClassLoader} provides methods for defining and resolving core and
@code{VMClassLoader} provides methods for defining and resolving core and
primitive classes, as well as handling resources, packages and assertions.
primitive classes, as well as handling resources, packages and assertions.
The class is a mixture of @code{native} methods and Java-based
The class is a mixture of @code{native} methods and Java-based
implementations, with some of the latter being @emph{stubs}.
implementations, with some of the latter being @emph{stubs}.
 
 
@itemize @bullet
@itemize @bullet
@item Native Methods
@item Native Methods
@itemize @bullet
@itemize @bullet
@item @code{defineClass(ClassLoader,String,byte[],int,int,ProtectionDomain)}
@item @code{defineClass(ClassLoader,String,byte[],int,int,ProtectionDomain)}
-- The VM should create a @code{Class} instance from the supplied byte array.
-- The VM should create a @code{Class} instance from the supplied byte array.
@item @code{resolveClass(Class)} -- Resolve references to other classes in the
@item @code{resolveClass(Class)} -- Resolve references to other classes in the
supplied class.
supplied class.
@item @code{loadClass(name,boolean)} -- Load a class using the bootstrap
@item @code{loadClass(name,boolean)} -- Load a class using the bootstrap
loader.
loader.
@item @code{getPrimitiveClass(char)} -- The VM should provide a @code{Class}
@item @code{getPrimitiveClass(char)} -- The VM should provide a @code{Class}
implementation for one of the primitive classes.  The supplied character
implementation for one of the primitive classes.  The supplied character
matches the JNI code for the primitive class e.g.@: `B' for byte and
matches the JNI code for the primitive class e.g.@: `B' for byte and
`Z' for boolean.
`Z' for boolean.
@end itemize
@end itemize
@item Java Methods
@item Java Methods
@itemize @bullet
@itemize @bullet
@item @code{getResource(String)} -- The default implementation calls
@item @code{getResource(String)} -- The default implementation calls
@code{getResources} and returns the first element in the returned enumeration,
@code{getResources} and returns the first element in the returned enumeration,
or @code{null} if there are no elements.
or @code{null} if there are no elements.
@item @code{getResources(String)} -- By default, this compiles a list of
@item @code{getResources(String)} -- By default, this compiles a list of
URLs via the boot class path.  Any matching files within a zip file are added,
URLs via the boot class path.  Any matching files within a zip file are added,
and directories on the boot class path are automatically converted to file
and directories on the boot class path are automatically converted to file
URLs that refer to join the directory with the resource name (whether or not
URLs that refer to join the directory with the resource name (whether or not
it actually exists).
it actually exists).
@item @code{getPackage(String)} -- Always returns null, which may be suitable
@item @code{getPackage(String)} -- Always returns null, which may be suitable
if the VM does not wish to return a @code{Package} implementation. Otherwise,
if the VM does not wish to return a @code{Package} implementation. Otherwise,
it may be necessary to make this a @code{native} method.
it may be necessary to make this a @code{native} method.
@item @code{getPackages()} -- As with the last, a default stub implementation
@item @code{getPackages()} -- As with the last, a default stub implementation
exists (returning an empty array) which may be replaced if support is
exists (returning an empty array) which may be replaced if support is
required.
required.
@item @code{defaultAssertionStatus()} -- A stub which can be implemented
@item @code{defaultAssertionStatus()} -- A stub which can be implemented
by VMs providing assertion support.  At present, it always returns @code{true}.
by VMs providing assertion support.  At present, it always returns @code{true}.
@item @code{packageAssertionStatus()} -- Much the same status as the above.
@item @code{packageAssertionStatus()} -- Much the same status as the above.
The method should return a map converting package names to boolean status
The method should return a map converting package names to boolean status
values.  The stub implementation provides an empty map.
values.  The stub implementation provides an empty map.
@item @code{classAssertionStatus()} -- Same as the last, but for classes.
@item @code{classAssertionStatus()} -- Same as the last, but for classes.
@item @code{getSystemClassLoader()} -- The default calls @code{ClassLoader}
@item @code{getSystemClassLoader()} -- The default calls @code{ClassLoader}
to create a new auxiliary class loader with a system and extension class
to create a new auxiliary class loader with a system and extension class
loader.  The VM may wish to replace it if it wishes to supply its own custom
loader.  The VM may wish to replace it if it wishes to supply its own custom
system class loader.
system class loader.
@end itemize
@end itemize
@end itemize
@end itemize
@node java.lang.VMSystem, java.lang.VMThrowable, java.lang.VMClassLoader, java.lang
@node java.lang.VMSystem, java.lang.VMThrowable, java.lang.VMClassLoader, java.lang
@subsection @code{java.lang.VMSystem}
@subsection @code{java.lang.VMSystem}
@code{VMSystem} handles the default I/O streams, provides access to the
@code{VMSystem} handles the default I/O streams, provides access to the
system clock and environment variables and provides methods for
system clock and environment variables and provides methods for
@code{System.arraycopy} and the @code{identityHashCode} of an
@code{System.arraycopy} and the @code{identityHashCode} of an
@code{Object}.  It consists of @code{native} methods, but the default
@code{Object}.  It consists of @code{native} methods, but the default
implementation also provides some helper methods to simplify stream
implementation also provides some helper methods to simplify stream
creation.
creation.
 
 
@itemize @bullet
@itemize @bullet
@item Native Methods
@item Native Methods
@itemize @bullet
@itemize @bullet
@item @code{arraycopy(Object,int,Object,int,int)} -- The VM should copy
@item @code{arraycopy(Object,int,Object,int,int)} -- The VM should copy
a specified number of array objects from one array to another, with
a specified number of array objects from one array to another, with
appropriate checks for compatible typing, available elements and space.
appropriate checks for compatible typing, available elements and space.
The VM should be able to perform this more efficiently using native code
The VM should be able to perform this more efficiently using native code
and direct memory manipulation than would have been achieved by using Java.
and direct memory manipulation than would have been achieved by using Java.
@item @code{identityHashCode(Object)} -- This is the hashcode for
@item @code{identityHashCode(Object)} -- This is the hashcode for
@code{Object}, which relates to the actual location of the object in memory.
@code{Object}, which relates to the actual location of the object in memory.
@item @code{setIn(InputStream)} -- Set the system input stream.
@item @code{setIn(InputStream)} -- Set the system input stream.
@item @code{setOut(PrintStream)} -- Set the system output stream.
@item @code{setOut(PrintStream)} -- Set the system output stream.
@item @code{setErr(PrintStream)} -- Set the system error stream.
@item @code{setErr(PrintStream)} -- Set the system error stream.
@item @code{currentTimeMillis()} -- Gets the system time in milliseconds.
@item @code{currentTimeMillis()} -- Gets the system time in milliseconds.
@item @code{getenv(String)} -- Returns the value of the specified environment
@item @code{getenv(String)} -- Returns the value of the specified environment
variable.
variable.
@item @code{getenv()} -- Returns a list of `name=value' pairs which correspond
@item @code{getenv()} -- Returns a list of `name=value' pairs which correspond
to the environment variables.
to the environment variables.
@end itemize
@end itemize
@item Java Methods
@item Java Methods
@itemize @bullet
@itemize @bullet
@item @code{makeStandardInputStream()} -- Helps provide the functionality of
@item @code{makeStandardInputStream()} -- Helps provide the functionality of
@code{System.in} by wrapping the appropriate file descriptor in a
@code{System.in} by wrapping the appropriate file descriptor in a
buffered file input stream.  VMs may choose to create the stream from
buffered file input stream.  VMs may choose to create the stream from
the descriptor differently rather than using this method.
the descriptor differently rather than using this method.
@item @code{makeStandardOutputStream()} -- Helps provide the functionality of
@item @code{makeStandardOutputStream()} -- Helps provide the functionality of
@code{System.out} by wrapping the appropriate file descriptor in a buffered
@code{System.out} by wrapping the appropriate file descriptor in a buffered
file output stream.  VMs may choose to create the stream from the descriptor
file output stream.  VMs may choose to create the stream from the descriptor
differently rather than using this method.
differently rather than using this method.
@item @code{makeStandardErrorStream()} -- Helps provide the functionality of
@item @code{makeStandardErrorStream()} -- Helps provide the functionality of
@code{System.err} by wrapping the appropriate file descriptor in a buffered
@code{System.err} by wrapping the appropriate file descriptor in a buffered
file output stream.  VMs may choose to create the stream from the descriptor
file output stream.  VMs may choose to create the stream from the descriptor
differently rather than using this method.
differently rather than using this method.
@end itemize
@end itemize
@end itemize
@end itemize
 
 
Classpath also provides native implementations of
Classpath also provides native implementations of
 
 
@itemize @bullet
@itemize @bullet
@item @code{setIn(InputStream)}
@item @code{setIn(InputStream)}
@item @code{setOut(PrintStream)}
@item @code{setOut(PrintStream)}
@item @code{setErr(PrintStream)}
@item @code{setErr(PrintStream)}
@item @code{currentTimeMillis()}
@item @code{currentTimeMillis()}
@item @code{getenv(String)}
@item @code{getenv(String)}
@end itemize
@end itemize
 
 
making a VM implementation optional.
making a VM implementation optional.
 
 
@node java.lang.VMThrowable, java.lang.VMCompiler, java.lang.VMSystem, java.lang
@node java.lang.VMThrowable, java.lang.VMCompiler, java.lang.VMSystem, java.lang
@subsection @code{java.lang.VMThrowable}
@subsection @code{java.lang.VMThrowable}
@code{VMThrowable} is used to hold the VM state of a throwable, created either
@code{VMThrowable} is used to hold the VM state of a throwable, created either
when a @code{Throwable} is created or the @code{fillInStackTrace()} method is
when a @code{Throwable} is created or the @code{fillInStackTrace()} method is
called (i.e., when the actual stack trace is needed, as a lot of exceptions are
called (i.e., when the actual stack trace is needed, as a lot of exceptions are
never actually used).  The actual class has two @code{native} methods,
never actually used).  The actual class has two @code{native} methods,
one (@code{fillInStackTrace()}) being a method of the class used to obtain
one (@code{fillInStackTrace()}) being a method of the class used to obtain
instances, and the other an instance method, @code{getStackTrace()}.
instances, and the other an instance method, @code{getStackTrace()}.
@itemize @bullet
@itemize @bullet
@item @code{fillInStackTrace(Throwable)} -- The VM should return the current
@item @code{fillInStackTrace(Throwable)} -- The VM should return the current
execution state of the @code{Throwable} in the form of a @code{VMThrowable}
execution state of the @code{Throwable} in the form of a @code{VMThrowable}
instance.  The VM may also return @code{null} if it does not support this
instance.  The VM may also return @code{null} if it does not support this
functionality.
functionality.
@item @code{getStackTrace()} -- This is used to create a real
@item @code{getStackTrace()} -- This is used to create a real
@code{StackTraceElement} array for the exception, using the state data
@code{StackTraceElement} array for the exception, using the state data
stored during creation of the instance.
stored during creation of the instance.
@end itemize
@end itemize
 
 
@node java.lang.VMCompiler, java.lang.VMDouble, java.lang.VMThrowable, java.lang
@node java.lang.VMCompiler, java.lang.VMDouble, java.lang.VMThrowable, java.lang
@subsection @code{java.lang.VMCompiler}
@subsection @code{java.lang.VMCompiler}
 
 
@code{VMCompiler} provides an interface for VMs which wish to provide
@code{VMCompiler} provides an interface for VMs which wish to provide
JIT compilation support.  The default implementation is simply a series
JIT compilation support.  The default implementation is simply a series
of stubs. The property, @code{java.compiler}, should point to a library
of stubs. The property, @code{java.compiler}, should point to a library
containing the function @code{java_lang_Compiler_start()} if such support
containing the function @code{java_lang_Compiler_start()} if such support
is to be provided.
is to be provided.
 
 
@itemize @bullet
@itemize @bullet
@item @code{compileClass(Class)} -- Invoke the compiler to compile the specific
@item @code{compileClass(Class)} -- Invoke the compiler to compile the specific
class, returning @code{true} if successful.
class, returning @code{true} if successful.
@item @code{compileClasses(String)} -- The compiler should compile the classes
@item @code{compileClasses(String)} -- The compiler should compile the classes
matching the specified string, again returning @code{true} on success.
matching the specified string, again returning @code{true} on success.
@item @code{command(Object)} -- The object represents a command given to the
@item @code{command(Object)} -- The object represents a command given to the
compiler, and is specific to the compiler implementation.
compiler, and is specific to the compiler implementation.
@item @code{enable} -- Enable the operation of the compiler.
@item @code{enable} -- Enable the operation of the compiler.
@item @code{disable} -- Disable compiler operation.
@item @code{disable} -- Disable compiler operation.
@end itemize
@end itemize
 
 
@node java.lang.VMDouble, java.lang.VMFloat, java.lang.VMCompiler, java.lang
@node java.lang.VMDouble, java.lang.VMFloat, java.lang.VMCompiler, java.lang
@subsection @code{java.lang.VMDouble}
@subsection @code{java.lang.VMDouble}
 
 
@code{VMDouble} provides native support for the conversion and parsing
@code{VMDouble} provides native support for the conversion and parsing
of doubles.
of doubles.
 
 
@itemize @bullet
@itemize @bullet
@item @code{doubleToRawLongBits(double)} -- Converts the double to the IEEE 754
@item @code{doubleToRawLongBits(double)} -- Converts the double to the IEEE 754
bit layout, preserving NaNs.
bit layout, preserving NaNs.
@item @code{longBitsToDouble(long)} -- This is the inverse of the last method,
@item @code{longBitsToDouble(long)} -- This is the inverse of the last method,
preserving NaNs so that the output of one can be fed into the other without
preserving NaNs so that the output of one can be fed into the other without
data loss.
data loss.
@item @code{toString(double,boolean)} -- Converts the double to a string,
@item @code{toString(double,boolean)} -- Converts the double to a string,
giving a shorter value if the flag @code{isFloat} is @code{true}, indicating
giving a shorter value if the flag @code{isFloat} is @code{true}, indicating
that the conversion was requested by @code{java.lang.Float} rather than
that the conversion was requested by @code{java.lang.Float} rather than
@code{java.lang.Double}.
@code{java.lang.Double}.
@item @code{initIDs} -- Used by JNI-based solutions to initialize the cache
@item @code{initIDs} -- Used by JNI-based solutions to initialize the cache
of the static field IDs.  The default @code{VMDouble} implementation has a
of the static field IDs.  The default @code{VMDouble} implementation has a
static initializer which loads the JNI library and calls this method.
static initializer which loads the JNI library and calls this method.
@item @code{parseDouble} -- Turn the string into a usable double value.
@item @code{parseDouble} -- Turn the string into a usable double value.
@end itemize
@end itemize
 
 
Classpath provides native implementations of all these, making VM
Classpath provides native implementations of all these, making VM
implementation optional.
implementation optional.
 
 
@node java.lang.VMFloat, java.lang.VMProcess, java.lang.VMDouble, java.lang
@node java.lang.VMFloat, java.lang.VMProcess, java.lang.VMDouble, java.lang
@subsection @code{java.lang.VMFloat}
@subsection @code{java.lang.VMFloat}
 
 
@code{VMFloat} provides native support for the conversion of floats.
@code{VMFloat} provides native support for the conversion of floats.
 
 
@itemize @bullet
@itemize @bullet
@item @code{floatToRawIntBits(float)} -- Converts the float to the IEEE 754
@item @code{floatToRawIntBits(float)} -- Converts the float to the IEEE 754
bit layout, preserving NaNs.
bit layout, preserving NaNs.
@item @code{intBitsToFloat(int)} -- This is the inverse of the last method,
@item @code{intBitsToFloat(int)} -- This is the inverse of the last method,
preserving NaNs so that the output of one can be fed into the other without
preserving NaNs so that the output of one can be fed into the other without
data loss.
data loss.
@end itemize
@end itemize
 
 
Classpath provides native implementations of all these, making VM
Classpath provides native implementations of all these, making VM
implementation optional.
implementation optional.
 
 
@node java.lang.VMProcess, java.lang.VMRuntime, java.lang.VMFloat, java.lang
@node java.lang.VMProcess, java.lang.VMRuntime, java.lang.VMFloat, java.lang
@subsection @code{java.lang.VMProcess}
@subsection @code{java.lang.VMProcess}
 
 
@code{VMProcess} handles the execution of external processes.  In the
@code{VMProcess} handles the execution of external processes.  In the
default implementation, threads are spawned and reaped by @code{ProcessThread}.
default implementation, threads are spawned and reaped by @code{ProcessThread}.
A constructor creates a new @code{VMProcess}, which extends rather than
A constructor creates a new @code{VMProcess}, which extends rather than
complements @code{Process}, using an array of arguments, an array of
complements @code{Process}, using an array of arguments, an array of
environment variables and a working directory.  The instance maintains
environment variables and a working directory.  The instance maintains
system input, output and error streams linked to the external process.
system input, output and error streams linked to the external process.
Three @code{native} methods are used, and implementations are provided
Three @code{native} methods are used, and implementations are provided
for all three by Classpath, making VM implementation optional.  These use
for all three by Classpath, making VM implementation optional.  These use
the POSIX functions, @code{fork()}, @code{waitpid()} and @code{kill()}.
the POSIX functions, @code{fork()}, @code{waitpid()} and @code{kill()}.
 
 
@itemize @bullet
@itemize @bullet
@item @code{nativeSpawn(String[],String[],File,boolean)} -- The VM should
@item @code{nativeSpawn(String[],String[],File,boolean)} -- The VM should
create a new process which uses the specified command-line arguments,
create a new process which uses the specified command-line arguments,
environment variables and working directory.  Unlike the other two
environment variables and working directory.  Unlike the other two
methods, this method is linked to an instance, and must call
methods, this method is linked to an instance, and must call
@code{setProcessInfo()} with the results before returning.  The
@code{setProcessInfo()} with the results before returning.  The
boolean argument maps to the @code{redirectErrorStream} property of
boolean argument maps to the @code{redirectErrorStream} property of
@code{java.lang.ProcessBuilder}.  When true, the output and error streams
@code{java.lang.ProcessBuilder}.  When true, the output and error streams
are merged.
are merged.
@item @code{nativeReap()} -- This is called to perform a reap of any
@item @code{nativeReap()} -- This is called to perform a reap of any
zombie processes, and should not block, instead returning a boolean as to
zombie processes, and should not block, instead returning a boolean as to
whether reaping actually took place.
whether reaping actually took place.
@item @code{nativeKill(long)} -- The VM should terminate the specified PID.
@item @code{nativeKill(long)} -- The VM should terminate the specified PID.
@end itemize
@end itemize
 
 
@node java.lang.VMRuntime, java.lang.VMString, java.lang.VMProcess, java.lang
@node java.lang.VMRuntime, java.lang.VMString, java.lang.VMProcess, java.lang
@subsection @code{java.lang.VMRuntime}
@subsection @code{java.lang.VMRuntime}
 
 
The @code{VMRuntime} class provides a series of native methods
The @code{VMRuntime} class provides a series of native methods
which divulge information about the runtime or invoke certain
which divulge information about the runtime or invoke certain
operations.  This includes retrieving the amount of available memory,
operations.  This includes retrieving the amount of available memory,
and scheduling the garbage collector.  There are two exceptions: the
and scheduling the garbage collector.  There are two exceptions: the
@code{enableShutdownHooks} method, which allows the VM to put in its own
@code{enableShutdownHooks} method, which allows the VM to put in its own
shutdown hooks when @code{Runtime.addShutdownHook()} is first invoked,
shutdown hooks when @code{Runtime.addShutdownHook()} is first invoked,
and @code{exec(String[],String[],File)} which spawns an external process.
and @code{exec(String[],String[],File)} which spawns an external process.
These are Java-based static methods instead.  The first is simply a stub by
These are Java-based static methods instead.  The first is simply a stub by
default, while the second simply links to the functionality of
default, while the second simply links to the functionality of
@code{VMProcess} (and should be changed if a different @code{Process}
@code{VMProcess} (and should be changed if a different @code{Process}
implementation is used).
implementation is used).
 
 
@itemize @bullet
@itemize @bullet
@item @code{availableProcessors()} -- Returns the number of processors
@item @code{availableProcessors()} -- Returns the number of processors
available to the VM.
available to the VM.
@item @code{freeMemory()} -- Returns the amount of memory the VM has available
@item @code{freeMemory()} -- Returns the amount of memory the VM has available
on the heap for allocating.
on the heap for allocating.
@item @code{totalMemory()} -- Returns the size of the heap.
@item @code{totalMemory()} -- Returns the size of the heap.
@item @code{maxMemory()} -- Returns the maximum memory block the VM will
@item @code{maxMemory()} -- Returns the maximum memory block the VM will
attempt to allocate.  May be simply @code{Long.MAX_VALUE} (8 exabytes!)
attempt to allocate.  May be simply @code{Long.MAX_VALUE} (8 exabytes!)
@item @code{gc()} -- Allows users to explicitly invoke the garbage collector.
@item @code{gc()} -- Allows users to explicitly invoke the garbage collector.
This is a suggestion to the VM, rather than a command, and the garbage
This is a suggestion to the VM, rather than a command, and the garbage
collector should run anyway @emph{without} it being invoked.
collector should run anyway @emph{without} it being invoked.
@item @code{runFinalization()} -- Like the above, but related to the
@item @code{runFinalization()} -- Like the above, but related to the
finalilzation of objects rather than the garbage collector.
finalilzation of objects rather than the garbage collector.
@item @code{runFinalizationForExit()} -- Called immediately prior to VM
@item @code{runFinalizationForExit()} -- Called immediately prior to VM
shutdown in order to finalize all objects (including `live' ones)
shutdown in order to finalize all objects (including `live' ones)
@item @code{traceInstructions(boolean)} -- This turns on and off the optional
@item @code{traceInstructions(boolean)} -- This turns on and off the optional
VM functionality of printing a trace of executed bytecode instructions.
VM functionality of printing a trace of executed bytecode instructions.
@item @code{traceMethodCalls(boolean)} -- This turns on and off the optional
@item @code{traceMethodCalls(boolean)} -- This turns on and off the optional
VM functionality of printing a trace of methods called.
VM functionality of printing a trace of methods called.
@item @code{runFinalizersOnExit(boolean)} -- A toggleable setting for
@item @code{runFinalizersOnExit(boolean)} -- A toggleable setting for
running the finalization process at exit.
running the finalization process at exit.
@item @code{exit(int)} -- The VM should shutdown with the specified exit code.
@item @code{exit(int)} -- The VM should shutdown with the specified exit code.
@item @code{nativeLoad(String,ClassLoader)} -- Attempts to load a file,
@item @code{nativeLoad(String,ClassLoader)} -- Attempts to load a file,
returning an integer which is non-zero for success.  Nothing happens if the
returning an integer which is non-zero for success.  Nothing happens if the
file has already been loaded.
file has already been loaded.
@item @code{mapLibraryName(String)} -- The VM should map the system-independent
@item @code{mapLibraryName(String)} -- The VM should map the system-independent
library name supplied to the platform-dependent equivalent (e.g.@: a @code{.so}
library name supplied to the platform-dependent equivalent (e.g.@: a @code{.so}
or @code{.dll} file)
or @code{.dll} file)
@end itemize
@end itemize
 
 
@node java.lang.VMString, java.lang.VMThread, java.lang.VMRuntime, java.lang
@node java.lang.VMString, java.lang.VMThread, java.lang.VMRuntime, java.lang
@subsection @code{java.lang.VMString}
@subsection @code{java.lang.VMString}
@code{VMString} is responsible for handling interned strings.  If two strings
@code{VMString} is responsible for handling interned strings.  If two strings
are equal (using the @code{equals()} method), then the results of calling
are equal (using the @code{equals()} method), then the results of calling
the @code{intern()} method on each of them makes them equal
the @code{intern()} method on each of them makes them equal
(using @code{==}).  Thus, the same string object is always returned by
(using @code{==}).  Thus, the same string object is always returned by
@code{intern} if the two strings are equal.  The default implementation
@code{intern} if the two strings are equal.  The default implementation
is Java-based and implements @code{intern(String)} by maintaining a
is Java-based and implements @code{intern(String)} by maintaining a
@code{WeakHashMap} which links the strings to their @code{WeakReference}.
@code{WeakHashMap} which links the strings to their @code{WeakReference}.
A new mapping is created for each new string being @code{intern}ed.
A new mapping is created for each new string being @code{intern}ed.
A VM may implement this differently by implementing this method,
A VM may implement this differently by implementing this method,
which is @code{static} and the only one in @code{VMString}.
which is @code{static} and the only one in @code{VMString}.
 
 
@node java.lang.VMThread, java.lang.VMMath, java.lang.VMString, java.lang
@node java.lang.VMThread, java.lang.VMMath, java.lang.VMString, java.lang
@subsection @code{java.lang.VMThread}
@subsection @code{java.lang.VMThread}
 
 
@code{VMThread} provides the link between Java's threads and the platform
@code{VMThread} provides the link between Java's threads and the platform
threading support.  A @code{VMThread} is created via a private constructor
threading support.  A @code{VMThread} is created via a private constructor
and linked to a @code{Thread} instance.  This occurs when the @code{Thread}
and linked to a @code{Thread} instance.  This occurs when the @code{Thread}
instance is started by the static @code{create(Thread,long)} method (the second
instance is started by the static @code{create(Thread,long)} method (the second
argument requests a certain stack size, usually zero).  The thread itself is
argument requests a certain stack size, usually zero).  The thread itself is
executed via the @code{run()} method, which handles any problems with the
executed via the @code{run()} method, which handles any problems with the
running of the thread and its eventual death.
running of the thread and its eventual death.
 
 
@code{VMThread} provides the following accessors and mutators for accessing
@code{VMThread} provides the following accessors and mutators for accessing
the thread state via @code{VMThread},
the thread state via @code{VMThread},
 
 
@itemize @bullet
@itemize @bullet
@item @code{getName()}
@item @code{getName()}
@item @code{setName(String)}
@item @code{setName(String)}
@item @code{getPriority()}
@item @code{getPriority()}
@item @code{setPriotity(int)}
@item @code{setPriotity(int)}
@item @code{isDaemon()}
@item @code{isDaemon()}
@end itemize
@end itemize
 
 
all of which refer to the @code{Thread} instance. @code{setPriority(int)} also
all of which refer to the @code{Thread} instance. @code{setPriority(int)} also
calls the appropriate native method.  @code{stop(Throwable)} similarly wraps
calls the appropriate native method.  @code{stop(Throwable)} similarly wraps
a native method, merely adding in a check for the state of the thread.
a native method, merely adding in a check for the state of the thread.
 
 
The default implementation also provides Java-based implementations of
The default implementation also provides Java-based implementations of
@code{join(long,int)}, @code{sleep(long,int)} and
@code{join(long,int)}, @code{sleep(long,int)} and
@code{holdsLock(Object)}.  @code{join} and @code{sleep} simply wait for
@code{holdsLock(Object)}.  @code{join} and @code{sleep} simply wait for
the appropriate amount of time, with @code{join} additionally waiting
the appropriate amount of time, with @code{join} additionally waiting
for the thread instance to become @code{null}.  @code{holdsLock} simply
for the thread instance to become @code{null}.  @code{holdsLock} simply
checks if an object is locked by the current thread by trying to invoke
checks if an object is locked by the current thread by trying to invoke
the @code{notify} method, and catching the failing exception if this is
the @code{notify} method, and catching the failing exception if this is
not the case.
not the case.
 
 
The remainder of the class is a series of @code{native} methods, some of
The remainder of the class is a series of @code{native} methods, some of
which are mandatory for VM implementation and others which provide optional
which are mandatory for VM implementation and others which provide optional
or deprecated functionality.
or deprecated functionality.
 
 
@itemize @bullet
@itemize @bullet
@item Mandatory Instance Methods
@item Mandatory Instance Methods
@itemize @bullet
@itemize @bullet
@item @code{start(long)} -- The VM should create the native thread and start
@item @code{start(long)} -- The VM should create the native thread and start
it running using the @code{run} method of the @code{VMThread} instance on
it running using the @code{run} method of the @code{VMThread} instance on
which this method is called.
which this method is called.
@item @code{interrupt()} -- The VM should interrupt the running thread and
@item @code{interrupt()} -- The VM should interrupt the running thread and
throw an appropriate exception.
throw an appropriate exception.
@item @code{isInterrupted()} -- Checks the interrupted state of the thread.
@item @code{isInterrupted()} -- Checks the interrupted state of the thread.
@item @code{suspend()} -- The thread should be suspended until resumed.
@item @code{suspend()} -- The thread should be suspended until resumed.
@item @code{resume()} -- The thread should be resumed from its suspended state.
@item @code{resume()} -- The thread should be resumed from its suspended state.
This pair of methods are deprecated, due to the possibility of a deadlock
This pair of methods are deprecated, due to the possibility of a deadlock
occurring when a thread with locks is suspended.
occurring when a thread with locks is suspended.
@item @code{nativeSetPriority(int)} -- Called by @code{setPriority}
@item @code{nativeSetPriority(int)} -- Called by @code{setPriority}
to allow the setting to flow down to the native thread.
to allow the setting to flow down to the native thread.
@item @code{nativeStop(Throwable)} -- The VM should stop the thread abnormally
@item @code{nativeStop(Throwable)} -- The VM should stop the thread abnormally
and throw the specified exception.  This is clearly deprecated, due to the
and throw the specified exception.  This is clearly deprecated, due to the
ambiguous state an abruptly-stopped thread may leave.
ambiguous state an abruptly-stopped thread may leave.
@item @code{getState()} -- Returns the VM's impression of the current state
@item @code{getState()} -- Returns the VM's impression of the current state
of the thread.  The applicable states are supplied by the @code{State}
of the thread.  The applicable states are supplied by the @code{State}
enumeration in @code{java.lang.Thread}.
enumeration in @code{java.lang.Thread}.
@end itemize
@end itemize
@item Mandatory Class Methods
@item Mandatory Class Methods
@itemize @bullet
@itemize @bullet
@item @code{currentThread()} -- Return a reference to the thread currently
@item @code{currentThread()} -- Return a reference to the thread currently
being executed.
being executed.
@item @code{yield()} -- The VM should allow some other thread to run.
@item @code{yield()} -- The VM should allow some other thread to run.
The current thread maintains its locks even though it stops executing for
The current thread maintains its locks even though it stops executing for
the time being.
the time being.
@item @code{interrupted()} -- A shortcut to obtaining the interrupted state
@item @code{interrupted()} -- A shortcut to obtaining the interrupted state
of the current thread.
of the current thread.
@end itemize
@end itemize
@item Other Methods
@item Other Methods
@itemize @bullet
@itemize @bullet
@item @code{countStackFrames()} -- Returns a count of the number of stack
@item @code{countStackFrames()} -- Returns a count of the number of stack
frames in the thread.  This depends on the deprecated method @code{suspend()}
frames in the thread.  This depends on the deprecated method @code{suspend()}
having returned true, and is thus deprecated as a result.
having returned true, and is thus deprecated as a result.
@end itemize
@end itemize
@end itemize
@end itemize
 
 
@node java.lang.VMMath,, java.lang.VMThread, java.lang
@node java.lang.VMMath,, java.lang.VMThread, java.lang
@subsection @code{java.lang.VMMath}
@subsection @code{java.lang.VMMath}
 
 
The @code{VMMath} class provides a series of native methods
The @code{VMMath} class provides a series of native methods
for some of the mathematical functions present in @code{java.lang.Math}.
for some of the mathematical functions present in @code{java.lang.Math}.
Classpath provides a default implementation of these which maps the
Classpath provides a default implementation of these which maps the
functions to those provided by @code{fdlibm}.  VM implementors are welcome
functions to those provided by @code{fdlibm}.  VM implementors are welcome
to replace this with more efficient implementations, as long as the accuracy
to replace this with more efficient implementations, as long as the accuracy
contract of these methods, specified in @code{java.lang.Math}, is maintained.
contract of these methods, specified in @code{java.lang.Math}, is maintained.
 
 
@itemize @bullet
@itemize @bullet
@item 1.0
@item 1.0
@itemize @bullet
@itemize @bullet
@item @code{sin(double)} -- Returns the sine value for the given angle.
@item @code{sin(double)} -- Returns the sine value for the given angle.
@item @code{cos(double)} -- Returns the cosine value for the given angle.
@item @code{cos(double)} -- Returns the cosine value for the given angle.
@item @code{tan(double)} -- Returns the tangent value for the given angle.
@item @code{tan(double)} -- Returns the tangent value for the given angle.
@item @code{asin(double)} -- Returns the arc sine value for the given angle.
@item @code{asin(double)} -- Returns the arc sine value for the given angle.
@item @code{acos(double)} -- Returns the arc cosine value for the given angle.
@item @code{acos(double)} -- Returns the arc cosine value for the given angle.
@item @code{atan(double)} -- Returns the arc tangent value for the given angle.
@item @code{atan(double)} -- Returns the arc tangent value for the given angle.
@item @code{atan2(double,double)} -- Returns the arc tangent of the ratio of
@item @code{atan2(double,double)} -- Returns the arc tangent of the ratio of
the two arguments.
the two arguments.
@item @code{exp(double)} -- Returns the exponent raised to the given power.
@item @code{exp(double)} -- Returns the exponent raised to the given power.
@item @code{log(double)} -- Returns the natural logarithm for the given value.
@item @code{log(double)} -- Returns the natural logarithm for the given value.
@item @code{sqrt(double)} -- Returns the square root of the value.
@item @code{sqrt(double)} -- Returns the square root of the value.
@item @code{pow(double,double)} -- Returns x to the power of y.
@item @code{pow(double,double)} -- Returns x to the power of y.
@item @code{IEEEremainder(double,double)} -- Returns the IEEE 754 remainder
@item @code{IEEEremainder(double,double)} -- Returns the IEEE 754 remainder
for the two values.
for the two values.
@item @code{ceil(double)} -- Returns the nearest integer >= the value.
@item @code{ceil(double)} -- Returns the nearest integer >= the value.
@item @code{floor(double)} -- Returns the nearest integer <= the value.
@item @code{floor(double)} -- Returns the nearest integer <= the value.
@item @code{rint(double)} -- Returns the nearest integer or the even one
@item @code{rint(double)} -- Returns the nearest integer or the even one
if the distance between the two is equal.
if the distance between the two is equal.
@end itemize
@end itemize
@item 1.5
@item 1.5
@itemize @bullet
@itemize @bullet
@item @code{cbrt(double)} -- Returns the cube root of the value.
@item @code{cbrt(double)} -- Returns the cube root of the value.
@item @code{cosh(double)} -- Returns the hyperbolic cosine value for the given
@item @code{cosh(double)} -- Returns the hyperbolic cosine value for the given
angle.
angle.
@item @code{expm1(double)} -- Returns the exponent of the value minus one.
@item @code{expm1(double)} -- Returns the exponent of the value minus one.
@item @code{hypot(double,double)} -- Returns the hypotenuse corresponding to
@item @code{hypot(double,double)} -- Returns the hypotenuse corresponding to
x and y.
x and y.
@item @code{log10(double)} -- Returns the base 10 logarithm of the given value.
@item @code{log10(double)} -- Returns the base 10 logarithm of the given value.
@item @code{log1p(double)} -- Returns the natural logarithm of the value plus
@item @code{log1p(double)} -- Returns the natural logarithm of the value plus
one.
one.
@item @code{sinh(double)} -- Returns the hyperbolic sine value for the given
@item @code{sinh(double)} -- Returns the hyperbolic sine value for the given
angle.
angle.
@item @code{tanh(double)} -- Returns the hyperbolic tangent value for the given angle.
@item @code{tanh(double)} -- Returns the hyperbolic tangent value for the given angle.
@end itemize
@end itemize
@end itemize
@end itemize
 
 
@node gnu.classpath, java.util, java.lang, Classpath Hooks
@node gnu.classpath, java.util, java.lang, Classpath Hooks
@section @code{gnu.classpath}
@section @code{gnu.classpath}
 
 
The @code{gnu.classpath} package provides Classpath-specific functionality,
The @code{gnu.classpath} package provides Classpath-specific functionality,
primarily relating to the features in @code{java.lang}.  At present, this
primarily relating to the features in @code{java.lang}.  At present, this
includes the context of a class (the stack) and the system properties.
includes the context of a class (the stack) and the system properties.
 
 
@menu
@menu
* gnu.classpath.VMStackWalker::
* gnu.classpath.VMStackWalker::
* gnu.classpath.VMSystemProperties::
* gnu.classpath.VMSystemProperties::
* gnu.classpath.Unsafe::
* gnu.classpath.Unsafe::
@end menu
@end menu
 
 
@node gnu.classpath.VMStackWalker,gnu.classpath.VMSystemProperties,gnu.classpath,gnu.classpath
@node gnu.classpath.VMStackWalker,gnu.classpath.VMSystemProperties,gnu.classpath,gnu.classpath
@subsection @code{gnu.classpath.VMStackWalker}
@subsection @code{gnu.classpath.VMStackWalker}
 
 
@code{VMStackWalker} provides access to the class context or stack.  The
@code{VMStackWalker} provides access to the class context or stack.  The
default implementation consists of a @code{native} @code{static} method,
default implementation consists of a @code{native} @code{static} method,
@code{getClassContext()}, which obtains the class context, and two helper
@code{getClassContext()}, which obtains the class context, and two helper
methods which obtain the calling class (the 3rd element in the context array)
methods which obtain the calling class (the 3rd element in the context array)
and its class loader, respectively.
and its class loader, respectively.
 
 
@itemize @bullet
@itemize @bullet
@item @code{getClassContext()} -- The VM should return an array of
@item @code{getClassContext()} -- The VM should return an array of
@code{Class} objects, each of which relates to the method currently being
@code{Class} objects, each of which relates to the method currently being
executed at that point on the stack.  Thus, the first item (index 0) is the
executed at that point on the stack.  Thus, the first item (index 0) is the
class that contains this method.
class that contains this method.
@item @code{getCallingClass()} -- A Java-based helper method which returns
@item @code{getCallingClass()} -- A Java-based helper method which returns
the @code{Class} object which contains the method that called the method
the @code{Class} object which contains the method that called the method
accessing @code{getCallingClass()}.
accessing @code{getCallingClass()}.
@item @code{getCallingClassLoader()} -- Like the last, but returning the class
@item @code{getCallingClassLoader()} -- Like the last, but returning the class
loader of the class.
loader of the class.
@end itemize
@end itemize
 
 
@node gnu.classpath.VMSystemProperties,gnu.classpath.Unsafe,gnu.classpath.VMStackWalker,gnu.classpath
@node gnu.classpath.VMSystemProperties,gnu.classpath.Unsafe,gnu.classpath.VMStackWalker,gnu.classpath
@subsection @code{gnu.classpath.VMSystemProperties}
@subsection @code{gnu.classpath.VMSystemProperties}
 
 
@code{VMSystemProperties} allows the VM to hook into the property creation
@code{VMSystemProperties} allows the VM to hook into the property creation
process, both before and after the system properties are added by GNU
process, both before and after the system properties are added by GNU
Classpath.  The default implementation assumes that the VM will add its
Classpath.  The default implementation assumes that the VM will add its
properties first, by making the pre-initialisation method @code{native},
properties first, by making the pre-initialisation method @code{native},
and that the Classpath properties may then be altered by a Java-based
and that the Classpath properties may then be altered by a Java-based
post-initialisation method.
post-initialisation method.
 
 
As these methods are called as part of the bootstrap process, caution should
As these methods are called as part of the bootstrap process, caution should
be used as to what classes are used, and properties should only be set
be used as to what classes are used, and properties should only be set
using @code{Properties.setProperty()}.  Specifically, I/O classes should be
using @code{Properties.setProperty()}.  Specifically, I/O classes should be
avoided at this early stage.
avoided at this early stage.
 
 
@itemize @bullet
@itemize @bullet
@item @code{preInit(Properties)} -- Allows the VM to add properties
@item @code{preInit(Properties)} -- Allows the VM to add properties
@emph{before} the Classpath properties are added. The default implementation
@emph{before} the Classpath properties are added. The default implementation
includes a full list of properties that @emph{must} be added by the VM, but
includes a full list of properties that @emph{must} be added by the VM, but
additional VM-specific ones may also be added.
additional VM-specific ones may also be added.
@item @code{postInit(Properties)} -- Same as the last, but called after the
@item @code{postInit(Properties)} -- Same as the last, but called after the
Classpath properties have been added.  The main purpose of this is to allow
Classpath properties have been added.  The main purpose of this is to allow
the VM to alter the properties added by GNU Classpath to suit it.
the VM to alter the properties added by GNU Classpath to suit it.
@end itemize
@end itemize
 
 
@node gnu.classpath.Unsafe,,gnu.classpath.VMSystemProperties,gnu.classpath
@node gnu.classpath.Unsafe,,gnu.classpath.VMSystemProperties,gnu.classpath
@subsection @code{gnu.classpath.Unsafe}
@subsection @code{gnu.classpath.Unsafe}
 
 
The @code{Unsafe} class provides access to some low-level unsafe operations
The @code{Unsafe} class provides access to some low-level unsafe operations
as required by the addition of the java.util.concurrent classes.  These
as required by the addition of the java.util.concurrent classes.  These
focus on direct memory access to the fields within the VM and providing
focus on direct memory access to the fields within the VM and providing
atomic update methods.
atomic update methods.
 
 
@itemize @bullet
@itemize @bullet
@item @code{objectFieldOffset(Field)} -- Provides the caller with the memory
@item @code{objectFieldOffset(Field)} -- Provides the caller with the memory
offset of a particular field.
offset of a particular field.
@item @code{compareAndSwap*(Object,long,*,*)} -- One of these methods is
@item @code{compareAndSwap*(Object,long,*,*)} -- One of these methods is
provided for each of int, long and Object (hence the *s).  The value of
provided for each of int, long and Object (hence the *s).  The value of
a field pointed to by the given Object and offset is compared with the
a field pointed to by the given Object and offset is compared with the
first value and replaced with the second if they are the same.  The reason
first value and replaced with the second if they are the same.  The reason
for this method is to make this change operation atomic.
for this method is to make this change operation atomic.
@item @code{put/get*(Object,long,*)} -- These are like the last set of
@item @code{put/get*(Object,long,*)} -- These are like the last set of
methods, handling integers, longs and Objects, but the field is always
methods, handling integers, longs and Objects, but the field is always
changed on a put.  Different methods are provided for different semantics.
changed on a put.  Different methods are provided for different semantics.
Ordered variants perform a lazy put, in that the change does not
Ordered variants perform a lazy put, in that the change does not
immediately propogate to other threads, while the others provide
immediately propogate to other threads, while the others provide
volatile or 'normal' semantics.
volatile or 'normal' semantics.
@item @code{arrayBaseOffset(Class)} and @code{arrayIndexScale(Class)} --
@item @code{arrayBaseOffset(Class)} and @code{arrayIndexScale(Class)} --
These two methods allow an array class to be traversed by pointer
These two methods allow an array class to be traversed by pointer
arithmetic, by gaining the address of the first element and then
arithmetic, by gaining the address of the first element and then
scaling appropriately for the later ones.
scaling appropriately for the later ones.
@item @code{park(boolean,long)} and @code{unpark(Thread)} -- These methods
@item @code{park(boolean,long)} and @code{unpark(Thread)} -- These methods
block and unblock threads respectively, with an optional timeout being
block and unblock threads respectively, with an optional timeout being
provided for the blocking.  @code{unpark} is unsafe as the thread may have
provided for the blocking.  @code{unpark} is unsafe as the thread may have
been destroyed by native code.
been destroyed by native code.
@end itemize
@end itemize
 
 
@node java.util, java.io, gnu.classpath, Classpath Hooks
@node java.util, java.io, gnu.classpath, Classpath Hooks
@section java.util
@section java.util
 
 
The @code{java.util} VM hooks provide links between the mix of functionality
The @code{java.util} VM hooks provide links between the mix of functionality
present in that package, which includes collections, date and time handling
present in that package, which includes collections, date and time handling
and parsing.  At present, there is only one hook, which connects GNU Classpath
and parsing.  At present, there is only one hook, which connects GNU Classpath
to the timezone information provided by the underlying platform.
to the timezone information provided by the underlying platform.
 
 
@menu
@menu
* java.util.VMTimeZone::
* java.util.VMTimeZone::
@end menu
@end menu
 
 
@node java.util.VMTimeZone,,java.util,java.util
@node java.util.VMTimeZone,,java.util,java.util
@subsection @code{java.util.VMTimeZone}
@subsection @code{java.util.VMTimeZone}
 
 
@code{VMTimeZone} joins @code{TimeZone} to the platform timezone information
@code{VMTimeZone} joins @code{TimeZone} to the platform timezone information
via the static method, @code{getDefaultTimeZoneId()}.  The VM hook is
via the static method, @code{getDefaultTimeZoneId()}.  The VM hook is
expected to return a @code{TimeZone} instance that represents the current
expected to return a @code{TimeZone} instance that represents the current
timezone in use by the platform.  The default implementation provides
timezone in use by the platform.  The default implementation provides
this functionality for POSIX or GNU-like systems, and VMs that want this
this functionality for POSIX or GNU-like systems, and VMs that want this
functionality can keep this implementation and implement the native
functionality can keep this implementation and implement the native
method, @code{getSystemTimeZoneId()}.  This method is only called when
method, @code{getSystemTimeZoneId()}.  This method is only called when
obtaining the timezone name from the @code{TZ} environment variable,
obtaining the timezone name from the @code{TZ} environment variable,
@code{/etc/timezone} and @code{/etc/localtime} all fail.  This fallback
@code{/etc/timezone} and @code{/etc/localtime} all fail.  This fallback
mechanism also means that a system which doesn't provide the above three
mechanism also means that a system which doesn't provide the above three
methods, but does provide a timezone in string form, can still use this
methods, but does provide a timezone in string form, can still use this
implementation.
implementation.
 
 
@node java.io, java.security, java.util, Classpath Hooks
@node java.io, java.security, java.util, Classpath Hooks
@section java.io
@section java.io
 
 
The @code{java.io} package is heavily reliant on access to the I/O facilities
The @code{java.io} package is heavily reliant on access to the I/O facilities
of the underlying platform.  As far as its VM hooks go, they provide two
of the underlying platform.  As far as its VM hooks go, they provide two
areas of functionality to GNU Classpath, these being
areas of functionality to GNU Classpath, these being
 
 
@itemize @bullet
@itemize @bullet
@item File and directory queries and manipulation
@item File and directory queries and manipulation
@item Serialization of objects
@item Serialization of objects
@end itemize
@end itemize
 
 
The first corresponds directly to most of the @code{File} class, while
The first corresponds directly to most of the @code{File} class, while
the latter underlies the functionality provided by the
the latter underlies the functionality provided by the
@code{ObjectInputStream} and @code{ObjectOutputStream}.  More low-level I/O
@code{ObjectInputStream} and @code{ObjectOutputStream}.  More low-level I/O
is provided by @ref{java.nio}.
is provided by @ref{java.nio}.
 
 
@menu
@menu
* java.io.VMFile::
* java.io.VMFile::
* java.io.VMObjectInputStream::
* java.io.VMObjectInputStream::
* java.io.VMObjectStreamClass::
* java.io.VMObjectStreamClass::
@end menu
@end menu
 
 
@node java.io.VMFile,java.io.VMObjectInputStream,java.io,java.io
@node java.io.VMFile,java.io.VMObjectInputStream,java.io,java.io
@subsection @code{java.io.VMFile}
@subsection @code{java.io.VMFile}
 
 
@code{VMFile} allows GNU Classpath's @code{File} representations to
@code{VMFile} allows GNU Classpath's @code{File} representations to
probe and modify the file system using the native functions of the
probe and modify the file system using the native functions of the
platform.  The default implementation (which consists of both a
platform.  The default implementation (which consists of both a
@code{VMFile} class and the native methods) is primarily UNIX-centric,
@code{VMFile} class and the native methods) is primarily UNIX-centric,
working with POSIX functions and assuming case-sensitive filenames,
working with POSIX functions and assuming case-sensitive filenames,
without the restriction of the 8.3 format.  It consists mainly of
without the restriction of the 8.3 format.  It consists mainly of
@code{static} @code{native} methods, with a few Java helper methods.
@code{static} @code{native} methods, with a few Java helper methods.
The native methods represent the file as a string containing its path,
The native methods represent the file as a string containing its path,
rather than using the object itself.
rather than using the object itself.
 
 
@itemize @bullet
@itemize @bullet
@item Native Methods
@item Native Methods
@itemize @bullet
@itemize @bullet
@item @code{lastModified(String)} -- The native method should return a
@item @code{lastModified(String)} -- The native method should return a
@code{long} value that represents the last modified date of the file.
@code{long} value that represents the last modified date of the file.
@item @code{setReadOnly(String)} -- Sets the file's permissions to read only,
@item @code{setReadOnly(String)} -- Sets the file's permissions to read only,
in whichever way this is realised by the platform.
in whichever way this is realised by the platform.
@item @code{create(String)} -- Create the named file.
@item @code{create(String)} -- Create the named file.
@item @code{list(String)} -- The native method opens the named directory,
@item @code{list(String)} -- The native method opens the named directory,
reads the contents and returns them as a Java @code{String} array.
reads the contents and returns them as a Java @code{String} array.
@item @code{renameTo(String,String)} -- Renames the first file to the second.
@item @code{renameTo(String,String)} -- Renames the first file to the second.
@item @code{length(String)} -- Returns a @code{long} value representing
@item @code{length(String)} -- Returns a @code{long} value representing
the file size.
the file size.
@item @code{exists(String)} -- Tests for the existence of the named file
@item @code{exists(String)} -- Tests for the existence of the named file
or directory.
or directory.
@item @code{delete(String)} -- Deletes the file or directory.
@item @code{delete(String)} -- Deletes the file or directory.
@item @code{setLastModified(String,long)} -- Change the last modified time.
@item @code{setLastModified(String,long)} -- Change the last modified time.
@item @code{mkdir(String)} -- Creates the named directory.
@item @code{mkdir(String)} -- Creates the named directory.
@item @code{isFile(String)} -- Tests that the named path references a file.
@item @code{isFile(String)} -- Tests that the named path references a file.
@item @code{canWrite(String)} -- Tests that the file can be written to.
@item @code{canWrite(String)} -- Tests that the file can be written to.
This method is @code{synchronized}, so the object is locked during the check.
This method is @code{synchronized}, so the object is locked during the check.
@item @code{canRead(String)} -- Complement of the last method.
@item @code{canRead(String)} -- Complement of the last method.
@item @code{isDirectory(String)} -- Tests that the named path references
@item @code{isDirectory(String)} -- Tests that the named path references
a directory.
a directory.
@end itemize
@end itemize
@item Java Helper Methods
@item Java Helper Methods
@itemize @bullet
@itemize @bullet
@item @code{canWriteDirectory(File)} -- Checks that the directory can be
@item @code{canWriteDirectory(File)} -- Checks that the directory can be
written to, by trying to create a temporary file in it.
written to, by trying to create a temporary file in it.
@item @code{listRoots()} -- Returns the root of a GNU filesystem, i.e.@: `/'
@item @code{listRoots()} -- Returns the root of a GNU filesystem, i.e.@: `/'
in an array.
in an array.
@item @code{isHidden(String)} -- Checks whether the file starts with `.',
@item @code{isHidden(String)} -- Checks whether the file starts with `.',
which is how files are hidden on UNIX-style systems.
which is how files are hidden on UNIX-style systems.
@item @code{getName(String)} -- Pulls the actual filename from the end of
@item @code{getName(String)} -- Pulls the actual filename from the end of
the path, by breaking off the characters after the last occurrence of the
the path, by breaking off the characters after the last occurrence of the
platform's file separator.
platform's file separator.
@item @code{getCanonicalForm(String)} -- This converts a UNIX path to
@item @code{getCanonicalForm(String)} -- This converts a UNIX path to
its canonical form by removing the `.' and `..' sections that occur within.
its canonical form by removing the `.' and `..' sections that occur within.
@end itemize
@end itemize
@end itemize
@end itemize
 
 
@node java.io.VMObjectInputStream,java.io.VMObjectStreamClass,java.io.VMFile,java.io
@node java.io.VMObjectInputStream,java.io.VMObjectStreamClass,java.io.VMFile,java.io
@subsection @code{java.io.VMObjectInputStream}
@subsection @code{java.io.VMObjectInputStream}
 
 
This class consists of two methods which provide functionality used in
This class consists of two methods which provide functionality used in
deserializing an object.  @code{currentClassLoader()} provides the first
deserializing an object.  @code{currentClassLoader()} provides the first
user-defined class loader from the class context
user-defined class loader from the class context
(@xref{gnu.classpath.VMStackWalker},) via a @code{PrivilegedAction}.
(@xref{gnu.classpath.VMStackWalker},) via a @code{PrivilegedAction}.
@code{allocateObject(Class,Class,Constructor)} is a @code{native} method
@code{allocateObject(Class,Class,Constructor)} is a @code{native} method
(a reference implementation is provided) which creates an object but
(a reference implementation is provided) which creates an object but
calls the constructor of another class, which is a superclass of the
calls the constructor of another class, which is a superclass of the
object's class.
object's class.
 
 
@node java.io.VMObjectStreamClass,,java.io.VMObjectInputStream,java.io
@node java.io.VMObjectStreamClass,,java.io.VMObjectInputStream,java.io
@subsection @code{java.io.VMObjectStreamClass}
@subsection @code{java.io.VMObjectStreamClass}
 
 
@code{VMObjectStreamClass} is a series of @code{static} @code{native}
@code{VMObjectStreamClass} is a series of @code{static} @code{native}
methods that provide some of the groundwork for @code{ObjectStreamClass}
methods that provide some of the groundwork for @code{ObjectStreamClass}
and @code{ObjectStreamField}.  @code{hasClassInitializer(Class)} works
and @code{ObjectStreamField}.  @code{hasClassInitializer(Class)} works
with the former, and checks for the presence of a static initializer.
with the former, and checks for the presence of a static initializer.
The remaining methods are of the form @code{setXXXNative(Field,Object,XXX)}
The remaining methods are of the form @code{setXXXNative(Field,Object,XXX)}
and support @code{ObjectStreamField}.  One exists for each of the main types
and support @code{ObjectStreamField}.  One exists for each of the main types
(boolean, float, double, long, int, short, char, byte and object) and is used
(boolean, float, double, long, int, short, char, byte and object) and is used
to set the specified field in the supplied instance to the given value.
to set the specified field in the supplied instance to the given value.
 
 
A default implementation is provided for all of them, so a VM implementation
A default implementation is provided for all of them, so a VM implementation
is optional.
is optional.
 
 
@node java.security, java.net, java.io, Classpath Hooks
@node java.security, java.net, java.io, Classpath Hooks
@section java.security
@section java.security
 
 
The @code{java.security} package provides support for Java's security
The @code{java.security} package provides support for Java's security
architecture.
architecture.
 
 
@menu
@menu
* java.security.VMAccessController::
* java.security.VMAccessController::
* java.security.VMSecureRandom::
* java.security.VMSecureRandom::
@end menu
@end menu
 
 
@node java.security.VMAccessController,java.security.VMSecureRandom,java.security,java.security
@node java.security.VMAccessController,java.security.VMSecureRandom,java.security,java.security
@subsection @code{java.security.VMAccessController}
@subsection @code{java.security.VMAccessController}
 
 
The @code{AccessController} is used to perform privileged actions.  Its
The @code{AccessController} is used to perform privileged actions.  Its
hook class, @code{VMAccessController}, maintains the
hook class, @code{VMAccessController}, maintains the
@code{AccessControlContext} and the default implementation is purely
@code{AccessControlContext} and the default implementation is purely
Java-based.  The VM may choose to replace this with their own.
Java-based.  The VM may choose to replace this with their own.
The methods in the reference version are as follows:
The methods in the reference version are as follows:
 
 
@itemize @bullet
@itemize @bullet
@item @code{pushContext(AccessControlContext)} -- Adds a new context to the
@item @code{pushContext(AccessControlContext)} -- Adds a new context to the
stack for the current thread.  This is called before a privileged action
stack for the current thread.  This is called before a privileged action
takes place.
takes place.
@item @code{popContext()} -- Removes the top context from the stack.  This
@item @code{popContext()} -- Removes the top context from the stack.  This
is performed after the privileged action takes place.
is performed after the privileged action takes place.
@item @code{getContext()} -- Either derives a context based on the
@item @code{getContext()} -- Either derives a context based on the
@code{ProtectionDomain}s of the call stack (see the next method) or returns
@code{ProtectionDomain}s of the call stack (see the next method) or returns
the top of the context stack.
the top of the context stack.
@item @code{getStack()} -- Provides access to the call stack as a pair of
@item @code{getStack()} -- Provides access to the call stack as a pair of
arrays of classes and method names.  The actual implementation returns
arrays of classes and method names.  The actual implementation returns
an empty array, indicating that there are no permissions.
an empty array, indicating that there are no permissions.
@end itemize
@end itemize
 
 
@node java.security.VMSecureRandom,,java.security.VMAccessController,java.security
@node java.security.VMSecureRandom,,java.security.VMAccessController,java.security
@subsection @code{java.security.VMSecureRandom}
@subsection @code{java.security.VMSecureRandom}
 
 
The @code{VMSecureRandom} class is used to provide access to
The @code{VMSecureRandom} class is used to provide access to
cryptographically secure random numbers.  The default implementation
cryptographically secure random numbers.  The default implementation
of the class runs eight threads that increment counters in a tight
of the class runs eight threads that increment counters in a tight
loop, and XORs each counter to produce one byte of seed data. This is
loop, and XORs each counter to produce one byte of seed data. This is
not very efficient, and is not guaranteed to be random (the thread
not very efficient, and is not guaranteed to be random (the thread
scheduler is probably deterministic, after all). VM implementors
scheduler is probably deterministic, after all). VM implementors
should provide a version of this class, which implements the method
should provide a version of this class, which implements the method
@code{generateSeed(byte[],int,int)}, so that it fills the buffer using
@code{generateSeed(byte[],int,int)}, so that it fills the buffer using
a random seed from a system facility, such as a system entropy
a random seed from a system facility, such as a system entropy
gathering device or hardware random number generator.  The parameters
gathering device or hardware random number generator.  The parameters
are the usual set of buffer, offset and length and the method returns
are the usual set of buffer, offset and length and the method returns
the number of bytes actually generated, which may be less than that
the number of bytes actually generated, which may be less than that
requested.
requested.
 
 
@node java.net, java.nio, java.security, Classpath Hooks
@node java.net, java.nio, java.security, Classpath Hooks
@section java.net
@section java.net
 
 
The @code{java.net} package is heavily reliant on access to the networking
The @code{java.net} package is heavily reliant on access to the networking
facilities of the underlying platform.  The VM hooks provide information
facilities of the underlying platform.  The VM hooks provide information
about the available network interfaces, and access to lookup facilities
about the available network interfaces, and access to lookup facilities
for network addresses.
for network addresses.
 
 
@menu
@menu
* java.net.VMInetAddress::
* java.net.VMInetAddress::
* java.net.VMNetworkInterface::
* java.net.VMNetworkInterface::
@end menu
@end menu
 
 
@node java.net.VMInetAddress,java.net.VMNetworkInterface,java.net,java.net
@node java.net.VMInetAddress,java.net.VMNetworkInterface,java.net,java.net
@subsection @code{java.net.VMInetAddress}
@subsection @code{java.net.VMInetAddress}
 
 
@code{VMInetAddress} is a series of @code{static} @code{native} methods
@code{VMInetAddress} is a series of @code{static} @code{native} methods
which provide access to the platform's lookup facilities.  All the methods
which provide access to the platform's lookup facilities.  All the methods
are implemented by GNU Classpath, making VM implementation optional, and
are implemented by GNU Classpath, making VM implementation optional, and
are as follows:
are as follows:
 
 
@itemize @bullet
@itemize @bullet
@item @code{getLocalHostname()} -- Wraps the @code{gethostname} function, and
@item @code{getLocalHostname()} -- Wraps the @code{gethostname} function, and
falls back on `localhost'.
falls back on `localhost'.
@item @code{lookupInaddrAny()} -- Returns the value of @code{INADDR_ANY}.
@item @code{lookupInaddrAny()} -- Returns the value of @code{INADDR_ANY}.
@item @code{getHostByAddr(byte[])} -- Looks up the hostname based on an IP
@item @code{getHostByAddr(byte[])} -- Looks up the hostname based on an IP
address.
address.
@item @code{getHostByName(String)} -- The reverse of the last method, it
@item @code{getHostByName(String)} -- The reverse of the last method, it
returns the IP addresses which the given host name resolves to.
returns the IP addresses which the given host name resolves to.
@end itemize
@end itemize
 
 
@node java.net.VMNetworkInterface,,java.net.VMInetAddress,java.net
@node java.net.VMNetworkInterface,,java.net.VMInetAddress,java.net
@subsection @code{java.net.VMNetworkInterface}
@subsection @code{java.net.VMNetworkInterface}
 
 
@code{VMNetworkInterface} currently consists of a single @code{static}
@code{VMNetworkInterface} currently consists of a single @code{static}
@code{native} method, @code{getInterfaces()}, which retrieves the
@code{native} method, @code{getInterfaces()}, which retrieves the
network interfaces available on the underlying platform as a @code{Vector}.
network interfaces available on the underlying platform as a @code{Vector}.
The current GNU Classpath implementation is a native stub.
The current GNU Classpath implementation is a native stub.
 
 
@node java.nio, java.nio.channels, java.net, Classpath Hooks
@node java.nio, java.nio.channels, java.net, Classpath Hooks
@section java.nio
@section java.nio
 
 
The @code{java.nio} package is part of the New I/O framework added in
The @code{java.nio} package is part of the New I/O framework added in
Java 1.4.  This splits I/O into the concepts of @emph{buffers},
Java 1.4.  This splits I/O into the concepts of @emph{buffers},
@emph{charsets}, @emph{channels} and @emph{selectors}, and
@emph{charsets}, @emph{channels} and @emph{selectors}, and
@code{java.nio} defines the buffer classes.  As far as native and VM
@code{java.nio} defines the buffer classes.  As far as native and VM
code is concerned, the new package needs support for low-level efficient
code is concerned, the new package needs support for low-level efficient
buffer operations.
buffer operations.
 
 
@menu
@menu
* java.nio.VMDirectByteBuffer::
* java.nio.VMDirectByteBuffer::
@end menu
@end menu
 
 
@node java.nio.VMDirectByteBuffer,,java.nio,java.nio
@node java.nio.VMDirectByteBuffer,,java.nio,java.nio
@subsection @code{java.nio.VMDirectByteBuffer}
@subsection @code{java.nio.VMDirectByteBuffer}
 
 
A @code{ByteBuffer} maintains a buffer of bytes, and allows it to be
A @code{ByteBuffer} maintains a buffer of bytes, and allows it to be
manipulated using primitive operations such as @code{get}, @code{put},
manipulated using primitive operations such as @code{get}, @code{put},
@code{allocate} and @code{free}.  A direct buffer avoids intermediate
@code{allocate} and @code{free}.  A direct buffer avoids intermediate
copying, and uses native data which shouldn't be manipulated by a
copying, and uses native data which shouldn't be manipulated by a
garbage collector.  The VM class consists of @code{static} @code{native}
garbage collector.  The VM class consists of @code{static} @code{native}
methods, all of which are given default implementations by GNU
methods, all of which are given default implementations by GNU
Classpath.
Classpath.
 
 
@itemize @bullet
@itemize @bullet
@item @code{init()} -- Creates an instance of an appropriate
@item @code{init()} -- Creates an instance of an appropriate
@code{gnu.classpath.RawData} class.  This class is not garbage
@code{gnu.classpath.RawData} class.  This class is not garbage
collected, is created natively and is used in the other methods to reference
collected, is created natively and is used in the other methods to reference
the buffered data.
the buffered data.
@item @code{allocate(int)} -- Allocates the memory for the buffer using
@item @code{allocate(int)} -- Allocates the memory for the buffer using
@code{malloc} and returns a reference to the @code{RawData} class.
@code{malloc} and returns a reference to the @code{RawData} class.
@item @code{free(RawData)} -- Frees the memory used by the buffer.
@item @code{free(RawData)} -- Frees the memory used by the buffer.
@item @code{get(RawData,int)}  -- Returns the data at the specified index.
@item @code{get(RawData,int)}  -- Returns the data at the specified index.
@item @code{get(RawData,int,byte[],int,int)} -- Copies a section of the
@item @code{get(RawData,int,byte[],int,int)} -- Copies a section of the
data into a byte array using @code{memcpy}.
data into a byte array using @code{memcpy}.
@item @code{put(RawData,int,byte)} -- Puts the given data in the buffer
@item @code{put(RawData,int,byte)} -- Puts the given data in the buffer
at the specified index.
at the specified index.
@item @code{adjustAddress(RawData,int)} -- Adjusts the pointer into the buffer.
@item @code{adjustAddress(RawData,int)} -- Adjusts the pointer into the buffer.
@item @code{shiftDown(RawData,int,int,int)} -- Moves the content of the buffer
@item @code{shiftDown(RawData,int,int,int)} -- Moves the content of the buffer
at an offset down to a new offset using @code{memmove}.
at an offset down to a new offset using @code{memmove}.
@end itemize
@end itemize
 
 
@node java.nio.channels, gnu.java.nio, java.nio, Classpath Hooks
@node java.nio.channels, gnu.java.nio, java.nio, Classpath Hooks
@section java.nio.channels
@section java.nio.channels
 
 
Channels provide the data for the buffers with the New I/O packages.
Channels provide the data for the buffers with the New I/O packages.
For example, a channel may wrap a file or a socket.  The VM hooks,
For example, a channel may wrap a file or a socket.  The VM hooks,
at the moment, simply allow the channels to be accessed by @code{java.io}
at the moment, simply allow the channels to be accessed by @code{java.io}
streams.
streams.
 
 
@menu
@menu
* java.nio.channels.VMChannels::
* java.nio.channels.VMChannels::
@end menu
@end menu
 
 
@node java.nio.channels.VMChannels,,java.nio.channels,java.nio.channels
@node java.nio.channels.VMChannels,,java.nio.channels,java.nio.channels
@subsection @code{java.nio.channels.VMChannels}
@subsection @code{java.nio.channels.VMChannels}
 
 
@code{VMChannels} provides the methods that create the channels or
@code{VMChannels} provides the methods that create the channels or
streams.  The default implementation is in pure Java and simply wraps
streams.  The default implementation is in pure Java and simply wraps
the channels in standard I/O classes from @code{java.io}.
the channels in standard I/O classes from @code{java.io}.
 
 
@itemize @bullet
@itemize @bullet
@item @code{createStream(Class,Channel)} -- Creates a @code{FileChannel}
@item @code{createStream(Class,Channel)} -- Creates a @code{FileChannel}
which wraps an instance of the specified stream class, created by reflection.
which wraps an instance of the specified stream class, created by reflection.
This method is private, and is used by the other two.
This method is private, and is used by the other two.
@item @code{newInputStream(ReadableByteChannel)} -- Wraps the channel
@item @code{newInputStream(ReadableByteChannel)} -- Wraps the channel
in a @code{FileInputStream}.
in a @code{FileInputStream}.
@item @code{newOutputStream(WritableByteChannel)} -- Wraps the channel
@item @code{newOutputStream(WritableByteChannel)} -- Wraps the channel
in a @code{FileOutputStream}.
in a @code{FileOutputStream}.
@end itemize
@end itemize
 
 
@node gnu.java.nio, java.lang.reflect, java.nio.channels, Classpath Hooks
@node gnu.java.nio, java.lang.reflect, java.nio.channels, Classpath Hooks
@section gnu.java.nio
@section gnu.java.nio
 
 
The @code{gnu.java.nio} class provides Classpath implementations of the
The @code{gnu.java.nio} class provides Classpath implementations of the
interfaces provided by @code{java.nio}.  The VM classes provide the native
interfaces provided by @code{java.nio}.  The VM classes provide the native
support necessary to implement @emph{pipes} and @emph{selectors}.
support necessary to implement @emph{pipes} and @emph{selectors}.
 
 
@menu
@menu
* gnu.java.nio.VMPipe::
* gnu.java.nio.VMPipe::
* gnu.java.nio.VMSelector::
* gnu.java.nio.VMSelector::
@end menu
@end menu
 
 
@node gnu.java.nio.VMPipe,gnu.java.nio.VMSelector,gnu.java.nio,gnu.java.nio
@node gnu.java.nio.VMPipe,gnu.java.nio.VMSelector,gnu.java.nio,gnu.java.nio
@subsection @code{gnu.java.nio.VMPipe}
@subsection @code{gnu.java.nio.VMPipe}
 
 
@code{VMPipe} provides the native functionality for a uni-directional pipe
@code{VMPipe} provides the native functionality for a uni-directional pipe
between a source and a destination (sink) channel.  It consists of one
between a source and a destination (sink) channel.  It consists of one
@code{static} @code{native} method, @code{init(PipeImpl,SelectorProvider)},
@code{static} @code{native} method, @code{init(PipeImpl,SelectorProvider)},
the reference implementation of which is currently a native stub.  Ideally,
the reference implementation of which is currently a native stub.  Ideally,
this should initialise the pipe at the native level.
this should initialise the pipe at the native level.
 
 
@node gnu.java.nio.VMSelector,,gnu.java.nio.VMPipe,gnu.java.nio
@node gnu.java.nio.VMSelector,,gnu.java.nio.VMPipe,gnu.java.nio
@subsection @code{gnu.java.nio.VMSelector}
@subsection @code{gnu.java.nio.VMSelector}
 
 
A @code{Selector} selects between multiple @code{SelectableChannel}s based
A @code{Selector} selects between multiple @code{SelectableChannel}s based
on their readiness and a key set.  The VM hook for the Classpath implementation
on their readiness and a key set.  The VM hook for the Classpath implementation
of this is @code{VMSelector}, and this allows the actual @code{select()}
of this is @code{VMSelector}, and this allows the actual @code{select()}
operation to be performed.  This is represented by the @code{static}
operation to be performed.  This is represented by the @code{static}
@code{native} method, @code{select(int[],int[],int[],long)}, and a default
@code{native} method, @code{select(int[],int[],int[],long)}, and a default
implementation of this is provided.
implementation of this is provided.
 
 
@node java.lang.reflect, gnu.java.lang, gnu.java.nio, Classpath Hooks
@node java.lang.reflect, gnu.java.lang, gnu.java.nio, Classpath Hooks
@section @code{java.lang.reflect}
@section @code{java.lang.reflect}
@code{java.lang.reflect} provides the interface to Java's reflection
@code{java.lang.reflect} provides the interface to Java's reflection
facilities.  Via reflection, programmers can obtain type information about
facilities.  Via reflection, programmers can obtain type information about
a particular instance at runtime or dynamically create new instances.
a particular instance at runtime or dynamically create new instances.
 
 
@menu
@menu
* java.lang.reflect.VMArray::
* java.lang.reflect.VMArray::
@end menu
@end menu
 
 
@node java.lang.reflect.VMArray,,,java.lang.reflect
@node java.lang.reflect.VMArray,,,java.lang.reflect
@subsection @code{java.lang.reflect.VMArray}
@subsection @code{java.lang.reflect.VMArray}
 
 
The @code{VMArray} class provides a hook, @code{createObjectArray},
The @code{VMArray} class provides a hook, @code{createObjectArray},
which the VM uses to generate a new non-primitive array of a
which the VM uses to generate a new non-primitive array of a
particular class and size.  The default implementation simply passes
particular class and size.  The default implementation simply passes
the job down to the standard JNI function, @code{NewObjectArray}.
the job down to the standard JNI function, @code{NewObjectArray}.
 
 
@node gnu.java.lang, gnu.java.lang.management, java.lang.reflect, Classpath Hooks
@node gnu.java.lang, gnu.java.lang.management, java.lang.reflect, Classpath Hooks
@section @code{gnu.java.lang}
@section @code{gnu.java.lang}
 
 
@code{gnu.java.lang} provides VM interfaces for the GNU
@code{gnu.java.lang} provides VM interfaces for the GNU
implementations of features in java.lang.  Currently, this includes the
implementations of features in java.lang.  Currently, this includes the
implementation of instrumentation.
implementation of instrumentation.
 
 
@menu
@menu
* gnu.java.lang.VMInstrumentationImpl::
* gnu.java.lang.VMInstrumentationImpl::
@end menu
@end menu
 
 
@node gnu.java.lang.VMInstrumentationImpl,,,gnu.java.lang
@node gnu.java.lang.VMInstrumentationImpl,,,gnu.java.lang
@subsection @code{gnu.java.lang.VMInstrumentationImpl}
@subsection @code{gnu.java.lang.VMInstrumentationImpl}
 
 
The @code{gnu.java.lang.VMInstrumentationImpl} and
The @code{gnu.java.lang.VMInstrumentationImpl} and
@code{gnu.java.lang.InstrumentationImpl} classes provide an implementation of the
@code{gnu.java.lang.InstrumentationImpl} classes provide an implementation of the
@code{java.lang.instrument.Instrument} interface.
@code{java.lang.instrument.Instrument} interface.
A @code{InstrumentationImpl} object should be created by the VM when agents
A @code{InstrumentationImpl} object should be created by the VM when agents
are given in the command line (see the @code{java.lang.instrument} package
are given in the command line (see the @code{java.lang.instrument} package
documentation). The VM has to set the static field
documentation). The VM has to set the static field
@code{VMClassLoader.instrumenter} to this object. The VM should implement the
@code{VMClassLoader.instrumenter} to this object. The VM should implement the
static native methods of the @code{VMInstrumentationImpl} class.
static native methods of the @code{VMInstrumentationImpl} class.
 
 
@itemize @bullet
@itemize @bullet
@item @code{isRedefineClassesSupported()} -- Returns true if the JVM supports
@item @code{isRedefineClassesSupported()} -- Returns true if the JVM supports
class redefinition.
class redefinition.
@item @code{redefineClasses()} -- Gives a set of classes with new bytecodes.
@item @code{redefineClasses()} -- Gives a set of classes with new bytecodes.
The VM must redefine the classes by reading the new bytecodes.
The VM must redefine the classes by reading the new bytecodes.
@item @code{getAllLoadedClass()} -- Returns an array of all loaded classes.
@item @code{getAllLoadedClass()} -- Returns an array of all loaded classes.
@item @code{getInitiatedClass()} -- Returns an array of all classes loaded
@item @code{getInitiatedClass()} -- Returns an array of all classes loaded
by a specific class loader.
by a specific class loader.
@item @code{getObjectSize()} -- Gives the size of an object.
@item @code{getObjectSize()} -- Gives the size of an object.
@end itemize
@end itemize
 
 
Instrumentation allows to modify the bytecode of a class before it gets read
Instrumentation allows to modify the bytecode of a class before it gets read
by the VM@. In GNU Classpath, the @code{ClassLoader.defineClass} method calls
by the VM@. In GNU Classpath, the @code{ClassLoader.defineClass} method calls
the @code{VMClassLoader.defineClassWithTransformers} method which first checks
the @code{VMClassLoader.defineClassWithTransformers} method which first checks
if @code{VMClassLoader.instrumenter} is @code{null}. If it's the case, it
if @code{VMClassLoader.instrumenter} is @code{null}. If it's the case, it
directly calls @code{VMClassLoader.defineClass}. If it's not the case, the
directly calls @code{VMClassLoader.defineClass}. If it's not the case, the
method calls at first the @code{InstrumentationImpl.callTransformers} method,
method calls at first the @code{InstrumentationImpl.callTransformers} method,
which calls each transformer registered to the @code{InstrumentationImpl}
which calls each transformer registered to the @code{InstrumentationImpl}
object and returns a new bytecode array. Then, it calls the
object and returns a new bytecode array. Then, it calls the
@code{VMClassLoader.defineClass} method with this new bytecode array.
@code{VMClassLoader.defineClass} method with this new bytecode array.
 
 
The second use of instrumentation is to redefine a class after it has been
The second use of instrumentation is to redefine a class after it has been
loaded by the VM@. This is done in the Java application by calling the
loaded by the VM@. This is done in the Java application by calling the
@code{Instrumentation.redefineClasses} method of the standard interface on
@code{Instrumentation.redefineClasses} method of the standard interface on
a @code{Instrumentation} object. The @code{InstrumentationImpl.redefineClasses}
a @code{Instrumentation} object. The @code{InstrumentationImpl.redefineClasses}
method calls the @code{VMInstrumentationImpl.redefineClasses} native method
method calls the @code{VMInstrumentationImpl.redefineClasses} native method
which must be implemented by the VM@. The implementation should call the
which must be implemented by the VM@. The implementation should call the
@code{InstrumentationImpl.callTransformers} method.
@code{InstrumentationImpl.callTransformers} method.
 
 
@node gnu.java.lang.management, java.lang.management, gnu.java.lang, Classpath Hooks
@node gnu.java.lang.management, java.lang.management, gnu.java.lang, Classpath Hooks
@section @code{gnu.java.lang.management}
@section @code{gnu.java.lang.management}
 
 
@code{gnu.java.lang.management} provides the VM interfaces for the GNU
@code{gnu.java.lang.management} provides the VM interfaces for the GNU
implementations of the management beans.
implementations of the management beans.
 
 
@menu
@menu
* gnu.java.lang.management.VMRuntimeMXBeanImpl::
* gnu.java.lang.management.VMRuntimeMXBeanImpl::
* gnu.java.lang.management.VMClassLoadingMXBeanImpl::
* gnu.java.lang.management.VMClassLoadingMXBeanImpl::
* gnu.java.lang.management.VMThreadMXBeanImpl::
* gnu.java.lang.management.VMThreadMXBeanImpl::
* gnu.java.lang.management.VMMemoryMXBeanImpl::
* gnu.java.lang.management.VMMemoryMXBeanImpl::
* gnu.java.lang.management.VMCompilationMXBeanImpl::
* gnu.java.lang.management.VMCompilationMXBeanImpl::
* gnu.java.lang.management.VMMemoryPoolMXBeanImpl::
* gnu.java.lang.management.VMMemoryPoolMXBeanImpl::
* gnu.java.lang.management.VMMemoryManagerMXBeanImpl::
* gnu.java.lang.management.VMMemoryManagerMXBeanImpl::
* gnu.java.lang.management.VMGarbageCollectorMXBeanImpl::
* gnu.java.lang.management.VMGarbageCollectorMXBeanImpl::
@end menu
@end menu
 
 
@node gnu.java.lang.management.VMRuntimeMXBeanImpl,gnu.java.lang.management.VMClassLoadingMXBeanImpl,,gnu.java.lang.management
@node gnu.java.lang.management.VMRuntimeMXBeanImpl,gnu.java.lang.management.VMClassLoadingMXBeanImpl,,gnu.java.lang.management
@subsection @code{gnu.java.lang.management.VMRuntimeMXBeanImpl}
@subsection @code{gnu.java.lang.management.VMRuntimeMXBeanImpl}
 
 
The @code{gnu.java.lang.management.RuntimeMXBeanImpl} provides an
The @code{gnu.java.lang.management.RuntimeMXBeanImpl} provides an
implementation of the @code{java.lang.management.RuntimeMXBean} interface,
implementation of the @code{java.lang.management.RuntimeMXBean} interface,
and is supported by VM functionality in the form of
and is supported by VM functionality in the form of
@code{gnu.java.lang.management.VMRuntimeMXBeanImpl}.  This provides a
@code{gnu.java.lang.management.VMRuntimeMXBeanImpl}.  This provides a
series of methods, which should be implemented by the virtual machine
series of methods, which should be implemented by the virtual machine
in order to provide the required information for the bean.  The VM
in order to provide the required information for the bean.  The VM
methods are generally representative of information that is only
methods are generally representative of information that is only
available from the virtual machine, such as the command-line arguments
available from the virtual machine, such as the command-line arguments
it was given at startup.
it was given at startup.
 
 
The methods are as follows:
The methods are as follows:
 
 
@itemize @bullet
@itemize @bullet
@item @code{(getInputArguments())} -- The VM should supply
@item @code{(getInputArguments())} -- The VM should supply
a @code{String} array containing each of the command-line
a @code{String} array containing each of the command-line
arguments, excluding those that are directed at the
arguments, excluding those that are directed at the
@code{main()} method.  The reference implementation expects
@code{main()} method.  The reference implementation expects
this to be a native method.
this to be a native method.
@item @code{(getName())} -- The VM developer should choose
@item @code{(getName())} -- The VM developer should choose
an appropriate name for the virtual machine.  This name can
an appropriate name for the virtual machine.  This name can
be instance-specific e.g.@: it can include things like the
be instance-specific e.g.@: it can include things like the
process identifier or host name of the machine, which only
process identifier or host name of the machine, which only
apply to the current running instance.  Thus, the intention is
apply to the current running instance.  Thus, the intention is
that this name refers to the entity that the other information
that this name refers to the entity that the other information
refers to, rather than the VM in general.  The reference
refers to, rather than the VM in general.  The reference
implementation supplies a default concatenation of the VM
implementation supplies a default concatenation of the VM
name and version.
name and version.
@item @code{(getStartTime())} -- This should return the number
@item @code{(getStartTime())} -- This should return the number
of milliseconds at which the virtual machine was started.
of milliseconds at which the virtual machine was started.
The uptime property of the bean is provided relative to this
The uptime property of the bean is provided relative to this
value.  Again, the reference implementation also expects
value.  Again, the reference implementation also expects
this method to be native.
this method to be native.
@end itemize
@end itemize
 
 
The virtual machine also needs to provide either the
The virtual machine also needs to provide either the
@code{sun.boot.class.path} or @code{java.boot.class.path}
@code{sun.boot.class.path} or @code{java.boot.class.path}
property in order to support the optional boot class path
property in order to support the optional boot class path
retrieval functionality.
retrieval functionality.
 
 
@node gnu.java.lang.management.VMClassLoadingMXBeanImpl,gnu.java.lang.management.VMThreadMXBeanImpl,gnu.java.lang.management.VMRuntimeMXBeanImpl,gnu.java.lang.management
@node gnu.java.lang.management.VMClassLoadingMXBeanImpl,gnu.java.lang.management.VMThreadMXBeanImpl,gnu.java.lang.management.VMRuntimeMXBeanImpl,gnu.java.lang.management
@subsection @code{gnu.java.lang.management.VMClassLoadingMXBeanImpl}
@subsection @code{gnu.java.lang.management.VMClassLoadingMXBeanImpl}
 
 
The @code{gnu.java.lang.management.ClassLoadingMXBeanImpl} provides an
The @code{gnu.java.lang.management.ClassLoadingMXBeanImpl} provides an
implementation of the @code{java.lang.management.ClassLoadingMXBean} interface,
implementation of the @code{java.lang.management.ClassLoadingMXBean} interface,
and is supported by VM functionality in the form of
and is supported by VM functionality in the form of
@code{gnu.java.lang.management.VMClassLoadingMXBeanImpl}.  This provides a
@code{gnu.java.lang.management.VMClassLoadingMXBeanImpl}.  This provides a
series of methods, which should be implemented by the virtual machine
series of methods, which should be implemented by the virtual machine
in order to provide the required information for the bean.  Implementing
in order to provide the required information for the bean.  Implementing
this bean requires the VM to monitor when classes are loaded and unloaded,
this bean requires the VM to monitor when classes are loaded and unloaded,
and provide the option of verbose class loading output.
and provide the option of verbose class loading output.
 
 
The methods are as follows:
The methods are as follows:
 
 
@itemize @bullet
@itemize @bullet
@item @code{(getLoadedClassCount())} -- This should return
@item @code{(getLoadedClassCount())} -- This should return
the number of classes that are currently loaded by the VM.
the number of classes that are currently loaded by the VM.
@item @code{(getUnloadedClassCount())} -- This should return
@item @code{(getUnloadedClassCount())} -- This should return
the number of classes that have been loaded by the VM, but
the number of classes that have been loaded by the VM, but
have since been unloaded.
have since been unloaded.
@item @code{(isVerbose())} -- This should return @code{true}
@item @code{(isVerbose())} -- This should return @code{true}
or @code{false}, depending on whether verbose class loading
or @code{false}, depending on whether verbose class loading
output is turned or not, respectively.
output is turned or not, respectively.
@item @code{(setVerbose(boolean))} -- This should allow the
@item @code{(setVerbose(boolean))} -- This should allow the
verbose class loading output to be turned on and off.
verbose class loading output to be turned on and off.
@end itemize
@end itemize
 
 
@node gnu.java.lang.management.VMThreadMXBeanImpl,gnu.java.lang.management.VMMemoryMXBeanImpl,gnu.java.lang.management.VMClassLoadingMXBeanImpl,gnu.java.lang.management
@node gnu.java.lang.management.VMThreadMXBeanImpl,gnu.java.lang.management.VMMemoryMXBeanImpl,gnu.java.lang.management.VMClassLoadingMXBeanImpl,gnu.java.lang.management
@subsection @code{gnu.java.lang.management.VMThreadMXBeanImpl}
@subsection @code{gnu.java.lang.management.VMThreadMXBeanImpl}
 
 
The @code{gnu.java.lang.management.ThreadMXBeanImpl} provides an
The @code{gnu.java.lang.management.ThreadMXBeanImpl} provides an
implementation of the @code{java.lang.management.ThreadMXBean} interface,
implementation of the @code{java.lang.management.ThreadMXBean} interface,
and is supported by VM functionality in the form of
and is supported by VM functionality in the form of
@code{gnu.java.lang.management.VMThreadMXBeanImpl}.  This provides a
@code{gnu.java.lang.management.VMThreadMXBeanImpl}.  This provides a
series of methods, which should be implemented by the virtual machine
series of methods, which should be implemented by the virtual machine
in order to provide the required information for the bean.  Implementing
in order to provide the required information for the bean.  Implementing
this bean requires the VM to monitor thread-related statistics such as
this bean requires the VM to monitor thread-related statistics such as
how often the blocked and waiting states have been entered, as well as
how often the blocked and waiting states have been entered, as well as
additional optional support for time and contention monitoring.
additional optional support for time and contention monitoring.
 
 
Optional support is determined by the following properties:
Optional support is determined by the following properties:
 
 
@itemize @bullet
@itemize @bullet
@item @code{gnu.java.lang.management.CurrentThreadTimeSupport} --
@item @code{gnu.java.lang.management.CurrentThreadTimeSupport} --
This property should be present if the VM supports monitoring the
This property should be present if the VM supports monitoring the
time used by the current thread.  If time monitoring for all threads
time used by the current thread.  If time monitoring for all threads
is supported, this need not be provided.
is supported, this need not be provided.
@item @code{gnu.java.lang.management.ThreadTimeSupport} --
@item @code{gnu.java.lang.management.ThreadTimeSupport} --
This property should be present if the VM supports monitoring the
This property should be present if the VM supports monitoring the
time used by all threads.
time used by all threads.
@item @code{gnu.java.lang.management.ThreadContentionSupport} --
@item @code{gnu.java.lang.management.ThreadContentionSupport} --
This property should be present if the VM supports thread contention
This property should be present if the VM supports thread contention
monitoring.
monitoring.
@item @code{gnu.java.lang.management.MonitorUsageMonitoringSupport} --
@item @code{gnu.java.lang.management.MonitorUsageMonitoringSupport} --
This property should be present if the VM supports the monitoring
This property should be present if the VM supports the monitoring
of object monitor usage.
of object monitor usage.
@item @code{gnu.java.lang.management.OwnableSynchronizerUsageMonitoringSupport} --
@item @code{gnu.java.lang.management.OwnableSynchronizerUsageMonitoringSupport} --
This property should be present if the VM supports the monitoring
This property should be present if the VM supports the monitoring
of ownable synchronizer usage.
of ownable synchronizer usage.
@end itemize
@end itemize
 
 
In addition, the property
In addition, the property
@code{gnu.java.lang.management.ThreadTimeInitallyEnabled} may be
@code{gnu.java.lang.management.ThreadTimeInitallyEnabled} may be
set to the @code{String} value, @code{"true"}, if time monitoring
set to the @code{String} value, @code{"true"}, if time monitoring
is enabled at startup.
is enabled at startup.
 
 
The methods are as follows:
The methods are as follows:
 
 
@itemize @bullet
@itemize @bullet
@item @code{(findDeadlockedThreads())} -- This should return
@item @code{(findDeadlockedThreads())} -- This should return
an array of thread identifiers which match threads involved in
an array of thread identifiers which match threads involved in
deadlock cycles (where each thread is waiting to obtain a lock
deadlock cycles (where each thread is waiting to obtain a lock
held by one of the others) on object monitors or ownable
held by one of the others) on object monitors or ownable
synchronizers.  This is specified as a native method in the
synchronizers.  This is specified as a native method in the
reference implementation, and is optional.  It is only called
reference implementation, and is optional.  It is only called
when the VM supports ownable synchronizer monitoring.
when the VM supports ownable synchronizer monitoring.
@item @code{(findMonitorDeadlockedThreads())} -- This should return
@item @code{(findMonitorDeadlockedThreads())} -- This should return
an array of thread identifiers which match threads involved in
an array of thread identifiers which match threads involved in
deadlock cycles (where each thread is waiting to obtain a lock
deadlock cycles (where each thread is waiting to obtain a lock
held by one of the others) on object monitors.  This is specified
held by one of the others) on object monitors.  This is specified
as a native method in the reference implementation.
as a native method in the reference implementation.
@item @code{(getAllThreads())} -- This should return an array of
@item @code{(getAllThreads())} -- This should return an array of
all live threads and set the @code{filled} variable to the number
all live threads and set the @code{filled} variable to the number
found.  A default implementation is provided.
found.  A default implementation is provided.
@item @code{(getAllThreadIds())} -- This should return an array of
@item @code{(getAllThreadIds())} -- This should return an array of
all live thread identifiers.  An implementation is provided against
all live thread identifiers.  An implementation is provided against
@code{getAllThreads()} by default.
@code{getAllThreads()} by default.
@item @code{(getCurrentThreadCpuTime())} -- This should return the
@item @code{(getCurrentThreadCpuTime())} -- This should return the
approximate number of nanoseconds of CPU time the current thread
approximate number of nanoseconds of CPU time the current thread
has used.  This is an optional native method, which is used by VMs
has used.  This is an optional native method, which is used by VMs
supporting time monitoring.
supporting time monitoring.
@item @code{(getCurrentThreadUserTime())} -- This should return the
@item @code{(getCurrentThreadUserTime())} -- This should return the
approximate number of nanoseconds of user time the current thread
approximate number of nanoseconds of user time the current thread
has used.  This is an optional native method, which is used by VMs
has used.  This is an optional native method, which is used by VMs
supporting time monitoring.
supporting time monitoring.
@item @code{(getDaemonThreadCount())} -- This should return the number
@item @code{(getDaemonThreadCount())} -- This should return the number
of live daemon threads.  A default implementation is provided, based
of live daemon threads.  A default implementation is provided, based
on @code{getAllThreads()}.
on @code{getAllThreads()}.
@item @code{(getLockInfo(ThreadInfo))} -- This is an optional native
@item @code{(getLockInfo(ThreadInfo))} -- This is an optional native
method called when the VM supports ownable synchronizer usage monitoring
method called when the VM supports ownable synchronizer usage monitoring
and the user has requested information for a particular thread.  The
and the user has requested information for a particular thread.  The
supplied @code{ThreadInfo} object should be filled out with an
supplied @code{ThreadInfo} object should be filled out with an
array of @code{LockInfo} objects, providing details on each lock.
array of @code{LockInfo} objects, providing details on each lock.
@item @code{(getMonitorInfo(ThreadInfo))} -- This is an optional native
@item @code{(getMonitorInfo(ThreadInfo))} -- This is an optional native
method called when the VM supports object monitor usage monitoring
method called when the VM supports object monitor usage monitoring
and the user has requested information for a particular thread.  The
and the user has requested information for a particular thread.  The
supplied @code{ThreadInfo} object should be filled out with an
supplied @code{ThreadInfo} object should be filled out with an
array of @code{MonitorInfo} objects, providing details on each lock.
array of @code{MonitorInfo} objects, providing details on each lock.
@item @code{(getPeakThreadCount())} -- The VM should maintain a record
@item @code{(getPeakThreadCount())} -- The VM should maintain a record
of the peak number of live threads, and return it when this method is
of the peak number of live threads, and return it when this method is
called.  This is specified as a native method in the reference
called.  This is specified as a native method in the reference
implementation.
implementation.
@item @code{(resetPeakThreadCount())} -- This should reset the record
@item @code{(resetPeakThreadCount())} -- This should reset the record
of the peak number of live threads to the current number of live
of the peak number of live threads to the current number of live
threads.  This is specified as a native method in the reference
threads.  This is specified as a native method in the reference
implementation.
implementation.
@item @code{(getThreadCount())} -- This should return the number of
@item @code{(getThreadCount())} -- This should return the number of
live threads.  A default implementation is provided, based on
live threads.  A default implementation is provided, based on
@code{getAllThreads()}.
@code{getAllThreads()}.
@item @code{(getThreadCpuTime(long))} -- This should return the
@item @code{(getThreadCpuTime(long))} -- This should return the
approximate number of nanoseconds of CPU time the specified thread
approximate number of nanoseconds of CPU time the specified thread
has used.  This is an optional native method, which is used by VMs
has used.  This is an optional native method, which is used by VMs
supporting time monitoring.
supporting time monitoring.
@item @code{(getThreadUserTime(long))} -- This should return the
@item @code{(getThreadUserTime(long))} -- This should return the
approximate number of nanoseconds of CPU time the specified thread
approximate number of nanoseconds of CPU time the specified thread
has used.  This is an optional native method, which is used by VMs
has used.  This is an optional native method, which is used by VMs
supporting time monitoring.
supporting time monitoring.
@item @code{(getThreadInfoForId(long, int))} -- This return an instance
@item @code{(getThreadInfoForId(long, int))} -- This return an instance
of @code{java.lang.management.ThreadInfo} for the specified thread.
of @code{java.lang.management.ThreadInfo} for the specified thread.
The class includes a private constructor which VMs should use to initialise
The class includes a private constructor which VMs should use to initialise
it with the appropriate values for the thread.  The second argument
it with the appropriate values for the thread.  The second argument
given here specifies the depth of the stack trace supplied on construction
given here specifies the depth of the stack trace supplied on construction
of the instance.  Special values are 0 (return an empty array) and
of the instance.  Special values are 0 (return an empty array) and
@code{Integer.MAX_VALUE} (return the maximum depth possible).  This
@code{Integer.MAX_VALUE} (return the maximum depth possible).  This
is specified as a native method in the reference implementation.
is specified as a native method in the reference implementation.
@item @code{(getTotalStartedThreadCount())} -- This should return the
@item @code{(getTotalStartedThreadCount())} -- This should return the
total number of threads that have been started by the VM, including ones
total number of threads that have been started by the VM, including ones
that have died.  This is specified as a native method in the reference
that have died.  This is specified as a native method in the reference
implementation.
implementation.
@end itemize
@end itemize
 
 
@node gnu.java.lang.management.VMMemoryMXBeanImpl,gnu.java.lang.management.VMCompilationMXBeanImpl,gnu.java.lang.management.VMThreadMXBeanImpl,gnu.java.lang.management
@node gnu.java.lang.management.VMMemoryMXBeanImpl,gnu.java.lang.management.VMCompilationMXBeanImpl,gnu.java.lang.management.VMThreadMXBeanImpl,gnu.java.lang.management
@subsection @code{gnu.java.lang.management.VMMemoryMXBeanImpl}
@subsection @code{gnu.java.lang.management.VMMemoryMXBeanImpl}
 
 
The @code{gnu.java.lang.management.MemoryMXBeanImpl} provides an
The @code{gnu.java.lang.management.MemoryMXBeanImpl} provides an
implementation of the @code{java.lang.management.MemoryMXBean} interface,
implementation of the @code{java.lang.management.MemoryMXBean} interface,
and is supported by VM functionality in the form of
and is supported by VM functionality in the form of
@code{gnu.java.lang.management.VMMemoryMXBeanImpl}.  This provides a
@code{gnu.java.lang.management.VMMemoryMXBeanImpl}.  This provides a
series of methods, which should be implemented by the virtual machine
series of methods, which should be implemented by the virtual machine
in order to provide the required information for the bean.  Implementing
in order to provide the required information for the bean.  Implementing
this bean requires the VM to monitor the levels of heap and non-heap
this bean requires the VM to monitor the levels of heap and non-heap
memory, and provide the number of objects which are eligible for garbage
memory, and provide the number of objects which are eligible for garbage
collection.
collection.
 
 
The methods are as follows:
The methods are as follows:
 
 
@itemize @bullet
@itemize @bullet
@item @code{(getHeapMemoryUsage())} -- This should return
@item @code{(getHeapMemoryUsage())} -- This should return
an instance of @code{java.lang.management.MemoryUsage} with
an instance of @code{java.lang.management.MemoryUsage} with
values pertaining to the heap.  A default implementation is
values pertaining to the heap.  A default implementation is
provided, based on @code{java.lang.Runtime}'s methods.
provided, based on @code{java.lang.Runtime}'s methods.
@item @code{(getNonHeapMemoryUsage())} -- This should return
@item @code{(getNonHeapMemoryUsage())} -- This should return
an instance of @code{java.lang.management.MemoryUsage} with
an instance of @code{java.lang.management.MemoryUsage} with
values pertaining to non-heap memory.
values pertaining to non-heap memory.
@item @code{(getObjectPendingFinalizationCount())} -- Returns
@item @code{(getObjectPendingFinalizationCount())} -- Returns
the number of objects which are no longer referenced, and which
the number of objects which are no longer referenced, and which
will thus be garbage collected on the next run of the garbage
will thus be garbage collected on the next run of the garbage
collector.
collector.
@item @code{(isVerbose())} -- This should return @code{true}
@item @code{(isVerbose())} -- This should return @code{true}
or @code{false}, depending on whether verbose memory management
or @code{false}, depending on whether verbose memory management
output is turned or not, respectively.
output is turned or not, respectively.
@item @code{(setVerbose(boolean))} -- This should allow the
@item @code{(setVerbose(boolean))} -- This should allow the
verbose memory management output to be turned on and off.
verbose memory management output to be turned on and off.
@end itemize
@end itemize
 
 
@node gnu.java.lang.management.VMCompilationMXBeanImpl,gnu.java.lang.management.VMMemoryPoolMXBeanImpl,gnu.java.lang.management.VMMemoryMXBeanImpl,gnu.java.lang.management
@node gnu.java.lang.management.VMCompilationMXBeanImpl,gnu.java.lang.management.VMMemoryPoolMXBeanImpl,gnu.java.lang.management.VMMemoryMXBeanImpl,gnu.java.lang.management
@subsection @code{gnu.java.lang.management.VMCompilationMXBeanImpl}
@subsection @code{gnu.java.lang.management.VMCompilationMXBeanImpl}
 
 
The @code{gnu.java.lang.management.CompilationMXBeanImpl} provides an
The @code{gnu.java.lang.management.CompilationMXBeanImpl} provides an
implementation of the optional @code{java.lang.management.CompilationMXBean}
implementation of the optional @code{java.lang.management.CompilationMXBean}
interface, and is supported by VM functionality in the form of
interface, and is supported by VM functionality in the form of
@code{gnu.java.lang.management.VMCompilationMXBeanImpl}.  This provides a
@code{gnu.java.lang.management.VMCompilationMXBeanImpl}.  This provides a
single method for returning the number of milliseconds the virtual
single method for returning the number of milliseconds the virtual
machine's Just-In-Time (JIT) compiler has spent compiling.  Even if
machine's Just-In-Time (JIT) compiler has spent compiling.  Even if
a JIT compiler is available and an instance of the bean supplied, this
a JIT compiler is available and an instance of the bean supplied, this
method is still optional.
method is still optional.
 
 
Optional support is determined by the following properties:
Optional support is determined by the following properties:
 
 
@itemize @bullet
@itemize @bullet
@item @code{gnu.java.lang.compiler.name} -- This property should
@item @code{gnu.java.lang.compiler.name} -- This property should
specify the name of the JIT compiler.  Classpath also uses this,
specify the name of the JIT compiler.  Classpath also uses this,
within @code{java.lang.management.ManagementFactory}, to determine
within @code{java.lang.management.ManagementFactory}, to determine
whether a bean should be created.  If this property is set to a
whether a bean should be created.  If this property is set to a
non-null value, a bean will be created and its @code{getName()}
non-null value, a bean will be created and its @code{getName()}
method will return this value.
method will return this value.
@item @code{gnu.java.lang.management.CompilationTimeSupport} --
@item @code{gnu.java.lang.management.CompilationTimeSupport} --
This property should be present if the VM supports monitoring the
This property should be present if the VM supports monitoring the
time spent compiling.
time spent compiling.
@end itemize
@end itemize
 
 
Time support is implemented by the following method:
Time support is implemented by the following method:
 
 
@itemize @bullet
@itemize @bullet
@item @code{(getTotalCompilationTime())} -- This should return the
@item @code{(getTotalCompilationTime())} -- This should return the
number of milliseconds the JIT compiler has spent compiling.
number of milliseconds the JIT compiler has spent compiling.
@end itemize
@end itemize
 
 
@node gnu.java.lang.management.VMMemoryPoolMXBeanImpl,gnu.java.lang.management.VMMemoryManagerMXBeanImpl,gnu.java.lang.management.VMCompilationMXBeanImpl,gnu.java.lang.management
@node gnu.java.lang.management.VMMemoryPoolMXBeanImpl,gnu.java.lang.management.VMMemoryManagerMXBeanImpl,gnu.java.lang.management.VMCompilationMXBeanImpl,gnu.java.lang.management
@subsection @code{gnu.java.lang.management.VMMemoryPoolMXBeanImpl}
@subsection @code{gnu.java.lang.management.VMMemoryPoolMXBeanImpl}
 
 
The @code{gnu.java.lang.management.MemoryPoolMXBeanImpl} provides an
The @code{gnu.java.lang.management.MemoryPoolMXBeanImpl} provides an
implementation of the optional @code{java.lang.management.MemoryPoolMXBean}
implementation of the optional @code{java.lang.management.MemoryPoolMXBean}
interface, and is supported by VM functionality in the form of
interface, and is supported by VM functionality in the form of
@code{gnu.java.lang.management.VMMemoryPoolMXBeanImpl}.  Providing
@code{gnu.java.lang.management.VMMemoryPoolMXBeanImpl}.  Providing
this interface requires implementing a number of methods for each supported
this interface requires implementing a number of methods for each supported
pool.  These return statistics on memory usage, and, optionally, allows
pool.  These return statistics on memory usage, and, optionally, allows
monitoring of when memory usage exceeds a preset threshold.
monitoring of when memory usage exceeds a preset threshold.
 
 
Optional support is determined by the following properties:
Optional support is determined by the following properties:
 
 
@itemize @bullet
@itemize @bullet
@item @code{gnu.java.lang.management.CollectionUsageThresholdSupport} --
@item @code{gnu.java.lang.management.CollectionUsageThresholdSupport} --
This property should be present if the VM supports setting a collection
This property should be present if the VM supports setting a collection
usage threshold and monitoring when it is matched or exceeded.  Collection
usage threshold and monitoring when it is matched or exceeded.  Collection
usage thresholds are related to the remaining memory usage following a
usage thresholds are related to the remaining memory usage following a
garbage collection cycle.
garbage collection cycle.
@item @code{gnu.java.lang.management.UsageThresholdSupport} --
@item @code{gnu.java.lang.management.UsageThresholdSupport} --
This property should be present if the VM supports setting a
This property should be present if the VM supports setting a
usage threshold and monitoring when it is matched or exceeded.
usage threshold and monitoring when it is matched or exceeded.
@end itemize
@end itemize
 
 
The methods are as follows (all take a pool name as their
The methods are as follows (all take a pool name as their
first parameter):
first parameter):
 
 
@itemize @bullet
@itemize @bullet
@item @code{(getCollectionUsage(String))} -- Returns a
@item @code{(getCollectionUsage(String))} -- Returns a
@code{java.lang.management.MemoryUsage} object, containing the
@code{java.lang.management.MemoryUsage} object, containing the
memory usage statistics following a garbage collection cycle
memory usage statistics following a garbage collection cycle
for the specified pool.  This may also return @code{null} if
for the specified pool.  This may also return @code{null} if
the pool isn't an appropriate pool for this particular task.
the pool isn't an appropriate pool for this particular task.
@item @code{(getCollectionUsageThreshold(String))} -- Returns
@item @code{(getCollectionUsageThreshold(String))} -- Returns
the pool's collection usage threshold, if supported.
the pool's collection usage threshold, if supported.
@item @code{(getCollectionUsageThresholdCount(String))} -- Returns
@item @code{(getCollectionUsageThresholdCount(String))} -- Returns
the number of times the specified pool has matched or exceeded
the number of times the specified pool has matched or exceeded
its collection usage threshold, if supported.
its collection usage threshold, if supported.
@item @code{(getMemoryManagerNames(String))} -- Returns a list
@item @code{(getMemoryManagerNames(String))} -- Returns a list
of names of memory managers which manage the specified pool.
of names of memory managers which manage the specified pool.
@item @code{(getPeakUsage(String))} -- Returns a
@item @code{(getPeakUsage(String))} -- Returns a
@code{java.lang.management.MemoryUsage} object for the peak
@code{java.lang.management.MemoryUsage} object for the peak
usage level of the specified pool.
usage level of the specified pool.
@item @code{(getType(String))} -- Returns a string containing
@item @code{(getType(String))} -- Returns a string containing
either @code{"HEAP"} or @code{"NON_HEAP"} which indicates the type of
either @code{"HEAP"} or @code{"NON_HEAP"} which indicates the type of
memory used by the specified pool.
memory used by the specified pool.
@item @code{(getUsage(String))} -- Returns a
@item @code{(getUsage(String))} -- Returns a
@code{java.lang.management.MemoryUsage} object for the current
@code{java.lang.management.MemoryUsage} object for the current
usage level of the specified pool.
usage level of the specified pool.
@item @code{(getUsageThreshold(String))} -- Returns
@item @code{(getUsageThreshold(String))} -- Returns
the pool's usage threshold, if supported.
the pool's usage threshold, if supported.
@item @code{(getUsageThresholdCount(String))} -- Returns
@item @code{(getUsageThresholdCount(String))} -- Returns
the number of times the specified pool has matched or exceeded
the number of times the specified pool has matched or exceeded
its usage threshold, if supported.
its usage threshold, if supported.
@item @code{(isValid(String))} -- Returns true if the pool
@item @code{(isValid(String))} -- Returns true if the pool
is still in use by the virtual machine.
is still in use by the virtual machine.
@item @code{(resetPeakUsage(String))} -- Resets the peak usage
@item @code{(resetPeakUsage(String))} -- Resets the peak usage
levels to the current usage levels for the specified pool.
levels to the current usage levels for the specified pool.
@item @code{(setCollectionUsageThreshold(String, long))} -- Sets
@item @code{(setCollectionUsageThreshold(String, long))} -- Sets
the pool's collection usage threshold, if supported.
the pool's collection usage threshold, if supported.
@item @code{(setUsageThreshold(String, long))} -- Sets
@item @code{(setUsageThreshold(String, long))} -- Sets
the pool's usage threshold, if supported.
the pool's usage threshold, if supported.
@end itemize
@end itemize
 
 
@node gnu.java.lang.management.VMMemoryManagerMXBeanImpl,gnu.java.lang.management.VMGarbageCollectorMXBeanImpl,gnu.java.lang.management.VMMemoryPoolMXBeanImpl,gnu.java.lang.management
@node gnu.java.lang.management.VMMemoryManagerMXBeanImpl,gnu.java.lang.management.VMGarbageCollectorMXBeanImpl,gnu.java.lang.management.VMMemoryPoolMXBeanImpl,gnu.java.lang.management
@subsection @code{gnu.java.lang.management.VMMemoryManagerMXBeanImpl}
@subsection @code{gnu.java.lang.management.VMMemoryManagerMXBeanImpl}
 
 
The @code{gnu.java.lang.management.MemoryManagerMXBeanImpl} provides an
The @code{gnu.java.lang.management.MemoryManagerMXBeanImpl} provides an
implementation of the optional @code{java.lang.management.MemoryManagerMXBean}
implementation of the optional @code{java.lang.management.MemoryManagerMXBean}
interface, and is supported by VM functionality in the form of
interface, and is supported by VM functionality in the form of
@code{gnu.java.lang.management.VMMemoryManagerMXBeanImpl}.  Providing
@code{gnu.java.lang.management.VMMemoryManagerMXBeanImpl}.  Providing
this interface requires implementing two methods (each takes the name
this interface requires implementing two methods (each takes the name
of the manager as the first argument):
of the manager as the first argument):
 
 
@itemize @bullet
@itemize @bullet
@item @code{(getMemoryPoolNames(String))} -- Returns a list of the
@item @code{(getMemoryPoolNames(String))} -- Returns a list of the
memory pools that the manager maintains.  A default implementation
memory pools that the manager maintains.  A default implementation
which scans the results of @code{getMemoryManagerNames()} for each
which scans the results of @code{getMemoryManagerNames()} for each
pool is provided.
pool is provided.
@item @code{(isValid(String))} -- Returns true if the specified
@item @code{(isValid(String))} -- Returns true if the specified
manager is still valid, i.e., it is still in use by the virtual machine.
manager is still valid, i.e., it is still in use by the virtual machine.
@end itemize
@end itemize
 
 
@node gnu.java.lang.management.VMGarbageCollectorMXBeanImpl,,gnu.java.lang.management.VMMemoryManagerMXBeanImpl,gnu.java.lang.management
@node gnu.java.lang.management.VMGarbageCollectorMXBeanImpl,,gnu.java.lang.management.VMMemoryManagerMXBeanImpl,gnu.java.lang.management
@subsection @code{gnu.java.lang.management.VMGarbageCollectorMXBeanImpl}
@subsection @code{gnu.java.lang.management.VMGarbageCollectorMXBeanImpl}
 
 
The @code{gnu.java.lang.management.GarbageCollectorMXBeanImpl} provides an
The @code{gnu.java.lang.management.GarbageCollectorMXBeanImpl} provides an
implementation of the optional @code{java.lang.management.GarbageCollectorMXBean}
implementation of the optional @code{java.lang.management.GarbageCollectorMXBean}
interface, and is supported by VM functionality in the form of
interface, and is supported by VM functionality in the form of
@code{gnu.java.lang.management.VMGarbageCollectorMXBeanImpl}.  Providing
@code{gnu.java.lang.management.VMGarbageCollectorMXBeanImpl}.  Providing
this interface requires implementing two methods (each takes the name
this interface requires implementing two methods (each takes the name
of the garbage collector as the first argument):
of the garbage collector as the first argument):
 
 
@itemize @bullet
@itemize @bullet
@item @code{(getCollectionCount(String))} -- Returns the number of
@item @code{(getCollectionCount(String))} -- Returns the number of
times the specified garbage collector has run.
times the specified garbage collector has run.
@item @code{(getCollectionTime(String))} -- Returns the accumulated
@item @code{(getCollectionTime(String))} -- Returns the accumulated
number of milliseconds for which the garbage collector has run.
number of milliseconds for which the garbage collector has run.
@end itemize
@end itemize
 
 
Note that each garbage collector is also a memory manager, and so an
Note that each garbage collector is also a memory manager, and so an
implementation of the @code{gnu.java.lang.management.VMMemoryManagerMXBeanImpl}
implementation of the @code{gnu.java.lang.management.VMMemoryManagerMXBeanImpl}
methods for its name should also be provided.
methods for its name should also be provided.
 
 
@node java.lang.management, Classpath Callbacks, gnu.java.lang.management, Classpath Hooks
@node java.lang.management, Classpath Callbacks, gnu.java.lang.management, Classpath Hooks
@section @code{java.lang.management}
@section @code{java.lang.management}
 
 
@code{gnu.java.lang.management} provides the VM interfaces for the GNU
@code{gnu.java.lang.management} provides the VM interfaces for the GNU
implementations of the management beans.
implementations of the management beans.
 
 
@menu
@menu
* java.lang.management.VMManagementFactory::
* java.lang.management.VMManagementFactory::
@end menu
@end menu
 
 
@node java.lang.management.VMManagementFactory,,,java.lang.management
@node java.lang.management.VMManagementFactory,,,java.lang.management
@subsection @code{java.lang.management.VMManagementFactory}
@subsection @code{java.lang.management.VMManagementFactory}
 
 
This VM interface provides the names of the memory pools, memory managers
This VM interface provides the names of the memory pools, memory managers
and garbage collectors for use by the @code{java.lang.management.ManagementFactory}
and garbage collectors for use by the @code{java.lang.management.ManagementFactory}
in creating lists of appropriate beans for these types of managed object.
in creating lists of appropriate beans for these types of managed object.
 
 
The methods are as follows:
The methods are as follows:
 
 
@itemize @bullet
@itemize @bullet
@item @code{(getMemoryPoolNames())} -- Returns a list of the names
@item @code{(getMemoryPoolNames())} -- Returns a list of the names
of the current memory pools in use by the virtual machine.
of the current memory pools in use by the virtual machine.
@item @code{(getMemoryManagerNames())} -- Returns a list of the names
@item @code{(getMemoryManagerNames())} -- Returns a list of the names
of the current memory managers in use by the virtual machine.  This
of the current memory managers in use by the virtual machine.  This
should not include those that are also garbage collectors.
should not include those that are also garbage collectors.
@item @code{(getGarbageCollectorNames())} -- Returns a list of the names
@item @code{(getGarbageCollectorNames())} -- Returns a list of the names
of the current garbage collectors in use by the virtual machine.
of the current garbage collectors in use by the virtual machine.
@end itemize
@end itemize
 
 
@node Classpath Callbacks, , java.lang.management, Classpath Hooks
@node Classpath Callbacks, , java.lang.management, Classpath Hooks
Some of the classes you implement for the VM will need to call back to
Some of the classes you implement for the VM will need to call back to
package-private methods in Classpath:
package-private methods in Classpath:
 
 
@itemize @bullet
@itemize @bullet
@item @code{java.lang.ThreadGroup.addThread(Thread)}
@item @code{java.lang.ThreadGroup.addThread(Thread)}
Call this method from @code{Thread} when a new @code{Thread} is created, to add it to
Call this method from @code{Thread} when a new @code{Thread} is created, to add it to
the group.
the group.
 
 
@item @code{java.lang.ThreadGroup.removeThread(Thread)}
@item @code{java.lang.ThreadGroup.removeThread(Thread)}
Call this method from @code{Thread} when a @code{Thread} is stopped or destroyed.
Call this method from @code{Thread} when a @code{Thread} is stopped or destroyed.
 
 
@item @code{gnu.java.lang.management.MemoryMXBeanImpl.fireThresholdExceededNotification(String, long, long, long, long)}
@item @code{gnu.java.lang.management.MemoryMXBeanImpl.fireThresholdExceededNotification(String, long, long, long, long)}
If the monitoring of memory usage thresholds is supported, this method
If the monitoring of memory usage thresholds is supported, this method
should be called when the normal usage of a memory pool crosses the
should be called when the normal usage of a memory pool crosses the
threshold, in order to emit a notification.  Another notification
threshold, in order to emit a notification.  Another notification
should not be emitted until there is an intermittent period where the
should not be emitted until there is an intermittent period where the
usage is again below the threshold.  The parameters are the memory
usage is again below the threshold.  The parameters are the memory
pool name, the usage levels (init, used, committed and max) and the
pool name, the usage levels (init, used, committed and max) and the
number of times the threshold has been crossed.
number of times the threshold has been crossed.
 
 
@item @code{gnu.java.lang.management.MemoryMXBeanImpl.fireCollectionThresholdExceededNotification(String, long, long, long, long)}
@item @code{gnu.java.lang.management.MemoryMXBeanImpl.fireCollectionThresholdExceededNotification(String, long, long, long, long)}
If the monitoring of memory usage thresholds is supported, this method
If the monitoring of memory usage thresholds is supported, this method
should be called when the usage of a memory pool after a garbage
should be called when the usage of a memory pool after a garbage
collection cycle crosses the threshold, in order to emit a
collection cycle crosses the threshold, in order to emit a
notification.  Another notification should not be emitted until there
notification.  Another notification should not be emitted until there
is an intermittent period where the usage is again below the
is an intermittent period where the usage is again below the
threshold.  The parameters are the memory pool name, the usage levels
threshold.  The parameters are the memory pool name, the usage levels
(init, used, committed and max) and the number of times the threshold
(init, used, committed and max) and the number of times the threshold
has been crossed.
has been crossed.
 
 
@end itemize
@end itemize
 
 
@node VM Hooks, JNI Implementation, Classpath Hooks, Top
@node VM Hooks, JNI Implementation, Classpath Hooks, Top
@comment node-name, next, previous, up
@comment node-name, next, previous, up
@chapter VM Hooks
@chapter VM Hooks
 
 
VMs need to do some dirty work; there are some things in the VM that
VMs need to do some dirty work; there are some things in the VM that
unfortunately are dependent on the internal structure of various
unfortunately are dependent on the internal structure of various
classes.  This is a guide to all of the things the VM itself needs to
classes.  This is a guide to all of the things the VM itself needs to
know about classes.
know about classes.
 
 
Some of the core classes, while being implemented by GNU Classpath,
Some of the core classes, while being implemented by GNU Classpath,
provide space for state (in the form of a @code{vmdata} object) to be
provide space for state (in the form of a @code{vmdata} object) to be
stored by the VM, and can not be constructed normally.
stored by the VM, and can not be constructed normally.
 
 
@itemize @bullet
@itemize @bullet
@item java.lang.Class
@item java.lang.Class
@item java.lang.ClassLoader
@item java.lang.ClassLoader
@end itemize
@end itemize
 
 
The default implementations of some VM classes also follow this methodology,
The default implementations of some VM classes also follow this methodology,
when it is intended that most VMs will keep the default.
when it is intended that most VMs will keep the default.
 
 
@itemize @bullet
@itemize @bullet
@item java.lang.VMThread
@item java.lang.VMThread
@item java.lang.VMThrowable
@item java.lang.VMThrowable
@end itemize
@end itemize
 
 
Several core classes must be completely implemented by the VM for Classpath to
Several core classes must be completely implemented by the VM for Classpath to
work, although reference implementations are provided.  These classes are:
work, although reference implementations are provided.  These classes are:
 
 
@itemize @bullet
@itemize @bullet
@item java.lang.reflect.Constructor
@item java.lang.reflect.Constructor
@item java.lang.reflect.Method
@item java.lang.reflect.Method
@item java.lang.reflect.Field
@item java.lang.reflect.Field
@end itemize
@end itemize
 
 
The following issues are of note;
The following issues are of note;
 
 
@itemize @bullet
@itemize @bullet
@item @code{java.lang.Class} @*
@item @code{java.lang.Class} @*
The GNU Classpath implementation of @code{java.lang.Class} provides an
The GNU Classpath implementation of @code{java.lang.Class} provides an
object for storing the internal state of the class maintained by the VM.
object for storing the internal state of the class maintained by the VM.
This is the only known place where this matters.  The class is
This is the only known place where this matters.  The class is
constructed with this data by the VM@.  Some VMs do not create the
constructed with this data by the VM@.  Some VMs do not create the
@code{Class} object at the point where the class is defined; instead,
@code{Class} object at the point where the class is defined; instead,
they wait until a @code{Class} object is actually used.
they wait until a @code{Class} object is actually used.
 
 
@item Array Classes @*
@item Array Classes @*
When you are creating an array class, you should set the
When you are creating an array class, you should set the
@code{ClassLoader} of the array class to the @code{ClassLoader} of its
@code{ClassLoader} of the array class to the @code{ClassLoader} of its
component type.  Whenever you add a class to a @code{ClassLoader}, you
component type.  Whenever you add a class to a @code{ClassLoader}, you
need to notify the @code{ClassLoader} and add the new @code{Class} to
need to notify the @code{ClassLoader} and add the new @code{Class} to
its internal cache of classes.  To do this, call
its internal cache of classes.  To do this, call
@code{ClassLoader.addVMCreatedClass(Class)}.  @emph{Note: this is
@code{ClassLoader.addVMCreatedClass(Class)}.  @emph{Note: this is
written in anticipation of 1.2 support and does not apply just yet.}
written in anticipation of 1.2 support and does not apply just yet.}
 
 
@item Primordial Class Loader @*
@item Primordial Class Loader @*
When the primordial class loader loads a class, it needs to tell
When the primordial class loader loads a class, it needs to tell
Classpath what it has done in order for security stuff to work right.
Classpath what it has done in order for security stuff to work right.
To do this, call the static method
To do this, call the static method
@code{ClassLoader.newPrimordialClass(Class)}.
@code{ClassLoader.newPrimordialClass(Class)}.
 
 
Even the first few core classes need to do this; in order to do it,
Even the first few core classes need to do this; in order to do it,
simply call this method @emph{after} the initial class loading has been
simply call this method @emph{after} the initial class loading has been
done.  No harm will come, as long as you follow the guidelines in the
done.  No harm will come, as long as you follow the guidelines in the
@pxref{Initialization} section.
@pxref{Initialization} section.
 
 
@emph{Note: this is written in anticipation of 1.2 support and does not
@emph{Note: this is written in anticipation of 1.2 support and does not
apply just yet.}
apply just yet.}
 
 
@item Top-level Exception Handler @*
@item Top-level Exception Handler @*
Exceptions take care of themselves in Classpath; all you need to do in
Exceptions take care of themselves in Classpath; all you need to do in
the top-level exception handler is call @code{Throwable.printStackTrace()}.
the top-level exception handler is call @code{Throwable.printStackTrace()}.
 
 
@item Security and Traces @*
@item Security and Traces @*
There will eventually be a feature in the 1.2 security that keeps the
There will eventually be a feature in the 1.2 security that keeps the
@code{AccessController} from having to evaluate @emph{all} of the
@code{AccessController} from having to evaluate @emph{all} of the
@code{ProtectionDomain}s every time a security check is made.  I think a common
@code{ProtectionDomain}s every time a security check is made.  I think a common
case is a single method doing a lot of things that require security
case is a single method doing a lot of things that require security
checks.  However, I don't want to bog down the method stack too much, so
checks.  However, I don't want to bog down the method stack too much, so
this feature of the VM will have the @code{AccessController} for a thread
this feature of the VM will have the @code{AccessController} for a thread
calling out to the VM to tell it how high it was on the stack when it
calling out to the VM to tell it how high it was on the stack when it
made the last security request.  Every time the stack goes lower than
made the last security request.  Every time the stack goes lower than
that number, the VM will decrement the number.  The @code{AccessController}
that number, the VM will decrement the number.  The @code{AccessController}
will remember what the accumulated protection status was at every stack
will remember what the accumulated protection status was at every stack
level (an @code{AccessControlContext}) and use that aggregated information to
level (an @code{AccessControlContext}) and use that aggregated information to
do the check.  I am not sure, however, whether the savings are
do the check.  I am not sure, however, whether the savings are
substantial enough to outweigh the integer check and set after every
substantial enough to outweigh the integer check and set after every
method call.  I will investigate.
method call.  I will investigate.
 
 
@item Threading @*
@item Threading @*
I figured I'd put this here because a VM guy might be wondering about it.
I figured I'd put this here because a VM guy might be wondering about it.
We implement @code{ThreadGroup}, but that class is almost entirely
We implement @code{ThreadGroup}, but that class is almost entirely
VM-independent.  The root @code{ThreadGroup}, a static field called
VM-independent.  The root @code{ThreadGroup}, a static field called
@code{ThreadGroup.root}, should be initialized by Classpath, but if you wish to
@code{ThreadGroup.root}, should be initialized by Classpath, but if you wish to
reinitialize it yourself, there should be no harm.
reinitialize it yourself, there should be no harm.
 
 
@end itemize
@end itemize
 
 
@node JNI Implementation, JVMTI Implementation, VM Hooks, Top
@node JNI Implementation, JVMTI Implementation, VM Hooks, Top
@comment  node-name,  next,  previous,  up
@comment  node-name,  next,  previous,  up
@chapter JNI Implementation
@chapter JNI Implementation
 
 
Classpath comes with its own implementation of @file{jni.h}.  This
Classpath comes with its own implementation of @file{jni.h}.  This
file can be customized by the VM in a few ways, by defining macros
file can be customized by the VM in a few ways, by defining macros
that affect the interpretation of the file.  These macros are all
that affect the interpretation of the file.  These macros are all
intended for use by a VM which uses GNU Classpath and which wants to
intended for use by a VM which uses GNU Classpath and which wants to
use a single copy of @file{jni.h} for both internal and external use.
use a single copy of @file{jni.h} for both internal and external use.
 
 
@itemize @bullet
@itemize @bullet
@item _CLASSPATH_VM_JNI_TYPES_DEFINED
@item _CLASSPATH_VM_JNI_TYPES_DEFINED
Some VMs like to define JNI ``object'' types in a special way.  If
Some VMs like to define JNI ``object'' types in a special way.  If
this macro is defined, the Classpath @file{jni.h} will avoid defining
this macro is defined, the Classpath @file{jni.h} will avoid defining
these types.  By default, these types are defined in @file{jni.h}.
these types.  By default, these types are defined in @file{jni.h}.
The full list of types and macros treated this way is: @samp{jobject},
The full list of types and macros treated this way is: @samp{jobject},
@samp{jclass}, @samp{jstring}, @samp{jthrowable}, @samp{jweak},
@samp{jclass}, @samp{jstring}, @samp{jthrowable}, @samp{jweak},
@samp{jarray}, @samp{jobjectArray}, @samp{jbyteArray},
@samp{jarray}, @samp{jobjectArray}, @samp{jbyteArray},
@samp{jshortArray}, @samp{jintArray}, @samp{jlongArray},
@samp{jshortArray}, @samp{jintArray}, @samp{jlongArray},
@samp{jbooleanArray}, @samp{jcharArray}, @samp{jfloatArray},
@samp{jbooleanArray}, @samp{jcharArray}, @samp{jfloatArray},
@samp{jdoubleArray}, @samp{JNIEnv}, @samp{JavaVM}, @samp{JNI_TRUE}
@samp{jdoubleArray}, @samp{JNIEnv}, @samp{JavaVM}, @samp{JNI_TRUE}
(macro), @samp{JNI_FALSE} (macro).
(macro), @samp{JNI_FALSE} (macro).
 
 
@item _CLASSPATH_VM_INTERNAL_TYPES_DEFINED
@item _CLASSPATH_VM_INTERNAL_TYPES_DEFINED
If the VM has its own definitions for @samp{jfieldID} and
If the VM has its own definitions for @samp{jfieldID} and
@samp{jmethodID}, then it should define this macro.  Otherwise,
@samp{jmethodID}, then it should define this macro.  Otherwise,
@file{jni.h} will provide definitions for these types.
@file{jni.h} will provide definitions for these types.
 
 
@item _CLASSPATH_JNIIMPEXP
@item _CLASSPATH_JNIIMPEXP
Three functions -- @samp{JNI_GetDefaultJavaVMInitArgs},
Three functions -- @samp{JNI_GetDefaultJavaVMInitArgs},
@samp{JNI_CreateJavaVM}, and @samp{JNI_GetCreatedJavaVMs} -- must be
@samp{JNI_CreateJavaVM}, and @samp{JNI_GetCreatedJavaVMs} -- must be
marked as @samp{JNIIMPORT} when seen by user code, but most likely
marked as @samp{JNIIMPORT} when seen by user code, but most likely
should be marked as @samp{JNIEXPORT} when defined in the VM
should be marked as @samp{JNIEXPORT} when defined in the VM
implementation.  This macro can be defined to one or the other by the
implementation.  This macro can be defined to one or the other by the
VM as appropriate.  If this macro is not defined, it defaults to
VM as appropriate.  If this macro is not defined, it defaults to
@samp{JNIIMPORT}.
@samp{JNIIMPORT}.
 
 
@item _CLASSPATH_JNIENV_CONTENTS
@item _CLASSPATH_JNIENV_CONTENTS
A VM can add fields to the @samp{JNIEnv} structure by defining this to
A VM can add fields to the @samp{JNIEnv} structure by defining this to
be a sequence of field declarations.
be a sequence of field declarations.
 
 
@end itemize
@end itemize
 
 
@node JVMTI Implementation, Miscellaneous VM Requirements, JNI Implementation, Top
@node JVMTI Implementation, Miscellaneous VM Requirements, JNI Implementation, Top
@comment node-name, next, previous, up
@comment node-name, next, previous, up
@chapter JVMTI Implementation
@chapter JVMTI Implementation
 
 
Classpath comes with its own implementation of @file{jvmti.h}.  This
Classpath comes with its own implementation of @file{jvmti.h}.  This
file can be customized by the VM in a few ways by defining macros that
file can be customized by the VM in a few ways by defining macros that
affect the interpretation of the file.  These macros are all intended
affect the interpretation of the file.  These macros are all intended
for use for use by a VM which uses GNU Classpath and which wants to
for use for use by a VM which uses GNU Classpath and which wants to
use a single copy of @file{jvmti.h} for both internal and external use.
use a single copy of @file{jvmti.h} for both internal and external use.
 
 
@itemize @bullet
@itemize @bullet
@item _CLASSPATH_VM_JVMTI_TYPES_DEFINED
@item _CLASSPATH_VM_JVMTI_TYPES_DEFINED
Some VMs like to define JVMTI ``object'' types in a special way.  If
Some VMs like to define JVMTI ``object'' types in a special way.  If
this macro is defined, the Classpath @file{jvmti.h} will avoid defining
this macro is defined, the Classpath @file{jvmti.h} will avoid defining
these types.  By default these types are defined in @file{jvmti.h}.
these types.  By default these types are defined in @file{jvmti.h}.
The full list of types and macros treated this way is: @samp{jthread},
The full list of types and macros treated this way is: @samp{jthread},
@samp{jthreadGroup}, @samp{jlocation}, and @samp{jrawMonitorID}.  By
@samp{jthreadGroup}, @samp{jlocation}, and @samp{jrawMonitorID}.  By
default @samp{jrawMonitorID} is defined as an opaque pointer which
default @samp{jrawMonitorID} is defined as an opaque pointer which
must be defined by the VM.
must be defined by the VM.
 
 
@item _CLASSPATH_JVMTIENV_CONTENTS
@item _CLASSPATH_JVMTIENV_CONTENTS
A VM can add fields to the @samp{jvmtiEnv} structure by defining this
A VM can add fields to the @samp{jvmtiEnv} structure by defining this
to be a sequence of field declarations.
to be a sequence of field declarations.
 
 
@end itemize
@end itemize
 
 
@node Miscellaneous VM Requirements,  , JVMTI Implementation, Top
@node Miscellaneous VM Requirements,  , JVMTI Implementation, Top
@comment  node-name,  next,  previous,  up
@comment  node-name,  next,  previous,  up
@chapter Miscellaneous VM Requirements
@chapter Miscellaneous VM Requirements
 
 
Classpath places a few requirements on the VM that uses it.
Classpath places a few requirements on the VM that uses it.
 
 
@menu
@menu
* JNI Version::
* JNI Version::
* VM Threading Model::
* VM Threading Model::
* Boot Library Path Property::
* Boot Library Path Property::
@end menu
@end menu
 
 
@node JNI Version, VM Threading Model, Miscellaneous VM Requirements, Miscellaneous VM Requirements
@node JNI Version, VM Threading Model, Miscellaneous VM Requirements, Miscellaneous VM Requirements
@comment  node-name,  next,  previous,  up
@comment  node-name,  next,  previous,  up
@section JNI Version
@section JNI Version
 
 
Classpath currently uses only JNI 1.1, except for one JNI 1.2 function
Classpath currently uses only JNI 1.1, except for one JNI 1.2 function
in the JNI Invocation API: GetEnv().  And GetEnv() is only used in the
in the JNI Invocation API: GetEnv().  And GetEnv() is only used in the
now deprecated ``portable native sync'' code.
now deprecated ``portable native sync'' code.
 
 
A future direction will probably be to require that all VMs provide
A future direction will probably be to require that all VMs provide
JNI 1.2.  If this poses problems, please raise them on the classpath
JNI 1.2.  If this poses problems, please raise them on the classpath
mailing list.
mailing list.
 
 
@node VM Threading Model, Boot Library Path Property, JNI Version, Miscellaneous VM Requirements
@node VM Threading Model, Boot Library Path Property, JNI Version, Miscellaneous VM Requirements
@comment  node-name,  next,  previous,  up
@comment  node-name,  next,  previous,  up
@section VM Threading Model
@section VM Threading Model
 
 
VM authors can implement a number of different threading models. When
VM authors can implement a number of different threading models. When
native code is also threaded there is the potential for one threading
native code is also threaded there is the potential for one threading
model to deadlock the other. The
model to deadlock the other. The
@uref{http://java.sun.com/docs/books/jni/html/other.html#29406,Java
@uref{http://java.sun.com/docs/books/jni/html/other.html#29406,Java
Native Interface Programmer's Guide and Specification} suggests
Native Interface Programmer's Guide and Specification} suggests
consulting VM documentation in such situations. Classpath uses
consulting VM documentation in such situations. Classpath uses
existing libraries, for example the AWT peers can use the GTK+
existing libraries, for example the AWT peers can use the GTK+
graphics library. As these libraries assume a different threading
graphics library. As these libraries assume a different threading
model, there is the potential for the native code to deadlock a VM.
model, there is the potential for the native code to deadlock a VM.
 
 
The different threading models available to a VM author are:
The different threading models available to a VM author are:
@enumerate
@enumerate
@item
@item
@i{Native threads}: Map a Java thread to an underlying operating system
@i{Native threads}: Map a Java thread to an underlying operating system
thread (normally a POSIX compatible pthread). This approach reduces
thread (normally a POSIX compatible pthread). This approach reduces
the potential for deadlock as there is only one thread scheduling
the potential for deadlock as there is only one thread scheduling
mechanism.
mechanism.
@item
@item
@i{Green threads 1}: Green threads are threads scheduled by the VM,
@i{Green threads 1}: Green threads are threads scheduled by the VM,
typically by switching swapping registers. In early VMs green threads
typically by switching swapping registers. In early VMs green threads
were seen as advantageous as they didn't require the operating system
were seen as advantageous as they didn't require the operating system
to reschedule, save and swap all of a threads registers. The green
to reschedule, save and swap all of a threads registers. The green
thread 1 model switches thread on an externally created event, such as
thread 1 model switches thread on an externally created event, such as
a timer interrupt. An example of a VM using this approach is Kaffe
a timer interrupt. An example of a VM using this approach is Kaffe
configured with its jthreads model.
configured with its jthreads model.
@item
@item
@i{Green threads 2}: The essential difference with this model is to
@i{Green threads 2}: The essential difference with this model is to
not switch threads on an event, but at fixed points in the code being
not switch threads on an event, but at fixed points in the code being
executed by the VM@. Points chosen could be backward branches (loops)
executed by the VM@. Points chosen could be backward branches (loops)
or method calls. This approach can be advantageous to nonconservative
or method calls. This approach can be advantageous to nonconservative
garbage collectors, as non-running threads would be at known points
garbage collectors, as non-running threads would be at known points
and can have fixed register maps. It can also reduce the number of
and can have fixed register maps. It can also reduce the number of
registers it is necessary to swap when switching threads.
registers it is necessary to swap when switching threads.
@item
@item
@i{M:N threading}: a flaw to green threading is that it is unable to
@i{M:N threading}: a flaw to green threading is that it is unable to
use multiple processors. @i{M}:@i{N} threading fixes this problem by
use multiple processors. @i{M}:@i{N} threading fixes this problem by
running groups of green threads on multiple underlying native
running groups of green threads on multiple underlying native
threads. An example of a VM using this approach is the Jikes RVM,
threads. An example of a VM using this approach is the Jikes RVM,
which uses @i{M}:@i{N} threading combined with the green thread 2
which uses @i{M}:@i{N} threading combined with the green thread 2
model.
model.
@end enumerate
@end enumerate
 
 
An example of the problem of mixing threading models is:
An example of the problem of mixing threading models is:
@itemize @bullet
@itemize @bullet
@item
@item
A Java thread calls a native method. The native method acquires a lock.
A Java thread calls a native method. The native method acquires a lock.
@item
@item
The native method calls back into the VM.
The native method calls back into the VM.
@item
@item
An event triggers the VM to reschedule the currently running thread.
An event triggers the VM to reschedule the currently running thread.
@item
@item
A new VM thread, executing on the same underlying native thread, calls
A new VM thread, executing on the same underlying native thread, calls
a native method.
a native method.
@item
@item
The native method tries to acquire the lock already acquired earlier. As
The native method tries to acquire the lock already acquired earlier. As
the lock is busy the thread waits and allows the operating system to
the lock is busy the thread waits and allows the operating system to
reschedule native threads.
reschedule native threads.
@item
@item
The operating system reschedules the VM thread again, but the lock is
The operating system reschedules the VM thread again, but the lock is
still busy and in some threading models will remain busy forever
still busy and in some threading models will remain busy forever
(the VM is deadlocked).
(the VM is deadlocked).
@end itemize
@end itemize
 
 
VMs that don't use the underlying operating system thread scheduling
VMs that don't use the underlying operating system thread scheduling
mechanism need to avoid deadlock. One now deprecated approach was to
mechanism need to avoid deadlock. One now deprecated approach was to
build Classpath and VMs on top of a wrapper thread library (aka
build Classpath and VMs on top of a wrapper thread library (aka
portable native sync). The wrapper thread library used was GLIB's
portable native sync). The wrapper thread library used was GLIB's
@dfn{gthreads}. This approach has been deprecated because:
@dfn{gthreads}. This approach has been deprecated because:
@enumerate
@enumerate
@item
@item
The wrapper library is only in use by some native libraries. For
The wrapper library is only in use by some native libraries. For
example, GTK+ uses the gthread library but QT does not.
example, GTK+ uses the gthread library but QT does not.
@item
@item
The wrapper library can't be in use prior to the VM starting as the VM
The wrapper library can't be in use prior to the VM starting as the VM
must replace the wrapper libraries functions with its own. This
must replace the wrapper libraries functions with its own. This
prevents the VM from running as a plugin in an application that
prevents the VM from running as a plugin in an application that
already uses the wrapper library.
already uses the wrapper library.
@end enumerate
@end enumerate
 
 
An alternative approach is for the VM to detect deadlocked native code
An alternative approach is for the VM to detect deadlocked native code
and swap Java threads off of that native thread. The VM can't,
and swap Java threads off of that native thread. The VM can't,
however, swap two blocked native threads that are potentially
however, swap two blocked native threads that are potentially
deadlocking each other on a lock. The lock will be associated with the
deadlocking each other on a lock. The lock will be associated with the
native thread. To prevent this from happening the VM must hijack
native thread. To prevent this from happening the VM must hijack
functions that operate on locks. This is done by redefining the lock
functions that operate on locks. This is done by redefining the lock
functions inside the VM and configuring the linker so that it uses the
functions inside the VM and configuring the linker so that it uses the
VMs symbol in preference to that of the external thread support
VMs symbol in preference to that of the external thread support
library. The VM's lock function can then reschedule Java threads if it
library. The VM's lock function can then reschedule Java threads if it
must wait for the lock.
must wait for the lock.
 
 
@node Boot Library Path Property,  , VM Threading Model, Miscellaneous VM Requirements
@node Boot Library Path Property,  , VM Threading Model, Miscellaneous VM Requirements
@comment  node-name,  next,  previous,  up
@comment  node-name,  next,  previous,  up
@section Boot Library Path Property
@section Boot Library Path Property
 
 
As of GNU Classpath 0.15 a system property named @code{gnu.classpath.boot.library.path}
As of GNU Classpath 0.15 a system property named @code{gnu.classpath.boot.library.path}
can be set by the VM to specify the directories which contain GNU Classpath's native
can be set by the VM to specify the directories which contain GNU Classpath's native
libraries. Usually this value is given at configuration time and is then hardcoded
libraries. Usually this value is given at configuration time and is then hardcoded
in the VM@. However for development purposes it is handy to switch to another installation
in the VM@. However for development purposes it is handy to switch to another installation
by overriding the properties' value on the command line.
by overriding the properties' value on the command line.
 
 
A VM that does not support this feature can simply ignore the property.
A VM that does not support this feature can simply ignore the property.
 
 
For compatibility reasons we suggest to set the default value of @code{java.library.path}
For compatibility reasons we suggest to set the default value of @code{java.library.path}
to the value of the @code{LD_LIBRARY_PATH} environment if it exists on your platform.
to the value of the @code{LD_LIBRARY_PATH} environment if it exists on your platform.
 
 
@bye
@bye
 
 
 
 
 
 
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.