Can we really recommend to use the --release
option?
#3736
Replies: 3 comments 7 replies
-
This should be avoided with |
Beta Was this translation helpful? Give feedback.
-
Would be a killer for our product development, because we officially support two recent LTS JDK versions (17 and 21) and compile with --release 17 while running on Java 21+. |
Beta Was this translation helpful? Give feedback.
-
If there is a strong need, we could investigate, if MatchLocator could possibly switch compliance levels in mid-air, i.e., when processing sources from a JDK source attachment temporarily switch to the compliance of the physical JDK, and switch back for other sources. Theory speaking. I can't promise that this is feasible. |
Beta Was this translation helpful? Give feedback.
-
Initially, it sounded like a cool feature: users can download just one recent JDK and use if for developing various projects targeting various JDK versions, not only in terms of source version but also ensuring that JDK API is used in the exact version specified, e.g., no usage of methods that are not present in the target JDK version etc.
Some of us remember the significant pains required to implement compiler support for
--release
. Only recently we noticed that it is "tricky" to be consistent in various use cases where some IDE feature resolve JDK types and methods. It is far from trivial to ensure that all use cases are aware of the intended--release
version.Unfortunately, all this will only ever cover use cases working from binary types (.class or .sig). The most elaborate support for
--release
will invariable fail as soon as we access stuff that exists only in the latest version:I recently came across a test case where we search for references to some JDK type or method. What if we select to find references within the JDK itself? To locate any index matches and show them in the UI we need to access and resolve source files. What I observed in that particular test case looked like this:
--release 16
sealed
), which is illegal at--release 16
This is just an extreme case of the inherent difference between binary and source views of the JDK when
--release
is involved.Ergo: Should we generally and strongly discourage this kind of configuration? Should we educate (how?) users that still today there is no better configuration then to use the real JDK of that exact version you are targeting?
Beta Was this translation helpful? Give feedback.
All reactions