Open
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.