FileDocCategorySizeDatePackage
VM.javaAPI DocAndroid 1.5 API10247Wed May 06 22:41:04 BST 2009org.apache.harmony.kernel.vm

VM

public final class VM extends Object
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.

Fields Summary
private static final int
kernelVersion
static final int
CPE_TYPE_UNKNOWN
static final int
CPE_TYPE_DIRECTORY
static final int
CPE_TYPE_JAR
static final int
CPE_TYPE_TCP
static final int
CPE_TYPE_UNUSABLE
Constructors Summary
Methods Summary
public static voidaddShutdownHook(java.lang.Thread hook)
Registers a new virtual-machine shutdown hook. This is equivalent to the 1.3 API of the same name.

param
hook the hook (a Thread) to register

        return;
    
public static java.lang.ClassLoaderbootCallerClassLoader()
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.

return
a ClassLoader
throws
SecurityException when called from a non-bootstrap Class

        return null;
    
public static java.lang.ClassLoadercallerClassLoader()
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.

return
a ClassLoader or null for the bootstrap ClassLoader
throws
SecurityException when called from a non-bootstrap Class

        return null;
    
public static voidcloseJars()
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.

        return;
    
public static voiddeleteOnExit()
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.

        return;
    
public static voiddumpString(java.lang.String str)
Native used to dump a string to the system console for debugging.

param
str String the String to display

        return;
    
static java.lang.ClassfindClassOrNull(java.lang.String className, java.lang.ClassLoader classLoader)
Native used to find and load a class using the VM

return
java.lang.Class the class or null.
param
className String the name of the class to search for.
param
classLoader the classloader to do the work

        return null;
    
static intgetCPIndexImpl(java.lang.Class targetClass)
Get the classpath entry that was used to load the class that is the arg.

This method is for internal use only.

param
targetClass Class the class to set the classpath of.
see
java.lang.Class

        return 0;
    
static intgetClassPathCount()
Return the number of entries on the bootclasspath.

return
an int which is the number of entries on the bootclasspath

        return 0;
    
static final intgetClassPathEntryType(java.lang.Object classLoader, int cpIndex)
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

param
classLoader the ClassLoader
param
cpIndex the index on the class path
return
a int which specifies the class path entry type


                                                           
           
        return 0;
    
public static intgetKernelVersion()
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.

return
an int containing the kernel version number

        return kernelVersion;
    
public static final java.lang.ClassLoadergetNonBootstrapClassLoader()
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.

return
the first non-bootstrap ClassLoader on the stack

        return null;
    
static byte[]getPathFromClassPath(int index)
Return the specified bootclasspath entry.

param
index the index of the bootclasspath entry
return
a byte array containing the bootclasspath entry specified in the vm options

        return null;
    
static final java.lang.ClassLoadergetStackClassLoader(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. 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:
  • This method operates on the defining classes of methods on stack. NOT the classes of receivers.
  • The item at depth zero is the caller of this method

param
depth the stack depth of the requested ClassLoader
return
the ClassLoader at the specified depth
see
java.lang.ClassLoader#getStackClassLoader


                                                                                                                                                     
         
        return null;
    
public static java.lang.String[]getVMArgs()
Returns command line arguments passed to the VM. Internally these are broken into optionString and extraInfo. This only returns the optionString part.

return
a String array containing the optionString part of command line arguments

        return null;
    
public static final voidinitializeClassLoader(java.lang.ClassLoader loader, boolean bootLoader)
Initialize the classloader.

param
loader ClassLoader the ClassLoader instance
param
bootLoader boolean true for the bootstrap class loader

        return;
    
static voidinitializeVM()
Does internal initialization required by VM.

    
public static final java.lang.Stringintern(java.lang.String string)
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. Returns 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.

param
string the String to intern
return
the interned string equal to the specified String

        return null;
    
public static booleanremoveShutdownHook(java.lang.Thread hook)
De-registers a previously-registered virtual-machine shutdown hook. This is equivalent to the 1.3 API of the same name.

param
hook the hook (a Thread) to de-register
return
true if the hook could be de-registered

        return false;