< prev index next >
src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java
Print this page
*** 609,635 ****
mv.visitVarInsn(Opcodes.ALOAD, localsMap[0]);
mv.visitMethodInsn(Opcodes.INVOKESTATIC, MHI, "assertSame", LLV_SIG, false);
return true;
}
/**
* Generate an invoker method for the passed {@link LambdaForm}.
*/
private byte[] generateCustomizedCodeBytes() {
classFilePrologue();
// Suppress this method in backtraces displayed to the user.
! mv.visitAnnotation("Ljava/lang/invoke/LambdaForm$Hidden;", true);
// Mark this method as a compiled LambdaForm
! mv.visitAnnotation("Ljava/lang/invoke/LambdaForm$Compiled;", true);
if (lambdaForm.forceInline) {
// Force inlining of this invoker method.
! mv.visitAnnotation("Ljdk/internal/vm/annotation/ForceInline;", true);
} else {
! mv.visitAnnotation("Ljdk/internal/vm/annotation/DontInline;", true);
}
if (lambdaForm.customized != null) {
// Since LambdaForm is customized for a particular MethodHandle, it's safe to substitute
// receiver MethodHandle (at slot #0) with an embedded constant and use it instead.
--- 609,655 ----
mv.visitVarInsn(Opcodes.ALOAD, localsMap[0]);
mv.visitMethodInsn(Opcodes.INVOKESTATIC, MHI, "assertSame", LLV_SIG, false);
return true;
}
+ static String className(String cn) {
+ assert checkClassName(cn): "Class not found: " + cn;
+ return cn;
+ }
+
+ static boolean checkClassName(String cn) {
+ String fqcn = cn.substring(1, cn.length() - 1).replace('/', '.');
+ try {
+ Class<?> c = Class.forName(fqcn, false, null);
+ return true;
+ } catch (ClassNotFoundException e) {
+ return false;
+ }
+ }
+
+ static final String LAMBDA_FORM_HIDDEN_CLASS_SIG = className("Ljava/lang/invoke/LambdaForm$Hidden;");
+ static final String LAMBDA_FORM_COMPILED_CLASS_SIG = className("Ljava/lang/invoke/LambdaForm$Compiled;");
+ static final String FORCEINLINE_CLASS_SIG = className("Ljdk/internal/vm/annotation/ForceInline;");
+ static final String DONTINLINE_CLASS_SIG = className("Ljdk/internal/vm/annotation/DontInline;");
+
/**
* Generate an invoker method for the passed {@link LambdaForm}.
*/
private byte[] generateCustomizedCodeBytes() {
classFilePrologue();
// Suppress this method in backtraces displayed to the user.
! mv.visitAnnotation(LAMBDA_FORM_HIDDEN_CLASS_SIG, true);
// Mark this method as a compiled LambdaForm
! mv.visitAnnotation(LAMBDA_FORM_COMPILED_CLASS_SIG, true);
if (lambdaForm.forceInline) {
// Force inlining of this invoker method.
! mv.visitAnnotation(FORCEINLINE_CLASS_SIG, true);
} else {
! mv.visitAnnotation(DONTINLINE_CLASS_SIG, true);
}
if (lambdaForm.customized != null) {
// Since LambdaForm is customized for a particular MethodHandle, it's safe to substitute
// receiver MethodHandle (at slot #0) with an embedded constant and use it instead.
< prev index next >