< prev index next > src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java
Print this page
/*
! * Copyright (c) 2008, 2022, 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
/*
! * Copyright (c) 2008, 2024, 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
nf = NFS[func] = createFunction(func);
assert(InvokerBytecodeGenerator.isStaticallyInvocable(nf));
return nf;
}
! private static final MethodType OBJ_OBJ_TYPE = MethodType.methodType(Object.class, Object.class);
!
! private static final MethodType LONG_OBJ_TYPE = MethodType.methodType(long.class, Object.class);
private static NamedFunction createFunction(byte func) {
try {
switch (func) {
case NF_internalMemberName:
! return getNamedFunction("internalMemberName", OBJ_OBJ_TYPE);
case NF_internalMemberNameEnsureInit:
! return getNamedFunction("internalMemberNameEnsureInit", OBJ_OBJ_TYPE);
case NF_ensureInitialized:
return getNamedFunction("ensureInitialized", MethodType.methodType(void.class, Object.class));
case NF_fieldOffset:
! return getNamedFunction("fieldOffset", LONG_OBJ_TYPE);
case NF_checkBase:
! return getNamedFunction("checkBase", OBJ_OBJ_TYPE);
case NF_staticBase:
! return getNamedFunction("staticBase", OBJ_OBJ_TYPE);
case NF_staticOffset:
! return getNamedFunction("staticOffset", LONG_OBJ_TYPE);
case NF_checkCast:
return getNamedFunction("checkCast", MethodType.methodType(Object.class, Object.class, Object.class));
case NF_allocateInstance:
! return getNamedFunction("allocateInstance", OBJ_OBJ_TYPE);
case NF_constructorMethod:
! return getNamedFunction("constructorMethod", OBJ_OBJ_TYPE);
case NF_UNSAFE:
MemberName member = new MemberName(MethodHandleStatics.class, "UNSAFE", Unsafe.class, REF_getStatic);
return new NamedFunction(
MemberName.getFactory().resolveOrFail(REF_getStatic, member,
DirectMethodHandle.class, LM_TRUSTED,
NoSuchFieldException.class));
case NF_checkReceiver:
! member = new MemberName(DirectMethodHandle.class, "checkReceiver", OBJ_OBJ_TYPE, REF_invokeVirtual);
return new NamedFunction(
MemberName.getFactory().resolveOrFail(REF_invokeVirtual, member,
DirectMethodHandle.class, LM_TRUSTED,
NoSuchMethodException.class));
default:
nf = NFS[func] = createFunction(func);
assert(InvokerBytecodeGenerator.isStaticallyInvocable(nf));
return nf;
}
! static class AOTHolder {
! private static final MethodType OBJ_OBJ_TYPE = MethodType.methodType(Object.class, Object.class);
! private static final MethodType LONG_OBJ_TYPE = MethodType.methodType(long.class, Object.class);
+ }
private static NamedFunction createFunction(byte func) {
try {
switch (func) {
case NF_internalMemberName:
! return getNamedFunction("internalMemberName", AOTHolder.OBJ_OBJ_TYPE);
case NF_internalMemberNameEnsureInit:
! return getNamedFunction("internalMemberNameEnsureInit", AOTHolder.OBJ_OBJ_TYPE);
case NF_ensureInitialized:
return getNamedFunction("ensureInitialized", MethodType.methodType(void.class, Object.class));
case NF_fieldOffset:
! return getNamedFunction("fieldOffset", AOTHolder.LONG_OBJ_TYPE);
case NF_checkBase:
! return getNamedFunction("checkBase", AOTHolder.OBJ_OBJ_TYPE);
case NF_staticBase:
! return getNamedFunction("staticBase", AOTHolder.OBJ_OBJ_TYPE);
case NF_staticOffset:
! return getNamedFunction("staticOffset", AOTHolder.LONG_OBJ_TYPE);
case NF_checkCast:
return getNamedFunction("checkCast", MethodType.methodType(Object.class, Object.class, Object.class));
case NF_allocateInstance:
! return getNamedFunction("allocateInstance", AOTHolder.OBJ_OBJ_TYPE);
case NF_constructorMethod:
! return getNamedFunction("constructorMethod", AOTHolder.OBJ_OBJ_TYPE);
case NF_UNSAFE:
MemberName member = new MemberName(MethodHandleStatics.class, "UNSAFE", Unsafe.class, REF_getStatic);
return new NamedFunction(
MemberName.getFactory().resolveOrFail(REF_getStatic, member,
DirectMethodHandle.class, LM_TRUSTED,
NoSuchFieldException.class));
case NF_checkReceiver:
! member = new MemberName(DirectMethodHandle.class, "checkReceiver", AOTHolder.OBJ_OBJ_TYPE, REF_invokeVirtual);
return new NamedFunction(
MemberName.getFactory().resolveOrFail(REF_invokeVirtual, member,
DirectMethodHandle.class, LM_TRUSTED,
NoSuchMethodException.class));
default:
< prev index next >