package sys
The package object scala.sys
contains methods for reading
and altering core aspects of the virtual machine as well as the
world outside of it.
- Source
- package.scala
- Since
2.9
- Alphabetic
- By Inheritance
- sys
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
-
trait
BooleanProp extends Prop[Boolean]
A few additional conveniences for Boolean properties.
-
trait
Prop[+T] extends AnyRef
A lightweight interface wrapping a property contained in some unspecified map.
A lightweight interface wrapping a property contained in some unspecified map. Generally it'll be the system properties but this is not a requirement.
See
scala.sys.SystemProperties
for an example usage.- Since
2.9
-
class
ShutdownHookThread extends Thread
A minimal Thread wrapper to enhance shutdown hooks.
A minimal Thread wrapper to enhance shutdown hooks. It knows how to unregister itself.
- Since
2.9
-
class
SystemProperties extends AbstractMap[String, String] with Map[String, String]
A bidirectional map wrapping the java System properties.
A bidirectional map wrapping the java System properties. Changes to System properties will be immediately visible in the map, and modifications made to the map will be immediately applied to the System properties. If a security manager is in place which prevents the properties from being read or written, the AccessControlException will be caught and discarded.
Value Members
-
def
addShutdownHook(body: ⇒ Unit): ShutdownHookThread
Register a shutdown hook to be run when the VM exits.
Register a shutdown hook to be run when the VM exits. The hook is automatically registered: the returned value can be ignored, but is available in case the Thread requires further modification. It can also be unregistered by calling ShutdownHookThread#remove().
Note that shutdown hooks are NOT guaranteed to be run.
- body
the body of code to run at shutdown
- returns
the Thread which will run the shutdown hook.
- See also
-
def
allThreads(): IndexedSeq[Thread]
Returns all active thread in the current thread's thread group and subgroups.
Returns all active thread in the current thread's thread group and subgroups.
- returns
an IndexedSeq containing the threads.
-
def
env: Map[String, String]
An immutable Map representing the current system environment.
An immutable Map representing the current system environment.
- returns
a Map containing the system environment variables.
-
def
error(message: String): Nothing
Throw a new RuntimeException with the supplied message.
Throw a new RuntimeException with the supplied message.
- returns
Nothing.
-
def
exit(status: Int): Nothing
Exit the JVM with the given status code.
Exit the JVM with the given status code.
- returns
Nothing.
-
def
exit(): Nothing
Exit the JVM with the default status code.
Exit the JVM with the default status code.
- returns
Nothing.
-
def
props: SystemProperties
A bidirectional, mutable Map representing the current system Properties.
A bidirectional, mutable Map representing the current system Properties.
- returns
a SystemProperties.
- See also
-
def
runtime: Runtime
A convenience method to get the current Runtime instance.
A convenience method to get the current Runtime instance.
- returns
the result of
java.lang.Runtime.getRuntime()
- object BooleanProp
- object Prop
- object ShutdownHookThread
-
object
SystemProperties
The values in SystemProperties can be used to access and manipulate designated system properties.
The values in SystemProperties can be used to access and manipulate designated system properties. See
scala.sys.Prop
for particulars.if (!headless.isSet) headless.enable()
Example:
This is the documentation for the Scala standard library.
Package structure
The scala package contains core types like
Int
,Float
,Array
orOption
which are accessible in all Scala compilation units without explicit qualification or imports.Notable packages include:
scala.collection
and its sub-packages contain Scala's collections frameworkscala.collection.immutable
- Immutable, sequential data-structures such asVector
,List
,Range
,HashMap
orHashSet
scala.collection.mutable
- Mutable, sequential data-structures such asArrayBuffer
,StringBuilder
,HashMap
orHashSet
scala.collection.concurrent
- Mutable, concurrent data-structures such asTrieMap
scala.collection.parallel.immutable
- Immutable, parallel data-structures such asParVector
,ParRange
,ParHashMap
orParHashSet
scala.collection.parallel.mutable
- Mutable, parallel data-structures such asParArray
,ParHashMap
,ParTrieMap
orParHashSet
scala.concurrent
- Primitives for concurrent programming such asFutures
andPromises
scala.io
- Input and output operationsscala.math
- Basic math functions and additional numeric types likeBigInt
andBigDecimal
scala.sys
- Interaction with other processes and the operating systemscala.util.matching
- Regular expressionsOther packages exist. See the complete list on the right.
Additional parts of the standard library are shipped as separate libraries. These include:
scala.reflect
- Scala's reflection API (scala-reflect.jar)scala.xml
- XML parsing, manipulation, and serialization (scala-xml.jar)scala.swing
- A convenient wrapper around Java's GUI framework called Swing (scala-swing.jar)scala.util.parsing
- Parser combinators (scala-parser-combinators.jar)Automatic imports
Identifiers in the scala package and the
scala.Predef
object are always in scope by default.Some of these identifiers are type aliases provided as shortcuts to commonly used classes. For example,
List
is an alias forscala.collection.immutable.List
.Other aliases refer to classes provided by the underlying platform. For example, on the JVM,
String
is an alias forjava.lang.String
.