langtools/test/tools/javac/lambda/MethodReference51.java
author vromero
Wed, 23 Jan 2013 20:57:40 +0000
changeset 15384 5a8d00abf076
parent 14547 86d8d242b0c4
child 21718 74a5882faf79
permissions -rw-r--r--
8006694: temporarily workaround combo tests are causing time out in several platforms Reviewed-by: jjg Contributed-by: maurizio.cimadamore@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14547
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
     1
/*
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
     2
 * @test /nodynamiccopyright/
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
     3
 * @bug 8003280
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
     4
 * @summary Add lambda tests
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
     5
 *  certain cases of erroneous member reference lookup are not handled by Attr.visitReference
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
     6
 * @compile/fail/ref=MethodReference51.out -XDrawDiagnostics MethodReference51.java
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
     7
 */
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
     8
class MethodReference51 {
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
     9
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    10
    private static class Foo {
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    11
        static int j(int i) { return i; }
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    12
    }
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    13
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    14
    static Foo foo = new Foo();
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    15
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    16
    static void m(String s) { }
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    17
    static void m(Integer i) { }
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    18
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    19
    static int f(String s) { return 1; }
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    20
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    21
    static int g(Integer i, Number n) { return 1; }
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    22
    static int g(Number n, Integer i) { return 1; }
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    23
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    24
    int h(int i) { return i; }
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    25
}
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    26
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    27
class TestMethodReference51 {
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    28
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    29
    interface IntSam {
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    30
        int m(int i);
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    31
    }
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    32
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    33
    interface IntegerIntegerSam {
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    34
        int m(Integer i1, Integer i2);
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    35
    }
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    36
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    37
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    38
    static void test() {
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    39
        IntSam s1 = MethodReference51::unknown; //method not found
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    40
        IntSam s2 = MethodReference51::f; //inapplicable method
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    41
        IntSam s3 = MethodReference51::g; //inapplicable methods
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    42
        IntegerIntegerSam s4 = MethodReference51::g; //ambiguous
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    43
        IntSam s5 = MethodReference51::h; //static error
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    44
        IntSam s6 = MethodReference51.foo::j; //inaccessible method
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    45
    }
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    46
}