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

Created on 12 Oct 2017  路  13Comments  路  Source: junit-team/junit5

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

  • [x] 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.

invalid

Most helpful comment

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.

All 13 comments

@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?

Closing this issue as _invalid_.

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

You got this warning without including apiguardian, right?

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

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

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.

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

Right. It will then be an automatic transitive dependency.

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

NeedMoreInformationToHelpException ;-)

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.

Was this page helpful?
0 / 5 - 0 ratings