I have a Java project that while compiling with maven gave warning as in subject, but compilation passed.
[INFO] --- compiler:3.11.0:compile (default-compile) @ ******* ---
[INFO] Changes detected - recompiling the module! :source
[INFO] Compiling 10 source files with javac [debug target 1.8] to target/classes
[WARNING] bootstrap class path not set in conjunction with -source 8
But when I switched to JDK 8, compilation failed
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.11.0:compile (default-compile) on project ******-service: Compilation failure
[ERROR] /Users/******/Workspaces/****/src/main/java/com/*****/*****Service.java:[92,28] cannot find symbol
[ERROR] symbol: method readAllBytes()
[ERROR] location: variable resource of type java.io.InputStream
So clearly, while using JDK 17, I could not notice, that code was using method, that only appeared since Java 9.
Question: how to correctly solve such warning and specify bootstrap class path when compiling with JDK 17?
(Because we don't want to reconfigure JAVA_HOME several times, just to make sure that project still really runs on JDK/JRE 8)
mvn --version
Apache Maven 3.9.1 (2e178502fcdbffc201671fb2537d0cb4b4cc58f8)
Maven home: /opt/homebrew/Cellar/maven/3.9.1/libexec
Java version: 17.0.6, vendor: Amazon.com Inc., runtime: /Users/****/Library/Java/JavaVirtualMachines/corretto-17.0.6-1/Contents/Home