Skip to content
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

Unable to generate random values to record type #514

Open
garcia-jj opened this issue Apr 16, 2024 · 1 comment
Open

Unable to generate random values to record type #514

garcia-jj opened this issue Apr 16, 2024 · 1 comment

Comments

@garcia-jj
Copy link

garcia-jj commented Apr 16, 2024

I'm trying to use records with easy-random 5.0.0, but I was unable to run properly, as you can see in the following code.

public record MyRecord(Long b, String a) {

}

And the runner is

final var testing = new EasyRandom().nextObject(MyRecord.class);

And I got this error:

org.jeasy.random.ObjectCreationException: Unable to create a random instance of type class foo.bar.MyRecord


Caused by: java.lang.IllegalAccessException: Can not set final java.lang.Long field foo.bar.MyRecord.a to java.lang.Long
	at java.base/jdk.internal.reflect.UnsafeFieldAccessorImpl.throwFinalFieldIllegalAccessException(UnsafeFieldAccessorImpl.java:76)
	at java.base/jdk.internal.reflect.UnsafeFieldAccessorImpl.throwFinalFieldIllegalAccessException(UnsafeFieldAccessorImpl.java:80)
	at java.base/jdk.internal.reflect.UnsafeQualifiedObjectFieldAccessorImpl.set(UnsafeQualifiedObjectFieldAccessorImpl.java:79)

My Java version

java version "17.0.10" 2024-01-16 LTS
Java(TM) SE Runtime Environment (build 17.0.10+11-LTS-240)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.10+11-LTS-240, mixed mode, sharing)

Thank U

@pcuriel
Copy link

pcuriel commented Apr 26, 2024

Hi! This is not a bug, but a feature that's being implemented:
#397

This project is in maintaince mode, so sadly I think there is no estimation of when the feature will be finally released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants