ballerina-platform / ballerina-library

The Ballerina Library
https://ballerina.io/learn/api-docs/ballerina/
Apache License 2.0
136 stars 64 forks source link

Resolve GraalVM native image Java 21 warnings with experimental options #7252

Open TharmiganK opened 1 month ago

TharmiganK commented 1 month ago

Description:

With Java 21, GraalVM native image tool has marked some of the options/properties as experimental in order to remove them in the upcoming releases[1].

Currently there are added as warnings during the native-image build. Example:

Warning: The option '-H:Name=crypto' is experimental and must be enabled via '-H:+UnlockExperimentalVMOptions' in the future.
Warning: The option '-H:Path=/home/runner/work/module-ballerina-crypto/module-ballerina-crypto/ballerina/target/native' is experimental and must be enabled via '-H:+UnlockExperimentalVMOptions' in the future.
Warning: The option '-H:ReflectionConfigurationFiles=/home/runner/work/module-ballerina-crypto/module-ballerina-crypto/ballerina/target/cache/tests_cache/native-config/reflect-config.json' is experimental and must be enabled via '-H:+UnlockExperimentalVMOptions' in the future.
Warning: The option '-H:IncludeResources=resources/.*' is experimental and must be enabled via '-H:+UnlockExperimentalVMOptions' in the future.
Warning: Please re-evaluate whether any experimental option is required, and either remove or unlock it. The build output lists all active experimental options, including where they come from and possible alternatives. If you think an experimental option should be considered as stable, please file an issue.
 5 experimental option(s) unlocked:
 - '-H:ClassInitialization' (alternative API option(s): --initialize-at-run-time=org.bouncycastle.jcajce.provider.drbg.DRBG$Default:rerun,org.bouncycastle.jcajce.provider.drbg.DRBG$NonceAndIV:rerun; origin(s): 'META-INF/native-image/io.ballerina.stdlib/crypto-native/native-image.properties' in 'file:///home/runner/work/module-ballerina-crypto/module-ballerina-crypto/native/build/libs/crypto-native-2.8.0-SNAPSHOT.jar')
 - '-H:Name' (alternative API option(s): -o crypto; origin(s): command line)
 - '-H:ReflectionConfigurationFiles' (origin(s): command line)
 - '-H:Path' (origin(s): command line)
 - '-H:IncludeResources' (origin(s): command line)

[1] Experimental Build Options in Native Image in GraalVM for JDK 21 is here! article

Describe your task(s)

Most of them are used in the external Java dependencies(such as netty, bouncy castle etc.). If these options are added by either lang or standard libraries then we need to replace them with the appropriate option. If there is no replacement option, we need to inform the GraalVM community and ask for a resolution.

TharmiganK commented 1 month ago

@warunalakshitha FYI

TharmiganK commented 1 month ago

Experimental options used in Ballerina Lang:

Option Requirement Comment/ Resolution Status
H:Name The name of the executable Can be replaced by -o <enitre-file-path-with-name> PENDING
H:Path The path for the executable generation Can be replaced by -o <enitre-file-path-with-name> PENDING
H:IncludeResources Include all the resource files in the resources directory of a ballerina project A resource-config.json can be added for the same requirement. Here the issue is we need to add this for ballerina project only, not for a single file FIXED
H:ReflectionConfigurationFiles Include the reflection configurations required to run mock tests A reflect-config.json can be added for the same requirement. Here the issue is that the reflection config is not static, it can change based on the ballerina code PENDING
TharmiganK commented 1 month ago
Experimental options used in Standard Libraries: Library Option Requirement Comment/Resoultion Status
crypto H:ClassInitialization Initialize BC related classes with rerun strategy Use initialize-at-run-time instead FIXED
data.csv H:+IncludeAllLocales Include all the locales in the generated native image. This is not packed with the package. But used in tests
kafka H:AdditionalSecurityProviders Add additional security provider