-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[-Dnative] JPA class Person in integration-tests/spring-data-jpa uses j.u.Random #16018
Comments
/cc @geoand |
Example stack trace:
|
So this seems to just be an issue with the test class. I mean the use case in the test is rather contrived anyway |
Sure if you think this is not something user applications would run into too, then yeah sure. |
Yeah, there is no need to have this sort of Random here. |
This reworks the test so that Person (an Entity class) no longer uses j.u.Random directly, but delegates generation of random data to a separate class which gets runtime-initialized. Closes quarkusio#16018
Here you are: #16020 |
This reworks the test so that Person (an Entity class) no longer uses j.u.Random directly, but delegates generation of random data to a separate class which gets runtime-initialized. Closes quarkusio#16018 (cherry picked from commit b12f825)
This reworks the test so that Person (an Entity class) no longer uses j.u.Random directly, but delegates generation of random data to a separate class which gets runtime-initialized. Closes quarkusio#16018
Describe the bug
Person class in integration-tests/spring-data-jpa uses
java.util.Random
as part of its implementation. When generating a native-image from that app, this fails with graal 21.1-dev since Random is prohibited to end up in the native image heap (randomness would become predictable otherwise). The fix would be to runtime-initialize the class, but this turns out problematic since a generated JPA class,io.quarkus.it.spring.data.jpa.PersonRepository_bcb609283abd593bd6e8ce51955e38a20ba9d528Impl_Bean
, triggers initialization of the class and would, thus, need to get runtime-initialized as well. It's not clear how this could be done since the generated class name is not predictable. I'd expect for this example to be a valid use-case and as it stands there doesn't seem to be a good solution available yet to solve this runtime initialization config problem.Expected behavior
Have some way to allow for runtime initialized JPA-generated classes.
Actual behavior
No way to configure runtime initialization of generated classes
To Reproduce
export GRAALVM_HOME=/path/to/21.1-dev/build
./mvnw verify -Dnative -Dquarkus.native.additional-build-args="--trace-class-initialization=io.quarkus.it.spring.data.jpa.Person,--initialize-at-run-time=io.quarkus.it.spring.data.jpa.Person,--trace-object-instantiation=java.util.Random" -pl integration-tests/spring-data-jpa/
Configuration
Tried with that to fix the runtime init problem, but that's insufficient.
Additional context
This fix didn't work. I guess a more elaborate, more generic fix is needed.
The text was updated successfully, but these errors were encountered: