зеркало из https://github.com/mono/ikvm-fork.git
*** empty log message ***
This commit is contained in:
Родитель
4ac4d7e5e6
Коммит
bd6b0a0aee
|
@ -1,3 +1,5 @@
|
|||
gnu/classpath/VMSystemProperties.java
|
||||
../../classpath/gnu/classpath/SystemProperties.java
|
||||
ikvm/internal/LibraryVMInterface.java
|
||||
ikvm/lang/CIL.java
|
||||
gnu/classpath/Configuration.java
|
||||
|
@ -348,7 +350,6 @@ sun/misc/Ref.java
|
|||
../../classpath/gnu/java/rmi/server/UnicastRemoteStub.java
|
||||
../../classpath/gnu/java/rmi/server/UnicastServer.java
|
||||
../../classpath/gnu/java/rmi/server/UnicastServerRef.java
|
||||
../../classpath/gnu/java/security/action/GetPropertyAction.java
|
||||
../../classpath/gnu/java/security/action/GetSecurityPropertyAction.java
|
||||
../../classpath/gnu/java/security/action/SetAccessibleAction.java
|
||||
../../classpath/gnu/java/security/ber/BER.java
|
||||
|
|
|
@ -100,6 +100,4 @@ public interface Configuration
|
|||
* Name of default AWT peer library.
|
||||
*/
|
||||
String default_awt_peer_toolkit = "gnu.java.awt.peer.gtk.GTKToolkit";
|
||||
|
||||
boolean JAVA_LANG_SYSTEM_EXPLICIT_INITIALIZATION = false;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,193 @@
|
|||
package gnu.classpath;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
public class VMSystemProperties
|
||||
{
|
||||
public static cli.System.Collections.Hashtable props;
|
||||
|
||||
private static native String getVersion();
|
||||
|
||||
static void preInit(Properties p)
|
||||
{
|
||||
p.setProperty("java.version", "1.4");
|
||||
p.setProperty("java.vendor", "Jeroen Frijters");
|
||||
p.setProperty("java.vendor.url", "http://ikvm.net/");
|
||||
// HACK using the Assembly.Location property isn't correct
|
||||
cli.System.Reflection.Assembly asm = cli.System.Reflection.Assembly.GetExecutingAssembly();
|
||||
p.setProperty("java.home", new cli.System.IO.FileInfo(asm.get_Location()).get_DirectoryName());
|
||||
p.setProperty("java.vm.specification.version", "1.0");
|
||||
p.setProperty("java.vm.specification.vendor", "Sun Microsystems Inc.");
|
||||
p.setProperty("java.vm.specification.name", "Java Virtual Machine Specification");
|
||||
p.setProperty("java.vm.version", getVersion());
|
||||
p.setProperty("java.vm.vendor", "Jeroen Frijters");
|
||||
p.setProperty("java.vm.name", "IKVM.NET");
|
||||
p.setProperty("java.specification.version", "1.4");
|
||||
p.setProperty("java.specification.vendor", "Sun Microsystems Inc.");
|
||||
p.setProperty("java.specification.name", "Java Platform API Specification");
|
||||
p.setProperty("java.class.version", "48.0");
|
||||
String classpath = cli.System.Environment.GetEnvironmentVariable("CLASSPATH");
|
||||
if(classpath == null)
|
||||
{
|
||||
classpath = ".";
|
||||
}
|
||||
p.setProperty("java.class.path", classpath);
|
||||
String libraryPath = null;
|
||||
if(cli.System.Environment.get_OSVersion().ToString().indexOf("Unix") >= 0)
|
||||
{
|
||||
libraryPath = cli.System.Environment.GetEnvironmentVariable("LD_LIBRARY_PATH");
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
libraryPath = new cli.System.IO.FileInfo(cli.System.Reflection.Assembly.GetEntryAssembly().get_Location()).get_DirectoryName();
|
||||
}
|
||||
catch(Throwable t)
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
if(libraryPath == null)
|
||||
{
|
||||
libraryPath = ".";
|
||||
}
|
||||
else
|
||||
{
|
||||
libraryPath += cli.System.IO.Path.PathSeparator + ".";
|
||||
}
|
||||
libraryPath += cli.System.IO.Path.PathSeparator + cli.System.Environment.get_SystemDirectory() +
|
||||
cli.System.IO.Path.PathSeparator + cli.System.Environment.GetEnvironmentVariable("PATH");
|
||||
}
|
||||
if(libraryPath != null)
|
||||
{
|
||||
p.setProperty("java.library.path", libraryPath);
|
||||
}
|
||||
p.setProperty("java.io.tmpdir", cli.System.IO.Path.GetTempPath());
|
||||
p.setProperty("java.compiler", "");
|
||||
p.setProperty("java.ext.dirs", "");
|
||||
// NOTE os.name *must* contain "Windows" when running on Windows, because Classpath tests on that
|
||||
String osname = null;
|
||||
String osver = null;
|
||||
cli.System.OperatingSystem os = cli.System.Environment.get_OSVersion();
|
||||
int major = os.get_Version().get_Major();
|
||||
int minor = os.get_Version().get_Minor();
|
||||
switch(os.get_Platform().Value)
|
||||
{
|
||||
case cli.System.PlatformID.Win32NT:
|
||||
switch(major)
|
||||
{
|
||||
case 3:
|
||||
case 4:
|
||||
osver = major + "." + minor;
|
||||
osname = "Windows NT";
|
||||
break;
|
||||
case 5:
|
||||
switch(minor)
|
||||
{
|
||||
case 0:
|
||||
osver = "5.0";
|
||||
osname = "Windows 2000";
|
||||
break;
|
||||
case 1:
|
||||
osver = "5.1";
|
||||
osname = "Windows XP";
|
||||
break;
|
||||
case 2:
|
||||
osver = "5.2";
|
||||
osname = "Windows 2003";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case cli.System.PlatformID.Win32Windows:
|
||||
if(major == 4)
|
||||
{
|
||||
switch(minor)
|
||||
{
|
||||
case 0:
|
||||
osver = "4.0";
|
||||
osname = "Windows 95";
|
||||
break;
|
||||
case 10:
|
||||
osver = "4.10";
|
||||
osname = "Windows 98";
|
||||
break;
|
||||
case 90:
|
||||
osver = "4.90";
|
||||
osname = "Windows Me";
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
if(osname == null)
|
||||
{
|
||||
osname = cli.System.Environment.get_OSVersion().ToString();
|
||||
}
|
||||
if(osver == null)
|
||||
{
|
||||
osver = cli.System.Environment.get_OSVersion().get_Version().ToString();
|
||||
}
|
||||
p.setProperty("os.name", osname);
|
||||
p.setProperty("os.version", osver);
|
||||
String arch = cli.System.Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE");
|
||||
if(arch == null)
|
||||
{
|
||||
// TODO get this info from somewhere else
|
||||
arch = "x86";
|
||||
}
|
||||
p.setProperty("os.arch", arch);
|
||||
p.setProperty("file.separator", "" + cli.System.IO.Path.DirectorySeparatorChar);
|
||||
p.setProperty("file.encoding", "8859_1");
|
||||
p.setProperty("path.separator", "" + cli.System.IO.Path.PathSeparator);
|
||||
p.setProperty("line.separator", cli.System.Environment.get_NewLine());
|
||||
p.setProperty("user.name", cli.System.Environment.get_UserName());
|
||||
String home = cli.System.Environment.GetEnvironmentVariable("USERPROFILE");
|
||||
if(home == null)
|
||||
{
|
||||
// maybe we're on *nix
|
||||
home = cli.System.Environment.GetEnvironmentVariable("HOME");
|
||||
if(home == null)
|
||||
{
|
||||
// TODO maybe there is a better way
|
||||
// NOTE on MS .NET this doesn't return the correct path
|
||||
// (it returns "C:\\Documents and Settings\\username\\My Documents", but we really need
|
||||
// "C:\\Documents and Settings\\username" to be compatible with Sun, that's why we use %USERPROFILE% if it exists)
|
||||
home = cli.System.Environment.GetFolderPath(cli.System.Environment.SpecialFolder.wrap(cli.System.Environment.SpecialFolder.Personal));
|
||||
}
|
||||
}
|
||||
p.setProperty("user.home", home);
|
||||
p.setProperty("user.dir", cli.System.Environment.get_CurrentDirectory());
|
||||
p.setProperty("awt.toolkit", "ikvm.awt.NetToolkit, IKVM.AWT.WinForms");
|
||||
// HACK since we cannot use URL here (it depends on the properties being set), we manually encode the spaces in the assembly name
|
||||
p.setProperty("gnu.classpath.home.url", "ikvmres://" + ((cli.System.String)(Object)cli.System.Reflection.Assembly.GetExecutingAssembly().get_FullName()).Replace(" ", "%20") + "/lib");
|
||||
p.setProperty("gnu.cpu.endian", cli.System.BitConverter.IsLittleEndian ? "little" : "big");
|
||||
}
|
||||
|
||||
static void postInit(Properties p)
|
||||
{
|
||||
// read properties from app.config
|
||||
cli.System.Collections.Specialized.NameValueCollection appSettings = cli.System.Configuration.ConfigurationSettings.get_AppSettings();
|
||||
cli.System.Collections.IEnumerator keys = appSettings.GetEnumerator();
|
||||
while(keys.MoveNext())
|
||||
{
|
||||
String key = (String)keys.get_Current();
|
||||
if(key.startsWith("ikvm:"))
|
||||
{
|
||||
p.setProperty(key.substring(5), appSettings.get_Item(key));
|
||||
}
|
||||
}
|
||||
// set the properties that were specified with IKVM.Runtime.Startup.SetProperties()
|
||||
if(props != null)
|
||||
{
|
||||
cli.System.Collections.IEnumerator entries = ((cli.System.Collections.IEnumerable)props).GetEnumerator();
|
||||
while(entries.MoveNext())
|
||||
{
|
||||
cli.System.Collections.DictionaryEntry de = (cli.System.Collections.DictionaryEntry)entries.get_Current();
|
||||
p.setProperty((String)de.get_Key(), (String)de.get_Value());
|
||||
}
|
||||
props = null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -51,6 +51,8 @@ public interface LibraryVMInterface
|
|||
cli.System.IntPtr getDirectBufferAddress(Object buffer);
|
||||
int getDirectBufferCapacity(Object buffer);
|
||||
|
||||
void setProperties(cli.System.Collections.Hashtable props);
|
||||
|
||||
Throwable newIllegalAccessError(String msg);
|
||||
Throwable newIllegalAccessException(String msg);
|
||||
Throwable newIncompatibleClassChangeError(String msg);
|
||||
|
|
|
@ -25,6 +25,7 @@ package java.lang;
|
|||
|
||||
import java.io.*;
|
||||
import java.lang.reflect.*;
|
||||
import gnu.classpath.SystemProperties;
|
||||
|
||||
public final class ExceptionHelper
|
||||
{
|
||||
|
@ -33,8 +34,7 @@ public final class ExceptionHelper
|
|||
// able to distinguish it from a user specified blank string
|
||||
private static final String NULL_STRING = new String();
|
||||
private static final java.util.WeakHashMap exceptions = new java.util.WeakHashMap();
|
||||
// We access Runtime.defaultProperties directly, to prevent problems should an exception occur during library bootstrap
|
||||
private static final boolean cleanStackTrace = Runtime.defaultProperties.getProperty("ikvm.cleanstacktrace", "1").equals("1");
|
||||
private static final boolean cleanStackTrace = SystemProperties.getProperty("ikvm.cleanstacktrace", "1").equals("1");
|
||||
private static cli.System.Type System_Reflection_MethodBase = cli.System.Type.GetType("System.Reflection.MethodBase, mscorlib");
|
||||
private static cli.System.Type System_Exception = cli.System.Type.GetType("System.Exception, mscorlib");
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ class LibraryVMInterfaceImpl implements ikvm.internal.LibraryVMInterface
|
|||
|
||||
public Object getSystemClassLoader()
|
||||
{
|
||||
return System.systemClassLoader;
|
||||
return ClassLoader.StaticData.systemClassLoader;
|
||||
}
|
||||
|
||||
public Object box(Object val)
|
||||
|
@ -197,6 +197,11 @@ class LibraryVMInterfaceImpl implements ikvm.internal.LibraryVMInterface
|
|||
return ((java.nio.ByteBuffer)buffer).capacity();
|
||||
}
|
||||
|
||||
public void setProperties(cli.System.Collections.Hashtable props)
|
||||
{
|
||||
gnu.classpath.VMSystemProperties.props = props;
|
||||
}
|
||||
|
||||
public Throwable newIllegalAccessError(String msg)
|
||||
{
|
||||
return new IllegalAccessError(msg);
|
||||
|
|
|
@ -47,7 +47,7 @@ import java.util.HashMap;
|
|||
import java.util.ArrayList;
|
||||
import java.util.StringTokenizer;
|
||||
import java.lang.reflect.Constructor;
|
||||
import gnu.java.lang.SystemClassLoader;
|
||||
import gnu.classpath.SystemProperties;
|
||||
import gnu.java.util.DoubleEnumeration;
|
||||
import cli.System.*;
|
||||
import cli.System.Reflection.*;
|
||||
|
@ -255,7 +255,7 @@ final class VMClassLoader
|
|||
*/
|
||||
static boolean defaultAssertionStatus()
|
||||
{
|
||||
return Boolean.valueOf(ClassLoader.getSystemProperty("ikvm.assert.default", "false")).booleanValue();
|
||||
return Boolean.valueOf(SystemProperties.getProperty("ikvm.assert.default", "false")).booleanValue();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -271,7 +271,7 @@ final class VMClassLoader
|
|||
if(packageAssertionMap == null)
|
||||
{
|
||||
HashMap m = new HashMap();
|
||||
String enable = ClassLoader.getSystemProperty("ikvm.assert.enable", null);
|
||||
String enable = SystemProperties.getProperty("ikvm.assert.enable", null);
|
||||
if(enable != null)
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(enable, ":");
|
||||
|
@ -280,7 +280,7 @@ final class VMClassLoader
|
|||
m.put(st.nextToken(), Boolean.TRUE);
|
||||
}
|
||||
}
|
||||
String disable = ClassLoader.getSystemProperty("ikvm.assert.disable", null);
|
||||
String disable = SystemProperties.getProperty("ikvm.assert.disable", null);
|
||||
if(disable != null)
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(disable, ":");
|
||||
|
|
|
@ -195,14 +195,12 @@ final class VMRuntime
|
|||
static native int nativeLoad(String filename);
|
||||
|
||||
/**
|
||||
* Map a system-independent "short name" to the full file name, and append
|
||||
* it to the path.
|
||||
* Map a system-independent "short name" to the full file name.
|
||||
*
|
||||
* @param pathname the path
|
||||
* @param libname the short version of the library name
|
||||
* @return the full filename
|
||||
*/
|
||||
static String nativeGetLibname(String pathname, String libname)
|
||||
static String mapLibraryName(String libname)
|
||||
{
|
||||
if(cli.System.Environment.get_OSVersion().ToString().indexOf("Unix") >= 0)
|
||||
{
|
||||
|
@ -291,13 +289,9 @@ final class VMRuntime
|
|||
private DotNetProcess(cli.System.Diagnostics.Process proc)
|
||||
{
|
||||
this.proc = proc;
|
||||
// TODO enable this when Channels.new[Out|in]putStream is working
|
||||
//stdin = Channels.newOutputStream(new FileChannelImpl(proc.get_StandardInput().get_BaseStream()));
|
||||
//stdout = Channels.newInputStream(new FileChannelImpl(proc.get_StandardOutput().get_BaseStream()));
|
||||
//stderr = Channels.newInputStream(new FileChannelImpl(proc.get_StandardError().get_BaseStream()));
|
||||
stdin = new gnu.java.nio.ChannelOutputStream(new FileChannelImpl(proc.get_StandardInput().get_BaseStream()));
|
||||
stdout = new gnu.java.nio.ChannelInputStream(new FileChannelImpl(proc.get_StandardOutput().get_BaseStream()));
|
||||
stderr = new gnu.java.nio.ChannelInputStream(new FileChannelImpl(proc.get_StandardError().get_BaseStream()));
|
||||
stdin = Channels.newOutputStream(new FileChannelImpl(proc.get_StandardInput().get_BaseStream()));
|
||||
stdout = Channels.newInputStream(new FileChannelImpl(proc.get_StandardOutput().get_BaseStream()));
|
||||
stderr = Channels.newInputStream(new FileChannelImpl(proc.get_StandardError().get_BaseStream()));
|
||||
}
|
||||
|
||||
public OutputStream getOutputStream()
|
||||
|
@ -342,169 +336,4 @@ final class VMRuntime
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the system properties. This is done here, instead of in System,
|
||||
* because of the bootstrap sequence. Note that the native code should
|
||||
* not try to use the Java I/O classes yet, as they rely on the properties
|
||||
* already existing. The only safe method to use to insert these default
|
||||
* system properties is {@link Properties#setProperty(String, String)}.
|
||||
*
|
||||
* <p>These properties MUST include:
|
||||
* <dl>
|
||||
* <dt>java.version <dd>Java version number
|
||||
* <dt>java.vendor <dd>Java vendor specific string
|
||||
* <dt>java.vendor.url <dd>Java vendor URL
|
||||
* <dt>java.home <dd>Java installation directory
|
||||
* <dt>java.vm.specification.version <dd>VM Spec version
|
||||
* <dt>java.vm.specification.vendor <dd>VM Spec vendor
|
||||
* <dt>java.vm.specification.name <dd>VM Spec name
|
||||
* <dt>java.vm.version <dd>VM implementation version
|
||||
* <dt>java.vm.vendor <dd>VM implementation vendor
|
||||
* <dt>java.vm.name <dd>VM implementation name
|
||||
* <dt>java.specification.version <dd>Java Runtime Environment version
|
||||
* <dt>java.specification.vendor <dd>Java Runtime Environment vendor
|
||||
* <dt>java.specification.name <dd>Java Runtime Environment name
|
||||
* <dt>java.class.version <dd>Java class version number
|
||||
* <dt>java.class.path <dd>Java classpath
|
||||
* <dt>java.library.path <dd>Path for finding Java libraries
|
||||
* <dt>java.io.tmpdir <dd>Default temp file path
|
||||
* <dt>java.compiler <dd>Name of JIT to use
|
||||
* <dt>java.ext.dirs <dd>Java extension path
|
||||
* <dt>os.name <dd>Operating System Name
|
||||
* <dt>os.arch <dd>Operating System Architecture
|
||||
* <dt>os.version <dd>Operating System Version
|
||||
* <dt>file.separator <dd>File separator ("/" on Unix)
|
||||
* <dt>path.separator <dd>Path separator (":" on Unix)
|
||||
* <dt>line.separator <dd>Line separator ("\n" on Unix)
|
||||
* <dt>user.name <dd>User account name
|
||||
* <dt>user.home <dd>User home directory
|
||||
* <dt>user.dir <dd>User's current working directory
|
||||
* </dl>
|
||||
*
|
||||
* @param p the Properties object to insert the system properties into
|
||||
*/
|
||||
static void insertSystemProperties(Properties p)
|
||||
{
|
||||
p.setProperty("java.version", "1.4");
|
||||
p.setProperty("java.vendor", "Jeroen Frijters");
|
||||
p.setProperty("java.vendor.url", "http://ikvm.net/");
|
||||
// HACK using the Assembly.Location property isn't correct
|
||||
cli.System.Reflection.Assembly asm = cli.System.Reflection.Assembly.GetExecutingAssembly();
|
||||
p.setProperty("java.home", new cli.System.IO.FileInfo(asm.get_Location()).get_DirectoryName());
|
||||
p.setProperty("java.vm.specification.version", "1.0");
|
||||
p.setProperty("java.vm.specification.vendor", "Sun Microsystems Inc.");
|
||||
p.setProperty("java.vm.specification.name", "Java Virtual Machine Specification");
|
||||
p.setProperty("java.vm.version", getVersion());
|
||||
p.setProperty("java.vm.vendor", "Jeroen Frijters");
|
||||
p.setProperty("java.vm.name", "IKVM.NET");
|
||||
p.setProperty("java.specification.version", "1.4");
|
||||
p.setProperty("java.specification.vendor", "Sun Microsystems Inc.");
|
||||
p.setProperty("java.specification.name", "Java Platform API Specification");
|
||||
p.setProperty("java.class.version", "48.0");
|
||||
String classpath = cli.System.Environment.GetEnvironmentVariable("CLASSPATH");
|
||||
if(classpath == null)
|
||||
{
|
||||
classpath = ".";
|
||||
}
|
||||
p.setProperty("java.class.path", classpath);
|
||||
String libraryPath = null;
|
||||
if(cli.System.Environment.get_OSVersion().ToString().indexOf("Unix") >= 0)
|
||||
{
|
||||
libraryPath = cli.System.Environment.GetEnvironmentVariable("LD_LIBRARY_PATH");
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
libraryPath = new cli.System.IO.FileInfo(cli.System.Reflection.Assembly.GetEntryAssembly().get_Location()).get_DirectoryName();
|
||||
}
|
||||
catch(Throwable t)
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
if(libraryPath == null)
|
||||
{
|
||||
libraryPath = ".";
|
||||
}
|
||||
else
|
||||
{
|
||||
libraryPath += cli.System.IO.Path.PathSeparator + ".";
|
||||
}
|
||||
libraryPath += cli.System.IO.Path.PathSeparator + cli.System.Environment.get_SystemDirectory() +
|
||||
cli.System.IO.Path.PathSeparator + cli.System.Environment.GetEnvironmentVariable("PATH");
|
||||
}
|
||||
if(libraryPath != null)
|
||||
{
|
||||
p.setProperty("java.library.path", libraryPath);
|
||||
}
|
||||
p.setProperty("java.io.tmpdir", cli.System.IO.Path.GetTempPath());
|
||||
p.setProperty("java.compiler", "");
|
||||
p.setProperty("java.ext.dirs", "");
|
||||
// NOTE os.name *must* contain "Windows" when running on Windows, because Classpath tests on that
|
||||
String osname = cli.System.Environment.get_OSVersion().ToString();
|
||||
String osver = cli.System.Environment.get_OSVersion().get_Version().ToString();
|
||||
// HACK if the osname contains the version, we remove it
|
||||
osname = ((cli.System.String)(Object)osname).Replace(osver, "").trim();
|
||||
p.setProperty("os.name", osname);
|
||||
String arch = cli.System.Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE");
|
||||
if(arch == null)
|
||||
{
|
||||
// TODO get this info from somewhere else
|
||||
arch = "x86";
|
||||
}
|
||||
p.setProperty("os.arch", arch);
|
||||
p.setProperty("os.version", osver);
|
||||
p.setProperty("file.separator", "" + cli.System.IO.Path.DirectorySeparatorChar);
|
||||
p.setProperty("file.encoding", "8859_1");
|
||||
p.setProperty("path.separator", "" + cli.System.IO.Path.PathSeparator);
|
||||
p.setProperty("line.separator", cli.System.Environment.get_NewLine());
|
||||
p.setProperty("user.name", cli.System.Environment.get_UserName());
|
||||
String home = cli.System.Environment.GetEnvironmentVariable("USERPROFILE");
|
||||
if(home == null)
|
||||
{
|
||||
// maybe we're on *nix
|
||||
home = cli.System.Environment.GetEnvironmentVariable("HOME");
|
||||
if(home == null)
|
||||
{
|
||||
// TODO maybe there is a better way
|
||||
// NOTE on MS .NET this doesn't return the correct path
|
||||
// (it returns "C:\\Documents and Settings\\username\\My Documents", but we really need
|
||||
// "C:\\Documents and Settings\\username" to be compatible with Sun, that's why we use %USERPROFILE% if it exists)
|
||||
home = cli.System.Environment.GetFolderPath(cli.System.Environment.SpecialFolder.wrap(cli.System.Environment.SpecialFolder.Personal));
|
||||
}
|
||||
}
|
||||
p.setProperty("user.home", home);
|
||||
p.setProperty("user.dir", cli.System.Environment.get_CurrentDirectory());
|
||||
p.setProperty("awt.toolkit", "ikvm.awt.NetToolkit, IKVM.AWT.WinForms");
|
||||
// HACK since we cannot use URL here (it depends on the properties being set), we manually encode the spaces in the assembly name
|
||||
p.setProperty("gnu.classpath.home.url", "ikvmres://" + ((cli.System.String)(Object)cli.System.Reflection.Assembly.GetExecutingAssembly().get_FullName()).Replace(" ", "%20") + "/lib");
|
||||
|
||||
// read properties from app.config
|
||||
cli.System.Collections.Specialized.NameValueCollection appSettings = cli.System.Configuration.ConfigurationSettings.get_AppSettings();
|
||||
cli.System.Collections.IEnumerator keys = appSettings.GetEnumerator();
|
||||
while(keys.MoveNext())
|
||||
{
|
||||
String key = (String)keys.get_Current();
|
||||
if(key.startsWith("ikvm:"))
|
||||
{
|
||||
p.setProperty(key.substring(5), appSettings.get_Item(key));
|
||||
}
|
||||
}
|
||||
// set the properties that were specified with IKVM.Runtime.Startup.SetProperties()
|
||||
if(props != null)
|
||||
{
|
||||
cli.System.Collections.IEnumerator entries = ((cli.System.Collections.IEnumerable)props).GetEnumerator();
|
||||
while(entries.MoveNext())
|
||||
{
|
||||
cli.System.Collections.DictionaryEntry de = (cli.System.Collections.DictionaryEntry)entries.get_Current();
|
||||
p.setProperty((String)de.get_Key(), (String)de.get_Value());
|
||||
}
|
||||
props = null;
|
||||
}
|
||||
}
|
||||
|
||||
// HACK we need a way to get the assembly version of ik.vm.net.dll
|
||||
static native String getVersion();
|
||||
} // class VMRuntime
|
||||
|
|
|
@ -89,16 +89,6 @@ final class VMSystem
|
|||
return cli.System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(o);
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect big-endian systems.
|
||||
*
|
||||
* @return true if the system is big-endian.
|
||||
*/
|
||||
static boolean isWordsBigEndian()
|
||||
{
|
||||
return !cli.System.BitConverter.IsLittleEndian;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a library name to its platform-specific variant.
|
||||
*
|
||||
|
|
|
@ -132,10 +132,7 @@ public final class Constructor
|
|||
*/
|
||||
public Class[] getParameterTypes()
|
||||
{
|
||||
Object[] params = Method.GetParameterTypes(methodCookie);
|
||||
Class[] paramsClass = new Class[params.length];
|
||||
System.arraycopy(params, 0, paramsClass, 0, params.length);
|
||||
return paramsClass;
|
||||
return Method.GetParameterTypesHelper(methodCookie);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -143,13 +143,25 @@ public final class Method extends AccessibleObject implements Member
|
|||
* @return a list of the types of the method's parameters
|
||||
*/
|
||||
public Class[] getParameterTypes()
|
||||
{
|
||||
return GetParameterTypesHelper(methodCookie);
|
||||
}
|
||||
|
||||
static Class[] GetParameterTypesHelper(Object methodCookie)
|
||||
{
|
||||
Object[] params = GetParameterTypes(methodCookie);
|
||||
Class[] paramsClass = new Class[params.length];
|
||||
System.arraycopy(params, 0, paramsClass, 0, params.length);
|
||||
// NOTE don't use System.arraycopy because we don't want to initialize System
|
||||
// (it causes problems when gnu.java.io.EncodingManager initializes before
|
||||
// System is initialized.)
|
||||
for(int i = 0; i < params.length; i++)
|
||||
{
|
||||
paramsClass[i] = (Class)params[i];
|
||||
}
|
||||
return paramsClass;
|
||||
}
|
||||
static native Object[] GetParameterTypes(Object methodCookie);
|
||||
|
||||
private static native Object[] GetParameterTypes(Object methodCookie);
|
||||
|
||||
/**
|
||||
* Get the exception types this method says it throws, in no particular
|
||||
|
|
|
@ -31,6 +31,11 @@
|
|||
{
|
||||
.vtentry 1:1
|
||||
.export [1] as JNI_CreateJavaVM
|
||||
|
||||
// Make sure that the correct IKVM.GNU.Classpath assembly is loaded
|
||||
ldtoken [IKVM.GNU.Classpath]java.lang.Object
|
||||
pop
|
||||
|
||||
ldarg.0
|
||||
ldarg.1
|
||||
ldarg.2
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
<?xml version="1.0"?>
|
||||
<project name="JVM" default="JVM">
|
||||
<target name="JVM">
|
||||
<exec program="../tools/asmref.exe" useruntimeengine="true" commandline="mscorlib" output="jvm_h1.il" />
|
||||
<exec program="../tools/asmref.exe" useruntimeengine="true" commandline="../bin/IKVM.Runtime.dll" output="jvm_h2.il" />
|
||||
<exec program="ilasm" commandline="/dll /out:../bin/JVM.DLL jvm_h1.il jvm_h2.il JVM.il" />
|
||||
<exec program="../tools/asmref.exe" useruntimeengine="true" commandline="mscorlib ../bin/IKVM.Runtime.dll ../bin/IKVM.GNU.Classpath.dll" output="jvm_h.il" />
|
||||
<exec program="ilasm" commandline="/dll /out:../bin/JVM.DLL jvm_h.il JVM.il" />
|
||||
</target>
|
||||
</project>
|
||||
|
|
|
@ -115,8 +115,6 @@ namespace IKVM.Runtime
|
|||
return JNIEnv.JNI_ERR;
|
||||
}
|
||||
}
|
||||
// HACK make sure the Java library is loaded
|
||||
Assembly.Load("IKVM.GNU.Classpath");
|
||||
|
||||
Startup.SetProperties(props);
|
||||
|
||||
|
|
|
@ -279,11 +279,6 @@ namespace IKVM.NativeCode.java
|
|||
|
||||
public class VMRuntime
|
||||
{
|
||||
public static string getVersion()
|
||||
{
|
||||
return typeof(VMRuntime).Assembly.GetName().Version.ToString();
|
||||
}
|
||||
|
||||
public static int nativeLoad(string filename)
|
||||
{
|
||||
return IKVM.Runtime.JniHelper.LoadLibrary(filename);
|
||||
|
@ -1123,7 +1118,7 @@ namespace IKVM.NativeCode.java
|
|||
return NativeCode.java.lang.VMSecurityManager.currentClassLoader();
|
||||
}
|
||||
|
||||
public static object allocateObject(object ois, object clazz)
|
||||
public static object allocateObject(object ois, object clazz, object constructor_clazz, object constructor)
|
||||
{
|
||||
Profiler.Enter("ObjectInputStream.allocateObject");
|
||||
try
|
||||
|
@ -1136,41 +1131,17 @@ namespace IKVM.NativeCode.java
|
|||
}
|
||||
wrapper.Finish();
|
||||
// TODO do we need error handling? (e.g. when trying to instantiate an interface or abstract class)
|
||||
return NetSystem.Runtime.Serialization.FormatterServices.GetUninitializedObject(wrapper.TypeAsBaseType);
|
||||
object obj = NetSystem.Runtime.Serialization.FormatterServices.GetUninitializedObject(wrapper.TypeAsBaseType);
|
||||
MethodWrapper mw = (MethodWrapper)JVM.Library.getWrapperFromMethodOrConstructor(constructor);
|
||||
// TODO do we need error handling?
|
||||
mw.Invoke(obj, null, false);
|
||||
return obj;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Profiler.Leave("ObjectInputStream.allocateObject");
|
||||
}
|
||||
}
|
||||
|
||||
public static void callConstructor(object ois, object clazz, object obj)
|
||||
{
|
||||
Profiler.Enter("ObjectInputStream.callConstructor");
|
||||
try
|
||||
{
|
||||
TypeWrapper type = NativeCode.java.lang.VMClass.getWrapperFromClass(clazz);
|
||||
// if we're trying to deserialize a string as a TC_OBJECT, we already have an initialized emtpy string
|
||||
// so there is no need to call the constructor (which wouldn't work anyway).
|
||||
if(!(obj is string))
|
||||
{
|
||||
MethodWrapper mw = type.GetMethodWrapper(new MethodDescriptor("<init>", "()V"), false);
|
||||
if(mw == null)
|
||||
{
|
||||
// TODO what should we do here?
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
// TODO instead of calling link, we should probably Finish the wrapper
|
||||
mw.Link();
|
||||
// TODO what about exceptions? (should they be unwrapped?)
|
||||
mw.Invoke(obj, null, false);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
Profiler.Leave("ObjectInputStream.callConstructor");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1338,6 +1309,17 @@ namespace IKVM.NativeCode.gnu.java.nio.channels
|
|||
}
|
||||
}
|
||||
|
||||
namespace IKVM.NativeCode.gnu.classpath
|
||||
{
|
||||
public class VMSystemProperties
|
||||
{
|
||||
public static string getVersion()
|
||||
{
|
||||
return typeof(VMSystemProperties).Assembly.GetName().Version.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace gnu.classpath
|
||||
{
|
||||
// This type lives here, because we don't want unverifiable code in IKVM.GNU.Classpath
|
||||
|
@ -1420,6 +1402,8 @@ namespace ikvm.@internal
|
|||
IntPtr getDirectBufferAddress(object buffer);
|
||||
int getDirectBufferCapacity(object buffer);
|
||||
|
||||
void setProperties(System.Collections.Hashtable props);
|
||||
|
||||
Exception newIllegalAccessError(string msg);
|
||||
Exception newIllegalAccessException(string msg);
|
||||
Exception newIncompatibleClassChangeError(string msg);
|
||||
|
|
|
@ -155,8 +155,7 @@ namespace IKVM.Runtime
|
|||
|
||||
public static void SetProperties(System.Collections.Hashtable props)
|
||||
{
|
||||
Type vmruntime = Type.GetType("java.lang.VMRuntime, IKVM.GNU.Classpath");
|
||||
vmruntime.GetField("props", BindingFlags.NonPublic | BindingFlags.Static).SetValue(null, props.Clone());
|
||||
IKVM.Internal.JVM.Library.setProperties(props);
|
||||
}
|
||||
|
||||
public static void EnterMainThread()
|
||||
|
@ -165,11 +164,6 @@ namespace IKVM.Runtime
|
|||
{
|
||||
Thread.CurrentThread.Name = "main";
|
||||
}
|
||||
// HACK initialize java.lang.System first
|
||||
// (Ideally GNU Classpath wouldn't have circular initialization dependencies, but
|
||||
// it's hard to get support for that from the community).
|
||||
Type system = Type.GetType("java.lang.System, IKVM.GNU.Classpath");
|
||||
System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor(system.TypeHandle);
|
||||
}
|
||||
|
||||
public static void ExitMainThread()
|
||||
|
@ -219,8 +213,7 @@ namespace IKVM.Runtime
|
|||
{
|
||||
throw new ArgumentException("field");
|
||||
}
|
||||
// HACK we use reflection to extract the fieldCookie from the java.lang.reflect.Field object
|
||||
return (FieldWrapper)field.GetType().GetField("fieldCookie", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(field);
|
||||
return (FieldWrapper)IKVM.Internal.JVM.Library.getWrapperFromField(field);
|
||||
}
|
||||
|
||||
public static object GetFieldConstantValue(object field)
|
||||
|
@ -244,8 +237,7 @@ namespace IKVM.Runtime
|
|||
{
|
||||
throw new ArgumentException("method");
|
||||
}
|
||||
// HACK we use reflection to extract the methodCookie from the java.lang.reflect.Method object
|
||||
MethodWrapper mw = (MethodWrapper)method.GetType().GetField("methodCookie", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(method);
|
||||
MethodWrapper mw = (MethodWrapper)IKVM.Internal.JVM.Library.getWrapperFromMethodOrConstructor(method);
|
||||
MethodBase mb = mw.GetMethod();
|
||||
return mb != null && mb.IsDefined(typeof(ObsoleteAttribute), false);
|
||||
}
|
||||
|
@ -260,8 +252,7 @@ namespace IKVM.Runtime
|
|||
{
|
||||
throw new ArgumentException("constructor");
|
||||
}
|
||||
// HACK we use reflection to extract the methodCookie from the java.lang.reflect.Constructor object
|
||||
MethodWrapper mw = (MethodWrapper)constructor.GetType().GetField("methodCookie", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(constructor);
|
||||
MethodWrapper mw = (MethodWrapper)IKVM.Internal.JVM.Library.getWrapperFromMethodOrConstructor(constructor);
|
||||
MethodBase mb = mw.GetMethod();
|
||||
return mb != null && mb.IsDefined(typeof(ObsoleteAttribute), false);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче