0

I am unable to build JPA2 projects after upgrading my JDK to 11 and getting errors, cannot find symbol. I checked and the package names have changed in 11. So, for instance:

Generated is no longer in:

javax.annotation

Now, it is in:

javax.annotation.processing

I have upgraded to the latest version of hibernate jpamodelgen (5.4.6.Final) and the latest version of the maven-processor-plugin (3.3.3).

However, it seems they do not yet support JDK11. Is that accurate?

Stefan Zobel
  • 3,182
  • 7
  • 28
  • 38
Walter
  • 1,290
  • 2
  • 21
  • 46
  • I don't know anything about JPA but if javax.annotation.Generated is not found then it suggests your class path is the missing the JSR-250 common annotations. Java SE did define a subset of that Java EE defined API prior to Java SE 11 but it has been removed (it was deprecated-for-removal since 9). Existing code that relied on the JDK providing these annotations needs to download the standalone version of the so-called "Common Annotations" and put it on the class path. – Alan Bateman Oct 03 '19 at 12:31
  • That is not the problem, the problem is that the generated source is referring to a < JDK11 version. The package name changed in JDK11, but remained the same up to JDK10. Hence, I think the answer is, I need to contact RedHat/JBoss/Hibernate and confirm the issue with them. I figured this would have more visibility and I would think someone would have run into this issue earlier. I will move forward with using JDK10 begrudgingly for the time being, but I do want to move to JDK13 shortly ... – Walter Oct 04 '19 at 01:32
  • From a distance, it might look like the annotation moved but this isn't so. `javax.annotation.processing.Generated` was added in Java SE 9 to make it easier for tools/code that generate or consume the `@Generated` annotation but do not need any other of the JSR-250 and Java EE defined annotations in the `javax.annotation` package. When the JSR-250 annotations are deployed on the class path you will have both annotations. Cashing this up in the Hibernate issue tracker seems right. – Alan Bateman Oct 04 '19 at 06:51
  • Ok, so you're right, here is a link to both: https://docs.oracle.com/javase/9/docs/api/javax/annotation/Generated.html and https://docs.oracle.com/javase/9/docs/api/javax/annotation/processing/Generated.html, so then it really is that Hibernate's JPA2 ModelGen does not support JDK9 even technically, it just happens to work since that is all it is being used for (a marker) from what I can tell. – Walter Oct 04 '19 at 11:07

1 Answers1

0

I switched to JDK10 and that has resolved my build problem with JPA model gen. In the meantime, I am filing a bug report with Hibernate.

Note, that I had to depend on jsr250:

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

I added this to a profile which is only activated for JPA2 projects along with performing the JPA2 modelgen plugin stuff.

Link to bug report: https://hibernate.atlassian.net/browse/HBX-1869

Walter
  • 1,290
  • 2
  • 21
  • 46