springboot 3.2.0-RC1

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
        <compilerArgs>
            <arg>--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED</arg>
            <arg>--add-exports=java.base/jdk.internal.vm=ALL-UNNAMED</arg>
        </compilerArgs>
    </configuration>
</plugin>

the default property <maven.compiler.release>${java.version}</maven.compiler.release>

cause error

exporting a package from system module java.base is not allowed with --release

see SpringBoot Document that spring-boot-starter-parent sets maven.compiler.release and how to unset it if needed

source plexus-compiler-javac-2.13.0.jar

SpringBoot Document that spring-boot-starter-parent sets maven.compiler.release and how to unset it if needed

Comment From: wilkinsona

Thanks for trying to RC. Have you only just started seeing this problem? We started setting maven.compiler.release in 3.1.

Comment From: brucelwl

I previously discovered this PR https://github.com/spring-projects/spring-boot/pull/34365, but it still caused my program to not compile properly, and currently I have not found a corresponding solution SpringBoot Document that spring-boot-starter-parent sets maven.compiler.release and how to unset it if needed

Comment From: wilkinsona

Yes, I suspect that #34365 introduced the problem. However, if that is the case, this would also fail with Spring Boot 3.1. Does it?

Comment From: brucelwl

@wilkinsona I tried using Spring Boot version 3.1 and found the same problem

Comment From: wilkinsona

Thanks.

You can undo spring-boot-starter-parent setting maven.compiler.release by setting it to an empty string:

<maven.compiler.release></maven.compiler.release>

You then have to configure the source and target instead:

<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>

With these three properties in place, a project that uses --add-exports should work.

We'll have to decide if we want to continue to set maven.compiler.release or switch back to source and target.

Comment From: brucelwl

Thank you very much. <maven.compiler.release/> has solved my problem

Comment From: mhalbritter

We'll have to decide if we want to continue to set maven.compiler.release or switch back to source and target.

Upside of release is that the compiler then checks if you're using an API from a newer JDK, which is a definitive pro. Do we know why the JDK developers prohibit opening modules when using --release but allowing it when using --target and --source?

Comment From: wilkinsona

Upside of release is that the compiler then checks if you're using an API from a newer JDK, which is a definitive pro

It's definitely a good thing if you're building with a JDK version other than the one with which you'll run your app. However, if the two match, that benefit disappears and I wonder how common it is for them not to match.

Do we know why the JDK developers prohibit opening modules when using --release but allowing it when using --target and --source?

I don't.

Comment From: wilkinsona

We're going to document that we set maven.compiler.release by default and how and when to unset it. The JEP describes when. It's if you want to use --add-exports, --add-reads, or --patch-module to modify system modules.