Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Windows on ARM 64-bit #443

Closed
xanderberkhout opened this issue Dec 14, 2021 · 16 comments · Fixed by #707
Closed

Support for Windows on ARM 64-bit #443

xanderberkhout opened this issue Dec 14, 2021 · 16 comments · Fixed by #707
Milestone

Comments

@xanderberkhout
Copy link

I just tested a Java Swing application with the FlatLaf on Windows 11 ARM 64-bit and I got the following error:

java.lang.UnsatisfiedLinkError: C:\Users\xander\AppData\Local\Temp\flatlaf.temp\flatlaf-windows-x86-20900948333330.dll: Can't load IA 32-bit .dll on a ARM 64-bit platform
        at java.base/jdk.internal.loader.NativeLibraries.load(Native Method)
        at java.base/jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:384)
        at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:228)
        at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:170)
        at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2389)
        at java.base/java.lang.Runtime.load0(Runtime.java:755)
        at java.base/java.lang.System.load(System.java:1953)
        at com.formdev.flatlaf.util.NativeLibrary.loadLibraryFromJar(NativeLibrary.java:108)
        at com.formdev.flatlaf.util.NativeLibrary.<init>(NativeLibrary.java:59)
        at com.formdev.flatlaf.ui.FlatWindowsNativeWindowBorder.getInstance(FlatWindowsNativeWindowBorder.java:113)
        at com.formdev.flatlaf.ui.FlatNativeWindowBorder.initialize(FlatNativeWindowBorder.java:274)
        at com.formdev.flatlaf.ui.FlatNativeWindowBorder.isSupported(FlatNativeWindowBorder.java:68)
        at com.formdev.flatlaf.ui.FlatNativeWindowBorder.install(FlatNativeWindowBorder.java:76)
        at com.formdev.flatlaf.ui.FlatRootPaneUI.installNativeWindowBorder(FlatRootPaneUI.java:205)
        at com.formdev.flatlaf.ui.FlatRootPaneUI.installUI(FlatRootPaneUI.java:105)
        at java.desktop/javax.swing.JComponent.setUI(JComponent.java:730)
        at java.desktop/javax.swing.JRootPane.setUI(JRootPane.java:445)
        at java.desktop/javax.swing.JRootPane.updateUI(JRootPane.java:455)
        at java.desktop/javax.swing.JRootPane.<init>(JRootPane.java:349)
        at java.desktop/javax.swing.JWindow.createRootPane(JWindow.java:274)
        at java.desktop/javax.swing.JWindow.windowInit(JWindow.java:262)
        at java.desktop/javax.swing.JWindow.<init>(JWindow.java:189)

So the question is can I ignore this? There seems to be no DLL available for this platform. Is this planned?

@DevCharly
Copy link
Collaborator

Thanks for reporting.

So the question is can I ignore this?

Don't think so. Or does the application work?

Please disable the Flatlaf window decorations (that uses the DLL), via command line option: (see FlatLaf System Properties)

-Dflatlaf.useWindowDecorations=false

Then it should work without exception.

There seems to be no DLL available for this platform. Is this planned?

Not at the moment. Simply because I don't have a machine to build and test it.
Also don't know whether GitHub Actions, which are used to build release DLLs, support Windows ARM.
Maybe it is possible to build a ARM DLL on a x86 machine? Thanks.

Anyway I'm very interested in at least avoiding this exception, but I don't know how to detect whether running on ARM CPU.
Could you please run following program, which dumps Java's system properties, and post the output here?

import java.util.Properties;

public class DumpSystemProperties
{
    public static void main( String[] args ) {
        Properties properties = System.getProperties();
        properties.keySet().stream().sorted().forEach( key -> {
            System.out.println( key + " = '" + properties.getProperty( (String) key ) + "'" );
        });
    }
}

@xanderberkhout
Copy link
Author

xanderberkhout commented Dec 14, 2021

The application works as I don't know what the Window decoration does exactly.

os.arch=aarch64

This means you are running on ARM 64-bit.

I think now there is official support for Windows on ARM64 since Java 16/17 (I am using Bellsoft) I tried to run my application on a Mac with M1 processor running Windows 11 in a virtual machine in Parallels.

@xanderberkhout
Copy link
Author

xanderberkhout commented Dec 14, 2021

Here are the most interesting properties for Windows 11 on Arm 64-bit:

file.encoding=Cp1252
file.separator=\

os.version=10.0
os.name=Windows 10
os.arch=aarch64

java.version=17.0.1
java.vm.vendor=BellSoft
java.vm.name=OpenJDK 64-Bit Server VM
java.vm.specification.version=17
java.vm.specification.vendor=Oracle Corporation
java.vm.version=17.0.1+12-LTS

java.runtime.version=17.0.1+12-LTS
java.runtime.name=OpenJDK Runtime Environment
java.vendor=BellSoft

Using JShell:
System.getProperties().forEach((key, entry) -> System.out.println(key + "=" + entry));

DevCharly added a commit that referenced this issue Dec 14, 2021
@DevCharly
Copy link
Collaborator

Thanks for the info.

The application works as I don't know what the Window decoration does exactly.

This enables menu bar embedded into window title bar.
And also the full dark window title bar.

I tried to run my application on a Mac with M1 processor running Windows 11 in a virtual machine in Parallels.

Many thanks for this hint. Have an M1 Mac. 😄

A fix for the exception is in latest 2.0-SNAPSHOT build: https://github.com/JFormDesigner/FlatLaf#snapshots

Would be great if you could try it out.
Hope it works. Thanks.

@xberkhout
Copy link

xberkhout commented Dec 15, 2021

I don't see an exception anymore, so that looks good.

I have now installed Eclipse on Windows 11 Arm64 so I can debug faster.

Do you intend to add a .dll in the native part for Windows the coming year? There are now only two for x86 and x86_64. Would be nice to support all ARM platforms.

@xanderberkhout
Copy link
Author

It seems the original error is now solved with ARM64 bit Windows, but happens now on Windows x86, 32-bit on the 2.0rc1.

The program continues so it is not a big problem, but it is ugly.

@DevCharly
Copy link
Collaborator

..., but happens now on Windows x86, 32-bit on the 2.0rc1.

What exactly do you mean.
Is there now a UnsatisfiedLinkError on 32bit Windows?

What Java version / vendor do you use?

Just tried with a 32bit JRE (17.0.1 from adoption.net) on Windows 10 64bit and it works fine.

@xanderberkhout
Copy link
Author

yes, there was an UnsatisfiedLinkError with Bellsoft 17.0.1 on Windows 10 32-bit

@DevCharly
Copy link
Collaborator

Tried Bellsoft 17.0.1 32bit JRE and it works fine (on Windows 10 64bit; don't have 32bit Windows anymore)

What it the value of system property os.arch?
And it works with FlatLaf 1.6.x?
Can you post the exception?

@xanderberkhout
Copy link
Author

xanderberkhout commented Dec 23, 2021

It was not my own computer, so I cannot check directly. So I will try to find a virtual machine with Windows 10 32-bit. It is not a showstopper as the program continues.

@xanderberkhout
Copy link
Author

I have downloaded Windows 10 32-bit in Parallels and you are right. There is no issue with FlatLaf on Windows 32-bit in this virtual machine. I think there is an issue with the other computer and not with FlatLaf. So sorry to bother you.

@syoon2
Copy link
Contributor

syoon2 commented Aug 4, 2023

I use a Windows on ARM machine (Surface Pro X, to be specific) and tried running a FlatLaf application on it. Didn't encounter any crash or error with the latest stable (v3.1.1), but embedded menu bar seems unavailable.

Also don't know whether GitHub Actions, which are used to build release DLLs, support Windows ARM.
Maybe it is possible to build a ARM DLL on a x86 machine? Thanks.

#443 (comment)

AFAIK GitHub Actions do not offer a Windows on ARM VM. Fortunately Visual C++ provides cross compiling and an ARM DLL can be built on a x86 machine (see #707 for PoC).

I managed to compile and build FlatLaf with an ARM DLL, but even in this version, the embedded menu bar does not work right away (try building & running flatlaf-demo if you need a repro) - not quite sure what the cause of this would be though.

@DevCharly
Copy link
Collaborator

@syoon2 thanks for working on this issue 👍

You need to modify these lines:

if( SystemInfo.isWindows_10_orLater && (SystemInfo.isX86 || SystemInfo.isX86_64) ) {

and

classifier = SystemInfo.isX86_64 ? "windows-x86_64" : "windows-x86";

and

BTW please do no commit the ARM DLL to git. I'll do this when merging. I need to digitally sign the DLL.

@syoon2
Copy link
Contributor

syoon2 commented Aug 5, 2023

@DevCharly Yep, #707 is now updated with the edits to the lines you mentioned and ready for review :-)
I tried recompiling and building flatlaf-demo, and the embedded menu bar works flawlessly both on x86_64 and aarch64 🎉

DevCharly added a commit that referenced this issue Aug 5, 2023
, PR #707)

built by GitHub Actions:
https://github.com/JFormDesigner/FlatLaf/actions/runs/5771160235

locally signed Windows DLLs with FormDev Software GmbH code signing certificate
@DevCharly
Copy link
Collaborator

Merged in latest 3.2-SNAPSHOT: https://github.com/JFormDesigner/FlatLaf#snapshots

Could you please test this build and let me know whether it works? Thanks.

@DevCharly DevCharly added this to the 3.2 milestone Aug 5, 2023
@syoon2
Copy link
Contributor

syoon2 commented Aug 5, 2023

Just tested with my Surface Pro X - seems to work as expected :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants