I am currently using the latest version of Eclipse IDE and have my project setup to use JDK8, however when I attempt to use the autocomplete it provides suggestions from future compiler versions. This can get really annoying as every time that I need to rely on the autocomplete, I have to double check the Javadoc information to see if it is compatible. What settings do I need to change to force eclipse to only show <JDK8 suggestions?
Eclipse is doing exactly what you asked it to. The problem lies in the word 'compiler compliance'; this has evidently confused you.
It means language features. Specifically, it does not mean 'library support level'.
What you want is for methods introduced in the java.*
API that are not in the version you are targeting, to either be entirely non-existent (i.e. not in the autocomplete, and if you attempted to call them, red wavy underline), or possibly 'exists, but, marked off as unavailable / 'future'.
This is not possible without giving eclipse an actual JDK of the right version, at which point, you get that behaviour if you configure the project to use that JDK. This more or less happens automatically if projects are configured right and in the preferences 'JRE' section you told eclipse where this JDK 'lives'.
For example:
Once you've done that, you have what you want.
It doesn't matter what the compiler compliance level is set to. To highlight the point: With some acrobatics you can expose some JDK9+ java.*
API to JDK8's javac
and it would allow you to compile code that uses the newer APIs with it (and it would not run on a stock JDK8).
Remember: "Java.* classpath" and "which lang features can I use" are essentially unrelated.
For example, if you set compiler compliance to 10 or up, you can use var
. If you set it to 9 or below, you cannot. If you set it to 9 or up you can make module-info.java
files. 8 and below, you cannot do that.
But none of that affects whether you can e.g. access JDK25's java.lang.IO
.