java.lang.VerifyError from compile-time enhanced @Entity

Description

Add this to the https://github.com/spring-projects/spring-petclinic:

If you also change the parent pom version to spring boot 2.2.0.M4 you will get Hibernate 5.4. I also tried with 5.4.3.Final by manually setting hibernate.version. In all cases you get a java.lang.VerifyError at runtime (e.g. tests all fail). Example:

I found I can "fix" it by removing the <enableAssociationManagement>true</enableAssociationManagement>, so I guess that's a workaround.

Environment

Linux, Java 8 (and 11).

Activity

Show:
David Syer
July 26, 2019, 7:29 AM

Confused. Are you saying it works for you? Because it definitely doesn’t work for me. Sorry for the confusion, but the error isn’t on compilation. You actually have to run some code. E.g. something really simple like this (or any of the existing tests):

It will fail with the verify error (unless you explicily switch off bytecode verification in your JVM).

David Syer
July 26, 2019, 2:55 PM

…and it doesn’t fail if you use runtime proxies for the entities. So in that case it knows how to deal with the `Visit.petId` field being of type int. Shouldn’t it work the same for compile time enhancement?

Erik-Berndt Scheper
August 22, 2019, 1:40 PM

I’ve stumbled upon this issue when I tried to convert the Spring PetClinic to a Quarkus application. I’ve reported it there as .

I’ve been able to work around the issue by changing Vet like so:

And changing Pet like so:

Maybe this helps anyone who accidentally hits the same bug.

Maxim Yesman
September 6, 2019, 6:46 AM
Edited

Faced same issue, reproduced only in tests

Sanne Grinovero
October 26, 2019, 5:32 PM

Thanks for both reproducers! I’ve used them to verify Luis’s fix, looks all good.

 

N.B. for Spring Petclinic to fail I had to dig up an older version.

Assignee

Luis Barreiro

Reporter

David Syer

Fix versions

Labels

None

backPortable

Backport?

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Affects versions

Priority

Major
Configure