Add a function to be called on VM shutdown. Throw NotImmutableErr if the function is not immutable. Default implementation delegates to parent.
Microprocessor architecture name as one of the following constants:
Return a negative integer, zero, or a positive integer if this object is less than, equal to, or greater than the specified object:
this < that => <0
this == that => 0
this > that => >0
This method may also be accessed via the <
<=
<=>
>=
and >
shortcut operators. If not overridden the default
implementation compares the toStr
representations. Also see docLang.
Examples:
3.compare(8) => -1
8.compare(3) => 1
8.compare(8) => 0
3 <=> 8 => -1 // shortcut for 3.compare(8)
Compile a script file into a pod and return the first public type declared in the script file. If the file has been previously compiled and hasn't changed, then a cached type is returned. If the script contains errors then the first CompilerErr found is thrown. The options available:
true
to not use caching, always forces a
recompileCompile a script file into a pod and return the JS source code of resulting pod. If the script contains errors then the first CompilerErr found is thrown. The options available:
Lookup a configuration property for given pod/key pair. If
not found then return def
. Default implementation routes to
props using max age of one minute:
props(pod, `config.props`, 1min).get(key, def)
Also see Pod.config and docLang::Env.
Optional
def: stringCompare this object to the specified for equality. This
method may be accessed via the == and != shortcut operators.
If not overridden the default implementation compares for
reference equality using the === operator. If this method
is overridden, then hash() must also be overridden such that
any two objects which return true for equals() must return
the same value for hash(). This method must accept null
and
return false.
Terminate the current virtual machine. Default implementation delegates to parent.
Optional
status: numberRun the garbage collector. No guarantee is made to what the VM will actually do. Default implementation delegates to parent.
Return a unique hashcode for this object. If a class overrides hash() then it must ensure if equals() returns true for any two objects then they have same hash code.
Get the local host name of the machine running the virtual machine process. Default implementation delegates to parent.
Return list of all pod names that define the given key. NOTE: Java runtime only
Get the Java VM Version as a single integer (8, 9, etc.). If the runtime is not java, return 0.
Lookup a localized property for the specified pod/key pair. The following rules are used for resolution:
props(pod,
locale/{locale}.props)
props(pod,
locale/{lang}.props)
props(pod,
locale/en.props)
pod::key
unless def
specifiedWhere {locale}
is Locale.toStr and {lang}
is Locale.lang. The maxAge parameter is
set to Duration.maxVal (cached for life of the VM).
Also see Pod.locale and docLang::Localization.
Operating system name as one of the following constants:
Get the parent environment or null if this is the bootstrap environment. Many virtual methods delegate to their parent by default.
Search path of directories in priority order. The last item in the path is always the sys::Env.homeDir
Prompt the user to enter a command line from standard input. This method routes to util::Console.prompt.
Optional
msg: stringPrompt the user to enter a password from standard input with echo disabled. This method routes to util::Console.promptPassword.
Optional
msg: stringReturn a merged key/value map of all the prop files found using the following resolution rules:
sys.envProps
: "/{pod}/uri"The uri must be relative. Note that props such as locale files can be bundled into a pod for deployment and searched by adding an indexed prop with the key "sys.envProps" and the pod name as the value. This feature does not support "config.props".
The files are parsed using InStream.readProps
and merged according to their priority order. If the file
is defined as a resource in the pod itself, then it is
treated as lowest priority. The first file returned by findAllFiles
is treated as highest priority and overwrites any key-value
pairs defined at a lower priority.
The map is cached so that subsequent calls for the same path
don't require accessing the file system again. The maxAge
parameter specifies the tolerance accepted before a cache
refresh is performed to check if any of the files have been
modified.
Also see Pod.props and docLang::Env.
Remove a shutdown hook function which was added by addShutdownHook. Remove true if hook had been previously added and was unregistered, false otherwise. Default implementation delegates to parent.
Virtual machine runtime as one of the following constants:
Get an immutable representation of this instance or throw NotImmutableErr if this object cannot be represented as an immutable:
Return a string representation of this object.
Trap a dynamic call for handling. Dynamic calls are invoked with the -> shortcut operator:
a->x a.trap("x", null)
a->x() a.trap("x", null)
a->x = b a.trap("x", [b])
a->x(b) a.trap("x", [b])
a->x(b, c) a.trap("x", [b, c])
The default implementation provided by Obj attempts to use reflection. If name maps to a method, it is invoked with the specified arguments. If name maps to a field and args.size is zero, get the field. If name maps to a field and args.size is one, set the field and return args[0]. Otherwise throw UnknownSlotErr.
Get the user name of the user account used to run the virtual machine process. Default implementation delegates to parent.
Get the environment variables as a case insensitive, immutable map of Str name/value pairs. The environment map is initialized from the following sources from lowest priority to highest priority:
This method called whenever an it-block is applied to an
object. The default implementation calls the function with this
,
and then returns this
.
Static
curGet the current runtime environment
Static
echoWrite x.toStr
to standard output followed by newline. If x
is null then print "null". If no argument is provided then
print an empty line.
Optional
x: JsObjStatic
makeConstructor initializes the search path using the FAN_ENV_PATH
environment variable (see sys::Env.vars).
PathEnv is a simple implementation of a Fantom environment which uses a search path to resolve files.