jbang
jbang copied to clipboard
Use `--release` instead of `-source`/`-target` where appropriate
We use -source and -target compiler options in several places (eg https://github.com/maxandersen/jbang/blob/main/src/main/java/dev/jbang/source/buildsteps/CompileBuildStep.java#L74), we should use --release whenever using JDKs 9 and newer.
I think i agree but can you remind me why?
For this specific instance enable preview wasn't introduced before java 12 afaik so we could probably just use --release but i feel there was a reason i used --source..but can't remember :)
Well --release was only introduced in JDK 9 so we couldn't use it when supporting JDK 8. And the advantage seems to be that --source and --target only look at the source and bytecode level, but the JDK APIs might have changed as well. The --release option seems to somehow take that into account (this article explains it somewhat https://www.baeldung.com/java-compiler-release-option).