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

Throw IdentityException in monitorenter #19774

Merged
merged 2 commits into from
Jul 5, 2024
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
2 changes: 1 addition & 1 deletion runtime/codert_vm/cnathelp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1733,7 +1733,7 @@ slow_jitMonitorEnterImpl(J9VMThread *currentThread, bool forMethod)
#if defined(J9VM_OPT_VALHALLA_VALUE_TYPES)
if (J9_IS_J9CLASS_VALUETYPE(badClass)) {
currentThread->javaVM->internalVMFunctions->setCurrentExceptionNLSWithArgs(currentThread, J9NLS_VM_ERROR_BYTECODE_OBJECTREF_CANNOT_BE_VALUE_TYPE,
J9VMCONSTANTPOOL_JAVALANGILLEGALMONITORSTATEEXCEPTION, J9UTF8_LENGTH(className), J9UTF8_DATA(className));
J9VMCONSTANTPOOL_JAVALANGIDENTITYEXCEPTION, J9UTF8_LENGTH(className), J9UTF8_DATA(className));
} else
#endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */
{
Expand Down
2 changes: 1 addition & 1 deletion runtime/nls/j9vm/j9vm.nls
Original file line number Diff line number Diff line change
Expand Up @@ -1887,7 +1887,7 @@ J9NLS_VM_ERROR_BYTECODE_OBJECTREF_CANNOT_BE_VALUE_TYPE=bad object type %2$.*1$s:
J9NLS_VM_ERROR_BYTECODE_OBJECTREF_CANNOT_BE_VALUE_TYPE.sample_input_1=3
J9NLS_VM_ERROR_BYTECODE_OBJECTREF_CANNOT_BE_VALUE_TYPE.sample_input_2=Foo
J9NLS_VM_ERROR_BYTECODE_OBJECTREF_CANNOT_BE_VALUE_TYPE.explanation=The class has specified the bytecode monitorenter or monitorexit operation which cannot be performed on a value type but the object on stack is a value type.
J9NLS_VM_ERROR_BYTECODE_OBJECTREF_CANNOT_BE_VALUE_TYPE.system_action=The JVM will throw an IllegalMonitorStateException.
J9NLS_VM_ERROR_BYTECODE_OBJECTREF_CANNOT_BE_VALUE_TYPE.system_action=The JVM will throw an IdentityException.
J9NLS_VM_ERROR_BYTECODE_OBJECTREF_CANNOT_BE_VALUE_TYPE.user_response=Contact the provider of the classfile for a corrected version.
# END NON-TRANSLATABLE

Expand Down
2 changes: 1 addition & 1 deletion runtime/oti/cfr.h
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ typedef struct J9CfrClassFile {
#define CFR_MINOR_VERSION 3
#define CFR_PUBLIC_PRIVATE_PROTECTED_MASK (CFR_ACC_PUBLIC | CFR_ACC_PRIVATE | CFR_ACC_PROTECTED)

#define J9_IS_CLASSFILE_VALUETYPE(classfile) (((classfile)->majorVersion >= VALUE_TYPES_MAJOR_VERSION) && (PREVIEW_MINOR_VERSION == (classfile)->minorVersion) && J9_ARE_NO_BITS_SET((classfile)->accessFlags, CFR_ACC_IDENTITY))
#define J9_IS_CLASSFILE_VALUETYPE(classfile) (((classfile)->majorVersion >= VALUE_TYPES_MAJOR_VERSION) && (PREVIEW_MINOR_VERSION == (classfile)->minorVersion) && J9_ARE_NO_BITS_SET((classfile)->accessFlags, CFR_ACC_IDENTITY | CFR_ACC_INTERFACE))

#if defined(J9VM_OPT_VALHALLA_VALUE_TYPES)
#define CFR_CLASS_ACCESS_MASK (CFR_ACC_PUBLIC | CFR_ACC_FINAL | CFR_ACC_IDENTITY | CFR_ACC_INTERFACE | CFR_ACC_ABSTRACT | CFR_ACC_SYNTHETIC | CFR_ACC_ANNOTATION | CFR_ACC_ENUM)
Expand Down
2 changes: 1 addition & 1 deletion runtime/oti/j9modifiers_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
#define J9ROMCLASS_IS_CONTENDED(romClass) _J9ROMCLASS_J9MODIFIER_IS_SET((romClass), J9AccClassIsContended)

#ifdef J9VM_OPT_VALHALLA_VALUE_TYPES
#define J9ROMCLASS_IS_VALUE(romClass) (((romClass)->majorVersion >= VALUE_TYPES_MAJOR_VERSION) && (PREVIEW_MINOR_VERSION == (romClass)->minorVersion) && !_J9ROMCLASS_SUNMODIFIER_IS_SET((romClass), J9AccClassHasIdentity))
#define J9ROMCLASS_IS_VALUE(romClass) (((romClass)->majorVersion >= VALUE_TYPES_MAJOR_VERSION) && (PREVIEW_MINOR_VERSION == (romClass)->minorVersion) && !_J9ROMCLASS_SUNMODIFIER_IS_ANY_SET((romClass), J9AccClassHasIdentity | J9AccInterface))
#else /* J9VM_OPT_VALHALLA_VALUE_TYPES */
#define J9ROMCLASS_IS_VALUE(romClass) FALSE
#endif /* J9VM_OPT_VALHALLA_VALUE_TYPES */
Expand Down
1 change: 1 addition & 0 deletions runtime/oti/vmconstantpool.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-ex
<vmconstantpool>
<classref name="java/lang/ArrayStoreException"/>
<classref name="java/lang/ClassCastException"/>
<classref name="java/lang/IdentityException" flags="opt_valhallaValueTypes"/>
<classref name="java/lang/IllegalMonitorStateException"/>
<classref name="java/lang/IndexOutOfBoundsException"/>
<classref name="java/lang/NegativeArraySizeException"/>
Expand Down
2 changes: 1 addition & 1 deletion runtime/vm/BytecodeInterpreter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11224,7 +11224,7 @@ arrayIndex: {
#define badClassName J9ROMCLASS_CLASSNAME(J9OBJECT_CLAZZ(_currentThread, (j9object_t)_currentThread->tempSlot)->romClass)
#if defined(J9VM_OPT_VALHALLA_VALUE_TYPES)
if (J9_IS_J9CLASS_VALUETYPE(J9OBJECT_CLAZZ(_currentThread, (j9object_t)_currentThread->tempSlot))) {
setCurrentExceptionNLSWithArgs(_currentThread, J9NLS_VM_ERROR_BYTECODE_OBJECTREF_CANNOT_BE_VALUE_TYPE, J9VMCONSTANTPOOL_JAVALANGILLEGALMONITORSTATEEXCEPTION, J9UTF8_LENGTH(badClassName), J9UTF8_DATA(badClassName));
setCurrentExceptionNLSWithArgs(_currentThread, J9NLS_VM_ERROR_BYTECODE_OBJECTREF_CANNOT_BE_VALUE_TYPE, J9VMCONSTANTPOOL_JAVALANGIDENTITYEXCEPTION, J9UTF8_LENGTH(badClassName), J9UTF8_DATA(badClassName));
} else
#endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */
{
Expand Down
2 changes: 1 addition & 1 deletion runtime/vm/jnicsup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2055,7 +2055,7 @@ monitorEnter(JNIEnv* env, jobject obj)
J9UTF8 *badClassName = J9ROMCLASS_CLASSNAME(badClass->romClass);
#if defined(J9VM_OPT_VALHALLA_VALUE_TYPES)
if (J9_IS_J9CLASS_VALUETYPE(badClass)) {
setCurrentExceptionNLSWithArgs(vmThread, J9NLS_VM_ERROR_BYTECODE_OBJECTREF_CANNOT_BE_VALUE_TYPE, J9VMCONSTANTPOOL_JAVALANGILLEGALMONITORSTATEEXCEPTION, J9UTF8_LENGTH(badClassName), J9UTF8_DATA(badClassName));
setCurrentExceptionNLSWithArgs(vmThread, J9NLS_VM_ERROR_BYTECODE_OBJECTREF_CANNOT_BE_VALUE_TYPE, J9VMCONSTANTPOOL_JAVALANGIDENTITYEXCEPTION, J9UTF8_LENGTH(badClassName), J9UTF8_DATA(badClassName));
} else
#endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@ static public void testMonitorEnterAndExitOnValueType() throws Throwable {
try {
monitorEnterAndExitOnValueType.invoke(valueType);
Assert.fail("should throw exception. MonitorExit cannot be used with ValueType");
} catch (IllegalMonitorStateException e) {}
} catch (IdentityException e) {}

try {
monitorEnterAndExitOnValueType.invoke(valueTypeArray);
Expand Down