W3cubDocs

/Scala 2.12 Library

Package scala.sys

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

Linear Supertypes

Type Members

trait BooleanProp extends Prop[Boolean]

trait Prop[+T] extends AnyRef

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. 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. 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. 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

scala.sys.ShutdownHookThread

def allThreads(): IndexedSeq[Thread]

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.

returns

a Map containing the system environment variables.

def error(message: String): Nothing

Throw a new RuntimeException with the supplied message.

returns

Nothing.

def exit(status: Int): Nothing

Exit the JVM with the given status code.

returns

Nothing.

def exit(): Nothing

Exit the JVM with the default status code.

returns

Nothing.

def props: SystemProperties

A bidirectional, mutable Map representing the current system Properties.

returns

a SystemProperties.

See also

scala.sys.SystemProperties

def runtime: Runtime

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. See scala.sys.Prop for particulars.

Example:
    if (!headless.isSet) headless.enable()

© 2002-2019 EPFL, with contributions from Lightbend.
Licensed under the Apache License, Version 2.0.
https://www.scala-lang.org/api/2.12.9/scala/sys/index.html