1 /*
2 * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package jdk.incubator.code;
27
28 import java.lang.annotation.*;
29 import java.lang.reflect.Method;
30
31 /**
32 * A program element annotated with this annotation enables code reflection in the annotated program element,
33 * or in one or more program elements contained within the annotated program element.
34 * <p>
35 * The program elements for which code reflection is enabled are said to be a <em>reflectable</em> program elements.
36 * There are three kinds of reflectable program elements: methods, lambda expressions and method references.
37 * Code models for reflectable methods can be obtained using the {@link Op#ofMethod(Method)} method. Code
38 * models for reflectable lambdas and method references can be obtained using the {@link Op#ofQuotable(Object)} method.
39 * <p>
40 * This annotation only has effect on the program elements listed below:
41 * <li>When a method is annotated with this annotation, the method becomes reflectable, and all the lambda expressions
42 * and method references enclosed in it also become reflectable.</li>
43 * <li>When a variable declaration (a field, or a local variable) is annotated with this annotation, all lambda expressions
44 * and method references enclosed in the variable initializer (if present) also become reflectable.</li>
45 * <li>When the type of a cast expression is annotated with this annotation, the lambda expression
46 * or method reference the cast refers to (if any) becomes reflectable.</li>
47 * </ul>
48 */
49 @Target({ElementType.LOCAL_VARIABLE, ElementType.FIELD,
50 ElementType.METHOD, ElementType.TYPE_USE})
51 @Retention(RetentionPolicy.RUNTIME)
52 public @interface Reflect {
53 }