Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import static net.jodah.typetools.TypeResolver.resolveRawArgument;
public class Core {
interface Handler<T> {
void process(T x);
void p1(final String s) {}
void p1(final int i) {}
<T> void register(final Handler<T> h) {
final Class<T> clazz = classForHandler(h);
private static <T> Class<T> classForHandler(final Handler<T> h1) {
return (Class<T>)resolveRawArgument(Handler.class, h1.getClass());
public static void main(final String[] args) {
final Core core = new Core();
final Handler<String> h1 = core::p1;
final Handler<Integer> h2 = core::p1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.