TL; DR; JDBI annotations are @BindBeangenerated by IllegalAccessExceptiongenerated AutoValue types because the generated types are private and are not available by default using reflection.
Is JDBI inflexible or is there a workaround through AutoValue? (Full question below)
Fast background
I am trying to use a JDBI annotation @BindBeanwith a type whose source is generated using AutoValue.
package com.example;
@AutoValue
public abstract class Foo {
public String getBar();
}
The problem is that the generated code looks like this:
package com.example;
@AutoValue
class AutoValue_Foo extends Foo {
private final String bar;
@Override
public String getBar() {
return this.bar;
}
}
Please note that the class is closed to the package!
Now, if I try to use @BindBean, for example:
@SqlQuery("select * from baz where bar = :foo.bar")
Condition find(@BindBean("foo") Foo foo);
AutoValue_Foo , BindBeanFactory , find AutoValue_Foo, :
java.lang.IllegalAccessException: ... can not access a member of class com.example.Foo with modifiers "public"
JDBI . Java, setAccessible(true), PR JDBI.
, :
, Foo AutoValue_Foo @BindBean JDBI ?
@AutoValue , public. , ( , , ).
BindBeanFactory ? setAccessible(true) , ?