forEach broken in build 48?
bitter_fox
bitterfoxc at gmail.com
Wed Jul 25 19:53:55 PDT 2012
Hi, Arul and Mike
I guess Revision(langtools):1430[1] has a problem.
In LambdaTranslator#makeFunctionalDescriptorType:
return erased ? types.erasure(descType) : descType;
This is wrong I think.
I tried this one and the problem looks resolved:
return erased ? descType : types.erasure(descType);
Please ignore this mail if you already notice that.
[1]:http://mail.openjdk.java.net/pipermail/lambda-dev/2012-July/005187.html
Regards,
bitter_fox
2012/7/26 Mike Duigou <mike.duigou at oracle.com>
> I've looked into the problem and am able to replicate it. I did some
> debugging and it appears to be a problem in the VM. I am notifying those
> working on this area.
>
> Mike
>
>
> On Jul 21 2012, at 01:39 , Arul Dhesiaseelan wrote:
>
> > Hi,
> >
> > It looks like forEach is broke in the latest build. It always prints the
> > last item in the collection. It works fine in b45. It works in b48 only
> if
> > we expand the code, not if we perform method reference on an instance.
> >
> > public class InstanceMethodReference {
> >
> > public static void main(String[] args) {
> > Arrays.asList("Alice", "Bob", "Charlie",
> > "Dave").forEach(System.out::println);//INCORRECT RESULT
> > Arrays.asList("Alice", "Bob", "Charlie", "Dave").forEach(new
> > MyBlock(System.out));//CORRECT RESULT
> > }
> >
> > public static class MyBlock implements Block<String> {
> > PrintStream ps;
> >
> > public MyBlock(PrintStream ps) {
> > this.ps = ps;
> > }
> >
> > @Override
> > public void apply(String s) {
> > ps.println(s);
> > }
> > }
> > }
> >
> > build45 correctly prints:
> > Alice
> > Bob
> > Charlie
> > Dave
> > Alice
> > Bob
> > Charlie
> > Dave
> >
> > build48 prints:
> > Dave
> > Dave
> > Dave
> > Dave
> > Alice
> > Bob
> > Charlie
> > Dave
> >
> >
> > -Arul
> >
>
>
>
More information about the lambda-dev
mailing list