What is the type of a "method reference"?
Remi Forax
forax at univ-mlv.fr
Wed Jun 12 02:12:23 PDT 2013
On 06/12/2013 10:35 AM, Behrooz Nobakht wrote:
> 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?
There is this document from last year,
http://cr.openjdk.java.net/~briangoetz/lambda/lambda-translation.html
It's not fully accurate, but the first half of the doc is not too outdated.
cheers,
Rémi
>
>
>
>
> 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
>>
>
>
More information about the jdk8-dev
mailing list