Describe the bug
Under certain conditions, the fieldgenerator accepts private getters and generates code that won't compile.
Expected behavior
If the getter is private the fieldgenerator should issue a warning at runtime and generate a reference getter that throws an exception.
The field films has a private getter:
@Getter(value = AccessLevel.PRIVATE)
@ManyToMany(mappedBy = "actors")
private List<Film> films = new ArrayList<>();
Should generate (whether this is an optimal solution is up for discussion but this is the way it is designed to work at this point) :
/**
* This Field corresponds to the {@link Actor} field "films".
*/
public static final ReferenceField<Actor, List<Film>> films = ReferenceField.create(
Actor.class,
"films",
actor -> {throw new IllegalJavaBeanException(Actor.class, "films");},
false
);
Actual behavior
The generated ReferenceField references Actor::getFilms which is unavailable to the compiler of that class:
/**
* This Field corresponds to the {@link Actor} field "films".
*/
public static final ReferenceField<Actor, List<Film>> films = ReferenceField.create(
Actor.class,
"films",
Actor::getFilms,
false
);
How To Reproduce
Build the fieldgenerator-testmodule with IntelliJ (error does not occur when building with Maven).
I think the difference arises because the accessors Lombok generates are available at build time with IntelliJ and are erroneously detected as standard getters.
Describe the bug Under certain conditions, the fieldgenerator accepts private getters and generates code that won't compile.
Expected behavior If the getter is private the fieldgenerator should issue a warning at runtime and generate a reference getter that throws an exception.
The field films has a private getter:
Should generate (whether this is an optimal solution is up for discussion but this is the way it is designed to work at this point) :
Actual behavior The generated
ReferenceField
referencesActor::getFilms
which is unavailable to the compiler of that class:How To Reproduce Build the
fieldgenerator-test
module with IntelliJ (error does not occur when building with Maven).Build tool IntelliJ
JPAStreamer version 3.0.2
JPA Provider Hibernate 6.0.2.Final
Java Version 11.0.27