Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/ikvm-fork.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjfrijters <jfrijters>2015-06-25 16:59:10 +0300
committerjfrijters <jfrijters>2015-06-25 16:59:10 +0300
commit47041319ef431f40eb47539502b8bde2e6e35e35 (patch)
tree766b17ad9282ef1a8971e8c1569418c21f0933dc
parent196572bb111201caa28906249af9b544cc3e86e5 (diff)
Extract Windows version from kernel32.dll to avoid version lie.
-rw-r--r--openjdk/java/lang/VMSystemProperties.java60
-rw-r--r--runtime/common.cs21
2 files changed, 74 insertions, 7 deletions
diff --git a/openjdk/java/lang/VMSystemProperties.java b/openjdk/java/lang/VMSystemProperties.java
index c982e2dd..5c79248b 100644
--- a/openjdk/java/lang/VMSystemProperties.java
+++ b/openjdk/java/lang/VMSystemProperties.java
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2004-2011 Jeroen Frijters
+ Copyright (C) 2004-2015 Jeroen Frijters
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -24,6 +24,7 @@
package java.lang;
import java.util.Properties;
+import cli.System.Diagnostics.FileVersionInfo;
import static ikvm.internal.Util.SafeGetEnvironmentVariable;
final class VMSystemProperties
@@ -31,7 +32,7 @@ final class VMSystemProperties
private VMSystemProperties() { }
public static final String SPEC_TITLE = "Java Platform API Specification";
- public static final String SPEC_VERSION = "1.7";
+ public static final String SPEC_VERSION = "1.8";
public static final String SPEC_VENDOR = "Oracle Corporation";
private static String getLibraryPath()
@@ -114,11 +115,11 @@ final class VMSystemProperties
private static void initCommonProperties(Properties p)
{
- p.setProperty("java.version", "1.7.0");
+ p.setProperty("java.version", "1.8.0");
p.setProperty("java.vendor", "Jeroen Frijters");
p.setProperty("java.vendor.url", "http://ikvm.net/");
p.setProperty("java.vendor.url.bug", "http://www.ikvm.net/bugs");
- p.setProperty("java.vm.specification.version", "1.7");
+ p.setProperty("java.vm.specification.version", "1.8");
p.setProperty("java.vm.specification.vendor", "Oracle Corporation");
p.setProperty("java.vm.specification.name", "Java Virtual Machine Specification");
p.setProperty("java.vm.version", PropertyConstants.java_vm_version);
@@ -129,7 +130,7 @@ final class VMSystemProperties
p.setProperty("java.specification.version", SPEC_VERSION);
p.setProperty("java.specification.vendor", SPEC_VENDOR);
p.setProperty("java.specification.name", SPEC_TITLE);
- p.setProperty("java.class.version", "51.0");
+ p.setProperty("java.class.version", "52.0");
p.setProperty("java.class.path", "");
p.setProperty("java.library.path", getLibraryPath());
try
@@ -152,6 +153,13 @@ final class VMSystemProperties
switch(os.get_Platform().Value)
{
case cli.System.PlatformID.Win32NT:
+ // Windows lies about the version, so we extract the real version from kernel32.dll
+ FileVersionInfo kernel32 = getKernel32FileVersionInfo();
+ if (kernel32 != null)
+ {
+ major = kernel32.get_ProductMajorPart();
+ minor = kernel32.get_ProductMinorPart();
+ }
osname = "Windows NT (unknown)";
switch(major)
{
@@ -189,6 +197,23 @@ final class VMSystemProperties
osver = "6.1";
osname = "Windows 7";
break;
+ case 2:
+ osver = "6.2";
+ osname = "Windows 8";
+ break;
+ case 3:
+ osver = "6.3";
+ osname = "Windows 8.1";
+ break;
+ }
+ break;
+ case 10:
+ switch(minor)
+ {
+ case 0:
+ osver = "10.0";
+ osname = "Windows 10";
+ break;
}
break;
}
@@ -322,12 +347,32 @@ final class VMSystemProperties
p.setProperty("sun.nio.MaxDirectMemorySize", "-1");
p.setProperty("java.awt.graphicsenv", PropertyConstants.java_awt_graphicsenv);
p.setProperty("java.awt.printerjob", "sun.awt.windows.WPrinterJob");
+
+ String stdoutEncoding = getStdoutEncoding();
+ if(stdoutEncoding != null)
+ {
+ p.setProperty("sun.stdout.encoding", stdoutEncoding);
+ }
+ String stderrEncoding = getStderrEncoding();
+ if(stderrEncoding != null)
+ {
+ p.setProperty("sun.stderr.encoding", stderrEncoding);
+ }
+
+ if(ikvm.internal.Util.MACOSX)
+ {
+ p.setProperty("sun.jnu.encoding", "UTF-8");
+ }
+ else
+ {
+ p.setProperty("sun.jnu.encoding", cli.System.Text.Encoding.get_Default().get_WebName());
+ }
+
// TODO
// sun.cpu.isalist:=pentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86
// sun.desktop:=windows
// sun.io.unicode.encoding:=UnicodeLittle
- // sun.jnu.encoding:=Cp1252
// sun.management.compiler:=HotSpot Client Compiler
try
{
@@ -418,4 +463,7 @@ final class VMSystemProperties
private static native String getVirtualFileSystemRoot();
private static native String getBootClassPath();
+ private static native String getStdoutEncoding();
+ private static native String getStderrEncoding();
+ private static native FileVersionInfo getKernel32FileVersionInfo();
}
diff --git a/runtime/common.cs b/runtime/common.cs
index 94cad587..74db6848 100644
--- a/runtime/common.cs
+++ b/runtime/common.cs
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2002-2014 Jeroen Frijters
+ Copyright (C) 2002-2015 Jeroen Frijters
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -23,6 +23,7 @@
*/
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
@@ -131,6 +132,24 @@ namespace IKVM.NativeCode.java.lang
return IsWindowsConsole(false) ? GetConsoleEncoding() : null;
}
+ public static FileVersionInfo getKernel32FileVersionInfo()
+ {
+ try
+ {
+ foreach (ProcessModule module in Process.GetCurrentProcess().Modules)
+ {
+ if (string.Compare(module.ModuleName, "kernel32.dll", StringComparison.OrdinalIgnoreCase) == 0)
+ {
+ return module.FileVersionInfo;
+ }
+ }
+ }
+ catch
+ {
+ }
+ return null;
+ }
+
private static bool IsWindowsConsole(bool stdout)
{
if (Environment.OSVersion.Platform != PlatformID.Win32NT)