Will qtjambi support GraalVM native image in the future? #105
Replies: 17 comments 10 replies
-
I am not familiar with this framework. Up to now, there is nothing planned to connect these technologies. However, I am happy about more details. |
Beta Was this translation helpful? Give feedback.
-
Using QtJambi with GraalVM is possible. The next step is to run the program in normal VM to acknowledge all JNI, resource and reflection usages. Therefore call: graalvm\bin\java -agentlib:native-image-agent=config-output-dir=native-image -cp QtJambi\6.4.3\deployment\qtjambi-6.4.3.jar;. -Djava.library.path=C:\Qt\6.4.2\msvc2019_64\bin;QtJambi\6.4.3\build\windows-x64\qtjambi\bin -Dio.qt.acknowledge-resources=true Test ( GraalVM creates a number of json files in directory native-images. graalvm\bin\native-image -cp QtJambi\6.4.3\deployment\qtjambi-6.4.3.jar;. --no-fallback -H:ConfigurationFileDirectories=native-image Test Finally, call the program: set PATH=C:\Qt\6.4.2\msvc2019_64\bin;QtJambi\6.4.3\build\windows-x64\qtjambi\bin;%PATH%
test.exe |
Beta Was this translation helpful? Give feedback.
-
Wow! This is so cool. HOPEFULLY THE SAME WILL BE AVAILABLE IN QTJAMBI 5.X. Since exposure to QtJambi, the framework is the most powerful Gui in Java. Any GUI will have more or less problems later when it comes to binary distribution, either too slow to start or too high in memory. Obviously, if you can package QtJambi in GraalVM, this will be a revolutionary moment for QtJambi. |
Beta Was this translation helpful? Give feedback.
-
During your testing, after the executable is generated, does the executable need to run with a dependency on the jar? I see you use the --no-fallback compile option in the command. Use this to compile out the executable, I tried this. However, this kind of compilation failure is displayed after the compilation is completed, which means that the compilation with this option may be the product of failure. According to my tests, JavaFX compiled can be run without jar with only one executable. I don't know if the compilation on your side with this option runs independently of the jar? |
Beta Was this translation helpful? Give feedback.
-
Will the upcoming |
Beta Was this translation helpful? Give feedback.
-
I'm happy to make you happy with QtJambi. |
Beta Was this translation helpful? Give feedback.
-
Hi author! GraalVM compiles QtJambi without a GUI. I followed your operation to compile the local image with GraalVM on Windows 10, everything went smoothly, the compiled executable has 20.8 MB, but no GUI form shows up, it becomes a console app. Why is that? No other libraries are used, and the program is simple. public class Main {
public static void main(String[] args) {
QApplication.initialize(args);
var app = new QWidget();
app.resize(600, 400);
app.setWindowTitle("QtJambi 5.15.13");
app.show();
QApplication.exec();
QApplication.shutdown();
}
} The command to generate a reflection-related JSON file is as follows: But executing the command yields a warning: My pragma is as follows: At this point, the executable is generated. But there is no GUI. What's going on?
|
Beta Was this translation helpful? Give feedback.
-
Or did I miss something? When you tested before, did the GUI program display normally after compiling? |
Beta Was this translation helpful? Give feedback.
-
If the native program freezes there is a JNI call or Java reflection not listed in the configuration JSON files. |
Beta Was this translation helpful? Give feedback.
-
Hi, just tried again. QtJambi with GraalVM is doable, and as you said, Gui works as expected. But there will be a console window under Windows, and I think I'll probably have to go to the GraalVM community or the documentation for answers about that. I know that there is a Maven plugin on GitHub for GraalVM for JavaFX, and in the example link given to you above, they compile the Java native executable without a console, maybe I can check his compilation log. |
Beta Was this translation helpful? Give feedback.
-
It does seem to be caused by the package, and it works fine for me to leave Main not in the package, but the warning still appears when generating reflection-related JSON. I don't know why? It's exciting though!! At least QtJambi's development module will be deprecated in the future, and QtJambi should make a module compatible with GraalVM |
Beta Was this translation helpful? Give feedback.
-
Hi, I have found the answer in GraalVM on how to remove the console window under Windows system. This has nothing to do with GraalVM and QtJambi. THIS ONLY REQUIRES EXECUTING THE RELEVANT INSTRUCTIONS OF THE VC COMPILER: |
Beta Was this translation helpful? Give feedback.
-
At this point, I think it is necessary for you to customize a module for the combination of GraalVM and QtJambi. Because the project is bound to have complex situations, multiple packages... It is also inconvenient to compile manually, you can get a Maven plugin or other tools to implement it. |
Beta Was this translation helpful? Give feedback.
-
Oh no! I found that I used Microsoft's VC compiler to remove the console window and click the program's close button, and the Gui disappeared. But the process is still stationed... It seems that the instructions of one VC are not enough to completely solve the problem |
Beta Was this translation helpful? Give feedback.
-
It's strange, I executed the command |
Beta Was this translation helpful? Give feedback.
-
Hi author! I found that when using GraalVM to generate QtJambi native images, some of the functions required had to be triggered once with trace reflection. In this way, all functions of the compiled program can be guaranteed to be normal. Example: There is a QPushButton on the interface, the click event is processed in another class MainHandler, which needs to trigger the click event when tracking, otherwise, the compiled native program, and then click the button, the corresponding slot function will not be executed, and the program will be stuck |
Beta Was this translation helpful? Give feedback.
-
I found out again, hahaha. In the example program above where GraalVM compiles JavaFX, it seems that some classes are manually configured to avoid that some classes may not be automatically traced to the proxy to eventually cause some functionality of the program not to work as expected. It seems that I still have to study the documentation. There is also about removing the console window, you can pass parameters to the VC compiler's linker, and the parameter is the |
Beta Was this translation helpful? Give feedback.
-
Hello, author!
Javafx can be run in aot mode, which is cool.
Will qtjambi support GraalVM native image in the future?
Beta Was this translation helpful? Give feedback.
All reactions