langtools/test/tools/javac/lambda/8023558/T8023558a.java
author vromero
Sun, 22 Sep 2013 12:53:03 +0100
changeset 20245 c351f524fbc6
parent 19939 ab90fbc7b74e
permissions -rw-r--r--
8024696: Missing null check in bound method reference capture Reviewed-by: jjg, briangoetz
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
19939
ab90fbc7b74e 8023558: Javac creates invalid bootstrap methods for complex lambda/methodref case
vromero
parents:
diff changeset
     1
/*
ab90fbc7b74e 8023558: Javac creates invalid bootstrap methods for complex lambda/methodref case
vromero
parents:
diff changeset
     2
 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
ab90fbc7b74e 8023558: Javac creates invalid bootstrap methods for complex lambda/methodref case
vromero
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ab90fbc7b74e 8023558: Javac creates invalid bootstrap methods for complex lambda/methodref case
vromero
parents:
diff changeset
     4
 *
ab90fbc7b74e 8023558: Javac creates invalid bootstrap methods for complex lambda/methodref case
vromero
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
ab90fbc7b74e 8023558: Javac creates invalid bootstrap methods for complex lambda/methodref case
vromero
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
ab90fbc7b74e 8023558: Javac creates invalid bootstrap methods for complex lambda/methodref case
vromero
parents:
diff changeset
     7
 * published by the Free Software Foundation.
ab90fbc7b74e 8023558: Javac creates invalid bootstrap methods for complex lambda/methodref case
vromero
parents:
diff changeset
     8
 *
ab90fbc7b74e 8023558: Javac creates invalid bootstrap methods for complex lambda/methodref case
vromero
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
ab90fbc7b74e 8023558: Javac creates invalid bootstrap methods for complex lambda/methodref case
vromero
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ab90fbc7b74e 8023558: Javac creates invalid bootstrap methods for complex lambda/methodref case
vromero
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
ab90fbc7b74e 8023558: Javac creates invalid bootstrap methods for complex lambda/methodref case
vromero
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
ab90fbc7b74e 8023558: Javac creates invalid bootstrap methods for complex lambda/methodref case
vromero
parents:
diff changeset
    13
 * accompanied this code).
ab90fbc7b74e 8023558: Javac creates invalid bootstrap methods for complex lambda/methodref case
vromero
parents:
diff changeset
    14
 *
ab90fbc7b74e 8023558: Javac creates invalid bootstrap methods for complex lambda/methodref case
vromero
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
ab90fbc7b74e 8023558: Javac creates invalid bootstrap methods for complex lambda/methodref case
vromero
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
ab90fbc7b74e 8023558: Javac creates invalid bootstrap methods for complex lambda/methodref case
vromero
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ab90fbc7b74e 8023558: Javac creates invalid bootstrap methods for complex lambda/methodref case
vromero
parents:
diff changeset
    18
 *
ab90fbc7b74e 8023558: Javac creates invalid bootstrap methods for complex lambda/methodref case
vromero
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ab90fbc7b74e 8023558: Javac creates invalid bootstrap methods for complex lambda/methodref case
vromero
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
ab90fbc7b74e 8023558: Javac creates invalid bootstrap methods for complex lambda/methodref case
vromero
parents:
diff changeset
    21
 * questions.
ab90fbc7b74e 8023558: Javac creates invalid bootstrap methods for complex lambda/methodref case
vromero
parents:
diff changeset
    22
 */
ab90fbc7b74e 8023558: Javac creates invalid bootstrap methods for complex lambda/methodref case
vromero
parents:
diff changeset
    23
ab90fbc7b74e 8023558: Javac creates invalid bootstrap methods for complex lambda/methodref case
vromero
parents:
diff changeset
    24
/*
ab90fbc7b74e 8023558: Javac creates invalid bootstrap methods for complex lambda/methodref case
vromero
parents:
diff changeset
    25
 * @test
ab90fbc7b74e 8023558: Javac creates invalid bootstrap methods for complex lambda/methodref case
vromero
parents:
diff changeset
    26
 * @bug 8023558
ab90fbc7b74e 8023558: Javac creates invalid bootstrap methods for complex lambda/methodref case
vromero
parents:
diff changeset
    27
 * @summary Javac creates invalid bootstrap methods for complex lambda/methodref case
ab90fbc7b74e 8023558: Javac creates invalid bootstrap methods for complex lambda/methodref case
vromero
parents:
diff changeset
    28
 */
ab90fbc7b74e 8023558: Javac creates invalid bootstrap methods for complex lambda/methodref case
vromero
parents:
diff changeset
    29
public class T8023558a {
ab90fbc7b74e 8023558: Javac creates invalid bootstrap methods for complex lambda/methodref case
vromero
parents:
diff changeset
    30
    interface SAM<T> {
ab90fbc7b74e 8023558: Javac creates invalid bootstrap methods for complex lambda/methodref case
vromero
parents:
diff changeset
    31
        T get();
ab90fbc7b74e 8023558: Javac creates invalid bootstrap methods for complex lambda/methodref case
vromero
parents:
diff changeset
    32
    }
ab90fbc7b74e 8023558: Javac creates invalid bootstrap methods for complex lambda/methodref case
vromero
parents:
diff changeset
    33
20245
c351f524fbc6 8024696: Missing null check in bound method reference capture
vromero
parents: 19939
diff changeset
    34
    static class K<T> implements SAM<T> {
c351f524fbc6 8024696: Missing null check in bound method reference capture
vromero
parents: 19939
diff changeset
    35
        public T get() {
c351f524fbc6 8024696: Missing null check in bound method reference capture
vromero
parents: 19939
diff changeset
    36
            return (T)this;
c351f524fbc6 8024696: Missing null check in bound method reference capture
vromero
parents: 19939
diff changeset
    37
        }
c351f524fbc6 8024696: Missing null check in bound method reference capture
vromero
parents: 19939
diff changeset
    38
    }
c351f524fbc6 8024696: Missing null check in bound method reference capture
vromero
parents: 19939
diff changeset
    39
19939
ab90fbc7b74e 8023558: Javac creates invalid bootstrap methods for complex lambda/methodref case
vromero
parents:
diff changeset
    40
    public static void main(String[] args) {
20245
c351f524fbc6 8024696: Missing null check in bound method reference capture
vromero
parents: 19939
diff changeset
    41
        SAM<SAM> sam = new SAM<SAM>() { public SAM get() { return new K<>(); } };
19939
ab90fbc7b74e 8023558: Javac creates invalid bootstrap methods for complex lambda/methodref case
vromero
parents:
diff changeset
    42
        SAM temp = sam.get()::get;
ab90fbc7b74e 8023558: Javac creates invalid bootstrap methods for complex lambda/methodref case
vromero
parents:
diff changeset
    43
    }
ab90fbc7b74e 8023558: Javac creates invalid bootstrap methods for complex lambda/methodref case
vromero
parents:
diff changeset
    44
}