org.apache.harmony.kernel.vm.VM Class Reference

List of all members.


Detailed Description

This class must be implemented by the vm vendor.

Represents the running virtual machine. All VM specific API are implemented on this class.

Note that all methods in VM are static. There is no singleton instance which represents the actively running VM.

Static Public Member Functions

static final ClassLoader getNonBootstrapClassLoader ()
 This method must be provided by the vm vendor, as it is used by other provided class implementations.
static final void initializeClassLoader (ClassLoader loader, boolean bootLoader)
 Initialize the classloader.
static final String intern (String string)
 This method must be provided by the vm vendor.
static ClassLoader callerClassLoader ()
 This method must be included, as it is used by ResourceBundle.getBundle(), and other places as well.
static ClassLoader bootCallerClassLoader ()
 This method must be provided by the vm vendor, as it is used by org.apache.harmony.luni.util.MsgHelp.setLocale() to get the bootstrap ClassLoader.
static void dumpString (String str)
 Native used to dump a string to the system console for debugging.
static void addShutdownHook (Thread hook)
 Registers a new virtual-machine shutdown hook.
static boolean removeShutdownHook (Thread hook)
 De-registers a previously-registered virtual-machine shutdown hook.
static void closeJars ()
 This method must be provided by the vm vendor.
static void deleteOnExit ()
 This method must be provided by the vm vendor.
static String[] getVMArgs ()
 Returns command line arguments passed to the VM.
static int getKernelVersion ()
 This method must be provided by the vm vendor.

Static Package Functions

static final ClassLoader getStackClassLoader (int depth)
 This method must be provided by the vm vendor, as it is used by org.apache.harmony.kernel.vm.MsgHelp.setLocale() to get the bootstrap ClassLoader.
static Class<?> findClassOrNull (String className, ClassLoader classLoader)
 Native used to find and load a class using the VM.
static int getCPIndexImpl (Class<?> targetClass)
 Get the classpath entry that was used to load the class that is the arg.
static void initializeVM ()
 Does internal initialization required by VM.
static final int getClassPathEntryType (Object classLoader, int cpIndex)
 Return the type of the specified entry on the class path for a ClassLoader.
static int getClassPathCount ()
 Return the number of entries on the bootclasspath.
static byte[] getPathFromClassPath (int index)
 Return the specified bootclasspath entry.

Static Package Attributes

static final int CPE_TYPE_UNKNOWN = 0
static final int CPE_TYPE_DIRECTORY = 1
static final int CPE_TYPE_JAR = 2
static final int CPE_TYPE_TCP = 3
static final int CPE_TYPE_UNUSABLE = 5

Static Private Attributes

static final int kernelVersion = 0x01000100


Member Function Documentation

static final ClassLoader org.apache.harmony.kernel.vm.VM.getStackClassLoader ( int  depth  )  [static, package]

This method must be provided by the vm vendor, as it is used by org.apache.harmony.kernel.vm.MsgHelp.setLocale() to get the bootstrap ClassLoader.

MsgHelp uses the bootstrap ClassLoader to find the resource bundle of messages packaged with the bootstrap classes. Returns the ClassLoader of the method (including natives) at the specified depth on the stack of the calling thread. Frames representing the VM implementation of java.lang.reflect are not included in the list. This is not a public method as it can return the bootstrap class loader, which should not be accessed by non-bootstrap classes. Notes:

Parameters:
depth the stack depth of the requested ClassLoader
Returns:
the ClassLoader at the specified depth
See also:
java.lang.ClassLoader.getStackClassLoader

static final ClassLoader org.apache.harmony.kernel.vm.VM.getNonBootstrapClassLoader (  )  [static]

This method must be provided by the vm vendor, as it is used by other provided class implementations.

For example, java.io.ObjectInputStream.readObject() and java.io.ObjectInputStream.resolveProxyClass(). It is also useful for other classes, such as java.rmi.server.RMIClassLoader. Walk the stack and answer the most recent non-null and non-bootstrap ClassLoader on the stack of the calling thread. If no such ClassLoader is found, null is returned. Notes: 1) This method operates on the defining classes of methods on stack. NOT the classes of receivers.

Returns:
the first non-bootstrap ClassLoader on the stack

static final void org.apache.harmony.kernel.vm.VM.initializeClassLoader ( ClassLoader  loader,
boolean  bootLoader 
) [static]

Initialize the classloader.

Parameters:
loader ClassLoader the ClassLoader instance
bootLoader boolean true for the bootstrap class loader

static final String org.apache.harmony.kernel.vm.VM.intern ( String  string  )  [static]

This method must be provided by the vm vendor.

Searches an internal table of strings for a string equal to the specified String. If the string is not in the table, it is added. Answers the string contained in the table which is equal to the specified String. The same string object is always answered for strings which are equal.

Parameters:
string the String to intern
Returns:
the interned string equal to the specified String

static Class<?> org.apache.harmony.kernel.vm.VM.findClassOrNull ( String  className,
ClassLoader  classLoader 
) [static, package]

Native used to find and load a class using the VM.

Returns:
java.lang.Class the class or null.
Parameters:
className String the name of the class to search for.
classLoader the classloader to do the work

static ClassLoader org.apache.harmony.kernel.vm.VM.callerClassLoader (  )  [static]

This method must be included, as it is used by ResourceBundle.getBundle(), and other places as well.

The reference implementation of this method uses the getStackClassLoader() method. Returns the ClassLoader of the method that called the caller. i.e. A.x() calls B.y() calls callerClassLoader(), A's ClassLoader will be returned. Returns null for the bootstrap ClassLoader.

Returns:
a ClassLoader or null for the bootstrap ClassLoader
Exceptions:
SecurityException when called from a non-bootstrap Class

static ClassLoader org.apache.harmony.kernel.vm.VM.bootCallerClassLoader (  )  [static]

This method must be provided by the vm vendor, as it is used by org.apache.harmony.luni.util.MsgHelp.setLocale() to get the bootstrap ClassLoader.

MsgHelp uses the bootstrap ClassLoader to find the resource bundle of messages packaged with the bootstrap classes. The reference implementation of this method uses the getStackClassLoader() method.

Returns the ClassLoader of the method that called the caller. i.e. A.x() calls B.y() calls callerClassLoader(), A's ClassLoader will be returned. Returns null for the bootstrap ClassLoader.

Returns:
a ClassLoader
Exceptions:
SecurityException when called from a non-bootstrap Class

static void org.apache.harmony.kernel.vm.VM.dumpString ( String  str  )  [static]

Native used to dump a string to the system console for debugging.

Parameters:
str String the String to display

static int org.apache.harmony.kernel.vm.VM.getCPIndexImpl ( Class<?>  targetClass  )  [static, package]

Get the classpath entry that was used to load the class that is the arg.

This method is for internal use only.

Parameters:
targetClass Class the class to set the classpath of.
See also:
java.lang.Class

static void org.apache.harmony.kernel.vm.VM.initializeVM (  )  [static, package]

Does internal initialization required by VM.

static void org.apache.harmony.kernel.vm.VM.addShutdownHook ( Thread  hook  )  [static]

Registers a new virtual-machine shutdown hook.

This is equivalent to the 1.3 API of the same name.

Parameters:
hook the hook (a Thread) to register

static boolean org.apache.harmony.kernel.vm.VM.removeShutdownHook ( Thread  hook  )  [static]

De-registers a previously-registered virtual-machine shutdown hook.

This is equivalent to the 1.3 API of the same name.

Parameters:
hook the hook (a Thread) to de-register
Returns:
true if the hook could be de-registered

static void org.apache.harmony.kernel.vm.VM.closeJars (  )  [static]

This method must be provided by the vm vendor.

Called to signal that the org.apache.harmony.luni.internal.net.www.protocol.jar.JarURLConnection class has been loaded and JarURLConnection.closeCachedFiles() should be called on VM shutdown.

static void org.apache.harmony.kernel.vm.VM.deleteOnExit (  )  [static]

This method must be provided by the vm vendor.

Called to signal that the org.apache.harmony.luni.util.DeleteOnExit class has been loaded and DeleteOnExit.deleteOnExit() should be called on VM shutdown.

static final int org.apache.harmony.kernel.vm.VM.getClassPathEntryType ( Object  classLoader,
int  cpIndex 
) [static, package]

Return the type of the specified entry on the class path for a ClassLoader.

Valid types are: CPE_TYPE_UNKNOWN CPE_TYPE_DIRECTORY CPE_TYPE_JAR CPE_TYPE_TCP - this is obsolete CPE_TYPE_UNUSABLE

Parameters:
classLoader the ClassLoader
cpIndex the index on the class path
Returns:
a int which specifies the class path entry type

static String [] org.apache.harmony.kernel.vm.VM.getVMArgs (  )  [static]

Returns command line arguments passed to the VM.

Internally these are broken into optionString and extraInfo. This only returns the optionString part.

Returns:
a String array containing the optionString part of command line arguments

static int org.apache.harmony.kernel.vm.VM.getClassPathCount (  )  [static, package]

Return the number of entries on the bootclasspath.

Returns:
an int which is the number of entries on the bootclasspath

static byte [] org.apache.harmony.kernel.vm.VM.getPathFromClassPath ( int  index  )  [static, package]

Return the specified bootclasspath entry.

Parameters:
index the index of the bootclasspath entry
Returns:
a byte array containing the bootclasspath entry specified in the vm options

static int org.apache.harmony.kernel.vm.VM.getKernelVersion (  )  [static]

This method must be provided by the vm vendor.

Returns an int containing the version number of the kernel. Used to check for kernel compatibility.

Returns:
an int containing the kernel version number


The documentation for this class was generated from the following file:

Genereated on Tue Dec 9 14:09:48 2008 by Doxygen.

(c) Copyright 2005, 2008 The Apache Software Foundation or its licensors, as applicable.