Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unblock JDK-next (JDK18) acceptance build #13890

Merged
merged 4 commits into from
Nov 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions jcl/src/java.base/share/classes/java/lang/System.java
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,12 @@ private static void ensureProperties(boolean isInitialization) {

/*[IF JAVA_SPEC_VERSION >= 18]*/
initializedProperties.put("os.version", sysPropOSVersion); //$NON-NLS-1$

/* Setting jdk.reflect.useDirectMethodHandle to false disables the new JEP 416
* changes where core reflection is reimplemented with MethodHandles. This flag
* will be reenabled once OpenJ9 completely supports JEP 416.
*/
initializedProperties.put("jdk.reflect.useDirectMethodHandle", "false"); //$NON-NLS-1$
babsingh marked this conversation as resolved.
Show resolved Hide resolved
/*[ENDIF] JAVA_SPEC_VERSION >= 18 */

if (osEncoding != null) {
Expand Down
22 changes: 16 additions & 6 deletions runtime/bcutil/ROMClassBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,18 +280,28 @@ ROMClassBuilder::handleAnonClassName(J9CfrClassFile *classfile, bool *isLambda,
PORT_ACCESS_FROM_PORT(_portLibrary);

#if defined(J9VM_OPT_OPENJDK_METHODHANDLE)
/* InjectedInvoker is a hidden class without the nestmate and strong
* attributes set. It is created by MethodHandleImpl.makeInjectedInvoker on
* the JCL side. ROM class name for InjectedInvoker is set using the hidden
* class name, which contains the correct host class name. The below filter
* is used to reduce the number of memcmps when identifying if a hidden
* class is named InjectedInvoker. Class name for InjectedInvoker:
/* InjectedInvoker is a hidden class without the strong attribute set. It
* is created by MethodHandleImpl.makeInjectedInvoker on the OpenJDK side.
* So, OpenJ9 does not have control over the implementation of InjectedInvoker.
* ROM class name for InjectedInvoker is set using the hidden class name, which
* contains the correct host class name. The below filter is used to reduce
* the number of memcmps when identifying if a hidden class is named
* InjectedInvoker. Class name for InjectedInvoker:
* - in class file bytecodes: "InjectedInvoker"; and
* - during hidden class creation: "<HOST_CLASS>$$InjectedInvoker".
*/
if (context->isClassHidden()
&& !context->isHiddenClassOptStrongSet()
/* In JDK17, InjectedInvoker does not have the nestmate attribute. In JDK18,
* InjectedInvoker has the nestmate attribute due to change in implementation.
* This filter checks for the nestmate attribute based upon the Java version
* in order to identify a InjectedInvoker class.
*/
#if JAVA_SPEC_VERSION <= 17
&& !context->isHiddenClassOptNestmateSet()
#else /* JAVA_SPEC_VERSION <= 17 */
&& context->isHiddenClassOptNestmateSet()
#endif /* JAVA_SPEC_VERSION <= 17 */
babsingh marked this conversation as resolved.
Show resolved Hide resolved
) {
#define J9_INJECTED_INVOKER_CLASSNAME "$$InjectedInvoker"
U_8 *nameData = context->className();
Expand Down
8 changes: 8 additions & 0 deletions runtime/compiler/env/j9method.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,11 @@ static const char * const excludeArray[] = {
"java/security/AccessController.doPrivileged(Ljava/security/PrivilegedAction;Ljava/security/AccessControlContext;[Ljava/security/Permission;)Ljava/lang/Object;",
"java/security/AccessController.doPrivileged(Ljava/security/PrivilegedExceptionAction;Ljava/security/AccessControlContext;[Ljava/security/Permission;)Ljava/lang/Object;",
"java/lang/NullPointerException.fillInStackTrace()Ljava/lang/Throwable;",
#if JAVA_SPEC_VERSION >= 18
"jdk/internal/loader/NativeLibraries.load(Ljdk/internal/loader/NativeLibraries$NativeLibraryImpl;Ljava/lang/String;ZZZ)Z",
#else /* JAVA_SPEC_VERSION >= 18 */
"jdk/internal/loader/NativeLibraries.load(Ljdk/internal/loader/NativeLibraries$NativeLibraryImpl;Ljava/lang/String;ZZ)Z",
#endif /* JAVA_SPEC_VERSION >= 18 */
};

bool
Expand Down Expand Up @@ -2996,7 +3000,11 @@ void TR_ResolvedJ9Method::construct()

static X NativeLibrariesMethods[] =
{
#if JAVA_SPEC_VERSION >= 18
{x(TR::jdk_internal_loader_NativeLibraries_load, "load", "(Ljdk/internal/loader/NativeLibraries$NativeLibraryImpl;Ljava/lang/String;ZZZ)Z")},
#else /* JAVA_SPEC_VERSION >= 18 */
{x(TR::jdk_internal_loader_NativeLibraries_load, "load", "(Ljdk/internal/loader/NativeLibraries$NativeLibraryImpl;Ljava/lang/String;ZZ)Z")},
#endif /* JAVA_SPEC_VERSION >= 18 */
babsingh marked this conversation as resolved.
Show resolved Hide resolved
{ TR::unknownMethod}
};

Expand Down
25 changes: 23 additions & 2 deletions runtime/jcl/common/java_lang_invoke_MethodHandleNatives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1494,18 +1494,39 @@ Java_java_lang_invoke_MethodHandleNatives_getMemberVMInfo(JNIEnv *env, jclass cl
arrayObject = POP_OBJECT_IN_SPECIAL_FRAME(currentThread);
j9object_t membernameObject = J9_JNI_UNWRAP_REFERENCE(self);
jint flags = J9VMJAVALANGINVOKEMEMBERNAME_FLAGS(currentThread, membernameObject);
jlong vmindex = (jlong)(UDATA)J9OBJECT_U64_LOAD(currentThread, membernameObject, vm->vmindexOffset);
j9object_t target = NULL;

/* For fields, vmindexOffset (J9JNIFieldID) is initialized using the field offset in
* jnicsup.cpp::getJNIFieldID. For methods, vmindexOffset (J9JNIMethodID) is initialized
* using jnicsup.cpp::initializeMethodID.
*/
jlong vmindex = (jlong)(UDATA)J9OBJECT_U64_LOAD(currentThread, membernameObject, vm->vmindexOffset);

if (J9_ARE_ANY_BITS_SET(flags, MN_IS_FIELD)) {
/* vmindex points to the field offset. */
vmindex = ((J9JNIFieldID*)vmindex)->offset;
target = J9VMJAVALANGINVOKEMEMBERNAME_CLAZZ(currentThread, membernameObject);
} else {
J9JNIMethodID *methodID = (J9JNIMethodID*)vmindex;
if (J9_ARE_ANY_BITS_SET(methodID->vTableIndex, J9_JNI_MID_INTERFACE)) {
/* vmindex points to an iTable index. */
vmindex = methodID->vTableIndex & ~J9_JNI_MID_INTERFACE;
} else if (0 == methodID->vTableIndex) {
vmindex = -1;
jint refKind = (flags >> MN_REFERENCE_KIND_SHIFT) & MN_REFERENCE_KIND_MASK;
if ((MH_REF_INVOKEVIRTUAL == refKind) || (MH_REF_INVOKEINTERFACE == refKind)) {
babsingh marked this conversation as resolved.
Show resolved Hide resolved
/* initializeMethodID will set J9JNIMethodID->vTableIndex to 0 for private interface
* methods and j.l.Object methods. Reference implementation (RI) expects vmindex to
* be 0 in such cases.
*/
vmindex = 0;
} else {
/* RI expects direct invocation, i.e. !invokevirtual and !invokeinterface ref kinds,
* to have a negative vmindex.
*/
vmindex = -1;
}
} else {
/* vmindex points to a vTable index. */
vmindex = methodID->vTableIndex;
}
target = membernameObject;
Expand Down
4 changes: 4 additions & 0 deletions runtime/jcl/common/stdinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,11 @@ standardInit( J9JavaVM *vm, char *dllName)
if (NULL == clz) {
goto _fail;
}
#if JAVA_SPEC_VERSION >= 18
mid = (*env)->GetStaticMethodID(env, clz, "load", "(Ljdk/internal/loader/NativeLibraries$NativeLibraryImpl;Ljava/lang/String;ZZZ)Z");
#else /* JAVA_SPEC_VERSION >= 18 */
mid = (*env)->GetStaticMethodID(env, clz, "load", "(Ljdk/internal/loader/NativeLibraries$NativeLibraryImpl;Ljava/lang/String;ZZ)Z");
#endif /* JAVA_SPEC_VERSION >= 18 */
if (NULL == mid) {
goto _fail;
}
Expand Down
4 changes: 3 additions & 1 deletion runtime/oti/vmconstantpool.xml
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,9 @@ SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-excepti
<!-- Static method references needed to support OpenJDK MethodHandles. -->
<staticmethodref class="java/lang/invoke/MethodHandleResolver" name="linkCallerMethod" signature="(Ljava/lang/Class;ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/Object;" flags="opt_openjdkMethodhandle"/>

<staticmethodref class="jdk/internal/loader/NativeLibraries" name="load" signature="(Ljdk/internal/loader/NativeLibraries$NativeLibraryImpl;Ljava/lang/String;ZZ)Z" versions="15-"/>
<staticmethodref class="jdk/internal/loader/NativeLibraries" name="load" signature="(Ljdk/internal/loader/NativeLibraries$NativeLibraryImpl;Ljava/lang/String;ZZ)Z" versions="15-17">
<methodalias name="load" signature="(Ljdk/internal/loader/NativeLibraries$NativeLibraryImpl;Ljava/lang/String;ZZZ)Z" versions="18-"/>
</staticmethodref>

<!-- Security manager check -->
<staticfieldref class="java/lang/System" name="security" signature="Ljava/lang/SecurityManager;"/>
Expand Down