1 /*
   2  * Copyright (c) 2018, 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 package java.lang.compiler;
  26 
  27 import java.lang.annotation.*;
  28 
  29 /**
  30  * Indicates an <i>intrinsic candidate</i>: a method whose invocation may be <i>intrinsified</i> by the compiler in a
  31  * behaviorally-compatible way. Intrinsification generally involves the compiler recognizing when constant arguments
  32  * are passed to a passed to a variable-arity method, where the overhead of boxing is significant. In some cases,
  33  * the compiler can fold the entire invocation into a constant at compile time. In other cases, the compiler can generate
  34  * bytecode that invokes a specialized method (based on the constant arguments or based on the types of all arguments)
  35  * at run time.
  36  * <p>
  37  * The compiler is free to optimize a given invocation in source code differently in each
  38  * compilation, and to optimize adjacent invocations of the same intrinsic candidate in source code in different ways.
  39  * <p>
  40  * This annotation may only be applied to {@code public} methods in classes of the {@code java.base} module.
  41  * Applying it to other methods is not an error, but has no effect.
  42  *
  43  * @apiNote
  44  * This type's retention policy ensures that annotations of this type are not available through the reflection API.
  45  * This prevents clients from identifying intrinsic candidates and thus prevents assumptions about the treatment of
  46  * intrinsic candidates by a Java compiler. Being an intrinsic candidate is never part of a method's specification.
  47  */
  48 @Retention(RetentionPolicy.CLASS)
  49 @Target({ ElementType.METHOD })
  50 public @interface IntrinsicCandidate {
  51 }