Skip to content

Commit

Permalink
Vm update from Preload to LoadableDescriptor
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 11, 2024
1 parent 6d58520 commit d7ee5c0
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 33 deletions.
2 changes: 1 addition & 1 deletion runtime/bcutil/ClassFileOracle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ ClassFileOracle::walkAttributes()
_preloadAttribute = (J9CfrAttributePreload *)attrib;
for (U_16 numberOfClasses = 0; numberOfClasses < _preloadAttribute->numberOfClasses; numberOfClasses++) {
U_16 classCpIndex = _preloadAttribute->classes[numberOfClasses];
markClassAsReferenced(classCpIndex);
markConstantUTF8AsReferenced(classCpIndex);
}
break;
}
Expand Down
3 changes: 1 addition & 2 deletions runtime/bcutil/ClassFileOracle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1024,8 +1024,7 @@ class RecordComponentIterator
U_16 getPreloadClassNameAtIndex(U_16 index) const {
U_16 result = 0;
if (hasPreloadClasses()) {
U_16 classCpIndex = _preloadAttribute->classes[index];
result = _classFile->constantPool[classCpIndex].slot1;
result = _preloadAttribute->classes[index];
}
return result;
}
Expand Down
16 changes: 2 additions & 14 deletions runtime/bcutil/ClassFileWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ DECLARE_UTF8_ATTRIBUTE_NAME(BOOTSTRAP_METHODS, "BootstrapMethods");
DECLARE_UTF8_ATTRIBUTE_NAME(RECORD, "Record");
DECLARE_UTF8_ATTRIBUTE_NAME(PERMITTED_SUBCLASSES, "PermittedSubclasses");
#if defined(J9VM_OPT_VALHALLA_VALUE_TYPES)
DECLARE_UTF8_ATTRIBUTE_NAME(PRELOAD, "Preload");
DECLARE_UTF8_ATTRIBUTE_NAME(PRELOAD, "LoadableDescriptors");
#endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */
#if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES)
DECLARE_UTF8_ATTRIBUTE_NAME(IMPLICITCREATION, "ImplicitCreation");
Expand Down Expand Up @@ -1232,19 +1232,7 @@ ClassFileWriter::writeAttributes()

for (U_32 i = 0; i < numberPreloadClasses; i++) {
J9UTF8* preloadClassNameUtf8 = preloadClassNameAtIndex(preloadInfoPtr, i);
/* CONSTANT_Class_info index should be written. Find class entry that references the preload class name in constant pool. */
J9HashTableState hashTableState;
HashTableEntry * entry = (HashTableEntry *) hashTableStartDo(_cpHashTable, &hashTableState);
while (NULL != entry) {
if (CFR_CONSTANT_Class == entry->cpType) {
J9UTF8* classNameCandidate = (J9UTF8*)entry->address;
if (J9UTF8_EQUALS(classNameCandidate, preloadClassNameUtf8)) {
writeU16(entry->cpIndex);
break;
}
}
entry = (HashTableEntry *) hashTableNextDo(&hashTableState);
}
writeU16(indexForUTF8(preloadClassNameUtf8));
}
}
#endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */
Expand Down
2 changes: 1 addition & 1 deletion runtime/bcutil/attrlookup.gperf
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,5 @@ NestHost, CFR_ATTRIBUTE_NestHost, CFR_ATTRIBUTE_NestHost
Record, CFR_ATTRIBUTE_Record, CFR_ATTRIBUTE_Record
PermittedSubclasses, CFR_ATTRIBUTE_PermittedSubclasses, CFR_ATTRIBUTE_PermittedSubclasses
ImplicitCreation, CFR_ATTRIBUTE_ImplicitCreation, CFR_ATTRIBUTE_ImplicitCreation
Preload, CFR_ATTRIBUTE_Preload, CFR_ATTRIBUTE_Preload
LoadableDescriptors, CFR_ATTRIBUTE_Preload, CFR_ATTRIBUTE_Preload
NullRestricted, CFR_ATTRIBUTE_NullRestricted, CFR_ATTRIBUTE_NullRestricted
10 changes: 5 additions & 5 deletions runtime/bcutil/attrlookup.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ attributeHash (register const char *str, register size_t len)
51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
51, 31, 51, 51, 51, 15, 51, 51, 51, 5,
0, 0, 51, 51, 0, 51, 15, 0, 51, 51,
0, 0, 51, 51, 51, 51, 15, 0, 51, 51,
25, 0, 51, 51, 51, 51, 51, 51, 51, 51,
51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
Expand Down Expand Up @@ -121,8 +121,6 @@ lookupKnownAttribute (register const char *str, register size_t len)
{
#line 47 "attrlookup.gperf"
{"Code", CFR_ATTRIBUTE_Code, CFR_ATTRIBUTE_Code},
#line 76 "attrlookup.gperf"
{"Preload", CFR_ATTRIBUTE_Preload, CFR_ATTRIBUTE_Preload},
#line 49 "attrlookup.gperf"
{"Synthetic", CFR_ATTRIBUTE_Synthetic, CFR_ATTRIBUTE_Synthetic},
#line 53 "attrlookup.gperf"
Expand All @@ -141,6 +139,8 @@ lookupKnownAttribute (register const char *str, register size_t len)
{"AnnotationDefault", CFR_ATTRIBUTE_AnnotationDefault, CFR_ATTRIBUTE_AnnotationDefault},
#line 61 "attrlookup.gperf"
{"LocalVariableTable", CFR_ATTRIBUTE_LocalVariableTable, CFR_ATTRIBUTE_StrippedLocalVariableTable},
#line 76 "attrlookup.gperf"
{"LoadableDescriptors", CFR_ATTRIBUTE_Preload, CFR_ATTRIBUTE_Preload},
#line 62 "attrlookup.gperf"
{"SourceDebugExtension", CFR_ATTRIBUTE_SourceDebugExtension, CFR_ATTRIBUTE_StrippedSourceDebugExtension},
#line 75 "attrlookup.gperf"
Expand Down Expand Up @@ -185,8 +185,8 @@ lookupKnownAttribute (register const char *str, register size_t len)

static const signed char lookup[] =
{
-1, -1, -1, -1, 0, -1, -1, 1, -1, 2, 3, -1, 4, 5,
6, 7, 8, 9, 10, -1, 11, 12, 13, 14, 15, 16, -1, 17,
-1, -1, -1, -1, 0, -1, -1, -1, -1, 1, 2, -1, 3, 4,
5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, -1, 17,
18, 19, 20, 21, -1, -1, 22, 23, 24, 25, -1, 26, -1, 27,
28, -1, -1, -1, -1, 29, -1, -1, 30
};
Expand Down
8 changes: 4 additions & 4 deletions runtime/bcutil/cfreader.c
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,7 @@ readAttributes(J9CfrClassFile * classfile, J9CfrAttribute *** pAttributes, U_32
case CFR_ATTRIBUTE_Preload:
/* JVMS: There may be at most one Preload attribute in the attributes table of a ClassFile structure... */
if (preloadAttributeRead) {
errorCode = J9NLS_CFR_ERR_MULTIPLE_PRELOAD_ATTRIBUTES__ID;
errorCode = J9NLS_CFR_ERR_MULTIPLE_LOADABLEDESCRIPTORS_ATTRIBUTES__ID;
offset = address;
goto _errorFound;
}
Expand Down Expand Up @@ -2558,7 +2558,7 @@ checkAttributes(J9PortLibrary* portLib, J9CfrClassFile* classfile, J9CfrAttribut
break;
}
if ((0 != value) && (cpBase[value].tag != CFR_CONSTANT_Utf8)) {
errorCode = J9NLS_CFR_ERR_PRELOAD_NAME_NOT_UTF8__ID;
errorCode = J9NLS_CFR_ERR_LOADABLEDESCRIPTORS_NAME_NOT_UTF8__ID;
goto _errorFound;
break;
}
Expand All @@ -2570,8 +2570,8 @@ checkAttributes(J9PortLibrary* portLib, J9CfrClassFile* classfile, J9CfrAttribut
goto _errorFound;
break;
}
if ((0 != value) && (cpBase[value].tag != CFR_CONSTANT_Class)) {
errorCode = J9NLS_CFR_ERR_PRELOAD_CLASS_ENTRY_NOT_CLASS_TYPE__ID;
if ((0 != value) && (cpBase[value].tag != CFR_CONSTANT_Utf8)) {
errorCode = J9NLS_CFR_ERR_LOADABLEDESCRIPTORS_ENTRY_NOT_UTF8_TYPE__ID;
goto _errorFound;
break;
}
Expand Down
6 changes: 2 additions & 4 deletions runtime/cfdumper/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -933,13 +933,11 @@ static void dumpAttribute(J9CfrClassFile* classfile, J9CfrAttribute* attrib, U_3
#if defined(J9VM_OPT_VALHALLA_VALUE_TYPES)
case CFR_ATTRIBUTE_Preload:
for(i = 0; i < ((J9CfrAttributePreload*)attrib)->numberOfClasses; i++) {
U_16 classIndex = ((J9CfrAttributePreload*)attrib)->classes[i];
U_16 nameIndex = classfile->constantPool[classIndex].slot1;

U_16 descriptorIndex = ((J9CfrAttributePreload*)attrib)->classes[i];
for(j = 0; j < tabLevel + 1; j++) {
j9tty_printf(PORTLIB, " ");
}
j9tty_printf(PORTLIB, "Preload class index, name: %i, %i -> %s\n", classIndex, nameIndex, classfile->constantPool[nameIndex].bytes);
j9tty_printf(PORTLIB, "Preload class index, name: %i -> %s\n", descriptorIndex, classfile->constantPool[descriptorIndex].bytes);
}
break;
#endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */
Expand Down
24 changes: 24 additions & 0 deletions runtime/nls/cfre/cfrerr.nls
Original file line number Diff line number Diff line change
Expand Up @@ -1809,3 +1809,27 @@ J9NLS_CFR_ERR_STRICT_FIELD_MUST_BE_FINAL.explanation=Please consult the Java Vir
J9NLS_CFR_ERR_STRICT_FIELD_MUST_BE_FINAL.system_action=The JVM will throw a verification or classloading related exception such as java.lang.ClassFormatError.
J9NLS_CFR_ERR_STRICT_FIELD_MUST_BE_FINAL.user_response=Contact the provider of the classfile for a corrected version.
# END NON-TRANSLATABLE

# LoadableDescriptors is not translatable
J9NLS_CFR_ERR_MULTIPLE_LOADABLEDESCRIPTORS_ATTRIBUTES=Multiple LoadableDescriptors attributes
# START NON-TRANSLATABLE
J9NLS_CFR_ERR_MULTIPLE_LOADABLEDESCRIPTORS_ATTRIBUTES.explanation=Please consult the Java Virtual Machine Specification for a detailed explanation.
J9NLS_CFR_ERR_MULTIPLE_LOADABLEDESCRIPTORS_ATTRIBUTES.system_action=The JVM will throw a verification or classloading related exception such as java.lang.ClassFormatError.
J9NLS_CFR_ERR_MULTIPLE_LOADABLEDESCRIPTORS_ATTRIBUTES.user_response=Contact the provider of the classfile for a corrected version.
# END NON-TRANSLATABLE

# LoadableDescriptors is not translatable
J9NLS_CFR_ERR_LOADABLEDESCRIPTORS_NAME_NOT_UTF8=LoadableDescriptors name must be a string
# START NON-TRANSLATABLE
J9NLS_CFR_ERR_LOADABLEDESCRIPTORS_NAME_NOT_UTF8.explanation=Please consult the Java Virtual Machine Specification for a detailed explanation.
J9NLS_CFR_ERR_LOADABLEDESCRIPTORS_NAME_NOT_UTF8.system_action=The JVM will throw a verification or classloading related exception such as java.lang.ClassFormatError.
J9NLS_CFR_ERR_LOADABLEDESCRIPTORS_NAME_NOT_UTF8.user_response=Contact the provider of the classfile for a corrected version.
# END NON-TRANSLATABLE

# LoadableDescriptors is not translatable
J9NLS_CFR_ERR_LOADABLEDESCRIPTORS_ENTRY_NOT_UTF8_TYPE=descriptor in LoadableDescriptors attribute is not a UTF8 type
# START NON-TRANSLATABLE
J9NLS_CFR_ERR_LOADABLEDESCRIPTORS_ENTRY_NOT_UTF8_TYPE.explanation=Please consult the Java Virtual Machine Specification for a detailed explanation.
J9NLS_CFR_ERR_LOADABLEDESCRIPTORS_ENTRY_NOT_UTF8_TYPE.system_action=The JVM will throw a verification or classloading related exception such as java.lang.ClassFormatError.
J9NLS_CFR_ERR_LOADABLEDESCRIPTORS_ENTRY_NOT_UTF8_TYPE.user_response=Contact the provider of the classfile for a corrected version.
# END NON-TRANSLATABLE
15 changes: 13 additions & 2 deletions runtime/vm/createramclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2048,10 +2048,21 @@ loadFlattenableFieldValueClasses(J9VMThread *currentThread, J9ClassLoader *class

for (U_32 i = 0; i < *numberOfPreloadClassesPtr; i++) {
J9UTF8 *preloadClassNameUtf8 = preloadClassNameAtIndex(numberOfPreloadClassesPtr, i);

/* Use the full descriptor name for array or base type */
U_8 *preloadClassName = J9UTF8_DATA(preloadClassNameUtf8);
U_16 preloadClassLength = J9UTF8_LENGTH(preloadClassNameUtf8);
internalFindClassUTF8(currentThread, preloadClassName, preloadClassLength, classLoader, classPreloadFlags & ~J9_FINDCLASS_FLAG_THROW_ON_FAIL);
if (IS_CLASS_SIGNATURE(J9UTF8_DATA(preloadClassNameUtf8)[0])) {
/* Strip L/; from object type descriptors */
preloadClassName = &preloadClassName[1];
preloadClassLength = preloadClassLength - 2;

}
internalFindClassUTF8(
currentThread,
preloadClassName,
preloadClassLength,
classLoader,
classPreloadFlags & ~J9_FINDCLASS_FLAG_THROW_ON_FAIL);
}
}
done:
Expand Down

0 comments on commit d7ee5c0

Please sign in to comment.