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

[Native Image] Not able to launch native App created using SWT #9810

Open
2 tasks
shireeshakalle opened this issue Oct 3, 2024 · 3 comments
Open
2 tasks
Assignees

Comments

@shireeshakalle
Copy link

Describe the Issue

I'm getting the following exception when I try to launch the native app which created using swt.

SWT version:3.126.0
JDK:21
GraalVM Version:graalvm-jdk-21.0.4+8.1

When I try to load shell = new Shell(SWT.CLOSE | SWT.MIN);I'm getting the following error.
I'm passing all config files(proxy-config.json, reflect-config.json, jni-config.json, resource-config.json)

Exception in thread "main" java.lang.NoSuchFieldError: org.eclipse.swt.internal.win32.GESTURECONFIG.dwBlock
at org.graalvm.nativeimage.builder/com.oracle.svm.core.jni.functions.JNIFunctions$Support.getFieldID(JNIFunctions.java:1357)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.jni.functions.JNIFunctions.GetFieldID(JNIFunctions.java:449)
at org.eclipse.swt.internal.win32.OS.SetGestureConfig(Native Method)
at org.eclipse.swt.widgets.Control.checkGesture(Control.java:692)
at org.eclipse.swt.widgets.Control.createWidget(Control.java:709)
at org.eclipse.swt.widgets.Scrollable.createWidget(Scrollable.java:160)
at org.eclipse.swt.widgets.Decorations.createWidget(Decorations.java:375)
at org.eclipse.swt.widgets.Shell.(Shell.java:318)
at org.eclipse.swt.widgets.Shell.(Shell.java:281)
at org.eclipse.swt.widgets.Shell.(Shell.java:207).

Can someone please help me on this!!!

Using the latest version of GraalVM can resolve many issues.

GraalVM Version

I have tried with
1.graalvm-jdk-21.0.4+8.1, java 21 version and
2.Java 17 and graalvm-ce-java17-22.3.1.

Operating System and Version

Windows 11

Diagnostic Flag Confirmation

  • I tried the -H:ThrowMissingRegistrationErrors= flag.

Run Command

just double click on native image.

Expected Behavior

it should launch an app with login credentials.

Actual Behavior

its throwing an error which is mentioned above.

Steps to Reproduce

Just create simple swt application to open dialogue box and run native image.

Additional Context

No response

Run-Time Log Output and Error Messages

No response

@shireeshakalle shireeshakalle changed the title [Native Image] Not able to launch native App due following issue. [Native Image] Not able to launch native App due to following issue. Oct 3, 2024
@shireeshakalle
Copy link
Author

shireeshakalle commented Oct 4, 2024

Here is the sample code to reproduce the issue.

public class SimpleShell {
    public static void main(String[] args) {
    	try {
			// Create display and shell
			Display display = new Display();
			Shell shell = new Shell(display, SWT.SHELL_TRIM); // Adds min, max, and close buttons
 
			// Set the shell title
			shell.setText("SWT Shell with Min/Max/Close");
 
			// Set size and open the shell
			shell.setSize(400, 300);
			shell.open();
 
			// Event loop to keep shell open
			while (!shell.isDisposed()) {
			    if (!display.readAndDispatch()) {
			        display.sleep();
			    }
			}
 
			// Dispose the display when shell is closed
			display.dispose();
			System.out.println("....end....");
		} catch (Exception e) {
			System.out.println("....error....");
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    }
}

Please any one help me on this

@shireeshakalle shireeshakalle changed the title [Native Image] Not able to launch native App due to following issue. [Native Image] Not able to launch native App created using SWT Oct 4, 2024
@oubidar-Abderrahim oubidar-Abderrahim self-assigned this Oct 4, 2024
@oubidar-Abderrahim
Copy link
Member

Hi, can you please provide a complete reproducer? the example you shared is missing the imports and the dependencies needed to compile it

@shireeshakalle
Copy link
Author

shireeshakalle commented Oct 4, 2024

package test;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class SimpleShell {
public static void main(String[] args) {
try {
// Create display and shell
Display display = new Display();
Shell shell = new Shell(display, SWT.SHELL_TRIM); // Adds min, max, and close buttons

		// Set the shell title
		shell.setText("SWT Shell with Min/Max/Close");

		// Set size and open the shell
		shell.setSize(400, 300);
		shell.open();

		// Event loop to keep shell open
		while (!shell.isDisposed()) {
		    if (!display.readAndDispatch()) {
		        display.sleep();
		    }
		}

		// Dispose the display when shell is closed
		display.dispose();
	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}

}

org.eclipse.platform org.eclipse.swt.win32.win32.x86_64 3.126.0

Please find the sample code and SWT dependency which I have used

@oubidar-Abderrahim let me know if you need more details

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

No branches or pull requests

2 participants