diff --git a/jcl/src/java.base/share/classes/java/lang/Object.java b/jcl/src/java.base/share/classes/java/lang/Object.java index 7dcada8e3c1..21c31665f13 100644 --- a/jcl/src/java.base/share/classes/java/lang/Object.java +++ b/jcl/src/java.base/share/classes/java/lang/Object.java @@ -22,6 +22,10 @@ *******************************************************************************/ package java.lang; +/*[IF JAVA_SPEC_VERSION >= 19] */ +import jdk.internal.misc.Blocker; +/*[ENDIF] JAVA_SPEC_VERSION >= 19 */ + /** * Object is the root of the java class hierarchy. All non-base types * respond to the messages defined in this class. @@ -269,7 +273,20 @@ public final void wait(long time) throws InterruptedException { * @see #wait(long) * @see java.lang.Thread */ -public final native void wait(long time, int frac) throws InterruptedException; +public final void wait(long time, int frac) throws InterruptedException { +/*[IF JAVA_SPEC_VERSION >= 19] */ + long blockerRC = Blocker.begin(); + try { + waitImpl(time, frac); + } finally { + Blocker.end(blockerRC); + } +/*[ELSE] JAVA_SPEC_VERSION >= 19 */ + waitImpl(time, frac); +/*[ENDIF] JAVA_SPEC_VERSION >= 19 */ +} + +private final native void waitImpl(long time, int frac) throws InterruptedException; /* * Used as a prototype for the jit. diff --git a/runtime/util/final.c b/runtime/util/final.c index 308fa162307..0425cf74cb8 100644 --- a/runtime/util/final.c +++ b/runtime/util/final.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 1991, 2014 IBM Corp. and others + * Copyright (c) 1991, 2022 IBM Corp. and others * * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which accompanies this @@ -27,15 +27,15 @@ UDATA methodIsFinalInObject(UDATA nameLength, U_8* name, UDATA sigLength, U_8* sig) { - const char names[] = "wait\0" "wait\0" "wait\0" "notify\0" "notifyAll\0" "getClass\0"; + const char names[] = "wait\0" "wait\0" "wait\0" "waitImpl\0" "notify\0" "notifyAll\0" "getClass\0"; const U_8 nameLengths[] = { - sizeof("wait") - 1, sizeof("wait") - 1, sizeof("wait") - 1, + sizeof("wait") - 1, sizeof("wait") - 1, sizeof("wait") - 1, sizeof("waitImpl") - 1, sizeof("notify") - 1, sizeof("notifyAll") - 1, sizeof("getClass") - 1 }; - const char sigs[] = "()V\0" "(J)V\0" "(JI)V\0" "()V\0" "()V\0" "()Ljava/lang/Class;\0"; + const char sigs[] = "()V\0" "(J)V\0" "(JI)V\0" "(JI)V\0" "()V\0" "()V\0" "()Ljava/lang/Class;\0"; const U_8 sigLengths[] = { - sizeof("()V") - 1, sizeof("(J)V") - 1, sizeof("(JI)V") - 1, + sizeof("()V") - 1, sizeof("(J)V") - 1, sizeof("(JI)V") - 1, sizeof("(JI)V") - 1, sizeof("()V") - 1, sizeof("()V") - 1, sizeof("()Ljava/lang/Class;") - 1 }; -#define OBJECT_FINAL_COUNT 6 +#define OBJECT_FINAL_COUNT 7 #define SHORTEST_METHOD_NAME (sizeof("wait") - 1) #define LONGEST_METHOD_NAME (sizeof("notifyAll") - 1) diff --git a/runtime/vm/BytecodeInterpreter.hpp b/runtime/vm/BytecodeInterpreter.hpp index e241a957b90..aad6564eb4f 100644 --- a/runtime/vm/BytecodeInterpreter.hpp +++ b/runtime/vm/BytecodeInterpreter.hpp @@ -4853,9 +4853,9 @@ class INTERPRETER_CLASS return rc; } - /* java.lang.Object: public final native void wait(long millis, int nanos); */ + /* java.lang.Object: public final native void waitImpl(long millis, int nanos); */ VMINLINE VM_BytecodeAction - inlObjectWait(REGISTER_ARGS_LIST) + inlObjectWaitImpl(REGISTER_ARGS_LIST) { VM_BytecodeAction rc = EXECUTE_BYTECODE; I_32 nanos = *(I_32*)_sp; @@ -10701,7 +10701,7 @@ runMethod: { JUMP_TARGET(J9_BCLOOP_SEND_TARGET_INL_THREAD_SLEEP): PERFORM_ACTION(inlThreadSleep(REGISTER_ARGS)); JUMP_TARGET(J9_BCLOOP_SEND_TARGET_INL_OBJECT_WAIT): - PERFORM_ACTION(inlObjectWait(REGISTER_ARGS)); + PERFORM_ACTION(inlObjectWaitImpl(REGISTER_ARGS)); JUMP_TARGET(J9_BCLOOP_SEND_TARGET_INL_CLASSLOADER_LOADLIBRARYWITHPATH): PERFORM_ACTION(inlClassLoaderLoadLibraryWithPath(REGISTER_ARGS)); JUMP_TARGET(J9_BCLOOP_SEND_TARGET_INL_THREAD_ISINTERRUPTEDIMPL): diff --git a/runtime/vm/FastJNI_java_lang_Object.cpp b/runtime/vm/FastJNI_java_lang_Object.cpp index d5fbe7ad407..3319044e0ea 100644 --- a/runtime/vm/FastJNI_java_lang_Object.cpp +++ b/runtime/vm/FastJNI_java_lang_Object.cpp @@ -33,7 +33,7 @@ extern "C" { -/* java.lang.Object: public final native void wait(long millis, int nanos) throws InterruptedException; */ +/* java.lang.Object: public final native void waitImpl(long millis, int nanos) throws InterruptedException; */ void JNICALL Fast_java_lang_Object_wait(J9VMThread *currentThread, j9object_t receiverObject, jlong millis, jint nanos) { @@ -90,7 +90,7 @@ Fast_java_lang_Object_notify(J9VMThread *currentThread, j9object_t receiverObjec } J9_FAST_JNI_METHOD_TABLE(java_lang_Object) - J9_FAST_JNI_METHOD("wait", "(JI)V", Fast_java_lang_Object_wait, + J9_FAST_JNI_METHOD("waitImpl", "(JI)V", Fast_java_lang_Object_wait, J9_FAST_JNI_RETAIN_VM_ACCESS | J9_FAST_JNI_DO_NOT_WRAP_OBJECTS) J9_FAST_JNI_METHOD("notifyAll", "()V", Fast_java_lang_Object_notifyAll, J9_FAST_JNI_RETAIN_VM_ACCESS | J9_FAST_JNI_DO_NOT_WRAP_OBJECTS) diff --git a/runtime/vm/bindnatv.cpp b/runtime/vm/bindnatv.cpp index 436871e350d..32349073b2d 100644 --- a/runtime/vm/bindnatv.cpp +++ b/runtime/vm/bindnatv.cpp @@ -198,7 +198,7 @@ static inlMapping mappings[] = { { "Java_java_lang_invoke_MethodHandles_getStackClass__I", J9_BCLOOP_SEND_TARGET_INL_VM_GETSTACKCLASS }, { "Java_java_lang_Class_getStackClass__I", J9_BCLOOP_SEND_TARGET_INL_VM_GETSTACKCLASS }, { "Java_java_lang_Thread_sleepImpl__JI", J9_BCLOOP_SEND_TARGET_INL_THREAD_SLEEP }, - { "Java_java_lang_Object_wait__JI", J9_BCLOOP_SEND_TARGET_INL_OBJECT_WAIT }, + { "Java_java_lang_Object_waitImpl__JI", J9_BCLOOP_SEND_TARGET_INL_OBJECT_WAIT }, { "Java_java_lang_ClassLoader_loadLibraryWithPath___3BLjava_lang_ClassLoader_2_3B", J9_BCLOOP_SEND_TARGET_INL_CLASSLOADER_LOADLIBRARYWITHPATH }, { "Java_java_lang_Thread_isInterruptedImpl__", J9_BCLOOP_SEND_TARGET_INL_THREAD_ISINTERRUPTEDIMPL }, { "Java_java_lang_ClassLoader_initAnonClassLoader__Ljava_lang_InternalAnonymousClassLoader_2", J9_BCLOOP_SEND_TARGET_INL_CLASSLOADER_INITIALIZEANONCLASSLOADER },