Skip to content

Commit

Permalink
Remove outdated value type field verification checks
Browse files Browse the repository at this point in the history
Signed-off-by: Theresa Mammarella <[email protected]>
  • Loading branch information
theresa-m committed Oct 25, 2024
1 parent 4934df0 commit 4715350
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 21 deletions.
19 changes: 3 additions & 16 deletions runtime/bcutil/cfreader.c
Original file line number Diff line number Diff line change
Expand Up @@ -1708,34 +1708,21 @@ checkFields(J9PortLibrary* portLib, J9CfrClassFile * classfile, U_8 * segment, U

#if defined(J9VM_OPT_VALHALLA_VALUE_TYPES)
if (J9_IS_CLASSFILE_VALUETYPE(classfile)) {
if (J9_ARE_ALL_BITS_SET(classfile->accessFlags, CFR_ACC_ABSTRACT)) {
if (J9_ARE_NO_BITS_SET(value, CFR_ACC_STATIC)) {
errorCode = J9NLS_CFR_ERR_MISSING_ACC_STATIC_ON_ABSTRACT_IDENTITYLESS_CLASS_FIELD__ID;
goto _errorFound;
}
} else {
if (J9_ARE_NO_BITS_SET(value, CFR_ACC_STATIC | CFR_ACC_FINAL)) {
errorCode = J9NLS_CFR_ERR_VALUE_CLASS_FIELD_NOT_STATIC_OR_FINAL__ID;
goto _errorFound;
}
}

/* Each field of a value class must have exactly one of its ACC_STATIC or ACC_STRICT flags set. */
if (J9_ARE_NO_BITS_SET(value, CFR_ACC_STRICT | CFR_ACC_STATIC)) {
errorCode = J9NLS_CFR_ERR_VALUE_CLASS_FIELD_NOT_STATIC_OR_STRICT__ID;
goto _errorFound;
}
}

if (J9_IS_CLASSFILE_OR_ROMCLASS_VALUETYPE_VERSION(classfile)) {
if (J9ROMFIELD_IS_STRICT(classfile, value)) {
/* A field must not have set both ACC_STRICT and ACC_STATIC. */
if (J9_ARE_ALL_BITS_SET(value, CFR_ACC_STRICT | CFR_ACC_STATIC)) {
if (J9_ARE_ALL_BITS_SET(value, CFR_ACC_STATIC)) {
errorCode = J9NLS_CFR_ERR_FIELD_CANT_BE_STRICT_AND_STATIC__ID;
goto _errorFound;
}

/* A field that has set ACC_STRICT must also have set ACC_FINAL. */
if (J9_ARE_ALL_BITS_SET(value, CFR_ACC_STRICT) && J9_ARE_NO_BITS_SET(value, CFR_ACC_FINAL)) {
if (J9_ARE_NO_BITS_SET(value, CFR_ACC_FINAL)) {
errorCode = J9NLS_CFR_ERR_STRICT_FIELD_MUST_BE_FINAL__ID;
goto _errorFound;
}
Expand Down
5 changes: 1 addition & 4 deletions runtime/bcverify/vrfyhelp.c
Original file line number Diff line number Diff line change
Expand Up @@ -906,10 +906,7 @@ isFieldAccessCompatible(J9BytecodeVerificationData *verifyData, J9ROMFieldRef *f
J9BranchTargetStack *liveStack = (J9BranchTargetStack *)verifyData->liveStack;
J9ROMFieldShape *field = findFieldFromCurrentRomClass(romClass, fieldRef);
#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
IDATA isStrictField =
(NULL != field)
&& J9_IS_CLASSFILE_OR_ROMCLASS_VALUETYPE_VERSION(romClass)
&& J9_ARE_ALL_BITS_SET(field->modifiers, J9AccStrict);
IDATA isStrictField = (NULL != field) && J9ROMFIELD_IS_STRICT(romClass, field->modifiers);
#endif /* defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) */
if (J9_ARE_ALL_BITS_SET(receiver, BCV_SPECIAL_INIT)) {
#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
Expand Down
2 changes: 2 additions & 0 deletions runtime/oti/j9.h
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ static const struct { \
#define J9_VALUETYPE_FLATTENED_SIZE(clazz) (J9CLASS_HAS_4BYTE_PREPADDING((clazz)) ? ((clazz)->totalInstanceSize - sizeof(U_32)) : (clazz)->totalInstanceSize)
#define J9_IS_J9ARRAYCLASS_NULL_RESTRICTED(clazz) J9_ARE_ALL_BITS_SET((clazz)->classFlags, J9ClassArrayIsNullRestricted)
#define J9CLASS_GET_NULLRESTRICTED_ARRAY(clazz) (J9_IS_J9CLASS_VALUETYPE(clazz) ? (clazz)->nullRestrictedArrayClass : NULL)
#define J9ROMFIELD_IS_STRICT(romClassOrClassfile, fieldModifiers) (J9_IS_CLASSFILE_OR_ROMCLASS_VALUETYPE_VERSION(romClassOrClassfile) && J9_ARE_ALL_BITS_SET(fieldModifiers, J9AccStrict))
#else /* defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) */
#define J9CLASS_UNPADDED_INSTANCE_SIZE(clazz) ((clazz)->totalInstanceSize)
#define J9_IS_J9CLASS_ALLOW_DEFAULT_VALUE(clazz) FALSE
Expand All @@ -362,6 +363,7 @@ static const struct { \
#define J9_VALUETYPE_FLATTENED_SIZE(clazz)((UDATA) 0) /* It is not possible for this macro to be used since we always check J9_IS_J9CLASS_FLATTENED before ever using it. */
#define J9_IS_J9ARRAYCLASS_NULL_RESTRICTED(clazz) FALSE
#define J9CLASS_GET_NULLRESTRICTED_ARRAY(clazz) NULL
#define J9ROMFIELD_IS_STRICT(romClassOrClassfile, fieldModifiers) FALSE
#endif /* defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) */
#define IS_CLASS_SIGNATURE(firstChar) ('L' == (firstChar))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2904,7 +2904,7 @@ static public void testAccStrictFieldMustHaveAccFinal() {
}

/* Each field of a value class must have exactly one of its ACC_STATIC or ACC_STRICT flags set */
@Test(expectedExceptions = java.lang.ClassFormatError.class, expectedExceptionsMessageRegExp = ".*Fields of value classes must have either ACC_STATIC or ACC_FINAL flags set.*")
@Test(expectedExceptions = java.lang.ClassFormatError.class, expectedExceptionsMessageRegExp = ".*Value class fields must have either ACC_STATIC or ACC_STRICT set.*")
static public void testValueClassFieldMustHaveAccStaticOrAccStrict() {
ValueTypeGenerator.generateTestValueClassFieldMustHaveAccStaticOrAccStrict();
}
Expand Down

0 comments on commit 4715350

Please sign in to comment.