langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/DefinedBy.java
author jlahoda
Wed, 27 Aug 2014 07:44:00 +0200
changeset 26266 2d24bda701dc
permissions -rw-r--r--
8056061: Mark implementations of public interfaces with an annotation Summary: Adding @DefinedBy annotation to mark methods that implement public API methods; annotating the methods; adding a coding rules analyzer to enforce all such methods are annotated. Reviewed-by: jjg, mcimadamore, jfranck Contributed-by: jan.lahoda@oracle.com, jonathan.gibbons@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
26266
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
     1
/*
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
     4
 *
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
    10
 *
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
    15
 * accompanied this code).
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
    16
 *
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
    20
 *
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
    23
 * questions.
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
    24
 */
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
    25
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
    26
package com.sun.tools.javac.util;
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
    27
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
    28
import java.lang.annotation.ElementType;
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
    29
import java.lang.annotation.Retention;
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
    30
import java.lang.annotation.RetentionPolicy;
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
    31
import java.lang.annotation.Target;
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
    32
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
    33
/**Methods that directly implement a method declared in a public, supported API should be marked
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
    34
 * with this annotation.
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
    35
 */
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
    36
@Target(ElementType.METHOD)
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
    37
@Retention(RetentionPolicy.SOURCE)
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
    38
public @interface DefinedBy {
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
    39
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
    40
    /**The API which defines the implemented method.
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
    41
     */
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
    42
    Api value();
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
    43
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
    44
    public enum Api {
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
    45
        ANNOTATION_PROCESSING("javax.annotation.processing"),
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
    46
        COMPILER("javax.tools"),
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
    47
        COMPILER_TREE("com.sun.source"),
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
    48
        LANGUAGE_MODEL("javax.lang.model");
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
    49
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
    50
        /**The package under which all interfaces/classes of this API belong.
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
    51
         */
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
    52
        public final String packageRoot;
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
    53
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
    54
        private Api(String packageRoot) {
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
    55
            this.packageRoot = packageRoot;
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
    56
        }
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
    57
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
    58
    }
2d24bda701dc 8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
diff changeset
    59
}