procyon icon indicating copy to clipboard operation
procyon copied to clipboard

ClassCastException when reflecting a type that has generic constructors

Open AjaxGb opened this issue 3 years ago • 0 comments

Source seems to be this code here: https://github.com/mstrobel/procyon/blob/master/Procyon.Reflection/src/main/java/com/strobel/reflection/Resolver.java#L331-L350

It assumes that the only sources of generic declarations are 1) methods and 2) classes, but misses 3) constructors.

Minimal reproduction case:

static class Foo {
	public int bar;
	
	public <T> Foo(List<T> b) { }
}

public static void main(final String[] args) {
	Type.of(Foo.class).getField("bar");
}

AjaxGb avatar Jul 20 '21 22:07 AjaxGb