Runtime problem with method references

Sam Pullara spullara at gmail.com
Tue Mar 26 23:38:05 PDT 2013


When he says latest build I think he means build it from the source. The website isn't updated that often I think.

Sam

On Mar 26, 2013, at 11:27 PM, Howard Lovatt <howard.lovatt at gmail.com> wrote:

> Thanks. I will try the latest build, but the java.net download site seems
> to be down at the moment (reporting a 20 h download time for the JDK dmg as
> I write).
> 
> 
> On 27 March 2013 15:44, Brian Goetz <brian.goetz at oracle.com> wrote:
> 
>> I believe this is already fixed; have you tried with a more recent build?
>> 
>> On Mar 26, 2013, at 8:15 PM, Howard Lovatt wrote:
>> 
>>> Hi,
>>> 
>>> On my Mac running:
>>> 
>>> openjdk version "1.8.0-ea"
>>> OpenJDK Runtime Environment (build
>>> 1.8.0-ea-lambda-nightly-h3500-20130225-b79-b00)
>>> OpenJDK 64-Bit Server VM (build 25.0-b19, mixed mode)
>>> 
>>> The following gives the runtime error below.
>>> 
>>> /**
>>> * Bug in method references, doesn't work at runtime. Relevant part of
>>> error message is:
>>> * <pre>
>>> * Caused by: java.lang.IllegalAccessException: member is private:
>>> rhjod.stream.BugInMethodReferences.twice(double)double/invokeStatic, from
>>> rhjod.stream.BugInMethodReferences$Calls$2
>>> * at java.lang.invoke.MemberName.makeAccessException(MemberName.java:732)
>>> * at
>>> 
>> java.lang.invoke.MethodHandles$Lookup.checkAccess(MethodHandles.java:1135)
>>> * at
>>> 
>> java.lang.invoke.MethodHandles$Lookup.checkMethod(MethodHandles.java:1098)
>>> * at
>>> 
>> java.lang.invoke.MethodHandles$Lookup.getDirectMethodCommon(MethodHandles.java:1209)
>>> * at
>>> 
>> java.lang.invoke.MethodHandles$Lookup.getDirectMethod(MethodHandles.java:1199)
>>> * at
>>> 
>> java.lang.invoke.MethodHandles$Lookup.linkMethodHandleConstant(MethodHandles.java:1265)
>>> * </pre>
>>> *
>>> * @author Howard Lovatt
>>> */
>>> public final class BugInMethodReferences {
>>> private static double twice(final double in) { return 2 * in; }
>>> 
>>> @FunctionalInterface interface MethodDD { double call(double in); }
>>> 
>>> private static enum Calls {
>>>   Lambda {
>>>     @Override MethodDD get() { return (in) -> twice(in); }
>>>   },
>>>   Reference {
>>>     @Override MethodDD get() { return BugInMethodReferences::twice; }
>>>   };
>>>   abstract MethodDD get();
>>> }
>>> 
>>> /**
>>>  * @param notUsed the command line arguments
>>>  */
>>> public static void main(final String... notUsed) {
>>>   final double in = 42 / 2;
>>>   System.out.println(Calls.Lambda + ": " + Calls.Lambda.get().call(in));
>>> // OK
>>>   System.out.println(Calls.Reference + ": " +
>>> Calls.Reference.get().call(in)); // Crash!!!
>>> }
>>> }
>>> 
>>> 
>>> -- Howard.
>>> 
>> 
>> 
> 
> 
> -- 
>  -- Howard.
> 



More information about the lambda-dev mailing list