Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

warning: unknown enum constant Status.STABLE while compiling org.junit.jupiter.api.Test using Java9 #1104

Closed
1 task done
namannigam-zz opened this issue Oct 12, 2017 · 13 comments

Comments

@namannigam-zz
Copy link

Overview

Bug report. Using the junit-jupiter-api-5.0.0 with java version "9" (build 9+181) in IntelliJ 2017.2.5(if that might matter)

Steps to reproduce:-

  1. Add a JDK9 based module to the project.
  2. Add JUnit5 to the classpath using IntelliJ's shortcut. (lib folder) [junit-jupiter-api-5.0.0.jar]
  3. Note that it brings along the opentest4j-1.0.0.jar along with to the lib/ folder.
  4. Compile the sample project (shared just to draw a picture of the directory structure in use) using the command
    javac --module-path lib -d "target" $(find src -name "*.java")

Results into warnings post the compilation of the classes as -

warning: unknown enum constant Status.STABLE
reason: class file for org.apiguardian.api.API$Status not found
warning: unknown enum constant Status.STABLE
2 warnings

Deliverables

  • Ensure that such warnings are not displayed out of the box.

On a side note, it would be good to know what exactly is causing these warnings to occur. Since, if I comment out the code using JUnit and execute the same command, things seems to be working fine.

@sormuras
Copy link
Member

Include module org.apiguardian.api from https://github.com/apiguardian-team/apiguardian into your lib folder.

See Gradle example here: https://github.com/junit-team/junit5-samples/blob/master/junit5-java9-engine/build.gradle#L9

@namannigam-zz
Copy link
Author

@sormuras thanks for the prompt reply.

  1. The link shared is Gradle. I am unable to find such an option for plain java project on IntelliJ(IJ). Is this a transitive dependency of junit-jupiter-api? Shouldn't IJ add that to the classpath as well?
  2. Manually added the jar to the lib folder and the warning are no more there. But could you share any relevant link or provide some information about what was the error about and why did it turn up?

@sormuras
Copy link
Member

See https://youtrack.jetbrains.com/issue/IDEA-178888 for details.

@sbrannen
Copy link
Member

Closing this issue as invalid.

@FranklinYu
Copy link

I still got this warning. Tried 5.0.2 and 5.1.0-M1. Any ideas?

@marcphilipp
Copy link
Member

You got this warning without including apiguardian, right?

It will become a mandatory dependency again starting in 5.1.0-RC1.

@FranklinYu
Copy link

Wait what? Why? And Why didn't Gradle/Maven automatically pick it up?

@marcphilipp
Copy link
Member

That's a long story. In short, it is declared as an optional dependency in its POM. Thus, Gradle/Maven will not pick it up by default. Since it's confusing and annoying we'll remove the optional tag starting in 5.1.0-RC. Then, Maven/Gradle will pick it up automatically and you won't see these warnings anymore.

@FranklinYu
Copy link

Oh, so I won't need to declare the dependency myself? Looking forward to 5.1.0-RC1 then!

@sbrannen
Copy link
Member

sbrannen commented Jan 6, 2018

Right. It will then be an automatic transitive dependency.

@memelet
Copy link

memelet commented Jun 9, 2018

I have compile 'org.apiguardian:apiguardian-api:1.0.0' but still get the warning

@sormuras
Copy link
Member

sormuras commented Jun 9, 2018

NeedMoreInformationToHelpException ;-)

@memelet
Copy link

memelet commented Jun 9, 2018

I don't even know (yet) if the problem is due to junit. I stated to get the error after I added exclude group: 'junit', module: 'junit' so IDEA and Gradle would use the correct runner, but that could be a decoy.

I was able to remove the warnings by adding compileOnly 'com.google.code.findbugs:jsr305:3.0.2'. apiguardian had no effet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants