jdk/src/share/classes/java/lang/FunctionalInterface.java
author darcy
Tue, 08 Jan 2013 16:08:29 -0800
changeset 15012 8fa5871c30c6
child 15304 6ea4b4f728b7
permissions -rw-r--r--
8005298: Add FunctionalInterface type to the core libraries Reviewed-by: mduigou
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15012
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
     1
/*
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
     2
 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
     4
 *
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    10
 *
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    15
 * accompanied this code).
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    16
 *
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    20
 *
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    23
 * questions.
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    24
 */
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    25
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    26
package java.lang;
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    27
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    28
import java.lang.annotation.*;
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    29
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    30
/**
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    31
 * Indicates that an interface type declaration is intended to be a
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    32
 * <i>functional interface</i> as defined by the Java Language
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    33
 * Specification.
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    34
 *
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    35
 * Conceptually, a functional interface has exactly one abstract
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    36
 * method.  Since {@linkplain java.lang.reflect.Method#isDefault()
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    37
 * default methods} have an implementation, they are not abstract.  If
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    38
 * an interface declares an abstract method overriding one of the
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    39
 * public methods of {@code java.lang.Object}, that also does
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    40
 * <em>not</em> count toward the interface's abstract method count
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    41
 * since any implementation of the interface will have an
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    42
 * implementation from {@code java.lang.Object} or elsewhere.
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    43
 *
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    44
 * <p>Note that instances of functional interfaces can be created with
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    45
 * lambda expressions, method references, or constructor references.
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    46
 *
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    47
 * <p>If a type is annotated with this annotation type, compilers are
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    48
 * required to generate an error message unless:
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    49
 *
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    50
 * <ul>
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    51
 * <li> The type is an interface type and not an annotation type, enum, or class.
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    52
 * <li> The annotated type satisfies the requirements of a functional interface.
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    53
 * </ul>
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    54
 *
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    55
 * @jls 4.3.2. The Class Object
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    56
 * @jls 9.8 Functional Interfaces
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    57
 * @jls 9.4.3 Interface Method Body
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    58
 * @since 1.8
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    59
 */
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    60
@Documented
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    61
@Retention(RetentionPolicy.RUNTIME)
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    62
@Target(ElementType.TYPE)
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    63
public @interface FunctionalInterface {}