forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid getting the GraalVM version at deployment time for AWT
- Loading branch information
Showing
3 changed files
with
38 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
extensions/awt/runtime/src/main/java/io/quarkus/awt/runtime/graal/AwtFeature.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package io.quarkus.awt.runtime.graal; | ||
|
||
import org.graalvm.nativeimage.hosted.Feature; | ||
import org.graalvm.nativeimage.hosted.RuntimeJNIAccess; | ||
|
||
import io.quarkus.runtime.util.JavaVersionUtil; | ||
|
||
public class AwtFeature implements Feature { | ||
@Override | ||
public void afterRegistration(AfterRegistrationAccess access) { | ||
// Added for JDK 19+ due to: https://github.com/openjdk/jdk20/commit/9bc023220 calling FontUtilities | ||
if (JavaVersionUtil.isJava19OrHigher()) { | ||
try { | ||
Class<?> fontUtilitiesClass = Class.forName("sun.font.FontUtilities"); | ||
RuntimeJNIAccess.register(fontUtilitiesClass); | ||
RuntimeJNIAccess.register(fontUtilitiesClass.getDeclaredFields()); | ||
RuntimeJNIAccess.register(fontUtilitiesClass.getDeclaredMethods()); | ||
RuntimeJNIAccess.register(fontUtilitiesClass.getDeclaredConstructors()); | ||
} catch (ClassNotFoundException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} | ||
} |