test/tools/javac/lambda/MethodReference44.java

changeset 2000
4a6acc42c3a1
parent 1415
01c9d4161882
child 2015
a4b9a8859e58
     1.1 --- a/test/tools/javac/lambda/MethodReference44.java	Fri Aug 30 17:36:47 2013 -0700
     1.2 +++ b/test/tools/javac/lambda/MethodReference44.java	Mon Sep 02 22:38:36 2013 +0100
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -26,18 +26,10 @@
    1.11   * @bug 8003280
    1.12   * @summary Add lambda tests
    1.13   *  check that generic method reference is inferred when type parameters are omitted
    1.14 - * @run main MethodReference44
    1.15 + * @compile/fail/ref=MethodReference44.out -XDrawDiagnostics MethodReference44.java
    1.16   */
    1.17  public class MethodReference44 {
    1.18  
    1.19 -    static int assertionCount = 0;
    1.20 -
    1.21 -    static void assertTrue(boolean cond) {
    1.22 -        assertionCount++;
    1.23 -        if (!cond)
    1.24 -            throw new AssertionError();
    1.25 -    }
    1.26 -
    1.27      static class SuperFoo<X> { }
    1.28  
    1.29      static class Foo<X extends Number> extends SuperFoo<X> { }
    1.30 @@ -56,12 +48,20 @@
    1.31  
    1.32      static <X extends Number> Foo<X> m() { return null; }
    1.33  
    1.34 -    static void g(SAM1 s) { assertTrue(false); }
    1.35 -    static void g(SAM2 s) { assertTrue(true); }
    1.36 -    static void g(SAM3 s) { assertTrue(false); }
    1.37 +    static void g1(SAM1 s) { }
    1.38 +
    1.39 +    static void g2(SAM2 s) { }
    1.40 +
    1.41 +    static void g3(SAM3 s) { }
    1.42 +
    1.43 +    static void g4(SAM1 s) { }
    1.44 +    static void g4(SAM2 s) { }
    1.45 +    static void g4(SAM3 s) { }
    1.46  
    1.47      public static void main(String[] args) {
    1.48 -        g(MethodReference44::m);
    1.49 -        assertTrue(assertionCount == 1);
    1.50 +        g1(MethodReference44::m);
    1.51 +        g2(MethodReference44::m);
    1.52 +        g3(MethodReference44::m);
    1.53 +        g4(MethodReference44::m);
    1.54      }
    1.55  }

mercurial