As users start upgrading to JDK17 and beyond, they will sometimes be impacted by stricter Java modularization enforcement.
[main] WARN c.e.SomeImpl - [MAM] jvmm Failed to access compilationMxBean
java.lang.IllegalAccessError: class com.example.SomeImpl (in unnamed module @0x7e9a5fbe) cannot access
class sun.management.ManagementFactoryHelper (in module java.management) because module
java.management does not export sun.management to unnamed module @0x7e9a5fbe
The JDK has two mechanisms for loosening those restrictions described here:
add-exports
add-opens
Current Solutions
When launching a springboot target using bazel run, you can currently utilize the workarounds in two ways:
Defined in the shell:
export JAVA_OPTS="--add-opens=java.management/sun.management=ALL-UNNAMED"
bazel run //examples/helloworld
This issue proposes first class support of these workarounds in the BUILD file. This will be cleaner, and will also allow easy reuse across many springboot rules in a monorepo.
add-exports would be handled in the same way as its own attribute.
Downstream Considerations
Consider also that many teams will have a macro (not included in rules_spring) that packages up their springboot executable jar into an OCI/Docker image. That macro will want to have similar support such that the launch of the service within the container will also use the opens/exports. Having these lists defined as variables will help with that.
As users start upgrading to JDK17 and beyond, they will sometimes be impacted by stricter Java modularization enforcement.
The JDK has two mechanisms for loosening those restrictions described here:
Current Solutions
When launching a springboot target using bazel run, you can currently utilize the workarounds in two ways:
Defined in the shell:
Defined in the BUILD file:
//examples/helloworld/BUILD
Proposed Enhancements
This issue proposes first class support of these workarounds in the BUILD file. This will be cleaner, and will also allow easy reuse across many springboot rules in a monorepo.
//common/jdk.bzl
//examples/helloworld/BUILD
add-exports would be handled in the same way as its own attribute.
Downstream Considerations
Consider also that many teams will have a macro (not included in rules_spring) that packages up their springboot executable jar into an OCI/Docker image. That macro will want to have similar support such that the launch of the service within the container will also use the opens/exports. Having these lists defined as variables will help with that.