Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
521 views
in Technique[技术] by (71.8m points)

Intellij - Unable to use newer Java 8 classes - Error : "Usage of API documented as @since 1.6+.."

I'm trying to use a java.lang.function.Function in my java 8 code base, but i keep getting the following error in Intellij.

Usage of API documented as @since 1.6+ This inspection finds all usages of methods that have @since tag in their documentation. This may be useful when development is performed under newer SDK version as the target platform for production

I seem to have the correct Project and Compiler settings

Project Settings: (File -> Project Structure)

Project Settings -> Project -> Project SDK = Java 1.8
Project Settings -> Project -> Project Language Level = 8 - Lambdas, Type Annotations etc

Compiler Settings: (File -> Settings)

Build, Execution, Deployment -> Compiler -> Java Compiler -> Project Bytecode Version : 1.8
Build, Execution, Deployment -> Compiler -> Java Compiler -> Per module Bytecode Version -> Target Bytecode Version : 1.8

What is the problem?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Edited the answer based on Bastien Jansen comment.

Seems that there is another project setting that affects the compiler level. A subtle indication of this problem is when your compiler starts complaining of the source and target java version being different from the one you specified while you are compiling the code

Warning:java: source value 1.5 is obsolete and will be removed in a future release
Warning:java: target value 1.5 is obsolete and will be removed in a future release
Warning:java: To suppress warnings about obsolete options, use -Xlint:-options.

To get rid of this, you need to open up

File -> Project Structure -> Project Settings -> Modules -> "Your Module Name" -> Sources -> Language Level

and change that to the desired level i.e 1.8 or the Project Default language level


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...