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

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -