swagger-api / swagger-api/swagger-codegen

Does not compile with Java 9

Open
#7,976 2 comments 7 reactions 1 assignee View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

This is a friendly reminder that swagger-codegen fails on Java 9.
Everything compiles as expected with Java 8.

Swagger-codegen version

all version 2.x and 3.x

Steps to reproduce

Install Java 9

java --version
java 9.0.4
Java(TM) SE Runtime Environment (build 9.0.4+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.4+11, mixed mode)
mvn clean package
-------------------------------------------------------------------------------
Test set: TestSuite
-------------------------------------------------------------------------------
Tests run: 582, Failures: 128, Errors: 0, Skipped: 3, Time elapsed: 7.065 sec <<< FAILURE! - in TestSuite
checkOptionsHelp(io.swagger.codegen.lagomScalaApi.LagomScalaApiOptionsTest)  Time elapsed: 0.03 sec  <<< FAILURE!
java.lang.NoClassDefFoundError: javax/annotation/PostConstruct
Caused by: java.lang.ClassNotFoundException: javax.annotation.PostConstruct

....

This might be related to:
https://stackoverflow.com/questions/34947994/neon-how-to-run-on-jdk9

Suggest a fix/enhancement

Right now it's fine to install Java 8 as instructed in the README.
This issue hopefully helps other people when searching for a solution.
But this should be fixed some day, too! 😉

In example, on my Mac I did the following:

brew cask install caskroom/versions/java8

export JAVA_HOME=`/usr/libexec/java_home -v 1.8`
export PATH=${JAVA_HOME}/bin:$PATH

java -version

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.