Skip to content

[BUG][JAVA] JDK 17 doesn't work with jaxrs-spec. Missing class javax.annotation.Generated. #11795

@jsyrjala

Description

@jsyrjala

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

Generating code with jaxrs-spec generates pom.xml that doesn't work with JDK17 and Maven 3.8.4. It is missing class javax.annotation.Generated.

mvn package

....

[INFO] Compiling 10 source files to /xxx/build/generated-oas-jaxrs-spec/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /xxx/build/generated-oas-jaxrs-spec/src/gen/java/com/xxx/model/Translation.java:[15,18] cannot find symbol
  symbol:   class Generated
  location: package javax.annotation
...

[INFO] 7 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.294 s
[INFO] Finished at: 2022-03-04T13:43:28+02:00
[INFO] ------------------------------------------------------------------------
...

Java version

% java -version
openjdk version "17.0.2" 2022-01-18
OpenJDK Runtime Environment (build 17.0.2+8-86)
OpenJDK 64-Bit Server VM (build 17.0.2+8-86, mixed mode, sharing)

Maven version

% mvn --version
Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537)
Maven home: /usr/local/Cellar/maven/3.8.4/libexec
Java version: 17.0.2, vendor: Homebrew, runtime: /usr/local/Cellar/openjdk/17.0.2/libexec/openjdk.jdk/Contents/Home
Default locale: en_FI, platform encoding: UTF-8
OS name: "mac os x", version: "12.2.1", arch: "x86_64", family: "mac"
openapi-generator version

5.4.0. Same thing happens with 5.3.1, after you enable compiler to generate JDK 1.8 code.

OpenAPI declaration file content or url
Generation Details
Steps to reproduce
Related issues/PRs
Suggest a fix

Include this in generated pom.xml

    <dependency>
      <groupId>javax.annotation</groupId>
      <artifactId>javax.annotation-api</artifactId>
      <version>1.3.2</version>
    </dependency>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions