spring-projects / spring-projects/spring-data-commons
Provide better handling of incompatible visibilities between domain type and repository
@mp911de is already working on this.
Since Nov 27, 2023.
- Dominant language
- Java
- Stars
- 838
- Forks
- 730
- PR merge metrics
- No merged PRs in 30d
Description
Related to #2526
Given a package-private entity
@Entity
class Book {
@Id
private String isbn;
// no-args-constructor, getter, setter etc.
}
and a public repository with a custom findBy method
public interface BookRepository extends CrudRepository<Book, String> {
Book findByIsbn(String isbn);
}
then the invocation of the findBy method fails with an error message that is more cryptic than helpful:
java.lang.IllegalAccessError: failed to access class org.example.Book from class jdk.proxy2.$Proxy105 (org.example.Book is in unnamed module of loader 'app'; jdk.proxy2.$Proxy105 is in module jdk.proxy2 of loader 'app')
The cause comes from the different visibilities. If the entity is public or the repository is package-private, it works.
I would expect this construct to work out of the box, because if the repository is package-private, it works again. Or provide a helpful error message at startup indicating the incompatible visibilities.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.