зеркало из https://github.com/mono/ikvm-fork.git
Moved a couple of java.lang.System native methods to the Java side.
This commit is contained in:
Родитель
6a1c4cea55
Коммит
7d472777de
|
@ -54,7 +54,7 @@ final class Props
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
props = new Properties();
|
props = new Properties();
|
||||||
System.initProperties(props);
|
initProperties(props);
|
||||||
|
|
||||||
// after we've initialized the system properties, we need to fixate certain
|
// after we've initialized the system properties, we need to fixate certain
|
||||||
// results that depend on system properties, because we don't want Java code to
|
// results that depend on system properties, because we don't want Java code to
|
||||||
|
@ -62,6 +62,18 @@ final class Props
|
||||||
ClassLoader.initializeLibraryPaths(props);
|
ClassLoader.initializeLibraryPaths(props);
|
||||||
sun.misc.VM.initializeAllowArraySyntax();
|
sun.misc.VM.initializeAllowArraySyntax();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void initProperties(Properties props)
|
||||||
|
{
|
||||||
|
props.put("openjdk.version", "OpenJDK 7 b13");
|
||||||
|
props.put("gnu.classpath.version", "0.95");
|
||||||
|
String vfsroot = getVirtualFileSystemRoot();
|
||||||
|
props.put("java.home", vfsroot.substring(0, vfsroot.length() - 1));
|
||||||
|
props.put("sun.boot.library.path", vfsroot + "bin");
|
||||||
|
gnu.classpath.VMSystemProperties.initOpenJDK(props);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static native String getVirtualFileSystemRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -381,7 +393,10 @@ public final class System {
|
||||||
* the current time and midnight, January 1, 1970 UTC.
|
* the current time and midnight, January 1, 1970 UTC.
|
||||||
* @see java.util.Date
|
* @see java.util.Date
|
||||||
*/
|
*/
|
||||||
public static native long currentTimeMillis();
|
public static long currentTimeMillis() {
|
||||||
|
long january_1st_1970 = 62135596800000L;
|
||||||
|
return cli.System.DateTime.get_UtcNow().get_Ticks() / 10000L - january_1st_1970;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current value of the most precise available system
|
* Returns the current value of the most precise available system
|
||||||
|
@ -517,7 +532,9 @@ public final class System {
|
||||||
* @return the hashCode
|
* @return the hashCode
|
||||||
* @since JDK1.1
|
* @since JDK1.1
|
||||||
*/
|
*/
|
||||||
public static native int identityHashCode(Object x);
|
public static int identityHashCode(Object x) {
|
||||||
|
return cli.System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(x);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* System properties. The following properties are guaranteed to be defined:
|
* System properties. The following properties are guaranteed to be defined:
|
||||||
|
@ -540,7 +557,7 @@ public final class System {
|
||||||
* </dl>
|
* </dl>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static native Properties initProperties(Properties props);
|
//private static native Properties initProperties(Properties props);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines the current system properties.
|
* Determines the current system properties.
|
||||||
|
@ -670,7 +687,7 @@ public final class System {
|
||||||
}
|
}
|
||||||
if (props == null) {
|
if (props == null) {
|
||||||
props = new Properties();
|
props = new Properties();
|
||||||
initProperties(props);
|
Props.initProperties(props);
|
||||||
}
|
}
|
||||||
Props.props = props;
|
Props.props = props;
|
||||||
}
|
}
|
||||||
|
@ -1098,7 +1115,15 @@ public final class System {
|
||||||
* @see java.lang.ClassLoader#findLibrary(java.lang.String)
|
* @see java.lang.ClassLoader#findLibrary(java.lang.String)
|
||||||
* @since 1.2
|
* @since 1.2
|
||||||
*/
|
*/
|
||||||
public static native String mapLibraryName(String libname);
|
public static String mapLibraryName(String libname) {
|
||||||
|
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. */
|
/* returns the class of the caller. */
|
||||||
static Class getCallerClass() {
|
static Class getCallerClass() {
|
||||||
|
|
|
@ -1599,25 +1599,6 @@
|
||||||
</body>
|
</body>
|
||||||
</method>
|
</method>
|
||||||
</class>
|
</class>
|
||||||
<class name="java.lang.System">
|
|
||||||
<method name="identityHashCode" sig="(Ljava.lang.Object;)I">
|
|
||||||
<body>
|
|
||||||
<ldarg_0 />
|
|
||||||
<conditional framework="2.0">
|
|
||||||
<code>
|
|
||||||
<call type="System.Runtime.CompilerServices.RuntimeHelpers" name="GetHashCode" sig="(Ljava.lang.Object;)I" />
|
|
||||||
</code>
|
|
||||||
</conditional>
|
|
||||||
<conditional framework="1.1">
|
|
||||||
<code>
|
|
||||||
<!-- FXBUG RuntimeHelpers.GetHashCode is broken in multi AppDomain scenarios (on v1.x) -->
|
|
||||||
<call type="System.Object" name="GetHashCode" sig="()I" />
|
|
||||||
</code>
|
|
||||||
</conditional>
|
|
||||||
<ret />
|
|
||||||
</body>
|
|
||||||
</method>
|
|
||||||
</class>
|
|
||||||
<class name="sun.misc.Launcher">
|
<class name="sun.misc.Launcher">
|
||||||
<method name="<init>" sig="()V">
|
<method name="<init>" sig="()V">
|
||||||
<replace-method-call class="sun.misc.Launcher$ExtClassLoader" name="getExtClassLoader" sig="()Lsun.misc.Launcher$ExtClassLoader;">
|
<replace-method-call class="sun.misc.Launcher$ExtClassLoader" name="getExtClassLoader" sig="()Lsun.misc.Launcher$ExtClassLoader;">
|
||||||
|
|
|
@ -1025,14 +1025,14 @@ namespace IKVM.NativeCode.java
|
||||||
dict[RootPath] = new VfsDummyEntry(true);
|
dict[RootPath] = new VfsDummyEntry(true);
|
||||||
dict[RootPath + "lib/security/cacerts".Replace('/', sep)] = new VfsCacertsEntry();
|
dict[RootPath + "lib/security/cacerts".Replace('/', sep)] = new VfsCacertsEntry();
|
||||||
dict[RootPath + "bin"] = new VfsDummyEntry(true);
|
dict[RootPath + "bin"] = new VfsDummyEntry(true);
|
||||||
dict[RootPath + "bin" + sep + IKVM.NativeCode.java.lang.System.mapLibraryName("zip")] = new VfsDummyEntry(false);
|
dict[RootPath + "bin" + sep + global::java.lang.System.mapLibraryName("zip")] = new VfsDummyEntry(false);
|
||||||
dict[RootPath + "bin" + sep + IKVM.NativeCode.java.lang.System.mapLibraryName("awt")] = new VfsDummyEntry(false);
|
dict[RootPath + "bin" + sep + global::java.lang.System.mapLibraryName("awt")] = new VfsDummyEntry(false);
|
||||||
dict[RootPath + "bin" + sep + IKVM.NativeCode.java.lang.System.mapLibraryName("rmi")] = new VfsDummyEntry(false);
|
dict[RootPath + "bin" + sep + global::java.lang.System.mapLibraryName("rmi")] = new VfsDummyEntry(false);
|
||||||
dict[RootPath + "bin" + sep + IKVM.NativeCode.java.lang.System.mapLibraryName("w2k_lsa_auth")] = new VfsDummyEntry(false);
|
dict[RootPath + "bin" + sep + global::java.lang.System.mapLibraryName("w2k_lsa_auth")] = new VfsDummyEntry(false);
|
||||||
dict[RootPath + "bin" + sep + IKVM.NativeCode.java.lang.System.mapLibraryName("jaas_nt")] = new VfsDummyEntry(false);
|
dict[RootPath + "bin" + sep + global::java.lang.System.mapLibraryName("jaas_nt")] = new VfsDummyEntry(false);
|
||||||
dict[RootPath + "bin" + sep + IKVM.NativeCode.java.lang.System.mapLibraryName("jaas_unix")] = new VfsDummyEntry(false);
|
dict[RootPath + "bin" + sep + global::java.lang.System.mapLibraryName("jaas_unix")] = new VfsDummyEntry(false);
|
||||||
dict[RootPath + "bin" + sep + IKVM.NativeCode.java.lang.System.mapLibraryName("unpack")] = new VfsDummyEntry(false);
|
dict[RootPath + "bin" + sep + global::java.lang.System.mapLibraryName("unpack")] = new VfsDummyEntry(false);
|
||||||
dict[RootPath + "bin" + sep + IKVM.NativeCode.java.lang.System.mapLibraryName("net")] = new VfsDummyEntry(false);
|
dict[RootPath + "bin" + sep + global::java.lang.System.mapLibraryName("net")] = new VfsDummyEntry(false);
|
||||||
if (Interlocked.CompareExchange(ref entries, dict, null) != null)
|
if (Interlocked.CompareExchange(ref entries, dict, null) != null)
|
||||||
{
|
{
|
||||||
// we lost the race, so we close our zip file
|
// we lost the race, so we close our zip file
|
||||||
|
@ -3331,6 +3331,14 @@ namespace IKVM.NativeCode.java
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class Props
|
||||||
|
{
|
||||||
|
public static string getVirtualFileSystemRoot()
|
||||||
|
{
|
||||||
|
return io.VirtualFileSystem.RootPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static class Runtime
|
static class Runtime
|
||||||
{
|
{
|
||||||
public static int availableProcessors(object thisRuntime)
|
public static int availableProcessors(object thisRuntime)
|
||||||
|
@ -3598,18 +3606,6 @@ namespace IKVM.NativeCode.java
|
||||||
IKVM.Runtime.ByteCodeHelper.arraycopy(src, srcPos, dest, destPos, length);
|
IKVM.Runtime.ByteCodeHelper.arraycopy(src, srcPos, dest, destPos, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
// FXBUG this is implemented by a non-virtual call to System.Object.GetHashCode (in map.xml),
|
|
||||||
// because RuntimeHelpers.GetHashCode is broken (in v1.x) when called in a secondary AppDomain.
|
|
||||||
// See http://weblog.ikvm.net/PermaLink.aspx?guid=c2442bc8-7b48-4570-b082-82649cc347dc
|
|
||||||
//
|
|
||||||
// public static int identityHashCode(object obj)
|
|
||||||
|
|
||||||
public static long currentTimeMillis()
|
|
||||||
{
|
|
||||||
const long january_1st_1970 = 62135596800000L;
|
|
||||||
return DateTime.UtcNow.Ticks / 10000L - january_1st_1970;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static long nanoTime()
|
public static long nanoTime()
|
||||||
{
|
{
|
||||||
const long NANOS_PER_SEC = 1000000000;
|
const long NANOS_PER_SEC = 1000000000;
|
||||||
|
@ -3617,39 +3613,6 @@ namespace IKVM.NativeCode.java
|
||||||
double freq = global::System.Diagnostics.Stopwatch.Frequency;
|
double freq = global::System.Diagnostics.Stopwatch.Frequency;
|
||||||
return (long)((current / freq) * NANOS_PER_SEC);
|
return (long)((current / freq) * NANOS_PER_SEC);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string mapLibraryName(string libname)
|
|
||||||
{
|
|
||||||
#if FIRST_PASS
|
|
||||||
return null;
|
|
||||||
#else
|
|
||||||
if (global::ikvm.@internal.Util.WINDOWS)
|
|
||||||
{
|
|
||||||
return libname + ".dll";
|
|
||||||
}
|
|
||||||
else if (global::ikvm.@internal.Util.MACOSX)
|
|
||||||
{
|
|
||||||
return "lib" + libname + ".jnilib";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return "lib" + libname + ".so";
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
public static object initProperties(object props)
|
|
||||||
{
|
|
||||||
#if !FIRST_PASS
|
|
||||||
juProperties p = (juProperties)props;
|
|
||||||
p.put("openjdk.version", "b13");
|
|
||||||
p.put("gnu.classpath.version", "0.95");
|
|
||||||
p.put("java.home", io.VirtualFileSystem.RootPath.Substring(0, io.VirtualFileSystem.RootPath.Length - 1));
|
|
||||||
p.put("sun.boot.library.path", io.VirtualFileSystem.RootPath + "bin");
|
|
||||||
global::gnu.classpath.VMSystemProperties.initOpenJDK(p);
|
|
||||||
#endif
|
|
||||||
return props;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static class Thread
|
static class Thread
|
||||||
|
|
Загрузка…
Ссылка в новой задаче