This is a odd Java reflection issue, that happens because of type erasure:
<P, R> void printIt(Function<P, R> function) {
inner(function);
}
private void inner(Object function) {
for (Method method : function.getClass().getDeclaredMethods()) {
System.out.println(method);
}
}
@Test
public void testAnyHandler() {
printIt((String a) -> "Hello");
}
the result is:
public java.lang.Object com.dariodario.sqlsmile.QueryTest$$Lambda$1/1607460018.apply(java.lang.Object)
which is really a shame... Is there any way to keep the parameters?
Aucun commentaire:
Enregistrer un commentaire