8213234: Move LambdaForm.Hidden to jdk.internal.vm.annotation
Reviewed-by: mchung, dlong
--- a/src/hotspot/share/classfile/classFileParser.cpp Tue Jan 22 18:13:30 2019 -0800
+++ b/src/hotspot/share/classfile/classFileParser.cpp Tue Jan 22 18:13:49 2019 -0800
@@ -2120,12 +2120,7 @@
if (!privileged) break; // only allow in privileged code
return _method_LambdaForm_Compiled;
}
- case vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_invoke_LambdaForm_Hidden_signature): {
- if (_location != _in_method) break; // only allow for methods
- if (!privileged) break; // only allow in privileged code
- return _method_Hidden;
- }
- case vmSymbols::VM_SYMBOL_ENUM_NAME(java_security_AccessController_Hidden_signature): {
+ case vmSymbols::VM_SYMBOL_ENUM_NAME(jdk_internal_vm_annotation_Hidden_signature): {
if (_location != _in_method) break; // only allow for methods
if (!privileged) break; // only allow in privileged code
return _method_Hidden;
--- a/src/hotspot/share/classfile/vmSymbols.hpp Tue Jan 22 18:13:30 2019 -0800
+++ b/src/hotspot/share/classfile/vmSymbols.hpp Tue Jan 22 18:13:49 2019 -0800
@@ -278,9 +278,10 @@
\
/* Intrinsic Annotation (JDK 9 and above) */ \
template(jdk_internal_HotSpotIntrinsicCandidate_signature, "Ljdk/internal/HotSpotIntrinsicCandidate;") \
+ template(jdk_internal_vm_annotation_DontInline_signature, "Ljdk/internal/vm/annotation/DontInline;") \
template(jdk_internal_vm_annotation_ForceInline_signature, "Ljdk/internal/vm/annotation/ForceInline;") \
- template(jdk_internal_vm_annotation_DontInline_signature, "Ljdk/internal/vm/annotation/DontInline;") \
- template(jdk_internal_vm_annotation_Stable_signature, "Ljdk/internal/vm/annotation/Stable;") \
+ template(jdk_internal_vm_annotation_Hidden_signature, "Ljdk/internal/vm/annotation/Hidden;") \
+ template(jdk_internal_vm_annotation_Stable_signature, "Ljdk/internal/vm/annotation/Stable;") \
\
/* Support for JSR 292 & invokedynamic (JDK 1.7 and above) */ \
template(java_lang_invoke_CallSite, "java/lang/invoke/CallSite") \
@@ -304,9 +305,7 @@
template(java_lang_invoke_LambdaForm, "java/lang/invoke/LambdaForm") \
template(java_lang_invoke_InjectedProfile_signature, "Ljava/lang/invoke/InjectedProfile;") \
template(java_lang_invoke_LambdaForm_Compiled_signature, "Ljava/lang/invoke/LambdaForm$Compiled;") \
- template(java_lang_invoke_LambdaForm_Hidden_signature, "Ljava/lang/invoke/LambdaForm$Hidden;") \
template(java_lang_invoke_MethodHandleNatives_CallSiteContext_signature, "Ljava/lang/invoke/MethodHandleNatives$CallSiteContext;") \
- template(java_security_AccessController_Hidden_signature, "Ljava/security/AccessController$Hidden;") \
/* internal up-calls made only by the JVM, via class sun.invoke.MethodHandleNatives: */ \
template(findMethodHandleType_name, "findMethodHandleType") \
template(findMethodHandleType_signature, "(Ljava/lang/Class;[Ljava/lang/Class;)Ljava/lang/invoke/MethodType;") \
--- a/src/java.base/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java Tue Jan 22 18:13:30 2019 -0800
+++ b/src/java.base/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java Tue Jan 22 18:13:49 2019 -0800
@@ -77,6 +77,7 @@
private static final String DESCR_CTOR_NOT_SERIALIZABLE_EXCEPTION = "(Ljava/lang/String;)V";
private static final String[] SER_HOSTILE_EXCEPTIONS = new String[] {NAME_NOT_SERIALIZABLE_EXCEPTION};
+ private static final String DESCR_HIDDEN = "Ljdk/internal/vm/annotation/Hidden;";
private static final String[] EMPTY_STRING_ARRAY = new String[0];
@@ -279,7 +280,7 @@
// Forward the SAM method
MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, samMethodName,
samMethodType.toMethodDescriptorString(), null, null);
- mv.visitAnnotation("Ljava/lang/invoke/LambdaForm$Hidden;", true);
+ mv.visitAnnotation(DESCR_HIDDEN, true);
new ForwardingMethodGenerator(mv).generate(samMethodType);
// Forward the bridges
@@ -287,7 +288,7 @@
for (MethodType mt : additionalBridges) {
mv = cw.visitMethod(ACC_PUBLIC|ACC_BRIDGE, samMethodName,
mt.toMethodDescriptorString(), null, null);
- mv.visitAnnotation("Ljava/lang/invoke/LambdaForm$Hidden;", true);
+ mv.visitAnnotation(DESCR_HIDDEN, true);
new ForwardingMethodGenerator(mv).generate(mt);
}
}
--- a/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java Tue Jan 22 18:13:30 2019 -0800
+++ b/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java Tue Jan 22 18:13:49 2019 -0800
@@ -721,11 +721,11 @@
}
}
- static final String LF_HIDDEN_SIG = className("Ljava/lang/invoke/LambdaForm$Hidden;");
- static final String LF_COMPILED_SIG = className("Ljava/lang/invoke/LambdaForm$Compiled;");
- static final String FORCEINLINE_SIG = className("Ljdk/internal/vm/annotation/ForceInline;");
- static final String DONTINLINE_SIG = className("Ljdk/internal/vm/annotation/DontInline;");
- static final String INJECTEDPROFILE_SIG = className("Ljava/lang/invoke/InjectedProfile;");
+ static final String DONTINLINE_SIG = className("Ljdk/internal/vm/annotation/DontInline;");
+ static final String FORCEINLINE_SIG = className("Ljdk/internal/vm/annotation/ForceInline;");
+ static final String HIDDEN_SIG = className("Ljdk/internal/vm/annotation/Hidden;");
+ static final String INJECTEDPROFILE_SIG = className("Ljava/lang/invoke/InjectedProfile;");
+ static final String LF_COMPILED_SIG = className("Ljava/lang/invoke/LambdaForm$Compiled;");
/**
* Generate an invoker method for the passed {@link LambdaForm}.
@@ -748,7 +748,7 @@
methodPrologue();
// Suppress this method in backtraces displayed to the user.
- mv.visitAnnotation(LF_HIDDEN_SIG, true);
+ mv.visitAnnotation(HIDDEN_SIG, true);
// Mark this method as a compiled LambdaForm
mv.visitAnnotation(LF_COMPILED_SIG, true);
@@ -1752,7 +1752,7 @@
methodPrologue();
// Suppress this method in backtraces displayed to the user.
- mv.visitAnnotation(LF_HIDDEN_SIG, true);
+ mv.visitAnnotation(HIDDEN_SIG, true);
// Don't inline the interpreter entry.
mv.visitAnnotation(DONTINLINE_SIG, true);
@@ -1812,7 +1812,7 @@
methodPrologue();
// Suppress this method in backtraces displayed to the user.
- mv.visitAnnotation(LF_HIDDEN_SIG, true);
+ mv.visitAnnotation(HIDDEN_SIG, true);
// Force inlining of this invoker method.
mv.visitAnnotation(FORCEINLINE_SIG, true);
--- a/src/java.base/share/classes/java/lang/invoke/LambdaForm.java Tue Jan 22 18:13:30 2019 -0800
+++ b/src/java.base/share/classes/java/lang/invoke/LambdaForm.java Tue Jan 22 18:13:49 2019 -0800
@@ -27,6 +27,7 @@
import jdk.internal.perf.PerfCounter;
import jdk.internal.vm.annotation.DontInline;
+import jdk.internal.vm.annotation.Hidden;
import jdk.internal.vm.annotation.Stable;
import sun.invoke.util.Wrapper;
@@ -1828,15 +1829,6 @@
@interface Compiled {
}
- /**
- * Internal marker for LambdaForm interpreter frames.
- */
- /*non-public*/
- @Target(ElementType.METHOD)
- @Retention(RetentionPolicy.RUNTIME)
- @interface Hidden {
- }
-
private static final HashMap<String,Integer> DEBUG_NAME_COUNTERS;
private static final HashMap<LambdaForm,String> DEBUG_NAMES;
static {
--- a/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java Tue Jan 22 18:13:30 2019 -0800
+++ b/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java Tue Jan 22 18:13:49 2019 -0800
@@ -33,6 +33,7 @@
import jdk.internal.reflect.CallerSensitive;
import jdk.internal.reflect.Reflection;
import jdk.internal.vm.annotation.ForceInline;
+import jdk.internal.vm.annotation.Hidden;
import jdk.internal.vm.annotation.Stable;
import sun.invoke.empty.Empty;
import sun.invoke.util.ValueConversions;
@@ -681,7 +682,7 @@
return SimpleMethodHandle.make(srcType, form);
}
- @LambdaForm.Hidden
+ @Hidden
static
MethodHandle selectAlternative(boolean testResult, MethodHandle target, MethodHandle fallback) {
if (testResult) {
@@ -692,7 +693,7 @@
}
// Intrinsified by C2. Counters are used during parsing to calculate branch frequencies.
- @LambdaForm.Hidden
+ @Hidden
@jdk.internal.HotSpotIntrinsicCandidate
static
boolean profileBoolean(boolean result, int[] counters) {
@@ -708,7 +709,7 @@
}
// Intrinsified by C2. Returns true if obj is a compile-time constant.
- @LambdaForm.Hidden
+ @Hidden
@jdk.internal.HotSpotIntrinsicCandidate
static
boolean isCompileConstant(Object obj) {
@@ -1054,7 +1055,7 @@
* Intrinsified during LambdaForm compilation
* (see {@link InvokerBytecodeGenerator#emitGuardWithCatch emitGuardWithCatch}).
*/
- @LambdaForm.Hidden
+ @Hidden
static Object guardWithCatch(MethodHandle target, Class<? extends Throwable> exType, MethodHandle catcher,
Object... av) throws Throwable {
// Use asFixedArity() to avoid unnecessary boxing of last argument for VarargsCollector case.
@@ -1067,7 +1068,7 @@
}
/** Prepend elements to an array. */
- @LambdaForm.Hidden
+ @Hidden
private static Object[] prepend(Object[] array, Object... elems) {
int nArray = array.length;
int nElems = elems.length;
@@ -1265,7 +1266,7 @@
null, null);
// Suppress invoker method in stack traces.
- AnnotationVisitor av0 = mv.visitAnnotation("Ljava/lang/invoke/LambdaForm$Hidden;", true);
+ AnnotationVisitor av0 = mv.visitAnnotation(InvokerBytecodeGenerator.HIDDEN_SIG, true);
av0.visitEnd();
mv.visitCode();
@@ -1969,7 +1970,7 @@
* Intrinsified during LambdaForm compilation
* (see {@link InvokerBytecodeGenerator#emitLoop(int)}).
*/
- @LambdaForm.Hidden
+ @Hidden
static Object loop(BasicType[] localTypes, LoopClauses clauseData, Object... av) throws Throwable {
final MethodHandle[] init = clauseData.clauses[0];
final MethodHandle[] step = clauseData.clauses[1];
@@ -2174,7 +2175,7 @@
* Intrinsified during LambdaForm compilation
* (see {@link InvokerBytecodeGenerator#emitTryFinally emitTryFinally}).
*/
- @LambdaForm.Hidden
+ @Hidden
static Object tryFinally(MethodHandle target, MethodHandle cleanup, Object... av) throws Throwable {
Throwable t = null;
Object r = null;
--- a/src/java.base/share/classes/java/security/AccessController.java Tue Jan 22 18:13:30 2019 -0800
+++ b/src/java.base/share/classes/java/security/AccessController.java Tue Jan 22 18:13:49 2019 -0800
@@ -30,6 +30,8 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.ref.Reference;
+
+import jdk.internal.vm.annotation.Hidden;
import sun.security.util.Debug;
import sun.security.util.SecurityConstants;
import jdk.internal.reflect.CallerSensitive;
@@ -790,16 +792,6 @@
/**
- * Internal marker for hidden implementation frames.
- */
- /*non-public*/
- @Target(ElementType.METHOD)
- @Retention(RetentionPolicy.RUNTIME)
- @interface Hidden {
- }
-
-
- /**
* Wrap an exception. The annotations are used in a best effort to
* avoid StackOverflowError in the caller. Inlining the callees as
* well and tail-call elimination could also help here, but are not
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.base/share/classes/jdk/internal/vm/annotation/Hidden.java Tue Jan 22 18:13:49 2019 -0800
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.internal.vm.annotation;
+
+import java.lang.annotation.*;
+
+/**
+ * A method or constructor may be annotated as "hidden" to hint it is desirable
+ * to omit it from stack traces.
+ *
+ * @implNote
+ * This annotation only takes effect for methods or constructors of classes
+ * loaded by the boot loader. Annotations on methods or constructors of classes
+ * loaded outside of the boot loader are ignored.
+ *
+ * <p>HotSpot JVM provides diagnostic option {@code -XX:+ShowHiddenFrames} to
+ * always show "hidden" frames.
+ */
+@Target({ElementType.METHOD, ElementType.CONSTRUCTOR})
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Hidden {
+}