Skip to content

Commit

Permalink
Remove type checks for VT <init> method in constant pool
Browse files Browse the repository at this point in the history
The check is unnecessary and throws a ClassFormatError
when trying to verify a value class which calls a
non-value class constructor
  • Loading branch information
Ehren Julien-Neitzert committed Nov 4, 2022
1 parent a31c794 commit f19e774
Showing 1 changed file with 2 additions and 29 deletions.
31 changes: 2 additions & 29 deletions runtime/bcverify/staticverify.c
Original file line number Diff line number Diff line change
Expand Up @@ -1794,40 +1794,13 @@ j9bcv_verifyClassStructure (J9PortLibrary * portLib, J9CfrClassFile * classfile,
&& !isConstantInvokeDynamic
#endif /* JAVA_SPEC_VERSION >= 18 */
) {
BOOLEAN invalidRetType = FALSE;
if (
#if defined(J9VM_OPT_VALHALLA_VALUE_TYPES)
#if defined(J9VM_OPT_VALHALLA_NEW_FACTORY_METHOD)
(CFR_METHOD_NAME_NEW == isInit)
#else /* #if defined(J9VM_OPT_VALHALLA_NEW_FACTORY_METHOD) */
(CFR_METHOD_NAME_INIT == isInit) && J9_IS_CLASSFILE_VALUETYPE(classfile)
#endif /* #if defined(J9VM_OPT_VALHALLA_NEW_FACTORY_METHOD) */
#else /* #if defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */
FALSE
#endif /* #if defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */
) {
U_16 returnChar = getReturnTypeFromSignature(info->bytes, info->slot1, NULL);
if (J9_IS_CLASSFILE_PRIMITIVE_VALUETYPE(classfile)) {
if (!IS_QTYPE(returnChar)) {
invalidRetType = TRUE;
}
} else {
if (!IS_LTYPE(returnChar)) {
invalidRetType = TRUE;
}
}
/* This #if !defined check should be removed (along with all other code that references J9VM_OPT_VALHALLA_NEW_FACTORY_METHOD) once the <vnew> method is introduced */
#if !defined(J9VM_OPT_VALHALLA_VALUE_TYPES)
} else {
if (info->bytes[info->slot1 - 1] != 'V') {
invalidRetType = TRUE;
}
#endif /* #if !defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */
}
if (invalidRetType) {
if (info->bytes[info->slot1 - 1] != 'V') {
errorType = J9NLS_CFR_ERR_BC_METHOD_INVALID_SIG__ID;
goto _formatError;
}
#endif /* #if !defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */
}
if (argCount > 255) {
errorType = J9NLS_CFR_ERR_TOO_MANY_ARGS__ID;
Expand Down

0 comments on commit f19e774

Please sign in to comment.