Skip to content

Commit

Permalink
Allow ValueType creation with new/<init>/putfield
Browse files Browse the repository at this point in the history
Signed-off-by: Theresa Mammarella <[email protected]>
  • Loading branch information
theresa-m committed Dec 12, 2023
1 parent e6d0f3e commit 52b6b44
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 24 deletions.
18 changes: 3 additions & 15 deletions runtime/bcutil/cfreader.c
Original file line number Diff line number Diff line change
Expand Up @@ -1876,22 +1876,10 @@ checkMethods(J9PortLibrary* portLib, J9CfrClassFile* classfile, U_8* segment, U_
}

if (nameIndexOK && utf8Equal(&classfile->constantPool[method->nameIndex], "<init>", 6)) {
#if defined(J9VM_OPT_VALHALLA_VALUE_TYPES)
/**
* The spec says a method of a value class cannot be <init>. A method of an abstract class cannot be <vnew>.
* For a value abstract class, its constructor is compiled into <init> now, so allow <init> in abstract classes.
*/
if (J9_IS_CLASSFILE_VALUETYPE(classfile) && J9_ARE_NO_BITS_SET(classfile->accessFlags, CFR_ACC_ABSTRACT)) {
errorCode = J9NLS_CFR_ERR_INIT_ON_VALUE_CLASS__ID;
/* check no invalid flags set */
if (value & ~CFR_INIT_METHOD_ACCESS_MASK) {
errorCode = J9NLS_CFR_ERR_INIT_METHOD__ID;
goto _errorFound;
} else
#endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */
{
/* check no invalid flags set */
if (value & ~CFR_INIT_METHOD_ACCESS_MASK) {
errorCode = J9NLS_CFR_ERR_INIT_METHOD__ID;
goto _errorFound;
}
}

/* Java SE 9 Edition:
Expand Down
8 changes: 0 additions & 8 deletions runtime/nls/cfre/cfrerr.nls
Original file line number Diff line number Diff line change
Expand Up @@ -1505,14 +1505,6 @@ J9NLS_CFR_ERR_INVALID_FLAGS_ON_NEW.system_action=The JVM will throw a verificati
J9NLS_CFR_ERR_INVALID_FLAGS_ON_NEW.user_response=Contact the provider of the class file for a corrected version.
# END NON-TRANSLATABLE

# <init> is not translatable
J9NLS_CFR_ERR_INIT_ON_VALUE_CLASS=Methods of value classes cannot be named <init>
# START NON-TRANSLATABLE
J9NLS_CFR_ERR_INIT_ON_VALUE_CLASS.explanation=Please consult the Java Virtual Machine Specification for a detailed explanation.
J9NLS_CFR_ERR_INIT_ON_VALUE_CLASS.system_action=The JVM will throw a verification or classloading related exception such as java.lang.ClassFormatError.
J9NLS_CFR_ERR_INIT_ON_VALUE_CLASS.user_response=Contact the provider of the class file for a corrected version.
# END NON-TRANSLATABLE

J9NLS_CFR_ERR_MISSING_ACC_STATIC_ON_ABSTRACT_IDENTITYLESS_CLASS_FIELD=In an abstract non-identity class, each field must be declared static.
# START NON-TRANSLATABLE
J9NLS_CFR_ERR_MISSING_ACC_STATIC_ON_ABSTRACT_IDENTITYLESS_CLASS_FIELD.explanation=Please consult the Java Virtual Machine Specification for a detailed explanation.
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 @@ -140,7 +140,7 @@

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

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

0 comments on commit 52b6b44

Please sign in to comment.