runtime JAVA_VERSION vs. Java build target
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 21 Jul 2023 12:14:44 UTC
I've run into this recently: when I build a Java port, generated JAR will be built with a compiler set by JAVA_VERSION which is our runtime setting. For example, when building with OpenJDK 11, and later running something with env JAVA_VERSION=8 ... I will get class file version errors. Since textproc/xincluder is a small and obsolete piece of software, I have decided to tell javac to target Java 8 in all cases[1]. Shall this be a general practice? If someone decides to set JAVA_VERSION high and rebuild Java dependencies from source (those which can be rebuilt) - JAVA_VERSION cannot be really used to switch at runtime. On the other hand, one might the code to be optimized better. What is the best practice here? Shall we keep JAR libraries that can be used as dependencies compatible with the oldest Java runtime we have? Marcin [1] https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=272559