eclipse-jdt / eclipse-jdt/eclipse.jdt.core

`Exporting a package from system module 'java.desktop' is not allowed with --release` suddenly appear when compile with java 21

Open
#3,794 3 comments 0 reactions 1 assignee Claimed by @jarthana View on GitHub
Dominant language
Java
Stars
237
Forks
195
Avg merge
1d 12h
Merged PRs (30d)
47

Description

I'm currently try to update Tycho to use [Java 21 as a runtime JVM](https://github.com/eclipse-tycho/tycho/pull/4863) while doing so now one of the tests start to fail with a rather strange message

> `Exporting a package from system module 'java.desktop' is not allowed with --release`

the full output can be seen [here](https://ci.eclipse.org/tycho/job/tycho-github/job/PR-4863/3/testReport/junit/org.eclipse.tycho.test.compiler/CompilerExtraExportsJava17Test/testExtraExports/) compiler args are (with shorten path for brevity):

```
--add-exports
java.desktop/com.sun.imageio.plugins.gif=ALL-UNNAMED
--add-exports
java.desktop/com.sun.imageio.plugins.png=ALL-UNNAMED
-s
target/generated-sources/annotations
-d
target/classes
-classpath
target/classes:org/osgi/org.osgi.annotation.versioning/1.1.2/org.osgi.annotation.versioning-1.1.2.jar[+org/osgi/annotation/versioning/*:?**/*]:org/osgi/org.osgi.annotation.bundle/1.1.1/org.osgi.annotation.bundle-1.1.1.jar[+org/osgi/annotation/bundle/*:?**/*]:org/osgi/org.osgi.service.event/1.4.1/org.osgi.service.event-1.4.1.jar[+org/osgi/service/event/annotations/*:?**/*]:org/osgi/org.osgi.service.cm/1.6.1/org.osgi.service.cm-1.6.1.jar[+org/osgi/service/cm/annotations/*:?**/*]:org/osgi/org.osgi.service.metatype.annotations/1.4.1/org.osgi.service.metatype.annotations-1.4.1.jar[+org/osgi/service/metatype/annotations/*:?**/*]:org/osgi/org.osgi.service.component.annotations/1.5.1/org.osgi.service.component.annotations-1.5.1.jar[+org/osgi/service/component/annotations/*:?**/*]
src/main/java/Foo.java
-g
-nowarn
-target
17
-source
17
--release
17
```

So before we where running with **Java 17 and it works**, now we run with **Java 21 and it gives the error**.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.