aicas logoJamaica 6.4 release 1

java.lang
Class System

java.lang.Object
  extended by java.lang.System

public final class System
extends Object

System contains static fields and methods that permit access to properties of the current environment. This includes standard input, output and error streams, environment variables and security manager.

Since:
1.0

Field Summary
static PrintStream err
          The standard error stream.
static InputStream in
          The standard input stream.
static PrintStream out
          The standard output stream.
 
Method Summary
static void arraycopy(Object src, int sp, Object dst, int dp, int length)
          arraycopy copies element from one array to another array.
static String clearProperty(String key)
          clearProperty removes a given property
static Console console()
           
static long currentTimeMillis()
          setProp(b75b89c0,b75b89a0) currentTimeMillis returns the current time measured from 00:00:00 1 Jan 1970 in milliseconds.
static void exit(int status)
          exit terminates the currently running Java application and the VM.
static void gc()
          gc indicates to the VM that it may be a good time to run the garbage collector.
static Map<String,String> getenv()
          Returns an unmodifiable string map view of the current system environment.
static String getenv(String name)
          Gets the value of the specified environment variable.
static Properties getProperties()
          getProperties returns the system properties.
static String getProperty(String key)
          getProperty returns the value of a given property.
static String getProperty(String key, String def)
          getProperty returns the value of a given property, or a default value if the property is not set.
static SecurityManager getSecurityManager()
          getSecurityManager returns the currently installed security manager.
static int identityHashCode(Object x)
          identityHashCode returns the same hash code that is returned by the not-overwritten Object.hashCode() function.
static Channel inheritedChannel()
          inheritedChannel
static void load(String filename)
          load a library or system file.
static void loadLibrary(String libname)
          loadLibrary loads a system library with the given name into the system.
static String mapLibraryName(String libname)
          mapLibraryName maps a library name to the corresponding platform-specific native library name
static long nanoTime()
          nanoTime returns a raw high resolution time value.
static void runFinalization()
          runFinalization runs the finalize() method of all objects that are pending for finalization.
static void runFinalizersOnExit(boolean value)
          Deprecated. running the finalizers is unsafe, therefore this method is deprecated.
static void setErr(PrintStream err)
          setErr sets System.err to a new value.
static void setIn(InputStream in)
          setIn sets System.in to a new value.
static void setOut(PrintStream out)
          setOut sets System.out to a new value.
static void setProperties(Properties props)
          Set the current set of system properties to the given argument.
static String setProperty(String key, String value)
          setProperty sets property for a given key.
static void setSecurityManager(SecurityManager s)
          setSecurityManager sets a new security manager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

in

public static final InputStream in
The standard input stream.

NOTE: This field is not as final as it may seem, its value can be modified by a call to setIn.


out

public static final PrintStream out
The standard output stream.

NOTE: This field is not as final as it may seem, its value can be modified by a call to setOut.


err

public static final PrintStream err
The standard error stream.

NOTE: This field is not as final as it may seem, its value can be modified by a call to setErr.

Method Detail

identityHashCode

public static int identityHashCode(Object x)
identityHashCode returns the same hash code that is returned by the not-overwritten Object.hashCode() function. This hashcode value is guaranteed never to change during the lifetime of an object.

For JamaicaVM, on a 32-bit system, this function returns the object's memory address modified with shift and XOR operations. The hashcode is unique for every object with JamaicaVM.

Parameters:
x - an object or null
Returns:
a hashcode value for x, or 0 if x is null.
Since:
1.1

setIn

public static void setIn(InputStream in)
setIn sets System.in to a new value.

Parameters:
in - new value for System.in
Throws:
SecurityException - if a security manager sm is installed and sm.checkPermission(new RuntimePermission("setIO")) throws this exception.
Since:
1.1

setOut

public static void setOut(PrintStream out)
setOut sets System.out to a new value.

Parameters:
out - new value for System.out
Throws:
SecurityException - if a security manager sm is installed and sm.checkPermission(new RuntimePermission("setIO")) throws this exception.
Since:
1.1

setErr

public static void setErr(PrintStream err)
setErr sets System.err to a new value.

Parameters:
err - new value for System.err
Throws:
SecurityException - if a security manager sm is installed and sm.checkPermission(new RuntimePermission("setIO")) throws this exception.
Since:
1.1

setSecurityManager

public static void setSecurityManager(SecurityManager s)
setSecurityManager sets a new security manager.

ensure

   (getSecurityManager() == s)
 

Parameters:
s - the new security manager, null to reset the security manager
Throws:
SecurityException - if a security manager sm is installed and sm.checkPermission(new RuntimePermission("setSecurityManager")) throws this exception.

getSecurityManager

public static SecurityManager getSecurityManager()
getSecurityManager returns the currently installed security manager.

Returns:
the current security manager or null if none.

arraycopy

public static void arraycopy(Object src,
                             int sp,
                             Object dst,
                             int dp,
                             int length)
arraycopy copies element from one array to another array.

src and dst must be arrays E[] of a common element type E that is one of boolean, byte, short, char, int, float, long, double or Object.

ensure

   (for all i=0..length-1: dst[dp+i] == old src[sp+i]);
 

Parameters:
src - a source array
sp - start index in src
dst - (out!) the destination array
dp - start index in dst
length - the number of elements to be copied.
Throws:
NullPointerException - if src or dst are null. No modifications are made in this case.
ArrayStoreException - if src or dst is not an array or if src and dst are arrays of different primitive element types or if one of src and dst is an array of references and the other array is an array of primitive types. No modifications are made in these cases.
ArrayStoreException - if src and dst are reference arrays and one element of src[sp+k] cannot be stored into dst[dp+k]. In this case, elements from src[sp+0..sp+k-1] will have been copied to dst[dp+0..dp+k-1], or, if src==dst and dp>sp, then src[sp+k+1..sp+length-1] will haven been copied to dst[dp+k+1..dp+length-1].
IndexOutOfBoundsException - if sp<0 || dp<0 || length<0 || sp+length>src.length || dp+length>dst.length.

currentTimeMillis

public static long currentTimeMillis()
setProp(b75b89c0,b75b89a0) currentTimeMillis returns the current time measured from 00:00:00 1 Jan 1970 in milliseconds.

The underlying system may have a granularity that is less than this function.

Returns:
the current time in milliseconds.

getProperties

public static Properties getProperties()
getProperties returns the system properties. Repeated calls to getProperties will return the same reference (unless the properties were reset via setProperties(Properties)).

The standard properties include:

   java.version                   Java version
   java.vendor                    Java vendor (aicas GmbH in this case)
   java.vendor.url                Java vendor URL (http://www.aicas.com)
   java.home                      VM's home directory
   java.vm.specification.version  JVM spec version
   java.vm.specification.vendor   JVM spec vendor
   java.vm.specification.name     JVM spec name
   java.vm.version                JVM version
   java.vm.vendor                 JVM vendor (aicas GmbH)
   java.vm.name                   JVM name (JamaicaVM)
   java.specification.version     Java spec version
   java.specification.vendor      Java spec vendor
   java.specification.name        Java spec name
   java.class.version             Java class file version
   java.class.path                Java classpath
   java.library.path              Java shared library path
   java.io.tmpdir                 path for temporary directory
   java.compiler                  Compiler used
   java.ext.dirs                  extension library directory
   os.name                        OS name
   os.arch                        CPU architecture
   os.version                     OS version
   file.separator                 "/" on Linux, "\\" on Windows, etc.
   path.separator                 ":" on Linux, ";" on Windows, etc.
   line.separator                 "\n" on Linux, "\n\r" on Windows, etc.
   user.name                      user login name
   user.home                      user home directory
   user.dir                       current working directory
 

Returns:
the current system properties, never null.
Throws:
SecurityException - if a security manager sm is installed and sm.checkPropertiesAccess() throws this exception.

setProperties

public static void setProperties(Properties props)
Set the current set of system properties to the given argument.

Parameters:
props - the new properties. null to erase all current properties.
Throws:
SecurityException - if a security manager is installed and its checkPropertiesAccess() method throws this exception.

getProperty

public static String getProperty(String key)
getProperty returns the value of a given property.

Parameters:
key - the property name
Returns:
the value of the property with name key, or null if this property was not set.
Throws:
IllegalArgumentException - if key is ""
NullPointerException - if key is null
SecurityException - if a security manager sm is installed and sm.checkPropertyAccess(key) throws this exception.

getProperty

public static String getProperty(String key,
                                 String def)
getProperty returns the value of a given property, or a default value if the property is not set.

Parameters:
key - the property name
Returns:
the value of the property with name key, or def if this property was not set.
Throws:
IllegalArgumentException - if key is ""
NullPointerException - if key is null
SecurityException - if a security manager sm is installed and sm.checkPropertyAccess(key) throws this exception.

setProperty

public static String setProperty(String key,
                                 String value)
setProperty sets property for a given key.

Parameters:
key - the property key
value - the new property value
Returns:
the old value of the property with name key or null if it was not set.
Throws:
IllegalArgumentException - if key is ""
NullPointerException - if key or value is null
SecurityException - if a security manager sm is installed and sm.checkPermission(new PropertyPermission(key,"write")) throws this exception.
Since:
1.2

clearProperty

public static String clearProperty(String key)
clearProperty removes a given property

Parameters:
key - the property key
Returns:
the old value of the property with name key or null if it was not set.
Throws:
IllegalArgumentException - if key is ""
NullPointerException - if key is null
SecurityException - if a security manager sm is installed and sm.checkPermission(new PropertyPermission(key,"write")) throws this exception.
Since:
1.5

getenv

public static String getenv(String name)
Gets the value of the specified environment variable. Handling environment variables must be supported on the system. If the environment variable can't be read, null is returned. Both the name and the value of the variable are limited to the maximum path length of the system.

Parameters:
name - name of the environment variable
Returns:
the string value of the variable, or null if the variable is not defined in the system environment
Throws:
NullPointerException - if name is null *
SecurityException - if a security manager sm is installed and sm.checkPermission(new RuntimePermission("getenv." + name)) throws this exception.
See Also:
ProcessBuilder.environment()

getenv

public static Map<String,String> getenv()
Returns an unmodifiable string map view of the current system environment. The environment is a system-dependent mapping from names to values which is passed from parent to child processes.

If the system does not support environment variables, an empty map is returned.

The returned map will never contain null keys or values. Attempting to query the presence of a null key or value will throw a NullPointerException. Attempting to query the presence of a key or value which is not of type String will throw a ClassCastException.

The returned map and its collection views may not obey the general contract of the Object.equals(java.lang.Object) and Object.hashCode() methods.

The returned map is typically case-sensitive on all platforms.

If a security manager exists, its checkPermission method is called with a RuntimePermission("getenv.*") permission. This may result in a SecurityException being thrown.

When passing information to a Java subprocess, system properties are generally preferred over environment variables.

Returns:
the environment as a map of variable names to values
Throws:
SecurityException - if a security manager exists and its checkPermission method doesn't allow access to the process environment
Since:
1.5
See Also:
getenv(String), ProcessBuilder.environment()

exit

public static void exit(int status)
exit terminates the currently running Java application and the VM. It runs the shutdown hooks and exits the VM.

This function is short hand for Runtime.getRuntime().exit(status).

Parameters:
status - exit status, 0 for ok.
Throws:
SecurityException - if a security manager is installed and its checkExit(status) method throws this exception.

gc

public static void gc()
gc indicates to the VM that it may be a good time to run the garbage collector.

For JamaicaVM, a call to Runtime.gc() will perform at least one full garbage collection cycle and at most two full garbage collection cycles. A call to gc() may therefore require a significant amount of time.

Note that running the garbage collector alone does not ensure that memory that is occupied by objects that have a finalize() method will be reclaimed: Their memory will be held until the finalize() method has been executed and the object is found to be unreachable after a second GC cycle. To ensure that all finalizers are executed and the memory of finalized objects is freed, three calls are required as follows:

   Runtime.getRuntime().gc();  // find garbage
   Runtime.getRuntime().runFinalization(); // execute finalizers
   Runtime.getRuntime().gc();  // recycle finalized objects.
 

Any weak, soft or phantom references used in JamaicaVM will be updated also via the runFinalization(), i.e., an object to which a weak, soft or phantom reference exist can only be reclaimed when runFinalization() is called either by the finalizer thread or by an application thread,

To increase the overall system performance, it may be wise to run a low-priority thread that calls gc() and runFinalization() perpetually:

   while (true)
     {
       Runtime.getRuntime().gc();
       Runtime.getRuntime().runFinalization();
     }
 

This will use all free CPU time to keep the amount of allocated memory as low as possible, such that memory allocation overhead for all higher-priority threads is minimized.

This function is short hand for Runtime.getRuntime().gc().


runFinalization

public static void runFinalization()
runFinalization runs the finalize() method of all objects that are pending for finalization. The finalize methods will be executed within the current thread.

Running the finalizers will permit the garbage collector to reclaim the memory occupied by these objects. However, the memory cannot be reclaimed immediately after execution of finalize(). Instead, since finalize() may have made the object reachable again, the garbage collector first has to show that no new references to the object have been generated. So in the worst case, the garbage collector needs to complete a full GC cycle before the memory can be reclaimed.

In JamaicaVM, runFinalization is wrapped into HeapMemory.executeInArea(), such that it can be called from scoped or immortal memory as well.

This function is short hand for Runtime.getRuntime().runFinalization().


runFinalizersOnExit

@Deprecated
public static void runFinalizersOnExit(boolean value)
Deprecated. running the finalizers is unsafe, therefore this method is deprecated.

Set flag if finalizers should be run in exit of the JVM.

For JamaicaVM, the finalizer of boot classes are not run even if this routine was called with a true argument. The reason is that these finalizers would do things like closing System.out, which would make it very hard to do anything useful afterwards.

This function is equivalent to Runtime.runFinalizersOnExit().

Parameters:
value - flag
Throws:
SecurityException - if a security manager is installed and its checkExit(0) method throws this exception.
Since:
1.1

load

public static void load(String filename)
load a library or system file.

If a security manager sm is installed, sm.checkLink(filename) is called to check the permission to load this library.

Repeated attempts to load the same library will have not effect.

This function is short hand for Runtime.getRuntime().load(String).

Parameters:
filename - absolute pathname of the library to loaded.
Throws:
NullPointerException - if filename is null
UnsatisfiedLinkError - if the library could not be loaded from the specified file.
SecurityException - if a security manager sm is installed and sm.checkLink(filename) throws this exception.

loadLibrary

public static void loadLibrary(String libname)
loadLibrary loads a system library with the given name into the system. The place where library are loaded from (e.g., the library path) and the exact file name (pre- and suffixes etc.) are system dependent.

If a security manager sm is installed, sm.checkLink(filename) is called to check the permission to load this library.

Repeated calls of this method have no effect, any library is loaded only once.

This function is short hand for Runtime.getRuntime().loadLibrary(String).

Parameters:
libname - the library name, excluding path, suffix etc.
Throws:
NullPointerException - if libname is null
UnsatisfiedLinkError - if the library with the specified name could not be loaded.
SecurityException - if a security manager sm is installed and sm.checkLink(libname) throws this exception.

mapLibraryName

public static String mapLibraryName(String libname)
mapLibraryName maps a library name to the corresponding platform-specific native library name

Parameters:
libname - the library name, e.g. "m"
Returns:
the native library name, e.g. "libm.so", never null
Throws:
NullPointerException - if libname is null.
Since:
1.2

inheritedChannel

public static Channel inheritedChannel()
                                throws IOException
inheritedChannel

Returns:
NYI
Throws:
IOException
Since:
1.5

nanoTime

public static long nanoTime()
nanoTime returns a raw high resolution time value. The result is not relative to any specific basis and is intended to measure intervals only. The result typically has a high precision for measuring short time intervals, but a low accuracy for longer intervals.

On systems with dynamically changing CPU clock speeds, the accuracy may vary dramatically with the changes in CPU clock.

On an overflow of the CPU cycle counter, the result of nanoTime() will drop suddenly from a high positive value to a low negative value. This occurs rarely, e.g., on a 3GHz system with a 64 bit cycle counter, an overflow occurs after 97 years (assuming an initial counter value of 0). When this happens, the difference between the result of nanoTime() and that of a call to nanoTime() before the CPU cycle counter overflow will not be a measure of the time between these two calls.

On a system with a cycle speed of less then 1GHz, an overflow of the nano seconds counter may occur before the CPU cycle counter overflows. In the case of an overflow of the result of nanoTime() will represent the lower 64 bits of the correct nano seconds, i.e. the difference between two consecutive calls will be correct unless the time passed between two calls exceeds about 292 years.

Returns:
a raw time value in nanoseconds. 0 on systems that don't permit access to CPU cycle counter.
Since:
1.5

console

public static Console console()

aicas logoJamaica 6.4 release 1

aicas GmbH, Karlsruhe, Germany —www.aicas.com
Copyright © 2001-2015 aicas GmbH. All Rights Reserved.