What is the type of a "method reference"?
Behrooz Nobakht
nobeh5 at gmail.com
Wed Jun 12 01:35:40 PDT 2013
Thanks for the reply. Just a follow-up question regarding the fact that
method references *do not* have a type:
When a Java 8 method reference is compiled, what is it translated to? Is
there any specific place in the source of Java 8 I can look up to study
this particular question in more details?
On Wed, Jun 12, 2013 at 10:22 AM, Florian Weimer <fweimer at redhat.com> wrote:
> On 06/11/2013 11:50 PM, Behrooz Nobakht wrote:
>
>> My question is that how should the method doAnotherThing be declared?
>>
>
> In most cases, it is appropriate to define an interface with a single
> method and use it as a parameter type.
>
>
> Studying the source code of Java 8, I found out that before Java 8 version
>> b75, there was an abstraction java.util.function.Block which was removed
>> from further revisions.
>>
>
> There is java.util.function.Function, but it's probably most useful in
> abstract contexts where no reasonably named concrete type is available.
>
> On the question in the subject, method references do not have a type.
>
> --
> Florian Weimer / Red Hat Product Security Team
>
--
-- Behrooz Nobakht
More information about the jdk8-dev
mailing list