java - How to get return type of constructor lambda -


i wondering if possible return type of supplier assigned constructor.

e.g.

supplier<foo> sfoo = foo::new; 

how "foo.class" supplier? have been using typetools solve problem other things.

this works, example:

supplier<foo> sfoo = () -> new foo(); class<?> fooclasss = net.jodah.typetools.typeresolver.resolverawarguments(supplier.class, sfoo.getclass())[0]; // fooclass == foo.class 

but if assign supplier like: supplier<foo> sfoo = foo::new, return type cannot resolved...

any thoughts? don't have use typetools btw...

seems parsing method references not supported typetools. there's open issue similar problem.

in general such feature quite fragile runtime lambda representation not specified , implementation dependent. may break 1 day. if need class suggest passing actual class<?> argument.


Comments

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -