langtools/test/tools/javac/T8023112/SkipLazyConstantCreationForMethodRefTest.java
author alundblad
Wed, 26 Aug 2015 09:02:02 +0200
changeset 32337 c9d3ab9f601c
parent 19656 7f0afbdbf142
permissions -rw-r--r--
8133671: langtools tests have bad license Summary: Dropped classpath exception from copyright notice in tests. Reviewed-by: jjg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
19656
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
     1
/*
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
     2
 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
     4
 *
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
32337
c9d3ab9f601c 8133671: langtools tests have bad license
alundblad
parents: 19656
diff changeset
     7
 * published by the Free Software Foundation.
19656
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
     8
 *
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
    13
 * accompanied this code).
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
    14
 *
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
    18
 *
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
    21
 * questions.
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
    22
 */
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
    23
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
    24
/*
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
    25
 * @test
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
    26
 * @bug 8023112
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
    27
 * @summary Mixing up the method type argument with the class type for method
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
    28
 *          reference ClassType<Q>::<T>new
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
    29
 * @compile SkipLazyConstantCreationForMethodRefTest.java
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
    30
 */
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
    31
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
    32
public class SkipLazyConstantCreationForMethodRefTest<T> {
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
    33
    SkipLazyConstantCreationForMethodRefTest(int a, boolean b) {}
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
    34
    SkipLazyConstantCreationForMethodRefTest() {}
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
    35
}
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
    36
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
    37
class SubClass<T> extends SkipLazyConstantCreationForMethodRefTest {
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
    38
    SubClass(int a, boolean b) {}
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
    39
}
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
    40
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
    41
interface SAM {
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
    42
    SubClass<SkipLazyConstantCreationForMethodRefTest> m(int a, boolean b);
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
    43
}
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
    44
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
    45
interface Tester1 {
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
    46
    SAM s11 = SubClass<SkipLazyConstantCreationForMethodRefTest>::<Object>new;
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
    47
    SAM s12 = (SubClass<SkipLazyConstantCreationForMethodRefTest>::<Object>new);
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
    48
    SAM s13 = (SAM)SubClass<SkipLazyConstantCreationForMethodRefTest>::<Object>new;
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
    49
    SAM s14 = true ? s11 : s12;
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
    50
    SAM s15 = true ? s11 : (SAM)SubClass<SkipLazyConstantCreationForMethodRefTest>::<Object>new;
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
    51
    SAM s16 = true ? (SAM)SubClass<SkipLazyConstantCreationForMethodRefTest>::<Object>new : s12;
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
    52
}
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
    53
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
    54
interface Tester2 {
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
    55
    SAM s21 = Tester1.s11;
7f0afbdbf142 8023112: javac should not use lazy constant evaluation approach for method references
vromero
parents:
diff changeset
    56
}