Skip to content

Commit 2bff083

Browse files
committed
Value class is indicated by missing ACC_IDENTITY
This change is needed to support @ImplicitlyConstructible and @NullRestricted annotations for functional tests. See #19459 In this change: - J9ROMCLASS_IS_VALUE macro checks for ACC_IDENTITY flag instead of ACC_VALUE - Remove J9AccValueType from codebase There is more work to be done to fully remove ACC_VALUE (#18829) such as removing CFR_ACC_VALUE and adding runtime class file verification checks. Because functional value type tests are not able to run currently due to a recent update of the extensions repository I am making just a few changes toward getting those working. I am also removing the assert in JVM_IsNullRestrictedArray which is triggered when building OpenJ9. This method can't be implemented right now because OpenJ9 doesn't have support for null restricted arrays yet. See #17340 #19460
1 parent ef12769 commit 2bff083

File tree

8 files changed

+20
-36
lines changed

8 files changed

+20
-36
lines changed

debugtools/DDR_VM/src/com/ibm/j9ddr/CompatibilityConstants29.dat

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ J9FieldFlags.J9FieldFlagIsNullRestricted = 0
5959
J9JavaAccessFlags.J9AccClassIsUnmodifiable = 0
6060
J9JavaAccessFlags.J9AccRecord = 0
6161
J9JavaAccessFlags.J9AccSealed = 0
62-
J9JavaAccessFlags.J9AccValueType = 0
62+
J9JavaAccessFlags.J9AccClassHasIdentity = 0
6363
J9JavaAccessFlags.J9StaticFieldIsNullRestricted = 0
6464
J9JavaAccessFlags.J9PutfieldNarrowing = 0
6565
J9JavaAccessFlags.J9StaticFieldRefBaseType = 0

debugtools/DDR_VM/src/com/ibm/j9ddr/vm29/pointer/helper/ValueTypeHelper.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ public J9ClassPointer findJ9ClassInFlattenedClassCacheWithSigName(J9ClassPointer
217217

218218
@Override
219219
public boolean isRomClassAValueType(J9ROMClassPointer romClass) throws CorruptDataException {
220-
return romClass.modifiers().allBitsIn(J9JavaAccessFlags.J9AccValueType);
220+
return !romClass.modifiers().allBitsIn(J9JavaAccessFlags.J9AccClassHasIdentity);
221221
}
222222

223223
@Override

runtime/bcutil/ClassFileOracle.cpp

+3-8
Original file line numberDiff line numberDiff line change
@@ -277,15 +277,10 @@ ClassFileOracle::ClassFileOracle(BufferManager *bufferManager, J9CfrClassFile *c
277277
_hasNonEmptyConstructor = true;
278278
}
279279

280-
if (J9_ARE_ALL_BITS_SET(_classFile->accessFlags, CFR_ACC_VALUE_TYPE | CFR_ACC_IDENTITY)) {
281-
_buildResult = InvalidValueType;
280+
if (J9_ARE_ALL_BITS_SET(_classFile->accessFlags, CFR_ACC_IDENTITY)) {
281+
_hasIdentityFlagSet = true;
282282
} else {
283-
if (J9_ARE_ALL_BITS_SET(_classFile->accessFlags, CFR_ACC_VALUE_TYPE)) {
284-
_isValueType = true;
285-
}
286-
if (J9_ARE_ALL_BITS_SET(_classFile->accessFlags, CFR_ACC_IDENTITY)) {
287-
_hasIdentityFlagSet = true;
288-
}
283+
_isValueType = true;
289284
}
290285
#endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */
291286

runtime/j9vm/javanextvmi.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ JVM_IsImplicitlyConstructibleClass(JNIEnv *env, jclass cls)
743743
JNIEXPORT jboolean JNICALL
744744
JVM_IsNullRestrictedArray(JNIEnv *env, jobject obj)
745745
{
746-
assert(!"JVM_IsNullRestrictedArray unimplemented");
746+
// TODO implement this with https://github.com/eclipse-openj9/openj9/issues/19460
747747
return JNI_FALSE;
748748
}
749749

runtime/oti/j9javaaccessflags.h

-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
#define J9AccSuper 0x00000020 /* class */
4747
#define J9AccClassHasIdentity 0x00000020 /* class */
4848
#define J9AccSynchronized 0x00000020 /* method */
49-
#define J9AccValueType 0x00000040 /* class(Valhalla) */
5049
#define J9AccBridge 0x00000040 /* method */
5150
#define J9AccVolatile 0x00000040 /* field */
5251
#define J9AccVarArgs 0x00000080 /* method */

runtime/oti/j9modifiers_api.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
* TODO: Will need to modify this if ValObject/RefObject proposal goes through.
8989
* Some exiting places using J9ROMCLASS_IS_VALUE() may need to check J9ROMCLASS_IS_PRIMITIVE_VALUE_TYPE().
9090
*/
91-
#define J9ROMCLASS_IS_VALUE(romClass) _J9ROMCLASS_SUNMODIFIER_IS_SET((romClass), J9AccValueType)
91+
#define J9ROMCLASS_IS_VALUE(romClass) !_J9ROMCLASS_SUNMODIFIER_IS_SET((romClass), J9AccClassHasIdentity)
9292
#else /* J9VM_OPT_VALHALLA_VALUE_TYPES */
9393
#define J9ROMCLASS_IS_VALUE(romClass) FALSE
9494
#endif /* J9VM_OPT_VALHALLA_VALUE_TYPES */
@@ -140,7 +140,7 @@
140140

141141
/* Class instances are allocated via the new bytecode */
142142
#define J9ROMCLASS_ALLOCATES_VIA_NEW(romClass) \
143-
J9_ARE_NO_BITS_SET((romClass)->modifiers, J9AccAbstract | J9AccInterface | J9AccClassArray | J9AccValueType)
143+
J9_ARE_NO_BITS_SET((romClass)->modifiers, J9AccAbstract | J9AccInterface | J9AccClassArray)
144144

145145
/* Class instances are allocated via J9RAMClass->totalInstanceSize */
146146
#define J9ROMCLASS_ALLOCATE_USES_TOTALINSTANCESIZE(romClass) \

runtime/vm/ClassInitialization.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ classInitStateMachine(J9VMThread *currentThread, J9Class *clazz, J9ClassInitStat
607607
/* A NullRestricted field must be in a value class with an
608608
* ImplicitCreation attribute. The attribute must have the ACC_DEFAULT flag set.
609609
*/
610-
if (J9_ARE_NO_BITS_SET(entryRomClass->modifiers, J9AccValueType)
610+
if (!J9ROMCLASS_IS_VALUE(entryRomClass)
611611
|| J9_ARE_NO_BITS_SET(entryRomClass->optionalFlags, J9_ROMCLASS_OPTINFO_IMPLICITCREATION_ATTRIBUTE)
612612
|| J9_ARE_NO_BITS_SET(getImplicitCreationFlags(entryRomClass), J9AccImplicitCreateHasDefaultValue)
613613
) {

runtime/vm/createramclass.cpp

+11-21
Original file line numberDiff line numberDiff line change
@@ -2011,7 +2011,7 @@ loadFlattenableFieldValueClasses(J9VMThread *currentThread, J9ClassLoader *class
20112011
* ImplicitCreation attribute. The attribute must have the ACC_DEFAULT flag set.
20122012
* Static fields will be checked during class preparation.
20132013
*/
2014-
if (J9_ARE_NO_BITS_SET(valueROMClass->modifiers, J9AccValueType)
2014+
if (!J9ROMCLASS_IS_VALUE(valueROMClass)
20152015
|| J9_ARE_NO_BITS_SET(valueROMClass->optionalFlags, J9_ROMCLASS_OPTINFO_IMPLICITCREATION_ATTRIBUTE)
20162016
|| J9_ARE_NO_BITS_SET(getImplicitCreationFlags(valueROMClass), J9AccImplicitCreateHasDefaultValue)
20172017
) {
@@ -2331,30 +2331,20 @@ internalCreateRAMClassDone(J9VMThread *vmThread, J9ClassLoader *classLoader, J9C
23312331
}
23322332

23332333
#if defined(J9VM_OPT_VALHALLA_VALUE_TYPES)
2334-
if (J9_ARE_ALL_BITS_SET(classFlags, J9ClassHasIdentity)) {
2335-
if (J9ROMCLASS_IS_VALUE(romClass)) {
2336-
J9UTF8* className = J9ROMCLASS_CLASSNAME(romClass);
2337-
J9UTF8 *superclassName = J9ROMCLASS_SUPERCLASSNAME(romClass);
2338-
setCurrentExceptionNLSWithArgs(vmThread, J9NLS_VM_VALUETYPE_HAS_WRONG_SUPERCLASS,
2339-
J9VMCONSTANTPOOL_JAVALANGINCOMPATIBLECLASSCHANGEERROR, J9UTF8_LENGTH(className),
2340-
J9UTF8_DATA(className), J9UTF8_LENGTH(superclassName), J9UTF8_DATA(superclassName));
2341-
}
2342-
} else {
2343-
if (J9ROMCLASS_HAS_IDENTITY(romClass)) {
2344-
classFlags |= J9ClassHasIdentity;
2345-
}
2334+
if (J9ROMCLASS_HAS_IDENTITY(romClass)) {
2335+
classFlags |= J9ClassHasIdentity;
23462336
}
23472337

23482338
#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
2349-
if (J9_ARE_ALL_BITS_SET(romClass->optionalFlags, J9_ROMCLASS_OPTINFO_IMPLICITCREATION_ATTRIBUTE)) {
2350-
U_16 implicitCreationFlags = getImplicitCreationFlags(romClass);
2351-
if (J9_ARE_ALL_BITS_SET(implicitCreationFlags, J9AccImplicitCreateNonAtomic)) {
2352-
classFlags |= J9ClassAllowsNonAtomicCreation;
2353-
}
2354-
if (J9_ARE_ALL_BITS_SET(implicitCreationFlags, J9AccImplicitCreateHasDefaultValue)) {
2355-
classFlags |= J9ClassAllowsInitialDefaultValue;
2339+
if (J9_ARE_ALL_BITS_SET(romClass->optionalFlags, J9_ROMCLASS_OPTINFO_IMPLICITCREATION_ATTRIBUTE)) {
2340+
U_16 implicitCreationFlags = getImplicitCreationFlags(romClass);
2341+
if (J9_ARE_ALL_BITS_SET(implicitCreationFlags, J9AccImplicitCreateNonAtomic)) {
2342+
classFlags |= J9ClassAllowsNonAtomicCreation;
2343+
}
2344+
if (J9_ARE_ALL_BITS_SET(implicitCreationFlags, J9AccImplicitCreateHasDefaultValue)) {
2345+
classFlags |= J9ClassAllowsInitialDefaultValue;
2346+
}
23562347
}
2357-
}
23582348
#endif /* defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) */
23592349

23602350
if (J9ROMCLASS_IS_VALUE(romClass)) {

0 commit comments

Comments
 (0)