public class Vm extends Object implements VmConstants
Modifier and Type | Field and Description |
---|---|
static int |
CLIPBOARD_APPLICATION |
static int |
CLIPBOARD_OPEN_FOR_READ_ONLY |
static int |
CLIPBOARD_SYSTEM |
static int |
DEBUG_END_OBJECT_CREATION
An operation for debug(Object,int) - indicates that the names of the classes of
created objects should no longer be output on the console.
|
static int |
DEBUG_END_STACK_TRACE_FOR_CLASS
An operation for debug(Object,int) - indicates that the name of a class
and the stack trace should not be displayed when a new instance of the class is created.
|
static int |
DEBUG_STACK_TRACE
An operation for debug(Object,int) - indicates that the current stack trace
should be output to the console.
|
static int |
DEBUG_START_OBJECT_CREATION
An operation for debug(Object,int) - indicates that the names of the classes of
created objects should be output on the console.
|
static int |
DEBUG_START_STACK_TRACE_FOR_CLASS
An operation for debug(Object,int) - indicates that the name of a class
and the stack trace should be displayed when a new instance of the class is created.
|
static boolean |
TomMode |
BUSY_CURSOR, COPY_MULTIPLE_CURSOR, COPY_SINGLE_CURSOR, CROSS_CURSOR, DEFAULT_CURSOR, DONT_DROP_CURSOR, DRAG_MULTIPLE_CURSOR, DRAG_SINGLE_CURSOR, GET_PARAMATER_SIP_BUTTON_HEIGHT, GET_PARAMATER_SOFTKEY_BAR_HEIGHT, GET_SET_PARAMATER_PAINT_BUFFER_TIME, GET_SET_PARAMATER_PEN_MOVE_BUFFER_TIME, GET_SET_PARAMATER_RESIZE_BUFFER_TIME, HAND_CURSOR, IBEAM_CURSOR, INVISIBLE_CURSOR, JAR_RESOURCE_ID, LEFT_RIGHT_CURSOR, MOVE_CURSOR, NO_CURSOR, RESIZE_CURSOR, SET_USE_SIP, SIMULATE_SIP, TIMER_TICK, TURN_OFF_VM_FLAG_BITS, TURN_ON_VM_FLAG_BITS, UP_DOWN_CURSOR, VM_CLASS_MEMORY, VM_FILE_SEPARATOR, VM_FLAG_HAS_BACK_BUTTON, VM_FLAG_HAS_SOFT_KEYS, VM_FLAG_HAS_SOFTKEY_MENU_BUTTON, VM_FLAG_HIDDEN_SOFTKEYS, VM_FLAG_IS_APPLET, VM_FLAG_IS_MOBILE, VM_FLAG_IS_MONOCHROME, VM_FLAG_IS_ZAURUS_EVM, VM_FLAG_LOAD_FAKE_FILE, VM_FLAG_LOW_MEMORY, VM_FLAG_MAXIMIZE_APPS, VM_FLAG_NO_CR, VM_FLAG_NO_GUI, VM_FLAG_NO_KEYBOARD, VM_FLAG_NO_MOUSE_POINTER, VM_FLAG_NO_PEN, VM_FLAG_NO_VISIBLE_WINDOW, VM_FLAG_NO_WINDOWS, VM_FLAG_SIP_BUTTON_ALWAYS_SHOWN, VM_FLAG_SIP_BUTTON_ON_SCREEN, VM_FLAG_SIP_DISABLED, VM_FLAG_SLOW_MACHINE, VM_FLAG_SYSTEM_FONTS_ONLY, VM_FLAG_USE_NATIVE_TEXT_INPUT, VM_FLAG_USE_SOFT_KEYPAD, VM_FLAG_USING_CLASSES, VM_FLAGS, VM_NUM_OBJECTS, VM_NUM_THREADS, VM_OBJECT_MEMORY, VM_PATH_SEPARATOR, WAIT_CURSOR
Constructor and Description |
---|
Vm() |
Modifier and Type | Method and Description |
---|---|
static void |
addResourceDirectory(File resourceDirectory) |
static void |
addShutdown(Runnable shutdown)
These are executed only when Vm.exit() is called and before
System.exit() is called.
|
static void |
applicationStarted()
On some systems the VM displays a "Wait" cursor while the
application is starting.
|
static void |
callBackInSystemThread(CallBack callBack,
Object data)
This method should not be used unless you are writing operating system
specific native code.
|
static boolean |
canInstallSignalHandlers()
Returns if you can install signal handlers on this platform.
|
static int |
countObjects(boolean gcFirst)
Count how many Objects have been allocated and not garbage collected.
|
static int |
countThreads() |
static String |
createStringWithChars(char[] chars)
Create a new String that uses the specified character array without
creating a new character array for the String.
|
static void |
debug(Object parameters,
int operation)
Perform a special debuggin operation.
|
static void |
debug(String what) |
static void |
debugStackTrace()
Display on the console the current stack trace - leaving out this method call.
|
static void |
eveMain(String[] args) |
static void |
eveMainSetNoVisibleWindow()
This should be called in the eveMain() method of the starting
application.
|
static void |
eveStarted()
You would not normally call this.
|
static Process |
execCommandLine(String commandLine)
Runs a command line with quoted executable.
|
static void |
exit(int exitValue) |
static File |
findResourceAsFile(String name)
See if the named resource is actually a readable file on the local file system.
|
static void |
fixFillInStackTrace(int toIgnore)
On a native VM this tells the VM that the next call to Throwable.fillInStackTrace()
should ignore the specified number of lines.
|
static Applet |
getApplet()
If this Application is running as an Applet in a Web Browser,
then this will return an Object that implements the eve.sys.Applet interface,
otherwise it returns null.
|
static String |
getAStackTrace(Throwable t)
This gets a String representation of the full stack trace for a Throwable, but not for any
of its possible chained exceptions.
|
static String |
getCallingClassName(String myClassName) |
static String |
getCallingClassName(String myClassName,
String[] ignoreStartsWith) |
static Throwable |
getCause(Throwable target)
Get the "cause" of a target Throwable if one has been set and
if it is supported by the underlying VM.
|
static String |
getClipboardText()
Deprecated.
use an IClipboard returned from openClipboard() instead.
|
static String |
getenv(String envName)
This method attempts to get a system environment value, but since
that is not allowed for an Applet and in some versions of Java
it will instead fetch it
from a local property list.
|
static String |
getEnvOrProperty(String envName,
String defaultValue)
This first searches for an environment value using getenv(), and if
that returns null it will call getProperty().
|
static String |
getFullStackTrace(Throwable th)
This gets the fully expanded stack trace for the Throwable and all chained throwables.
|
static int |
getJavaEveLibraryVersion()
This will test if the loading of the java_eve DLL was successful and returns
the version of the DLL.
|
static Locale |
getLocale() |
static int |
getParameter(int whichParameter) |
static String |
getProperty(String propertyName,
String defaultValue)
This method attempts to get a System property, but since
that is not allowed for an Applet it will instead fetch it
from a local property list.
|
static IRegistryKey |
getRegistryKey(boolean localKey,
String path,
boolean fullAccess,
boolean createIfDoesntExist)
Get a local or remote registry key if supported.
|
static IRemoteProxyMaker |
getRemoteProxyMaker(Class forInterface,
int iRemoteProxyMakerOptions,
ClassLoader proxyClassLoader)
Get an IRemoteProxyMaker if available.
|
static String |
getStackTrace(Throwable t)
Get a String representation of the stack trace for a Throwable object.
|
static String |
getStackTrace(Throwable t,
int lines)
Get a String representation of the stack trace for a Throwable object.
|
static char[] |
getStringChars(String str)
Using the native VM this will expose the char array which represents the
String.
|
static long |
getTimeStampLong() |
static int |
getTrackKey(Object obj) |
static int |
getUsedClassMemory() |
static int |
getUsedObjectMemory(boolean gcFirst) |
static int |
getVersion() |
static String |
getVersionPostFix() |
static int |
getVmFlags()
Get the VM Flag bits - this is equivalent to getParameter(VM_FLAGS);
|
static WebApplication |
getWebApplication()
If this Application is running as an Applet in a Web Browser,
then this will return an Object that implements the eve.sys.Applet interface,
otherwise it returns null.
|
static void |
initializeLibrary(PropertyList initializeParameters)
This is used to initialize the non-Gui components of the Eve Java library if it is being used as part of a
separate non-Eve application.
|
static boolean |
installSignalHandler(SignalHandler handler,
int signal)
This is used to install a Signal handler if supported.
|
static boolean |
inSystemThread()
This method returns true if the current thread is considered to be a
System Thread - but this only applies to a native Eve VM, it will not
apply to a true Java VM.
|
static boolean |
isCalledBy(Class c) |
static boolean |
isJavaVM() |
static boolean |
isSystemThread(Thread t)
This method returns true if the specified thread is considered to be a
System Thread - but this only applies to a native Eve VM, it will not
apply to a true Java VM.
|
static void |
javaEnvironmentSet()
This is only called when being initialized by a Java VM.
|
static boolean |
javaEveLibraryLoaded()
If a true Java VM is running the Eve library then this returns true
only if the java_eve library has been successfully loaded.
|
static void |
loadLibrary(String libraryName)
Load a DLL library to support native methods in a system dependent way.
|
static void |
main(String[] args) |
static long |
modifyVmFlags(int flagsToTurnOn,
int flagsToTurnOff)
Modify the VM Flag bits - this is equivalent to getParameter(VM_FLAGS);
|
static File |
newFileObject() |
static IClipboard |
openClipboard(int timeout)
This gets an IClipboard object, waiting for a fixed length of time without being interrupted
and always returning a non-null IClipboard object.
|
static IClipboard |
openClipboard(int timeout,
int clipboardOptions)
This gets an IClipboard object, waiting for a fixed length of time without being interrupted
and always returning a non-null IClipboard object.
|
static IClipboard |
openClipboard(TimeOut waitFor)
Get an IClipboard object referencing a lock on the system clipboard.
|
static IClipboard |
openClipboard(TimeOut waitFor,
int options)
Get an IClipboard object referencing a lock on the system clipboard.
|
static InputStream |
openResource(Class clazz,
String name)
Open a resource that may be associated with a specific Class as an
InputStream.
|
static RandomStream |
openResourceAsRandomStream(Class clazz,
String name)
Open a resource that may be associated with a specific Class as a
RandomStream.
|
static RandomStream |
openZippedResourceAsRandomStream(Class clazz,
String zipName,
String nameInZip)
Open a resource residing in a Zip file that may be associated with a specific Class as a
RandomStream.
|
static String[] |
processCommandLine(String commandLine)
Prepare a command line for running.
|
static ByteArray |
readResource(Class clazz,
String name,
ByteArray dest)
Read a resource that may be associated with a specific Class into a
ByteArray in the most efficient way.
|
static void |
restoreVmFlags(long fromModifyVmFlags)
Restore the VM Flag bits to what they were before modifyVmFlags() was
called.
|
static void |
runServiceCommand(String command)
This is used on mobile devices to initiate services on the running
VM.
|
static Throwable |
setCause(Throwable target,
Throwable cause)
This provides a fully portable method of setting the "cause" of a Throwable for
exception chaining.
|
static void |
setClipboardText(String text)
Deprecated.
use an IClipboard returned from openClipboard() instead.
|
static boolean |
setFileSystem(File f)
Set a new File system.
|
static void |
setParameter(int whichParameter,
int value) |
static void |
setProperty(String propertyName,
String value) |
static String[] |
splitCommand(String args,
String prepend)
Deprecated.
|
static void |
startEve(String[] args)
Have this as the first line of your main() method to ensure that the eveMain()
method is called should the application be run on a Java VM.
|
static void |
startEve(String[] args,
String startClassName)
Have this as the first line of your main() method to ensure that the eveMain()
method is called should the application be run on a Java VM.
|
static String |
trackObject(int obj,
int options) |
static Process |
tryExecCommandLine(String command,
String[] paths,
boolean onlyInPaths,
StringBuffer executed)
Try to execute a command which may be in a number of different paths.
|
public static boolean TomMode
public static final int CLIPBOARD_APPLICATION
public static final int CLIPBOARD_SYSTEM
public static final int CLIPBOARD_OPEN_FOR_READ_ONLY
public static final int DEBUG_START_OBJECT_CREATION
public static final int DEBUG_END_OBJECT_CREATION
public static final int DEBUG_STACK_TRACE
public static final int DEBUG_START_STACK_TRACE_FOR_CLASS
public static final int DEBUG_END_STACK_TRACE_FOR_CLASS
public static int getJavaEveLibraryVersion()
public static void loadLibrary(String libraryName)
libraryName
- the library name.public static boolean javaEveLibraryLoaded()
public static void eveMainSetNoVisibleWindow()
public static int getVmFlags()
public static long modifyVmFlags(int flagsToTurnOn, int flagsToTurnOff)
flagsToTurnOn
- - the bits to set, if any.flagsToTurnOff
- - the bits to clear, if any.public static void restoreVmFlags(long fromModifyVmFlags)
fromModifyVmFlags
- the value returned by modifyVmFlags().public static void applicationStarted()
public static int getVersion()
public static String getVersionPostFix()
public static int getTrackKey(Object obj)
public static String trackObject(int obj, int options)
public static void fixFillInStackTrace(int toIgnore)
toIgnore
- the number of lines to ignore.public static void setClipboardText(String text)
public static String getClipboardText()
public static IClipboard openClipboard(TimeOut waitFor) throws InterruptedException
waitFor
- the time to wait or null to wait indefinitely.InterruptedException
public static IClipboard openClipboard(TimeOut waitFor, int options) throws InterruptedException
waitFor
- the time to wait or null to wait indefinitely.clipboardOptions
- any of the CLIPBOARD_XXX values OR'ed together.InterruptedException
public static IClipboard openClipboard(int timeout)
timeout
- how long to wait in milliseconds. A negative value implies an indefinite wait time.public static IClipboard openClipboard(int timeout, int clipboardOptions)
timeout
- how long to wait in milliseconds. A negative value implies an indefinite wait time.clipboardOptions
- any of the CLIPBOARD_XXX values OR'ed together.public static IRegistryKey getRegistryKey(boolean localKey, String path, boolean fullAccess, boolean createIfDoesntExist)
localKey
- true for a local key, false for a remote key.path
- the full path, starting with "HKEY_XXXX\". Note that you must
use '\' and not '/' characters as separators.fullAccess
- true for full read/write access, false for read-only.createIfDoesntExist
- true to create the key if it does not yet exist.public static Throwable getCause(Throwable target)
target
- the target Throwable.public static Throwable setCause(Throwable target, Throwable cause) throws IllegalArgumentException, IllegalStateException
target
- The target Throwable.cause
- The cause for the target.IllegalArgumentException
- If the cause is the same as the target.IllegalStateException
- If the cause for the target has already been set.public static boolean isSystemThread(Thread t)
A System Thread is one that is called by specific internal VM functions or one that has been invoked from a native method.
A System Thread cannot sleep, or wait without freezing the entire VM. Therefore if it should attempt to hold a monitor that is already held, or if it should attempt to call sleep(), or wait() or join another thread, an InvalidThreadException will be thrown. Also, a call to join() on a System Thread will also fail because the System Thread will never die.
You will hardly ever need to deal with a System Thread - usually only if you are writing a native code interface or if you are trying to maximally optimize certain operations.
t
- The Thread to check.public static boolean inSystemThread()
A System Thread is one that is called by specific internal VM functions or one that has been invoked from a native method.
A System Thread cannot sleep, or wait without freezing the entire VM. Therefore if it should attempt to hold a monitor that is already held, or if it should attempt to call sleep(), or wait() or join another thread, an InvalidThreadException will be thrown. Also, a call to join() on a System Thread will also fail because the System Thread will never die.
You will hardly ever need to deal with a System Thread - usually only if you are writing a native code interface or if you are trying to maximally optimize certain operations.
public static boolean setFileSystem(File f)
f
- public static File newFileObject()
public static void debug(Object parameters, int operation)
parameters
- dependent on the operation.operation
- one of the DEBUG_XXX values.public static void setParameter(int whichParameter, int value)
public static int getParameter(int whichParameter)
public static int countObjects(boolean gcFirst)
gcFirst
- true to do a System.gc() call first.public static int countThreads()
public static int getUsedObjectMemory(boolean gcFirst)
public static int getUsedClassMemory()
public static char[] getStringChars(String str)
Use this with care! If you write into it using the native VM you will change the String which is SUPPOSED to be immutable. Under a JavaVM this will return a COPY of the string arrays.
public static String createStringWithChars(char[] chars)
Use this with care. After creating the String you may be able to change it since you may have direct access to the String's characters. However under some systems (e.g. Java) this method may allocate a new copy of the array so do not assume that the provided character array will be used directly.
public static long getTimeStampLong()
public static void callBackInSystemThread(CallBack callBack, Object data)
This method will cause the callBack() method of the specified CallBack object to be called in a separate System Thread. Under a true Java VM, this will be called under a separate normal Thread since there is no System Thread in a Java VM. Under the Eve VM it will be called back at the soonest opertunity within the System Thread.
callBack
- The CallBack to be called.data
- Optional data to send to the CallBack object.public static Locale getLocale()
public static void debug(String what)
public static void javaEnvironmentSet()
public static void addResourceDirectory(File resourceDirectory)
public static ByteArray readResource(Class clazz, String name, ByteArray dest)
clazz
- an optional Class if the resource is associated with a particular
Class.name
- a path name for the resource (which may include '/' characters).dest
- an optional destination ByteArray to append the data to. If this
is null a new one will be created and returned.public static InputStream openResource(Class clazz, String name) throws FileNotFoundException
clazz
- an optional Class if the resource is associated with a particular
Class.name
- a path name for the resource (which may include '/' characters).FileNotFoundException
- if the resource could not be found.public static File findResourceAsFile(String name)
name
- the relative resource name which may include "/" characters.public static RandomStream openResourceAsRandomStream(Class clazz, String name) throws FileNotFoundException
clazz
- an optional Class if the resource is associated with a particular
Class.name
- a path name for the resource (which may include '/' characters).FileNotFoundException
- if the resource could not be found.public static RandomStream openZippedResourceAsRandomStream(Class clazz, String zipName, String nameInZip) throws FileNotFoundException
clazz
- an optional Class if the resource is associated with a particular
Class.zipName
- a path name for the resource (which may include '/' characters) which should be a zip file.FileNotFoundException
- if the resource OR zip file could not be found.public static boolean isJavaVM()
public static String getProperty(String propertyName, String defaultValue)
propertyName
- the name of the property.defaultValue
- the default value if it is not found.public static String getenv(String envName)
envName
- the name of the environment value.public static String getEnvOrProperty(String envName, String defaultValue)
envName
- the environment value name.defaultValue
- the default value to return if not found.public static void eveStarted()
public static String getStackTrace(Throwable t)
t
- The throwable object.public static String getFullStackTrace(Throwable th)
th
- The throwable.public static String getAStackTrace(Throwable t)
t
- The Throwablepublic static String getStackTrace(Throwable t, int lines)
t
- The throwable object.lines
- The number of lines to retrieve. If lines <= 0 then all lines will be retrievedpublic static void debugStackTrace()
public static void exit(int exitValue)
public static void addShutdown(Runnable shutdown)
shutdown
- the Runnable to run at shutdown.public static void initializeLibrary(PropertyList initializeParameters)
public static void startEve(String[] args, String startClassName)
args
- the same arguments passed to your main() method.public static boolean isCalledBy(Class c)
public static String getCallingClassName(String myClassName, String[] ignoreStartsWith)
public static void startEve(String[] args)
args
- the same arguments passed to your main() method.public static String[] processCommandLine(String commandLine)
commandLine
- the command line to use, the executable may
be placed in quotes.public static Process tryExecCommandLine(String command, String[] paths, boolean onlyInPaths, StringBuffer executed)
command
- the command line to execute. This may have the
executable file in quotations if it contains spaces.paths
- a list of paths to check in or null to not check in
any paths. Do not place quotations around these. If the command itself
starts with a quotation mark, which indicates that the executable
is in quotations, then the quotations will be extended around
the paths as they are added to the front of the path.onlyInPaths
- if this is true then the command on its own
will not be executed - it will only be executed in one of the
provided paths.executed
- if this is not null and execution is successful
then the executed path is appended to this StringBuffer.public static Process execCommandLine(String commandLine) throws IOException
commandLine
- the command line to use, the executable may
be placed in quotes.IOException
- if the command line could not be executed.public static String[] splitCommand(String args, String prepend)
args
- a command list. This will be split using spaces as the
separator. Any text within quotes are preserved, including contained
spaces. The quotes themselves are also preserved.prepend
- an optional single String to place as the first
element in the array (this will NOT be split).public static Applet getApplet()
public static WebApplication getWebApplication()
public static void eveMain(String[] args)
public static IRemoteProxyMaker getRemoteProxyMaker(Class forInterface, int iRemoteProxyMakerOptions, ClassLoader proxyClassLoader)
forInterface
- the interface the IRemoteProxyMaker will be implementing.iRemoteProxyMakerOptions
- any of the IRemoteProxyMaker.OPTION_XXX values
ORed together.proxyClassLoader
- an optional ClassLoader to be used when making the proxy.public static void runServiceCommand(String command) throws IOException
command
- the command of the service request.IOException
- on any error.public static void main(String[] args)
public static boolean canInstallSignalHandlers()
public static boolean installSignalHandler(SignalHandler handler, int signal)
handler
- the handler to install.signal
- the signal to install a handler for.