jdk/src/java.base/share/classes/java/lang/FunctionalInterface.java
author thartmann
Tue, 03 Nov 2015 09:42:11 +0100
changeset 33663 2cd62a4bd471
parent 29232 1e69d3a5a305
permissions -rw-r--r--
8141132: JEP 254: Compact Strings Summary: Adopt a more space-efficient internal representation for strings. Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti Contributed-by: Brent Christian <brent.christian@oracle.com>, Vivek Deshpande <vivek.r.deshpande@intel.com>, Tobias Hartmann <tobias.hartmann@oracle.com>, Charlie Hunt <charlie.hunt@oracle.com>, Vladimir Kozlov <vladimir.kozlov@oracle.com>, Roger Riggs <roger.riggs@oracle.com>, Xueming Shen <xueming.shen@oracle.com>, Aleksey Shipilev <aleksey.shipilev@oracle.com>, Sandhya Viswanathan <sandhya.viswanathan@intel.com>
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
/*
29232
1e69d3a5a305 8074126: Correct @see cross-refs to the JLS in java.lang[.annotation]
darcy
parents: 25859
diff changeset
     2
 * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
15012
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
/**
15304
6ea4b4f728b7 8006895: Clarify that FunctionalInferface is only informative
darcy
parents: 15012
diff changeset
    31
 * An informative annotation type used to indicate that an interface
6ea4b4f728b7 8006895: Clarify that FunctionalInferface is only informative
darcy
parents: 15012
diff changeset
    32
 * type declaration is intended to be a <i>functional interface</i> as
6ea4b4f728b7 8006895: Clarify that FunctionalInferface is only informative
darcy
parents: 15012
diff changeset
    33
 * defined by the Java Language Specification.
15012
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
 *
15304
6ea4b4f728b7 8006895: Clarify that FunctionalInferface is only informative
darcy
parents: 15012
diff changeset
    55
 * <p>However, the compiler will treat any interface meeting the
6ea4b4f728b7 8006895: Clarify that FunctionalInferface is only informative
darcy
parents: 15012
diff changeset
    56
 * definition of a functional interface as a functional interface
6ea4b4f728b7 8006895: Clarify that FunctionalInferface is only informative
darcy
parents: 15012
diff changeset
    57
 * regardless of whether or not a {@code FunctionalInterface}
6ea4b4f728b7 8006895: Clarify that FunctionalInferface is only informative
darcy
parents: 15012
diff changeset
    58
 * annotation is present on the interface declaration.
6ea4b4f728b7 8006895: Clarify that FunctionalInferface is only informative
darcy
parents: 15012
diff changeset
    59
 *
15012
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    60
 * @jls 4.3.2. The Class Object
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    61
 * @jls 9.8 Functional Interfaces
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    62
 * @jls 9.4.3 Interface Method Body
29232
1e69d3a5a305 8074126: Correct @see cross-refs to the JLS in java.lang[.annotation]
darcy
parents: 25859
diff changeset
    63
 * @jls 9.6.4.9 @FunctionalInterface
15012
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    64
 * @since 1.8
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    65
 */
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    66
@Documented
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    67
@Retention(RetentionPolicy.RUNTIME)
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    68
@Target(ElementType.TYPE)
8fa5871c30c6 8005298: Add FunctionalInterface type to the core libraries
darcy
parents:
diff changeset
    69
public @interface FunctionalInterface {}