JavaVM for UWP (Help needed)

Hey Guys,
I decided to work on a Project called JVM4UWP (Name is subject to change), which brings you the power of java to all UWP (Unified Windows Platform)/WinRT.

The idea is that you can use the jvm.dll and java.dll as you have it in your regular jdk distribution.
You can then compile a native app which launches a vm to execute your code inside.

There only were two problems: Some API has been changed (LoadLibrary doesn’t allow dll’s other than those in system32, so you need LoadPackagedLibrary and package the libraries) and the build was made for Visual Studio 2013, so I had to upgrade some new things (C++14 conventions and stuff).

Now however I’ve reached a dead end where I am hoping that some bored and wise monkeys could help me out. The First issue (which isn’t a priority) is that the build crashes because of some linking issues because for some unknown reason the c runtime is compiled in statically.

The second (which I need your help with) is that for some reason the vm fails to initalize since the classpath isn’t properly used. It fails to load the very first class java/lang/Object, for some reason.

Everything you need to know is written in the Readme file of the repo.

Thanks :slight_smile:

3 Likes

Hey guys,
I made some progress, most issues are actually finding out what Windows RT also fordbids as security feature…

Currently it looks like we’d need to change the way how JME stores settings and/or change the Perferences to nbot behave consistently with other platforms. Not so cool :smiley:

Exception in thread "AWT-EventQueue-0" java.lang.SecurityException: Could not open windows registry node Software\JavaSoft\Prefs at root 0x80000001: Access denied
	at java.util.prefs.WindowsPreferences.openKey(WindowsPreferences.java:518)
	at java.util.prefs.WindowsPreferences.openKey(WindowsPreferences.java:480)
	at java.util.prefs.WindowsPreferences.<init>(WindowsPreferences.java:389)
	at java.util.prefs.WindowsPreferences.childSpi(WindowsPreferences.java:849)
	at java.util.prefs.AbstractPreferences.node(AbstractPreferences.java:833)
	at java.util.prefs.AbstractPreferences.node(AbstractPreferences.java:813)
	at com.jme3.system.AppSettings.load(AppSettings.java:288)
	at com.jme3.app.SettingsDialog.<init>(SettingsDialog.java:164)
	at com.jme3.system.JmeDesktopSystem$3.run(JmeDesktopSystem.java:170)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
	at java.awt.EventQueue.access$500(EventQueue.java:97)
	at java.awt.EventQueue$3.run(EventQueue.java:709)
	at java.awt.EventQueue$3.run(EventQueue.java:703)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

The thing is, even HKEY_CURRENT_USER, which was available for non admin users but now won’t be there anymore.
A workaround seems to be -Djava.util.prefs.PreferenceFactory=java.util.prefs.FileSystemPerferenceFactory, but I guess the FS Factory also needs an overhaul (AppData instead of ~/.java).

Now the problem is that the FileSystemPreferences are Unix only so I need to find out whether the platform specific chmod and file locking works on Windows (Visual Studio’s libc does a good job in adding posix compatible wrapper functions actually)

3 Likes

This is how I did:

String folderName="myJMEGame";
            defPath = "~/." + folderName + "/";
            if (System.getProperty("os.name").startsWith("Windows")) {
                defPath = Shell32Util.getKnownFolderPath(KnownFolders.FOLDERID_SavedGames) + "/" + folderName + "/";
            }
            File userSettings = new File(defPath + fileName + ".properties");
            File f = new File(defPath);
            if (!userSettings.exists()) {
                f.mkdirs();
//...           

I think you need JNA for Shell32.

2 Likes