You've already forked linux-packaging-mono
Imported Upstream version 4.2.1.36
Former-commit-id: fb75898888a02f4d3a74cf0a5b841681bc4c7fa8
This commit is contained in:
committed by
Jo Shields
parent
9668de7cb8
commit
dd547c45d4
162
external/ikvm/openjdk/java/lang/System.java
vendored
162
external/ikvm/openjdk/java/lang/System.java
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,24 +25,30 @@
|
||||
package java.lang;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Executable;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.security.AccessControlContext;
|
||||
import java.util.Properties;
|
||||
import java.util.PropertyPermission;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.Map;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.security.AllPermission;
|
||||
import java.nio.channels.Channel;
|
||||
import java.nio.channels.spi.SelectorProvider;
|
||||
import sun.nio.ch.Interruptible;
|
||||
import sun.reflect.CallerSensitive;
|
||||
import sun.reflect.Reflection;
|
||||
import sun.security.util.SecurityConstants;
|
||||
import sun.reflect.annotation.AnnotationType;
|
||||
|
||||
final class StdIO
|
||||
{
|
||||
private StdIO() { }
|
||||
static InputStream in = new BufferedInputStream(new FileInputStream(FileDescriptor.in));
|
||||
static PrintStream out = new PrintStream(new BufferedOutputStream(new FileOutputStream(FileDescriptor.out), 128), true);
|
||||
static PrintStream err = new PrintStream(new BufferedOutputStream(new FileOutputStream(FileDescriptor.err), 128), true);
|
||||
static PrintStream out = System.newPrintStream(new FileOutputStream(FileDescriptor.out), Props.props.getProperty("sun.stdout.encoding"));
|
||||
static PrintStream err = System.newPrintStream(new FileOutputStream(FileDescriptor.err), Props.props.getProperty("sun.stderr.encoding"));
|
||||
}
|
||||
|
||||
final class Props
|
||||
@ -85,6 +91,18 @@ final class Props
|
||||
*/
|
||||
public final class System {
|
||||
|
||||
/* register the natives via the static initializer.
|
||||
*
|
||||
* VM will invoke the initializeSystemClass method to complete
|
||||
* the initialization for this class separated from clinit.
|
||||
* Note that to use properties set by the VM, see the constraints
|
||||
* described in the initializeSystemClass method.
|
||||
*/
|
||||
private static native void registerNatives();
|
||||
static {
|
||||
//registerNatives();
|
||||
}
|
||||
|
||||
/** Don't let anyone instantiate this class */
|
||||
private System() {
|
||||
}
|
||||
@ -96,10 +114,8 @@ public final class System {
|
||||
* the host environment or user.
|
||||
*/
|
||||
@ikvm.lang.Property(get="get_in")
|
||||
public final static InputStream in;
|
||||
|
||||
static { in = null; }
|
||||
|
||||
public final static InputStream in = null;
|
||||
|
||||
private static InputStream get_in()
|
||||
{
|
||||
return StdIO.in;
|
||||
@ -131,10 +147,8 @@ public final class System {
|
||||
* @see java.io.PrintStream#println(java.lang.String)
|
||||
*/
|
||||
@ikvm.lang.Property(get="get_out")
|
||||
public final static PrintStream out;
|
||||
|
||||
static { out = null; }
|
||||
|
||||
public final static PrintStream out = null;
|
||||
|
||||
private static PrintStream get_out()
|
||||
{
|
||||
return StdIO.out;
|
||||
@ -153,9 +167,7 @@ public final class System {
|
||||
* destination that is typically not continuously monitored.
|
||||
*/
|
||||
@ikvm.lang.Property(get="get_err")
|
||||
public final static PrintStream err;
|
||||
|
||||
static { err = null ; }
|
||||
public final static PrintStream err = null;
|
||||
|
||||
private static PrintStream get_err()
|
||||
{
|
||||
@ -164,7 +176,7 @@ public final class System {
|
||||
|
||||
/* The security manager for the system.
|
||||
*/
|
||||
private static volatile SecurityManager security;
|
||||
private static volatile SecurityManager security = null;
|
||||
|
||||
/**
|
||||
* Reassigns the "standard" input stream.
|
||||
@ -188,7 +200,7 @@ public final class System {
|
||||
*/
|
||||
public static void setIn(InputStream in) {
|
||||
checkIO();
|
||||
StdIO.in = in;
|
||||
setIn0(in);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -212,7 +224,7 @@ public final class System {
|
||||
*/
|
||||
public static void setOut(PrintStream out) {
|
||||
checkIO();
|
||||
StdIO.out = out;
|
||||
setOut0(out);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -236,10 +248,10 @@ public final class System {
|
||||
*/
|
||||
public static void setErr(PrintStream err) {
|
||||
checkIO();
|
||||
StdIO.err = err;
|
||||
setErr0(err);
|
||||
}
|
||||
|
||||
private static volatile Console cons;
|
||||
private static volatile Console cons = null;
|
||||
/**
|
||||
* Returns the unique {@link java.io.Console Console} object associated
|
||||
* with the current Java virtual machine, if any.
|
||||
@ -293,6 +305,10 @@ public final class System {
|
||||
}
|
||||
}
|
||||
|
||||
private static native void setIn0(InputStream in);
|
||||
private static native void setOut0(PrintStream out);
|
||||
private static native void setErr0(PrintStream err);
|
||||
|
||||
/**
|
||||
* Sets the System security.
|
||||
*
|
||||
@ -576,7 +592,12 @@ public final class System {
|
||||
* </dl>
|
||||
*/
|
||||
|
||||
//private static native Properties initProperties(Properties props);
|
||||
@ikvm.lang.Property(get="get_props", set="set_props")
|
||||
private static Properties props;
|
||||
private static native Properties initProperties(Properties props);
|
||||
|
||||
private static Properties get_props() { return Props.props; }
|
||||
private static void set_props(Properties value) { Props.props = value; }
|
||||
|
||||
/**
|
||||
* Determines the current system properties.
|
||||
@ -597,7 +618,7 @@ public final class System {
|
||||
* <tr><td><code>java.version</code></td>
|
||||
* <td>Java Runtime Environment version</td></tr>
|
||||
* <tr><td><code>java.vendor</code></td>
|
||||
* <td>Java Runtime Environment vendor</td></tr
|
||||
* <td>Java Runtime Environment vendor</td></tr>
|
||||
* <tr><td><code>java.vendor.url</code></td>
|
||||
* <td>Java vendor URL</td></tr>
|
||||
* <tr><td><code>java.home</code></td>
|
||||
@ -631,7 +652,10 @@ public final class System {
|
||||
* <tr><td><code>java.compiler</code></td>
|
||||
* <td>Name of JIT compiler to use</td></tr>
|
||||
* <tr><td><code>java.ext.dirs</code></td>
|
||||
* <td>Path of extension directory or directories</td></tr>
|
||||
* <td>Path of extension directory or directories
|
||||
* <b>Deprecated.</b> <i>This property, and the mechanism
|
||||
* which implements it, may be removed in a future
|
||||
* release.</i> </td></tr>
|
||||
* <tr><td><code>os.name</code></td>
|
||||
* <td>Operating system name</td></tr>
|
||||
* <tr><td><code>os.arch</code></td>
|
||||
@ -674,7 +698,7 @@ public final class System {
|
||||
sm.checkPropertiesAccess();
|
||||
}
|
||||
|
||||
return Props.props;
|
||||
return props;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -684,11 +708,20 @@ public final class System {
|
||||
*
|
||||
* <p>On UNIX systems, it returns {@code "\n"}; on Microsoft
|
||||
* Windows systems it returns {@code "\r\n"}.
|
||||
*
|
||||
* @return the system-dependent line separator string
|
||||
* @since 1.7
|
||||
*/
|
||||
public static String lineSeparator() {
|
||||
return Props.lineSeparator;
|
||||
return lineSeparator;
|
||||
}
|
||||
|
||||
@ikvm.lang.Property(get="get_lineSeparator", set="set_lineSeparator")
|
||||
private static String lineSeparator;
|
||||
|
||||
private static String get_lineSeparator() { return Props.lineSeparator; }
|
||||
private static void set_lineSeparator(String value) { Props.lineSeparator = value; }
|
||||
|
||||
/**
|
||||
* Sets the system properties to the <code>Properties</code>
|
||||
* argument.
|
||||
@ -718,9 +751,9 @@ public final class System {
|
||||
}
|
||||
if (props == null) {
|
||||
props = new Properties();
|
||||
VMSystemProperties.initProperties(props);
|
||||
initProperties(props);
|
||||
}
|
||||
Props.props = props;
|
||||
System.props = props;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -756,7 +789,7 @@ public final class System {
|
||||
sm.checkPropertyAccess(key);
|
||||
}
|
||||
|
||||
return Props.props.getProperty(key);
|
||||
return props.getProperty(key);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -792,7 +825,7 @@ public final class System {
|
||||
sm.checkPropertyAccess(key);
|
||||
}
|
||||
|
||||
return Props.props.getProperty(key, def);
|
||||
return props.getProperty(key, def);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -832,7 +865,7 @@ public final class System {
|
||||
SecurityConstants.PROPERTY_WRITE_ACTION));
|
||||
}
|
||||
|
||||
return (String) Props.props.setProperty(key, value);
|
||||
return (String) props.setProperty(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -869,7 +902,7 @@ public final class System {
|
||||
sm.checkPermission(new PropertyPermission(key, "write"));
|
||||
}
|
||||
|
||||
return (String) Props.props.remove(key);
|
||||
return (String) props.remove(key);
|
||||
}
|
||||
|
||||
private static void checkKey(String key) {
|
||||
@ -1081,13 +1114,25 @@ public final class System {
|
||||
*/
|
||||
@Deprecated
|
||||
public static void runFinalizersOnExit(boolean value) {
|
||||
Runtime.getRuntime().runFinalizersOnExit(value);
|
||||
Runtime.runFinalizersOnExit(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a code file with the specified filename from the local file
|
||||
* system as a dynamic library. The filename
|
||||
* argument must be a complete path name.
|
||||
* Loads the native library specified by the filename argument. The filename
|
||||
* argument must be an absolute path name.
|
||||
*
|
||||
* If the filename argument, when stripped of any platform-specific library
|
||||
* prefix, path, and file extension, indicates a library whose name is,
|
||||
* for example, L, and a native library called L is statically linked
|
||||
* with the VM, then the JNI_OnLoad_L function exported by the library
|
||||
* is invoked rather than attempting to load a dynamic library.
|
||||
* A filename matching the argument does not have to exist in the
|
||||
* file system.
|
||||
* See the JNI Specification for more details.
|
||||
*
|
||||
* Otherwise, the filename argument is mapped to a native library image in
|
||||
* an implementation-dependent manner.
|
||||
*
|
||||
* <p>
|
||||
* The call <code>System.load(name)</code> is effectively equivalent
|
||||
* to the call:
|
||||
@ -1099,7 +1144,10 @@ public final class System {
|
||||
* @exception SecurityException if a security manager exists and its
|
||||
* <code>checkLink</code> method doesn't allow
|
||||
* loading of the specified dynamic library
|
||||
* @exception UnsatisfiedLinkError if the file does not exist.
|
||||
* @exception UnsatisfiedLinkError if either the filename is not an
|
||||
* absolute path name, the native library is not statically
|
||||
* linked with the VM, or the library cannot be mapped to
|
||||
* a native library image by the host system.
|
||||
* @exception NullPointerException if <code>filename</code> is
|
||||
* <code>null</code>
|
||||
* @see java.lang.Runtime#load(java.lang.String)
|
||||
@ -1111,9 +1159,16 @@ public final class System {
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the system library specified by the <code>libname</code>
|
||||
* argument. The manner in which a library name is mapped to the
|
||||
* actual system library is system dependent.
|
||||
* Loads the native library specified by the <code>libname</code>
|
||||
* argument. The <code>libname</code> argument must not contain any platform
|
||||
* specific prefix, file extension or path. If a native library
|
||||
* called <code>libname</code> is statically linked with the VM, then the
|
||||
* JNI_OnLoad_<code>libname</code> function exported by the library is invoked.
|
||||
* See the JNI Specification for more details.
|
||||
*
|
||||
* Otherwise, the libname argument is loaded from a system library
|
||||
* location and mapped to a native library image in an implementation-
|
||||
* dependent manner.
|
||||
* <p>
|
||||
* The call <code>System.loadLibrary(name)</code> is effectively
|
||||
* equivalent to the call
|
||||
@ -1125,7 +1180,10 @@ public final class System {
|
||||
* @exception SecurityException if a security manager exists and its
|
||||
* <code>checkLink</code> method doesn't allow
|
||||
* loading of the specified dynamic library
|
||||
* @exception UnsatisfiedLinkError if the library does not exist.
|
||||
* @exception UnsatisfiedLinkError if either the libname argument
|
||||
* contains a file path, the native library is not statically
|
||||
* linked with the VM, or the library cannot be mapped to a
|
||||
* native library image by the host system.
|
||||
* @exception NullPointerException if <code>libname</code> is
|
||||
* <code>null</code>
|
||||
* @see java.lang.Runtime#loadLibrary(java.lang.String)
|
||||
@ -1148,21 +1206,17 @@ public final class System {
|
||||
* @see java.lang.ClassLoader#findLibrary(java.lang.String)
|
||||
* @since 1.2
|
||||
*/
|
||||
public static String mapLibraryName(String libname) {
|
||||
if (libname == null) {
|
||||
throw new NullPointerException();
|
||||
public static native String mapLibraryName(String libname);
|
||||
|
||||
/**
|
||||
* Create PrintStream for stdout/err based on encoding.
|
||||
*/
|
||||
/*private*/ static PrintStream newPrintStream(FileOutputStream fos, String enc) {
|
||||
if (enc != null) {
|
||||
try {
|
||||
return new PrintStream(new BufferedOutputStream(fos, 128), true, enc);
|
||||
} catch (UnsupportedEncodingException uee) {}
|
||||
}
|
||||
if (ikvm.internal.Util.WINDOWS) {
|
||||
return libname + ".dll";
|
||||
} else if (ikvm.internal.Util.MACOSX) {
|
||||
return "lib" + libname + ".jnilib";
|
||||
} else {
|
||||
return "lib" + libname + ".so";
|
||||
}
|
||||
}
|
||||
/* returns the class of the caller. */
|
||||
static Class<?> getCallerClass() {
|
||||
// NOTE use of more generic Reflection.getCallerClass()
|
||||
return Reflection.getCallerClass(3);
|
||||
return new PrintStream(new BufferedOutputStream(fos, 128), true);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user