test/tools/javac/lambda/8071432/T8071432.java

changeset 2730
a513711d6171
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test/tools/javac/lambda/8071432/T8071432.java	Thu Feb 12 10:16:19 2015 +0530
     1.3 @@ -0,0 +1,50 @@
     1.4 +/*
     1.5 + * @test /nodynamiccopyright/
     1.6 + * @bug 8071432
     1.7 + * @summary structural most specific and stuckness
     1.8 + * @compile/fail/ref=T8071432.out -XDrawDiagnostics T8071432.java
     1.9 + */
    1.10 +
    1.11 +import java.util.Arrays;
    1.12 +import java.util.Collection;
    1.13 +
    1.14 +class T8071432 {
    1.15 +
    1.16 +    static class Point {
    1.17 +
    1.18 +        private double x, y;
    1.19 +
    1.20 +        public Point(double x, double y) {
    1.21 +            this.x = x;
    1.22 +            this.y = y;
    1.23 +        }
    1.24 +
    1.25 +        public double getX() {
    1.26 +            return x;
    1.27 +        }
    1.28 +
    1.29 +        public double getY() {
    1.30 +            return y;
    1.31 +        }
    1.32 +
    1.33 +        public double distance(Point p) {
    1.34 +            return Math.sqrt((this.x - p.x) * (this.x - p.x) +
    1.35 +                             (this.y - p.y) * (this.y - p.y));
    1.36 +        }
    1.37 +
    1.38 +        public double distance() {
    1.39 +            return Math.sqrt(this.x * this.x + this.y * this.y);
    1.40 +        }
    1.41 +
    1.42 +        public String toString() {
    1.43 +            return "(" + x + ":" + y + ")";
    1.44 +        }
    1.45 +    }
    1.46 +
    1.47 +    public static void main(String[] args) {
    1.48 +        Collection<Point> c = Arrays.asList(new Point(1.0, 0.1));
    1.49 +        System.out.println("------- 1 ---------------");
    1.50 +        System.out.println(c.stream().reduce(0.0,
    1.51 +                                            (s, p) -> s += p.distance(), (d1, d2) -> 0));
    1.52 +    }
    1.53 +}

mercurial