ikvmnet / ikvm

A Java Virtual Machine and Bytecode-to-IL Converter for .NET
Other
1.22k stars 111 forks source link

static compiled binary ignores VM flags #338

Closed Kojoley closed 1 year ago

Kojoley commented 1 year ago
public final class SysProps
{
    public static void main(String[] args)
    {
        System.getProperties().list(System.out);
    }
}
cd ikvm850\bin
cmd /c "echo public final class SysProps { public static void main(String[] args) { System.getProperties().list(System.out); } }" > SysProps.java
javac.exe SysProps.java
java.exe -Dsun.stdout.encoding=UTF-8 -Dmyprop=value SysProps > SysProps.ikvm
ikvmc.exe SysProps.class 
copy java.exe.config SysProps.exe.config
SysProps.exe -J-Dsun.stdout.encoding=UTF-8 -J-Dmyprop=value > SysProps.ikvmc
diff -u SysProps.ikvm SysProps.ikvmc
@@ -9,7 +9,6 @@
 file.encoding.pkg=sun.io
 user.script=
 user.country=US
-sun.java.launcher=SUN_STANDARD
 sun.os.patch.level=
 java.vm.specification.name=Java Virtual Machine Specification
 user.dir=C:\w
@@ -28,14 +27,12 @@
 javax.net.ssl.trustStore=G:\ikvm850\lib\security\cacerts
 java.specification.name=Java Platform API Specification
 java.class.version=52.0
-myprop=value
 os.version=10.0
 user.home=C:\Users\Nick
 user.timezone=
 file.encoding=utf-8
 java.specification.version=1.8
 user.name=Nick
-java.class.path=.
 java.vm.specification.version=1.8
 java.home=G:\ikvm850
 sun.arch.data.model=64
@@ -53,4 +50,3 @@
 file.separator=\
 java.vendor.url.bug=https://github.com/ikvmnet/ikvm/issues/
 sun.cpu.endian=little
-sun.stdout.encoding=UTF-8

The issue seems to that IKVM.Runtime.dll!IKVM.Runtime.JVM.Properties.GetInitProperties accesses IKVM.Runtime.JVM.Properties.user before IKVM.Runtime.dll!IKVM.Runtime.Launcher.Run is called and populates it.

I also checked 8.1 version and it seems the bug had been already there.

wasabii commented 1 year ago

Any change you can try this on the latest hotfix branch? 8.5.2

wasabii commented 1 year ago

No response.