-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
JNIRegistrationAwt::registerFreeType called for sun.font.FontConfigManager too #3417
Conversation
bcb85d6
to
b4f2d7e
Compare
See old #2729 |
Ad CI, I don't get what's wrong from the log in Ideas?
|
That's irrelevant to this PR, it appears that this test has been failing for some time now. |
Hello @christianwimmer, is this PR O.K. or am I merely covering up a deeper problem? |
I don't think anything related to AWT can be reasonably expected to work with Since @pejovica what do you think? |
Unfortunately, this is just covering up a deeper problem. To illustrate this, consider the class initializer of static {
/* At the moment fontmanager library depends on freetype library
and therefore no need to load it explicitly here */
FontManagerNativeLibrary.load();
initIDs(FreetypeFontScaler.class);
} By initializing The illustrated problems are obviously just the tip of the iceberg. The bottom line is that initializing all classes at image build time without prior close inspection of all relevant code (both Java and native) will result in fundamentally broken images. In other words, the fact that a given example works is nothing more but a mere coincidence. That said, we are not against making |
Summary: Initializing all classes at image build time for AWT/Swing is not feasible at this time. It would require quite extensive patching of the JDK code, which cannot be done in a maintainable way using substitutions. The only proper way would be to make changes to the JDK itself, i.e., contribute to OpenJDK. |
Thank you @christianwimmer for the summary. Thanks @pejovica for taking the time to explain it in detail. I learned a lot 🙏 |
Fixes #3416
With this patch,
registerFreeType
gets properly called and the build works. The resulting binary runs as expected and lists available fonts. Steps to reproduce are described on #3416. Copy-pasting here for clarity:The following code, Main.java:
compiled as:
The occasional deadlock mentioned in the original issue #3416 still occurs, although I am not sure it's not my system's fault so I ll be debugging and pursuing that in a separate issue/PR.
Feedback is welcome, I am definitely not sure I am approaching this the right way.