From 6d58520e08f4a16e0613b7b6ab35c2ec65788483 Mon Sep 17 00:00:00 2001 From: Theresa Mammarella Date: Fri, 4 Oct 2024 09:47:56 -0400 Subject: [PATCH 1/3] ValhallaAttributeTests Preload to LoadableDescriptors Signed-off-by: Theresa Mammarella --- .../lworld/ValhallaAttributeGenerator.java | 10 +-- .../test/lworld/ValhallaAttributeTests.java | 67 +++++++++++++------ .../org/openj9/test/lworld/ValhallaUtils.java | 10 +-- 3 files changed, 56 insertions(+), 31 deletions(-) diff --git a/test/functional/Valhalla/src/org/openj9/test/lworld/ValhallaAttributeGenerator.java b/test/functional/Valhalla/src/org/openj9/test/lworld/ValhallaAttributeGenerator.java index 20cfa0df03c..141823a929f 100644 --- a/test/functional/Valhalla/src/org/openj9/test/lworld/ValhallaAttributeGenerator.java +++ b/test/functional/Valhalla/src/org/openj9/test/lworld/ValhallaAttributeGenerator.java @@ -28,15 +28,15 @@ public class ValhallaAttributeGenerator extends ClassLoader { private static ValhallaAttributeGenerator generator = new ValhallaAttributeGenerator(); - public static Class generateClassWithTwoPreloadAttributes(String name, String[] classList1, String[] classList2) throws Throwable { + public static Class generateClassWithTwoLoadableDescriptorsAttributes(String name, String[] classList1, String[] classList2) throws Throwable { byte[] bytes = generateClass(name, ValhallaUtils.ACC_IDENTITY, new Attribute[] { - new ValhallaUtils.PreloadAttribute(classList1), - new ValhallaUtils.PreloadAttribute(classList2)}); + new ValhallaUtils.LoadableDescriptorsAttribute(classList1), + new ValhallaUtils.LoadableDescriptorsAttribute(classList2)}); return generator.defineClass(name, bytes, 0, bytes.length); } - public static Class generateClassWithPreloadAttribute(String name, String[] classList) throws Throwable { - byte[] bytes = generateClass(name, ValhallaUtils.ACC_IDENTITY, new Attribute[] {new ValhallaUtils.PreloadAttribute(classList)}); + public static Class generateClassWithLoadableDescriptorsAttribute(String name, String[] classList) throws Throwable { + byte[] bytes = generateClass(name, ValhallaUtils.ACC_IDENTITY, new Attribute[] {new ValhallaUtils.LoadableDescriptorsAttribute(classList)}); return generator.defineClass(name, bytes, 0, bytes.length); } diff --git a/test/functional/Valhalla/src/org/openj9/test/lworld/ValhallaAttributeTests.java b/test/functional/Valhalla/src/org/openj9/test/lworld/ValhallaAttributeTests.java index c2678909ad4..8f557caa2bb 100644 --- a/test/functional/Valhalla/src/org/openj9/test/lworld/ValhallaAttributeTests.java +++ b/test/functional/Valhalla/src/org/openj9/test/lworld/ValhallaAttributeTests.java @@ -28,39 +28,64 @@ @Test(groups = { "level.sanity" }) public class ValhallaAttributeTests { - class MultiPreloadTest {} + class MultiLoadableDescriptorsTest {} - /* A class may have no more than one Preload attribute. */ - @Test(expectedExceptions = java.lang.ClassFormatError.class, expectedExceptionsMessageRegExp = ".*Multiple Preload attributes.*") - static public void testMultiplePreloadAttributes() throws Throwable { - String className = MultiPreloadTest.class.getName(); - ValhallaAttributeGenerator.generateClassWithTwoPreloadAttributes("MultiPreloadAttributes", - new String[]{className}, new String[]{className}); + /* A class may have no more than one LoadableDescriptors attribute. */ + @Test(expectedExceptions = java.lang.ClassFormatError.class, + expectedExceptionsMessageRegExp = ".*Multiple LoadableDescriptors attributes.*") + static public void testMultipleLoadableDescriptorsAttributes() throws Throwable { + String className = MultiLoadableDescriptorsTest.class.getName(); + ValhallaAttributeGenerator.generateClassWithTwoLoadableDescriptorsAttributes( + "MultiLoadableDescriptorsAttributes", + new String[]{"L" + className + ";"}, new String[]{"L" + className + ";"} + ); } - class PreloadClass {} + class LoadableDescriptorsClass {} @Test - static public void testPreloadBehavior() throws Throwable { - String className = PreloadClass.class.getName(); - /* Verify PreloadClass is not loaded */ + static public void testLoadableDescriptorsBehavior() throws Throwable { + String className = LoadableDescriptorsClass.class.getName(); + /* Verify LoadableDescriptorsClass is not loaded */ Assert.assertNull(ValhallaAttributeGenerator.findLoadedTestClass(className)); - /* Generate and load class that preloads PreloadClass */ - ValhallaAttributeGenerator.generateClassWithPreloadAttribute("PreloadBehavior", new String[]{className}); - /* Verify that PreloadClass is loaded */ + /* Generate and load class that preloads LoadableDescriptorsClass */ + ValhallaAttributeGenerator.generateClassWithLoadableDescriptorsAttribute( + "LoadableDescriptorsBehavior", + new String[]{"L" + className + ";"} + ); + /* Verify that LoadableDescriptorsClass is loaded */ Assert.assertNotNull(ValhallaAttributeGenerator.findLoadedTestClass(className)); } - value class PreloadValueClass {} + value class LoadableDescriptorsValueClass {} @Test - static public void testPreloadValueClassBehavior() throws Throwable { - String className = PreloadValueClass.class.getName(); - /* Verify PreloadValueClass is not loaded */ + static public void testLoadableDescriptorsValueClassBehavior() throws Throwable { + String className = LoadableDescriptorsValueClass.class.getName(); + /* Verify LoadableDescriptorsValueClass is not loaded */ Assert.assertNull(ValhallaAttributeGenerator.findLoadedTestClass(className)); - /* Generate and load class that preloads PreloadClass */ - ValhallaAttributeGenerator.generateClassWithPreloadAttribute("PreloadValueClassBehavior", new String[]{className}); - /* Verify that PreloadValueClass is loaded */ + /* Generate and load class that preloads LoadableDescriptorsClass */ + ValhallaAttributeGenerator.generateClassWithLoadableDescriptorsAttribute( + "LoadableDescriptorsValueClassBehavior", + new String[]{"L" + className + ";"} + ); + /* Verify that LoadableDescriptorsValueClass is loaded */ + Assert.assertNotNull(ValhallaAttributeGenerator.findLoadedTestClass(className)); + } + + class LoadableDescriptorsArrayClass {} + + @Test + static public void testLoadableDescriptorsArrayBehavior() throws Throwable { + String className = LoadableDescriptorsArrayClass.class.getName(); + /* Verify LoadableDescriptorsArrayClass is not loaded */ + Assert.assertNull(ValhallaAttributeGenerator.findLoadedTestClass(className)); + /* Generate and load class that preloads LoadableDescriptorsClass */ + ValhallaAttributeGenerator.generateClassWithLoadableDescriptorsAttribute( + "testLoadableDescriptorsArrayBehavior", + new String[]{"[L" + className + ";"} + ); + /* Verify that LoadableDescriptorsClass is loaded */ Assert.assertNotNull(ValhallaAttributeGenerator.findLoadedTestClass(className)); } diff --git a/test/functional/Valhalla/src/org/openj9/test/lworld/ValhallaUtils.java b/test/functional/Valhalla/src/org/openj9/test/lworld/ValhallaUtils.java index 8c2893676d0..8949f97f488 100644 --- a/test/functional/Valhalla/src/org/openj9/test/lworld/ValhallaUtils.java +++ b/test/functional/Valhalla/src/org/openj9/test/lworld/ValhallaUtils.java @@ -39,11 +39,11 @@ public class ValhallaUtils { static final int ACC_DEFAULT = 0x1; static final int ACC_NON_ATOMIC = 0x2; - final static class PreloadAttribute extends Attribute { + final static class LoadableDescriptorsAttribute extends Attribute { private final String[] classes; - public PreloadAttribute(String[] classes) { - super("Preload"); + public LoadableDescriptorsAttribute(String[] classes) { + super("LoadableDescriptors"); this.classes = classes; } @@ -65,8 +65,8 @@ public ByteVector write(ClassWriter cw, byte[] code, int len, int maxStack, int b.putShort(classes.length); int cpIndex; - for (int i = 0; i < classes.length; i++) { - cpIndex = cw.newClass(classes[i].replace('.', '/')); + for (String clazz : classes) { + cpIndex = cw.newUTF8(clazz.replace('.', '/')); b.putShort(cpIndex); } return b; From d7ee5c0e7a3aea47f30fc44215e8025045efefcc Mon Sep 17 00:00:00 2001 From: Theresa Mammarella Date: Wed, 9 Oct 2024 09:20:13 -0400 Subject: [PATCH 2/3] Vm update from Preload to LoadableDescriptor Signed-off-by: Theresa Mammarella --- runtime/bcutil/ClassFileOracle.cpp | 2 +- runtime/bcutil/ClassFileOracle.hpp | 3 +-- runtime/bcutil/ClassFileWriter.cpp | 16 ++-------------- runtime/bcutil/attrlookup.gperf | 2 +- runtime/bcutil/attrlookup.h | 10 +++++----- runtime/bcutil/cfreader.c | 8 ++++---- runtime/cfdumper/main.c | 6 ++---- runtime/nls/cfre/cfrerr.nls | 24 ++++++++++++++++++++++++ runtime/vm/createramclass.cpp | 15 +++++++++++++-- 9 files changed, 53 insertions(+), 33 deletions(-) diff --git a/runtime/bcutil/ClassFileOracle.cpp b/runtime/bcutil/ClassFileOracle.cpp index e2ba7de9dd1..dc3b49c52f1 100644 --- a/runtime/bcutil/ClassFileOracle.cpp +++ b/runtime/bcutil/ClassFileOracle.cpp @@ -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; } diff --git a/runtime/bcutil/ClassFileOracle.hpp b/runtime/bcutil/ClassFileOracle.hpp index 612144c4a4e..968277c5a3f 100644 --- a/runtime/bcutil/ClassFileOracle.hpp +++ b/runtime/bcutil/ClassFileOracle.hpp @@ -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; } diff --git a/runtime/bcutil/ClassFileWriter.cpp b/runtime/bcutil/ClassFileWriter.cpp index 0d360eaef82..ee93574d739 100644 --- a/runtime/bcutil/ClassFileWriter.cpp +++ b/runtime/bcutil/ClassFileWriter.cpp @@ -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"); @@ -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) */ diff --git a/runtime/bcutil/attrlookup.gperf b/runtime/bcutil/attrlookup.gperf index 15014e36c21..84887eef9a2 100644 --- a/runtime/bcutil/attrlookup.gperf +++ b/runtime/bcutil/attrlookup.gperf @@ -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 diff --git a/runtime/bcutil/attrlookup.h b/runtime/bcutil/attrlookup.h index 6b3b4c0ed07..e0e45493bf1 100644 --- a/runtime/bcutil/attrlookup.h +++ b/runtime/bcutil/attrlookup.h @@ -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, @@ -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" @@ -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" @@ -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 }; diff --git a/runtime/bcutil/cfreader.c b/runtime/bcutil/cfreader.c index 3f75406ea40..6854bdf633e 100644 --- a/runtime/bcutil/cfreader.c +++ b/runtime/bcutil/cfreader.c @@ -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; } @@ -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; } @@ -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; } diff --git a/runtime/cfdumper/main.c b/runtime/cfdumper/main.c index 13891ce941b..9f87d151301 100644 --- a/runtime/cfdumper/main.c +++ b/runtime/cfdumper/main.c @@ -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) */ diff --git a/runtime/nls/cfre/cfrerr.nls b/runtime/nls/cfre/cfrerr.nls index 2bbd4fd5666..4f376991f14 100644 --- a/runtime/nls/cfre/cfrerr.nls +++ b/runtime/nls/cfre/cfrerr.nls @@ -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 diff --git a/runtime/vm/createramclass.cpp b/runtime/vm/createramclass.cpp index 9282e96771f..b5e469f083f 100644 --- a/runtime/vm/createramclass.cpp +++ b/runtime/vm/createramclass.cpp @@ -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: From 25469bad2ea14977362264eb0f0b860417c4e7c9 Mon Sep 17 00:00:00 2001 From: Theresa Mammarella Date: Wed, 9 Oct 2024 14:45:01 -0400 Subject: [PATCH 3/3] Rename Preload to LoadableDescriptors Signed-off-by: Theresa Mammarella --- .../ibm/j9ddr/CompatibilityConstants29.dat | 2 +- .../src/com/ibm/j9ddr/vm29/j9/OptInfo.java | 24 +++--- .../vm29/pointer/helper/J9ROMClassHelper.java | 6 +- .../tools/ddrinteractive/RomClassWalker.java | 18 ++-- .../ddrinteractive/commands/J9BCUtil.java | 12 +-- runtime/bcutil/ClassFileOracle.cpp | 12 +-- runtime/bcutil/ClassFileOracle.hpp | 12 +-- runtime/bcutil/ClassFileWriter.cpp | 40 ++++----- runtime/bcutil/ROMClassBuilder.cpp | 4 +- runtime/bcutil/ROMClassWriter.cpp | 34 ++++---- runtime/bcutil/ROMClassWriter.hpp | 4 +- runtime/bcutil/attrlookup.gperf | 2 +- runtime/bcutil/attrlookup.h | 2 +- runtime/bcutil/cfreader.c | 34 ++++---- runtime/cfdumper/main.c | 10 +-- runtime/nls/cfre/cfrerr.nls | 4 +- runtime/oti/cfr.h | 10 +-- runtime/oti/j9nonbuilder.h | 2 +- runtime/oti/util_api.h | 24 +++--- runtime/util/optinfo.c | 20 ++--- runtime/util/rcdump.c | 20 ++--- runtime/util/romclasswalk.c | 22 ++--- runtime/vm/createramclass.cpp | 32 ++++--- .../test/lworld/ValhallaAttributeTests.java | 85 ++++++++++--------- .../org/openj9/test/lworld/ValhallaUtils.java | 6 +- 25 files changed, 223 insertions(+), 218 deletions(-) diff --git a/debugtools/DDR_VM/src/com/ibm/j9ddr/CompatibilityConstants29.dat b/debugtools/DDR_VM/src/com/ibm/j9ddr/CompatibilityConstants29.dat index 1a49c2c27d5..e44ed55bb6e 100644 --- a/debugtools/DDR_VM/src/com/ibm/j9ddr/CompatibilityConstants29.dat +++ b/debugtools/DDR_VM/src/com/ibm/j9ddr/CompatibilityConstants29.dat @@ -84,8 +84,8 @@ J9JavaClassFlags.J9ClassRequiresPrePadding = 0 J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_IMPLICITCREATION_ATTRIBUTE = 0 J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_INJECTED_INTERFACE_INFO = 0 +J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_LOADABLEDESCRIPTORS_ATTRIBUTE = 0 J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_PERMITTEDSUBCLASSES_ATTRIBUTE = 0 -J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_PRELOAD_ATTRIBUTE = 0 J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_RECORD_ATTRIBUTE = 0 J9Object.OBJECT_HEADER_LOCK_LEARNING = 0 diff --git a/debugtools/DDR_VM/src/com/ibm/j9ddr/vm29/j9/OptInfo.java b/debugtools/DDR_VM/src/com/ibm/j9ddr/vm29/j9/OptInfo.java index 10b3866e673..4d20e6f735a 100644 --- a/debugtools/DDR_VM/src/com/ibm/j9ddr/vm29/j9/OptInfo.java +++ b/debugtools/DDR_VM/src/com/ibm/j9ddr/vm29/j9/OptInfo.java @@ -27,8 +27,8 @@ import static com.ibm.j9ddr.vm29.structure.J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_ENCLOSING_METHOD; import static com.ibm.j9ddr.vm29.structure.J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_GENERIC_SIGNATURE; import static com.ibm.j9ddr.vm29.structure.J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_IMPLICITCREATION_ATTRIBUTE; +import static com.ibm.j9ddr.vm29.structure.J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_LOADABLEDESCRIPTORS_ATTRIBUTE; import static com.ibm.j9ddr.vm29.structure.J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_PERMITTEDSUBCLASSES_ATTRIBUTE; -import static com.ibm.j9ddr.vm29.structure.J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_PRELOAD_ATTRIBUTE; import static com.ibm.j9ddr.vm29.structure.J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_SIMPLE_NAME; import static com.ibm.j9ddr.vm29.structure.J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_SOURCE_DEBUG_EXTENSION; import static com.ibm.j9ddr.vm29.structure.J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_SOURCE_FILE_NAME; @@ -268,28 +268,28 @@ public static J9UTF8Pointer getPermittedSubclassNameAtIndex(J9ROMClassPointer ro return J9UTF8Pointer.NULL; } - public static int getPreloadClassCount(J9ROMClassPointer romClass) throws CorruptDataException { - U32Pointer preloadClassInfoPointer = getPreloadClassInfoPointer(romClass); - if (preloadClassInfoPointer.notNull()) { - return preloadClassInfoPointer.at(0).intValue(); + public static int getLoadableDescriptorsCount(J9ROMClassPointer romClass) throws CorruptDataException { + U32Pointer loadableDescriptorsInfoPointer = getLoadableDescriptorsInfoPointer(romClass); + if (loadableDescriptorsInfoPointer.notNull()) { + return loadableDescriptorsInfoPointer.at(0).intValue(); } return 0; } - private static U32Pointer getPreloadClassInfoPointer(J9ROMClassPointer romClass) throws CorruptDataException { + private static U32Pointer getLoadableDescriptorsInfoPointer(J9ROMClassPointer romClass) throws CorruptDataException { SelfRelativePointer srpPtr = getSRPPtr(J9ROMClassHelper.optionalInfo(romClass), romClass.optionalFlags(), - J9_ROMCLASS_OPTINFO_PRELOAD_ATTRIBUTE); + J9_ROMCLASS_OPTINFO_LOADABLEDESCRIPTORS_ATTRIBUTE); if (srpPtr.notNull()) { return U32Pointer.cast(srpPtr.get()); } return U32Pointer.NULL; } - public static J9UTF8Pointer getPreloadClassNameAtIndex(J9ROMClassPointer romClass, int index) throws CorruptDataException { - U32Pointer preloadClassInfoPointer = getPreloadClassInfoPointer(romClass); - if (preloadClassInfoPointer.notNull()) { - /* extra 1 is to move past the preload class count */ - SelfRelativePointer nameSrp = SelfRelativePointer.cast(preloadClassInfoPointer.add(index + 1)); + public static J9UTF8Pointer getLoadableDescriptorAtIndex(J9ROMClassPointer romClass, int index) throws CorruptDataException { + U32Pointer loadableDescriptorsInfoPointer = getLoadableDescriptorsInfoPointer(romClass); + if (loadableDescriptorsInfoPointer.notNull()) { + /* extra 1 is to move past the descriptors count */ + SelfRelativePointer nameSrp = SelfRelativePointer.cast(loadableDescriptorsInfoPointer.add(index + 1)); return J9UTF8Pointer.cast(nameSrp.get()); } return J9UTF8Pointer.NULL; diff --git a/debugtools/DDR_VM/src/com/ibm/j9ddr/vm29/pointer/helper/J9ROMClassHelper.java b/debugtools/DDR_VM/src/com/ibm/j9ddr/vm29/pointer/helper/J9ROMClassHelper.java index 0e478351e7a..92da433489d 100644 --- a/debugtools/DDR_VM/src/com/ibm/j9ddr/vm29/pointer/helper/J9ROMClassHelper.java +++ b/debugtools/DDR_VM/src/com/ibm/j9ddr/vm29/pointer/helper/J9ROMClassHelper.java @@ -23,7 +23,7 @@ import static com.ibm.j9ddr.vm29.structure.J9JavaAccessFlags.*; import static com.ibm.j9ddr.vm29.structure.J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_IMPLICITCREATION_ATTRIBUTE; -import static com.ibm.j9ddr.vm29.structure.J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_PRELOAD_ATTRIBUTE; +import static com.ibm.j9ddr.vm29.structure.J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_LOADABLEDESCRIPTORS_ATTRIBUTE; import com.ibm.j9ddr.CorruptDataException; import com.ibm.j9ddr.vm29.pointer.U32Pointer; @@ -135,8 +135,8 @@ public static boolean isSealed(J9ROMClassPointer romclass) throws CorruptDataExc return romclass.extraModifiers().allBitsIn(J9AccSealed); } - public static boolean hasPreloadAttribute(J9ROMClassPointer romclass) throws CorruptDataException { - return romclass.optionalFlags().allBitsIn(J9_ROMCLASS_OPTINFO_PRELOAD_ATTRIBUTE); + public static boolean hasLoadableDescriptorsAttribute(J9ROMClassPointer romclass) throws CorruptDataException { + return romclass.optionalFlags().allBitsIn(J9_ROMCLASS_OPTINFO_LOADABLEDESCRIPTORS_ATTRIBUTE); } public static boolean hasImplicitCreationAttribute(J9ROMClassPointer romclass) throws CorruptDataException { diff --git a/debugtools/DDR_VM/src/com/ibm/j9ddr/vm29/tools/ddrinteractive/RomClassWalker.java b/debugtools/DDR_VM/src/com/ibm/j9ddr/vm29/tools/ddrinteractive/RomClassWalker.java index a21d9b79ca9..69e519e7768 100644 --- a/debugtools/DDR_VM/src/com/ibm/j9ddr/vm29/tools/ddrinteractive/RomClassWalker.java +++ b/debugtools/DDR_VM/src/com/ibm/j9ddr/vm29/tools/ddrinteractive/RomClassWalker.java @@ -750,9 +750,9 @@ void allSlotsInOptionalInfoDo() throws CorruptDataException cursor = cursor.add(1); } - if (J9ROMClassHelper.hasPreloadAttribute(romClass)) { - classWalkerCallback.addSlot(clazz, SlotType.J9_SRP, cursor, "preloadAttributeSRP"); - preloadAttributeDo(U32Pointer.cast(cursor.get())); + if (J9ROMClassHelper.hasLoadableDescriptorsAttribute(romClass)) { + classWalkerCallback.addSlot(clazz, SlotType.J9_SRP, cursor, "loadableDescriptorsAttributeSRP"); + loadableDescriptorsAttributeDo(U32Pointer.cast(cursor.get())); cursor = cursor.add(1); } } @@ -1018,19 +1018,21 @@ void permittedSubclassAttributeDo(U32Pointer attribute) throws CorruptDataExcept classWalkerCallback.addSection(clazz, attributeStart, attribute.getAddress() - attributeStart.getAddress(), "permittedSubclass", true); } - void preloadAttributeDo(U32Pointer attribute) throws CorruptDataException + void loadableDescriptorsAttributeDo(U32Pointer attribute) throws CorruptDataException { if (attribute.isNull()) { return; } U32Pointer attributeStart = attribute; - classWalkerCallback.addSlot(clazz, SlotType.J9_U32, attribute, "numberPreloadClasses"); - for (int i = 0, numPreloadClasses = attribute.at(0).intValue(); i < numPreloadClasses; i++) { + classWalkerCallback.addSlot(clazz, SlotType.J9_U32, attribute, "numberLoadableDescriptors"); + for (int i = 0, numLoadableDescriptors = attribute.at(0).intValue(); i < numLoadableDescriptors; i++) { attribute = attribute.add(1); - classWalkerCallback.addSlot(clazz, SlotType.J9_ROM_UTF8, attribute, "preloadClassName"); + classWalkerCallback.addSlot(clazz, SlotType.J9_ROM_UTF8, attribute, "loadableDescriptorName"); } attribute = attribute.add(1); - classWalkerCallback.addSection(clazz, attributeStart, attribute.getAddress() - attributeStart.getAddress(), "preloadAttribute", true); + classWalkerCallback.addSection(clazz, attributeStart, + attribute.getAddress() - attributeStart.getAddress(), + "loadableDescriptorsAttribute", true); } void implicitCreationAttributeDo(U32Pointer attribute) throws CorruptDataException diff --git a/debugtools/DDR_VM/src/com/ibm/j9ddr/vm29/tools/ddrinteractive/commands/J9BCUtil.java b/debugtools/DDR_VM/src/com/ibm/j9ddr/vm29/tools/ddrinteractive/commands/J9BCUtil.java index 11021161591..b8fd1cb0f29 100644 --- a/debugtools/DDR_VM/src/com/ibm/j9ddr/vm29/tools/ddrinteractive/commands/J9BCUtil.java +++ b/debugtools/DDR_VM/src/com/ibm/j9ddr/vm29/tools/ddrinteractive/commands/J9BCUtil.java @@ -639,13 +639,13 @@ public static void j9bcutil_dumpRomClass(PrintStream out, J9ROMClassPointer romC } } - if (J9ROMClassHelper.hasPreloadAttribute(romClass)) { - int preloadClassCount = OptInfo.getPreloadClassCount(romClass); - out.format("Preload classes (%d):%n", preloadClassCount); + if (J9ROMClassHelper.hasLoadableDescriptorsAttribute(romClass)) { + int loadableDescriptorsCount = OptInfo.getLoadableDescriptorsCount(romClass); + out.format("Loadable Descriptors (%d):%n", loadableDescriptorsCount); - for (int i = 0; i < preloadClassCount; i++) { - J9UTF8Pointer preloadClassName = OptInfo.getPreloadClassNameAtIndex(romClass, i); - out.format(" %s%n", J9UTF8Helper.stringValue(preloadClassName)); + for (int i = 0; i < loadableDescriptorsCount; i++) { + J9UTF8Pointer loadableDescriptor = OptInfo.getLoadableDescriptorAtIndex(romClass, i); + out.format(" %s%n", J9UTF8Helper.stringValue(loadableDescriptor)); } } diff --git a/runtime/bcutil/ClassFileOracle.cpp b/runtime/bcutil/ClassFileOracle.cpp index dc3b49c52f1..359dea5c20a 100644 --- a/runtime/bcutil/ClassFileOracle.cpp +++ b/runtime/bcutil/ClassFileOracle.cpp @@ -231,7 +231,7 @@ ClassFileOracle::ClassFileOracle(BufferManager *bufferManager, J9CfrClassFile *c _isRecord(false), #if defined(J9VM_OPT_VALHALLA_VALUE_TYPES) _hasNonStaticSynchronizedMethod(false), - _preloadAttribute(NULL), + _loadableDescriptorsAttribute(NULL), #endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */ #if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) _hasImplicitCreationAttribute(false), @@ -632,11 +632,11 @@ ClassFileOracle::walkAttributes() break; } #if defined(J9VM_OPT_VALHALLA_VALUE_TYPES) - case CFR_ATTRIBUTE_Preload: { - _preloadAttribute = (J9CfrAttributePreload *)attrib; - for (U_16 numberOfClasses = 0; numberOfClasses < _preloadAttribute->numberOfClasses; numberOfClasses++) { - U_16 classCpIndex = _preloadAttribute->classes[numberOfClasses]; - markConstantUTF8AsReferenced(classCpIndex); + case CFR_ATTRIBUTE_LoadableDescriptors: { + _loadableDescriptorsAttribute = (J9CfrAttributeLoadableDescriptors *)attrib; + for (U_16 numberOfDescriptors = 0; numberOfDescriptors < _loadableDescriptorsAttribute->numberOfDescriptors; numberOfDescriptors++) { + U_16 descriptorCpIndex = _loadableDescriptorsAttribute->descriptors[numberOfDescriptors]; + markConstantUTF8AsReferenced(descriptorCpIndex); } break; } diff --git a/runtime/bcutil/ClassFileOracle.hpp b/runtime/bcutil/ClassFileOracle.hpp index 968277c5a3f..46854d04c04 100644 --- a/runtime/bcutil/ClassFileOracle.hpp +++ b/runtime/bcutil/ClassFileOracle.hpp @@ -1018,13 +1018,13 @@ class RecordComponentIterator U_16 getPermittedSubclassesClassCount() const { return _isSealed ? _permittedSubclassesAttribute->numberOfClasses : 0; } bool isValueBased() const { return _isClassValueBased; } #if defined(J9VM_OPT_VALHALLA_VALUE_TYPES) - bool hasPreloadClasses() const { return NULL != _preloadAttribute; } - U_16 getPreloadClassCount() const { return hasPreloadClasses() ? _preloadAttribute->numberOfClasses : 0; } + bool hasLoadableDescriptors() const { return NULL != _loadableDescriptorsAttribute; } + U_16 getLoadableDescriptorsCount() const { return hasLoadableDescriptors() ? _loadableDescriptorsAttribute->numberOfDescriptors : 0; } - U_16 getPreloadClassNameAtIndex(U_16 index) const { + U_16 getLoadableDescriptorAtIndex(U_16 index) const { U_16 result = 0; - if (hasPreloadClasses()) { - result = _preloadAttribute->classes[index]; + if (hasLoadableDescriptors()) { + result = _loadableDescriptorsAttribute->descriptors[index]; } return result; } @@ -1162,7 +1162,7 @@ class RecordComponentIterator J9CfrAttributeBootstrapMethods *_bootstrapMethodsAttribute; J9CfrAttributePermittedSubclasses *_permittedSubclassesAttribute; #if defined(J9VM_OPT_VALHALLA_VALUE_TYPES) - J9CfrAttributePreload *_preloadAttribute; + J9CfrAttributeLoadableDescriptors *_loadableDescriptorsAttribute; #endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */ #if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) bool _hasImplicitCreationAttribute; diff --git a/runtime/bcutil/ClassFileWriter.cpp b/runtime/bcutil/ClassFileWriter.cpp index ee93574d739..3d51ecc7586 100644 --- a/runtime/bcutil/ClassFileWriter.cpp +++ b/runtime/bcutil/ClassFileWriter.cpp @@ -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, "LoadableDescriptors"); +DECLARE_UTF8_ATTRIBUTE_NAME(LOADABLEDESCRIPTORS, "LoadableDescriptors"); #endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */ #if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) DECLARE_UTF8_ATTRIBUTE_NAME(IMPLICITCREATION, "ImplicitCreation"); @@ -118,14 +118,14 @@ ClassFileWriter::analyzeROMClass() } #if defined(J9VM_OPT_VALHALLA_VALUE_TYPES) - if (J9_ARE_ALL_BITS_SET(_romClass->optionalFlags, J9_ROMCLASS_OPTINFO_PRELOAD_ATTRIBUTE)) { - addEntry((void*) &PRELOAD, 0, CFR_CONSTANT_Utf8); + if (J9_ARE_ALL_BITS_SET(_romClass->optionalFlags, J9_ROMCLASS_OPTINFO_LOADABLEDESCRIPTORS_ATTRIBUTE)) { + addEntry((void *) &LOADABLEDESCRIPTORS, 0, CFR_CONSTANT_Utf8); - U_32 *preloadInfoPtr = getPreloadInfoPtr(_romClass); - U_32 numberOfPreloadClasses = *preloadInfoPtr; - for (U_32 i = 0; i < numberOfPreloadClasses; i++) { - J9UTF8* preloadClassNameUtf8 = preloadClassNameAtIndex(preloadInfoPtr, i); - addEntry(preloadClassNameUtf8, 0, CFR_CONSTANT_Utf8); + U_32 *loadableDescriptorsInfoPtr = getLoadableDescriptorsInfoPtr(_romClass); + U_32 numberOfLoadableDescriptors = *loadableDescriptorsInfoPtr; + for (U_32 i = 0; i < numberOfLoadableDescriptors; i++) { + J9UTF8 *loadableDescriptorUtf8 = loadableDescriptorAtIndex(loadableDescriptorsInfoPtr, i); + addEntry(loadableDescriptorUtf8, 0, CFR_CONSTANT_Utf8); } } #endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */ @@ -1044,7 +1044,7 @@ ClassFileWriter::writeAttributes() } #endif /* JAVA_SPEC_VERSION >= 11 */ #if defined(J9VM_OPT_VALHALLA_VALUE_TYPES) - if (J9_ARE_ALL_BITS_SET(_romClass->optionalFlags, J9_ROMCLASS_OPTINFO_PRELOAD_ATTRIBUTE)) { + if (J9_ARE_ALL_BITS_SET(_romClass->optionalFlags, J9_ROMCLASS_OPTINFO_LOADABLEDESCRIPTORS_ATTRIBUTE)) { attributesCount += 1; } #endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */ @@ -1222,17 +1222,17 @@ ClassFileWriter::writeAttributes() } #if defined(J9VM_OPT_VALHALLA_VALUE_TYPES) - /* write Preload attribute */ - if (J9_ARE_ALL_BITS_SET(_romClass->optionalFlags, J9_ROMCLASS_OPTINFO_PRELOAD_ATTRIBUTE)) { - U_32 *preloadInfoPtr = getPreloadInfoPtr(_romClass); - /* The first 32 bits of preloadInfoPtr contain the number of preload classes */ - U_32 numberPreloadClasses = *preloadInfoPtr; - writeAttributeHeader((J9UTF8 *) &PRELOAD, sizeof(U_16) + (numberPreloadClasses * sizeof(U_16))); - writeU16(numberPreloadClasses); - - for (U_32 i = 0; i < numberPreloadClasses; i++) { - J9UTF8* preloadClassNameUtf8 = preloadClassNameAtIndex(preloadInfoPtr, i); - writeU16(indexForUTF8(preloadClassNameUtf8)); + /* write LoadableDescriptors attribute */ + if (J9_ARE_ALL_BITS_SET(_romClass->optionalFlags, J9_ROMCLASS_OPTINFO_LOADABLEDESCRIPTORS_ATTRIBUTE)) { + U_32 *loadableDescriptorsInfoPtr = getLoadableDescriptorsInfoPtr(_romClass); + /* The first 32 bits of loadableDescriptorsInfoPtr contain the number of descriptors */ + U_32 numberLoadableDescriptors = *loadableDescriptorsInfoPtr; + writeAttributeHeader((J9UTF8 *) &LOADABLEDESCRIPTORS, sizeof(U_16) + (numberLoadableDescriptors * sizeof(U_16))); + writeU16(numberLoadableDescriptors); + + for (U_32 i = 0; i < numberLoadableDescriptors; i++) { + J9UTF8 *loadableDescriptorUtf8 = loadableDescriptorAtIndex(loadableDescriptorsInfoPtr, i); + writeU16(indexForUTF8(loadableDescriptorUtf8)); } } #endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */ diff --git a/runtime/bcutil/ROMClassBuilder.cpp b/runtime/bcutil/ROMClassBuilder.cpp index 5d8f985a3ca..d7adf4e65ef 100644 --- a/runtime/bcutil/ROMClassBuilder.cpp +++ b/runtime/bcutil/ROMClassBuilder.cpp @@ -1429,8 +1429,8 @@ ROMClassBuilder::computeOptionalFlags(ClassFileOracle *classFileOracle, ROMClass if (_interfaceInjectionInfo.numOfInterfaces > 0) { optionalFlags |= J9_ROMCLASS_OPTINFO_INJECTED_INTERFACE_INFO; } - if (classFileOracle->hasPreloadClasses()) { - optionalFlags |= J9_ROMCLASS_OPTINFO_PRELOAD_ATTRIBUTE; + if (classFileOracle->hasLoadableDescriptors()) { + optionalFlags |= J9_ROMCLASS_OPTINFO_LOADABLEDESCRIPTORS_ATTRIBUTE; } #endif /* J9VM_OPT_VALHALLA_VALUE_TYPES */ #if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) diff --git a/runtime/bcutil/ROMClassWriter.cpp b/runtime/bcutil/ROMClassWriter.cpp index 0c8bd6d346e..d938a606ba6 100644 --- a/runtime/bcutil/ROMClassWriter.cpp +++ b/runtime/bcutil/ROMClassWriter.cpp @@ -321,7 +321,7 @@ ROMClassWriter::ROMClassWriter(BufferManager *bufferManager, ClassFileOracle *cl #endif /* defined(J9VM_OPT_METHOD_HANDLE) */ #if defined(J9VM_OPT_VALHALLA_VALUE_TYPES) _injectedInterfaceInfoSRPKey(srpKeyProducer->generateKey()), - _preloadInfoSRPKey(srpKeyProducer->generateKey()), + _loadableDescriptorsInfoSRPKey(srpKeyProducer->generateKey()), #endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */ #if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) _implicitCreationSRPKey(srpKeyProducer->generateKey()), @@ -460,7 +460,7 @@ ROMClassWriter::writeROMClass(Cursor *cursor, writePermittedSubclasses(cursor, markAndCountOnly); #if defined(J9VM_OPT_VALHALLA_VALUE_TYPES) writeInjectedInterfaces(cursor, markAndCountOnly); - writePreload(cursor, markAndCountOnly); + writeloadableDescriptors(cursor, markAndCountOnly); #endif /* J9VM_OPT_VALHALLA_VALUE_TYPES */ #if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) writeImplicitCreation(cursor, markAndCountOnly); @@ -1913,30 +1913,30 @@ ROMClassWriter::writeImplicitCreation(Cursor *cursor, bool markAndCountOnly) #if defined(J9VM_OPT_VALHALLA_VALUE_TYPES) /* - * Preload ROM class layout: - * 4 bytes for number of classes (actually takes up two, but use 4 for alignment) - * for number of classes: - * 4 byte SRP to class name + * LoadableDescriptors ROM class layout: + * 4 bytes for number of descriptors (actually takes up two, but use 4 for alignment) + * for number of descriptors: + * 4 byte SRP to descriptor */ void -ROMClassWriter::writePreload(Cursor *cursor, bool markAndCountOnly) +ROMClassWriter::writeloadableDescriptors(Cursor *cursor, bool markAndCountOnly) { - if (_classFileOracle->hasPreloadClasses()) { - cursor->mark(_preloadInfoSRPKey); + if (_classFileOracle->hasLoadableDescriptors()) { + cursor->mark(_loadableDescriptorsInfoSRPKey); - U_16 classCount = _classFileOracle->getPreloadClassCount(); + U_16 descriptorCount = _classFileOracle->getLoadableDescriptorsCount(); if (markAndCountOnly) { cursor->skip(sizeof(U_32)); } else { - cursor->writeU32(classCount, Cursor::GENERIC); + cursor->writeU32(descriptorCount, Cursor::GENERIC); } - for (U_16 index = 0; index < classCount; index++) { + for (U_16 index = 0; index < descriptorCount; index++) { if (markAndCountOnly) { cursor->skip(sizeof(J9SRP)); } else { - U_16 classNameCpIndex = _classFileOracle->getPreloadClassNameAtIndex(index); - cursor->writeSRP(_srpKeyProducer->mapCfrConstantPoolIndexToKey(classNameCpIndex), Cursor::SRP_TO_UTF8); + U_16 descriptorCpIndex = _classFileOracle->getLoadableDescriptorAtIndex(index); + cursor->writeSRP(_srpKeyProducer->mapCfrConstantPoolIndexToKey(descriptorCpIndex), Cursor::SRP_TO_UTF8); } } } @@ -1993,7 +1993,7 @@ ROMClassWriter::writeOptionalInfo(Cursor *cursor) * SRP to record class component attributes * SRP to PermittedSubclasses attribute * SRP to injected interfaces info - * SRP to Preload attribute + * SRP to LoadableDescriptors attribute * SRP to ImplicitCreation attribute */ cursor->mark(_optionalInfoSRPKey); @@ -2040,8 +2040,8 @@ ROMClassWriter::writeOptionalInfo(Cursor *cursor) if (_interfaceInjectionInfo->numOfInterfaces > 0) { cursor->writeSRP(_injectedInterfaceInfoSRPKey, Cursor::SRP_TO_GENERIC); } - if (_classFileOracle->hasPreloadClasses()) { - cursor->writeSRP(_preloadInfoSRPKey, Cursor::SRP_TO_GENERIC); + if (_classFileOracle->hasLoadableDescriptors()) { + cursor->writeSRP(_loadableDescriptorsInfoSRPKey, Cursor::SRP_TO_GENERIC); } #endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */ #if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) diff --git a/runtime/bcutil/ROMClassWriter.hpp b/runtime/bcutil/ROMClassWriter.hpp index 54001611689..9f2cb3a01a3 100644 --- a/runtime/bcutil/ROMClassWriter.hpp +++ b/runtime/bcutil/ROMClassWriter.hpp @@ -154,7 +154,7 @@ class ROMClassWriter void writePermittedSubclasses(Cursor *cursor, bool markAndCountOnly); #if defined(J9VM_OPT_VALHALLA_VALUE_TYPES) void writeInjectedInterfaces(Cursor *cursor, bool markAndCountOnly); - void writePreload(Cursor *cursor, bool markAndCountOnly); + void writeloadableDescriptors(Cursor *cursor, bool markAndCountOnly); #endif /* J9VM_OPT_VALHALLA_VALUE_TYPES */ #if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) void writeImplicitCreation(Cursor *cursor, bool markAndCountOnly); @@ -197,7 +197,7 @@ class ROMClassWriter UDATA _permittedSubclassesInfoSRPKey; #if defined(J9VM_OPT_VALHALLA_VALUE_TYPES) UDATA _injectedInterfaceInfoSRPKey; - UDATA _preloadInfoSRPKey; + UDATA _loadableDescriptorsInfoSRPKey; #endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */ #if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) UDATA _implicitCreationSRPKey; diff --git a/runtime/bcutil/attrlookup.gperf b/runtime/bcutil/attrlookup.gperf index 84887eef9a2..c144c1a9e55 100644 --- a/runtime/bcutil/attrlookup.gperf +++ b/runtime/bcutil/attrlookup.gperf @@ -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 -LoadableDescriptors, CFR_ATTRIBUTE_Preload, CFR_ATTRIBUTE_Preload +LoadableDescriptors, CFR_ATTRIBUTE_LoadableDescriptors, CFR_ATTRIBUTE_LoadableDescriptors NullRestricted, CFR_ATTRIBUTE_NullRestricted, CFR_ATTRIBUTE_NullRestricted diff --git a/runtime/bcutil/attrlookup.h b/runtime/bcutil/attrlookup.h index e0e45493bf1..2434cfba33c 100644 --- a/runtime/bcutil/attrlookup.h +++ b/runtime/bcutil/attrlookup.h @@ -140,7 +140,7 @@ lookupKnownAttribute (register const char *str, register size_t len) #line 61 "attrlookup.gperf" {"LocalVariableTable", CFR_ATTRIBUTE_LocalVariableTable, CFR_ATTRIBUTE_StrippedLocalVariableTable}, #line 76 "attrlookup.gperf" - {"LoadableDescriptors", CFR_ATTRIBUTE_Preload, CFR_ATTRIBUTE_Preload}, + {"LoadableDescriptors", CFR_ATTRIBUTE_LoadableDescriptors, CFR_ATTRIBUTE_LoadableDescriptors}, #line 62 "attrlookup.gperf" {"SourceDebugExtension", CFR_ATTRIBUTE_SourceDebugExtension, CFR_ATTRIBUTE_StrippedSourceDebugExtension}, #line 75 "attrlookup.gperf" diff --git a/runtime/bcutil/cfreader.c b/runtime/bcutil/cfreader.c index 6854bdf633e..dc2d276e433 100644 --- a/runtime/bcutil/cfreader.c +++ b/runtime/bcutil/cfreader.c @@ -147,7 +147,7 @@ readAttributes(J9CfrClassFile * classfile, J9CfrAttribute *** pAttributes, U_32 J9CfrAttributeRecord *record; J9CfrAttributePermittedSubclasses *permittedSubclasses; #if defined(J9VM_OPT_VALHALLA_VALUE_TYPES) - J9CfrAttributePreload *preload; + J9CfrAttributeLoadableDescriptors *loadableDescriptors; #endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */ #if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) J9CfrAttributeImplicitCreation *implicitCreation; @@ -175,7 +175,7 @@ readAttributes(J9CfrClassFile * classfile, J9CfrAttribute *** pAttributes, U_32 BOOLEAN recordAttributeRead = FALSE; BOOLEAN permittedSubclassesAttributeRead = FALSE; #if defined(J9VM_OPT_VALHALLA_VALUE_TYPES) - BOOLEAN preloadAttributeRead = FALSE; + BOOLEAN loadableDescriptorsAttributeRead = FALSE; #endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */ #if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) BOOLEAN implicitCreationAttributeRead = FALSE; @@ -933,29 +933,31 @@ readAttributes(J9CfrClassFile * classfile, J9CfrAttribute *** pAttributes, U_32 break; #if defined(J9VM_OPT_VALHALLA_VALUE_TYPES) - case CFR_ATTRIBUTE_Preload: - /* JVMS: There may be at most one Preload attribute in the attributes table of a ClassFile structure... */ - if (preloadAttributeRead) { + case CFR_ATTRIBUTE_LoadableDescriptors: + /* JVMS: There may be at most one LoadableDescriptors attribute + * in the attributes table of a ClassFile structure... + */ + if (loadableDescriptorsAttributeRead) { errorCode = J9NLS_CFR_ERR_MULTIPLE_LOADABLEDESCRIPTORS_ATTRIBUTES__ID; offset = address; goto _errorFound; } - preloadAttributeRead = TRUE; + loadableDescriptorsAttributeRead = TRUE; - if (!ALLOC(preload, J9CfrAttributePreload)) { + if (!ALLOC(loadableDescriptors, J9CfrAttributeLoadableDescriptors)) { return -2; } - attrib = (J9CfrAttribute*)preload; + attrib = (J9CfrAttribute *)loadableDescriptors; CHECK_EOF(2); - NEXT_U16(preload->numberOfClasses, index); + NEXT_U16(loadableDescriptors->numberOfDescriptors, index); - if (!ALLOC_ARRAY(preload->classes, preload->numberOfClasses, U_16)) { + if (!ALLOC_ARRAY(loadableDescriptors->descriptors, loadableDescriptors->numberOfDescriptors, U_16)) { return -2; } - for (j = 0; j < preload->numberOfClasses; j++) { + for (j = 0; j < loadableDescriptors->numberOfDescriptors; j++) { CHECK_EOF(2); - NEXT_U16(preload->classes[j], index); + NEXT_U16(loadableDescriptors->descriptors[j], index); } break; #endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */ @@ -2550,8 +2552,8 @@ checkAttributes(J9PortLibrary* portLib, J9CfrClassFile* classfile, J9CfrAttribut break; #if defined(J9VM_OPT_VALHALLA_VALUE_TYPES) - case CFR_ATTRIBUTE_Preload: - value = ((J9CfrAttributePreload*)attrib)->nameIndex; + case CFR_ATTRIBUTE_LoadableDescriptors: + value = ((J9CfrAttributeLoadableDescriptors *)attrib)->nameIndex; if ((0 == value) || (value >= cpCount)) { errorCode = J9NLS_CFR_ERR_BAD_INDEX__ID; goto _errorFound; @@ -2563,8 +2565,8 @@ checkAttributes(J9PortLibrary* portLib, J9CfrClassFile* classfile, J9CfrAttribut break; } - for (j = 0; j < ((J9CfrAttributePreload*)attrib)->numberOfClasses; j++) { - value = ((J9CfrAttributePreload*)attrib)->classes[j]; + for (j = 0; j < ((J9CfrAttributeLoadableDescriptors *)attrib)->numberOfDescriptors; j++) { + value = ((J9CfrAttributeLoadableDescriptors *)attrib)->descriptors[j]; if ((0 == value) || (value >= cpCount)) { errorCode = J9NLS_CFR_ERR_BAD_INDEX__ID; goto _errorFound; diff --git a/runtime/cfdumper/main.c b/runtime/cfdumper/main.c index 9f87d151301..6584b810557 100644 --- a/runtime/cfdumper/main.c +++ b/runtime/cfdumper/main.c @@ -931,13 +931,13 @@ static void dumpAttribute(J9CfrClassFile* classfile, J9CfrAttribute* attrib, U_3 break; #if defined(J9VM_OPT_VALHALLA_VALUE_TYPES) - case CFR_ATTRIBUTE_Preload: - for(i = 0; i < ((J9CfrAttributePreload*)attrib)->numberOfClasses; i++) { - U_16 descriptorIndex = ((J9CfrAttributePreload*)attrib)->classes[i]; - for(j = 0; j < tabLevel + 1; j++) { + case CFR_ATTRIBUTE_LoadableDescriptors: + for (i = 0; i < ((J9CfrAttributeLoadableDescriptors *)attrib)->numberOfDescriptors; i++) { + U_16 descriptorIndex = ((J9CfrAttributeLoadableDescriptors *)attrib)->descriptors[i]; + for (j = 0; j < tabLevel + 1; j++) { j9tty_printf(PORTLIB, " "); } - j9tty_printf(PORTLIB, "Preload class index, name: %i -> %s\n", descriptorIndex, classfile->constantPool[descriptorIndex].bytes); + j9tty_printf(PORTLIB, "Loadable descriptor index, name: %i -> %s\n", descriptorIndex, classfile->constantPool[descriptorIndex].bytes); } break; #endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */ diff --git a/runtime/nls/cfre/cfrerr.nls b/runtime/nls/cfre/cfrerr.nls index 4f376991f14..735e731f19b 100644 --- a/runtime/nls/cfre/cfrerr.nls +++ b/runtime/nls/cfre/cfrerr.nls @@ -1811,7 +1811,7 @@ J9NLS_CFR_ERR_STRICT_FIELD_MUST_BE_FINAL.user_response=Contact the provider of t # END NON-TRANSLATABLE # LoadableDescriptors is not translatable -J9NLS_CFR_ERR_MULTIPLE_LOADABLEDESCRIPTORS_ATTRIBUTES=Multiple LoadableDescriptors attributes +J9NLS_CFR_ERR_MULTIPLE_LOADABLEDESCRIPTORS_ATTRIBUTES=Multiple LoadableDescriptors attributes detected, there may be at most one in a classfile # 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. @@ -1827,7 +1827,7 @@ J9NLS_CFR_ERR_LOADABLEDESCRIPTORS_NAME_NOT_UTF8.user_response=Contact the provid # END NON-TRANSLATABLE # LoadableDescriptors is not translatable -J9NLS_CFR_ERR_LOADABLEDESCRIPTORS_ENTRY_NOT_UTF8_TYPE=descriptor in LoadableDescriptors attribute is not a UTF8 type +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. diff --git a/runtime/oti/cfr.h b/runtime/oti/cfr.h index e1b6f7dbbf7..f492d4e5690 100644 --- a/runtime/oti/cfr.h +++ b/runtime/oti/cfr.h @@ -241,7 +241,7 @@ typedef struct J9CfrAttribute { #define CFR_ATTRIBUTE_NestHost 26 #define CFR_ATTRIBUTE_Record 27 #define CFR_ATTRIBUTE_PermittedSubclasses 28 -#define CFR_ATTRIBUTE_Preload 29 +#define CFR_ATTRIBUTE_LoadableDescriptors 29 #define CFR_ATTRIBUTE_ImplicitCreation 30 #define CFR_ATTRIBUTE_NullRestricted 31 #define CFR_ATTRIBUTE_StrippedLocalVariableTypeTable 122 @@ -535,14 +535,14 @@ typedef struct J9CfrAttributePermittedSubclasses { } J9CfrAttributePermittedSubclasses; #if defined(J9VM_OPT_VALHALLA_VALUE_TYPES) -typedef struct J9CfrAttributePreload { +typedef struct J9CfrAttributeLoadableDescriptors { U_8 tag; U_16 nameIndex; U_32 length; UDATA romAddress; - U_16 numberOfClasses; - U_16* classes; -} J9CfrAttributePreload; + U_16 numberOfDescriptors; + U_16 *descriptors; +} J9CfrAttributeLoadableDescriptors; #endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */ #if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) typedef struct J9CfrAttributeImplicitCreation { diff --git a/runtime/oti/j9nonbuilder.h b/runtime/oti/j9nonbuilder.h index 1667d1a2c98..21adf3f449c 100644 --- a/runtime/oti/j9nonbuilder.h +++ b/runtime/oti/j9nonbuilder.h @@ -258,7 +258,7 @@ #define J9_ROMCLASS_OPTINFO_CLASS_ANNOTATION_INFO 0x8000 #define J9_ROMCLASS_OPTINFO_VARIABLE_TABLE_HAS_GENERIC 0x10000 #if defined(J9VM_OPT_VALHALLA_VALUE_TYPES) -#define J9_ROMCLASS_OPTINFO_PRELOAD_ATTRIBUTE 0x20000 +#define J9_ROMCLASS_OPTINFO_LOADABLEDESCRIPTORS_ATTRIBUTE 0x20000 #endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */ #if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) #define J9_ROMCLASS_OPTINFO_IMPLICITCREATION_ATTRIBUTE 0x40000 diff --git a/runtime/oti/util_api.h b/runtime/oti/util_api.h index 2e336db22a9..e513e46f916 100644 --- a/runtime/oti/util_api.h +++ b/runtime/oti/util_api.h @@ -1353,26 +1353,28 @@ U_32 getNumberOfInjectedInterfaces(J9ROMClass *romClass); /** - * Retrieves number of preload classes in this class. Assumes that - * ROM class parameter references a class with preloaded classes. + * Retrieves number of loadable descriptors in this class. This method + * assumes that the ROM class parameter references a class with a + * LoadableDescriptors attribute. * * @param J9ROMClass class - * @return U_32* the first U_32 is the number of classes, followed by that number - * of constant pool indices. + * @return U_32 * the first U_32 is the number of classes, followed by that + * number of constant pool indices */ -U_32* -getPreloadInfoPtr(J9ROMClass *romClass); +U_32 * +getLoadableDescriptorsInfoPtr(J9ROMClass *romClass); /** - * Find the preload class name constant pool entry at index in the optional data of the ROM class parameter. - * This method assumes there is at least one preloaded class in the ROM class. + * Find the loadable descriptor constant pool entry at index in the optional + * data of the ROM class parameter. This method assumes there is at least one + * loadable descriptor in the ROM class. * - * @param U_32* the pointer returned by getPreloadInfoPtr + * @param U_32 * the pointer returned by getLoadableDescriptorsInfoPtr * @param U_32 class index - * @return the preload class name at index from ROM class + * @return the loadable descriptor at index from ROM class */ J9UTF8* -preloadClassNameAtIndex(U_32* permittedSubclassesCountPtr, U_32 index); +loadableDescriptorAtIndex(U_32 *permittedSubclassesCountPtr, U_32 index); #endif /* J9VM_OPT_VALHALLA_VALUE_TYPES */ #if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) diff --git a/runtime/util/optinfo.c b/runtime/util/optinfo.c index e8889bcb390..13f8299ef46 100644 --- a/runtime/util/optinfo.c +++ b/runtime/util/optinfo.c @@ -713,26 +713,26 @@ getNumberOfInjectedInterfaces(J9ROMClass *romClass) { Assert_VMUtil_true(ptr != NULL); - return *SRP_PTR_GET(ptr, U_32*); + return *SRP_PTR_GET(ptr, U_32 *); } -U_32* -getPreloadInfoPtr(J9ROMClass *romClass) +U_32 * +getLoadableDescriptorsInfoPtr(J9ROMClass *romClass) { - U_32 *ptr = getSRPPtr(J9ROMCLASS_OPTIONALINFO(romClass), romClass->optionalFlags, J9_ROMCLASS_OPTINFO_PRELOAD_ATTRIBUTE); + U_32 *ptr = getSRPPtr(J9ROMCLASS_OPTIONALINFO(romClass), romClass->optionalFlags, J9_ROMCLASS_OPTINFO_LOADABLEDESCRIPTORS_ATTRIBUTE); Assert_VMUtil_true(ptr != NULL); - return SRP_PTR_GET(ptr, U_32*); + return SRP_PTR_GET(ptr, U_32 *); } -J9UTF8* -preloadClassNameAtIndex(U_32* preloadInfoPtr, U_32 index) +J9UTF8 * +loadableDescriptorAtIndex(U_32 *loadableDescriptorsInfoPtr, U_32 index) { - /* SRPs to Preload name constant pool entries start after the preloadClassesCountPtr */ - U_32* preloadClassesPtr = preloadInfoPtr + 1 + index; + /* SRPs to loadable descriptors constant pool entries start after the count. */ + U_32 *loadableDescriptorsPtr = loadableDescriptorsInfoPtr + 1 + index; - return NNSRP_PTR_GET(preloadClassesPtr, J9UTF8*); + return NNSRP_PTR_GET(loadableDescriptorsPtr, J9UTF8 *); } #endif /* J9VM_OPT_VALHALLA_VALUE_TYPES */ #if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) diff --git a/runtime/util/rcdump.c b/runtime/util/rcdump.c index 50bc163af50..e5c2992b638 100644 --- a/runtime/util/rcdump.c +++ b/runtime/util/rcdump.c @@ -80,7 +80,7 @@ static I_32 dumpPermittedSubclasses(J9PortLibrary *portLib, J9ROMClass *romClass static I_32 dumpNest (J9PortLibrary *portLib, J9ROMClass *romClass, U_32 flags); #endif /* JAVA_SPEC_VERSION >= 11 */ #if defined(J9VM_OPT_VALHALLA_VALUE_TYPES) -static I_32 dumpPreloadClasses (J9PortLibrary *portLib, J9ROMClass *romClass); +static I_32 dumpLoadableDescriptors(J9PortLibrary *portLib, J9ROMClass *romClass); #endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */ #if defined(J9VM_OPT_VALHALLA_FLATTENABLE_VALUE_TYPES) static I_32 dumpImplicitCreationFlags (J9PortLibrary *portLib, J9ROMClass *romClass); @@ -197,8 +197,8 @@ IDATA j9bcutil_dumpRomClass( J9ROMClass *romClass, J9PortLibrary *portLib, J9Tra #endif /* JAVA_SPEC_VERSION >= 11 */ #if defined(J9VM_OPT_VALHALLA_VALUE_TYPES) - if (J9_ARE_ALL_BITS_SET(romClass->optionalFlags, J9_ROMCLASS_OPTINFO_PRELOAD_ATTRIBUTE)) { - dumpPreloadClasses(portLib, romClass); + if (J9_ARE_ALL_BITS_SET(romClass->optionalFlags, J9_ROMCLASS_OPTINFO_LOADABLEDESCRIPTORS_ATTRIBUTE)) { + dumpLoadableDescriptors(portLib, romClass); } #endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */ @@ -891,17 +891,17 @@ dumpNest(J9PortLibrary *portLib, J9ROMClass *romClass, U_32 flags) #if defined(J9VM_OPT_VALHALLA_VALUE_TYPES) static I_32 -dumpPreloadClasses(J9PortLibrary *portLib, J9ROMClass *romClass) +dumpLoadableDescriptors(J9PortLibrary *portLib, J9ROMClass *romClass) { PORT_ACCESS_FROM_PORT(portLib); - U_32* preloadInfoPtr = getPreloadInfoPtr(romClass); - U_32 preloadClassCount = *preloadInfoPtr; + U_32 *loadableDescriptorsInfoPtr = getLoadableDescriptorsInfoPtr(romClass); + U_32 loadableDescriptorsCount = *loadableDescriptorsInfoPtr; U_16 i = 0; - j9tty_printf(PORTLIB, "Preload classes (%i):\n", preloadClassCount); - for (; i < preloadClassCount; i++) { - J9UTF8* preloadClassNameUtf8 = preloadClassNameAtIndex(preloadInfoPtr, i); - j9tty_printf(PORTLIB, " %.*s\n", J9UTF8_LENGTH(preloadClassNameUtf8), J9UTF8_DATA(preloadClassNameUtf8)); + j9tty_printf(PORTLIB, "Loadable descriptors (%i):\n", loadableDescriptorsCount); + for (; i < loadableDescriptorsCount; i++) { + J9UTF8 *loadableDescriptorUtf8 = loadableDescriptorAtIndex(loadableDescriptorsInfoPtr, i); + j9tty_printf(PORTLIB, " %.*s\n", J9UTF8_LENGTH(loadableDescriptorUtf8), J9UTF8_DATA(loadableDescriptorUtf8)); } return BCT_ERR_NO_ERROR; } diff --git a/runtime/util/romclasswalk.c b/runtime/util/romclasswalk.c index 4389a76a5f6..0f03d50091c 100644 --- a/runtime/util/romclasswalk.c +++ b/runtime/util/romclasswalk.c @@ -853,31 +853,31 @@ allSlotsInPermittedSubclassesDo(J9ROMClass* romClass, U_32* permittedSubclassesP #if defined(J9VM_OPT_VALHALLA_VALUE_TYPES) static void -allSlotsInPreloadAttributeDo(J9ROMClass* romClass, U_32* preloadAttributePointer, J9ROMClassWalkCallbacks* callbacks, void* userData) +allSlotsInloadableDescriptorsAttributeDo(J9ROMClass *romClass, U_32 *loadableDescriptorsAttributePointer, J9ROMClassWalkCallbacks *callbacks, void *userData) { BOOLEAN rangeValid = FALSE; - U_32 *cursor = preloadAttributePointer; - U_32 preloadAttributeCount = 0; + U_32 *cursor = loadableDescriptorsAttributePointer; + U_32 loadableDescriptorsAttributeCount = 0; rangeValid = callbacks->validateRangeCallback(romClass, cursor, sizeof(U_32), userData); if (FALSE == rangeValid) { return; } - callbacks->slotCallback(romClass, J9ROM_U32, cursor, "preloadAttributeCount", userData); + callbacks->slotCallback(romClass, J9ROM_U32, cursor, "loadableDescriptorsAttributeCount", userData); cursor += 1; - preloadAttributeCount = *preloadAttributePointer; + loadableDescriptorsAttributeCount = *loadableDescriptorsAttributePointer; - for (; preloadAttributeCount > 0; preloadAttributeCount--) { + for (; loadableDescriptorsAttributeCount > 0; loadableDescriptorsAttributeCount--) { rangeValid = callbacks->validateRangeCallback(romClass, cursor, sizeof(U_32), userData); if (FALSE == rangeValid) { return; } - callbacks->slotCallback(romClass, J9ROM_UTF8, cursor, "className", userData); + callbacks->slotCallback(romClass, J9ROM_UTF8, cursor, "descriptorName", userData); cursor += 1; } - callbacks->sectionCallback(romClass, preloadAttributePointer, (UDATA)cursor - (UDATA)preloadAttributePointer, "preloadAttributeInfo", userData); + callbacks->sectionCallback(romClass, loadableDescriptorsAttributePointer, (UDATA)cursor - (UDATA)loadableDescriptorsAttributePointer, "loadableDescriptorsAttributeInfo", userData); } #endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */ @@ -997,11 +997,11 @@ allSlotsInOptionalInfoDo(J9ROMClass* romClass, J9ROMClassWalkCallbacks* callback cursor++; } - if (J9_ARE_ANY_BITS_SET(romClass->optionalFlags, J9_ROMCLASS_OPTINFO_PRELOAD_ATTRIBUTE)) { + if (J9_ARE_ANY_BITS_SET(romClass->optionalFlags, J9_ROMCLASS_OPTINFO_LOADABLEDESCRIPTORS_ATTRIBUTE)) { rangeValid = callbacks->validateRangeCallback(romClass, cursor, sizeof(J9SRP), userData); if (rangeValid) { - callbacks->slotCallback(romClass, J9ROM_SRP, cursor, "preloadAttributeSRP", userData); - allSlotsInPreloadAttributeDo(romClass, SRP_PTR_GET(cursor, U_32*), callbacks, userData); + callbacks->slotCallback(romClass, J9ROM_SRP, cursor, "loadableDescriptorsAttributeSRP", userData); + allSlotsInloadableDescriptorsAttributeDo(romClass, SRP_PTR_GET(cursor, U_32*), callbacks, userData); } cursor++; } diff --git a/runtime/vm/createramclass.cpp b/runtime/vm/createramclass.cpp index b5e469f083f..c39d18696e0 100644 --- a/runtime/vm/createramclass.cpp +++ b/runtime/vm/createramclass.cpp @@ -1938,7 +1938,7 @@ checkSuperClassAndInterfaces(J9VMThread *vmThread, J9ClassLoader *classLoader, J * class type (NullRestricted attribute) that are not both flattened * and recursively compatible for the fast substitutability optimization. * - * 5. Speculatively preload classes with a preload class attribute. No class loading + * 5. Speculatively load classes with a LoadableDescriptors attribute. No class loading * errors will be thrown if loading fails at this stage. * * Caller must not hold the classTableMutex. @@ -2039,28 +2039,26 @@ loadFlattenableFieldValueClasses(J9VMThread *currentThread, J9ClassLoader *class *valueTypeFlags |= (J9ClassHasReferences & superClazz->classFlags); } - /* Speculatively load classes with a preload attribute. + /* Speculatively load classes listed in the LoadableDescriptors attribute. * By this point classes of fields that may be eligible for * flattening have already been loaded. */ - if (J9_ARE_ALL_BITS_SET(romClass->optionalFlags, J9_ROMCLASS_OPTINFO_PRELOAD_ATTRIBUTE)) { - U_32 *numberOfPreloadClassesPtr = getPreloadInfoPtr(romClass); - - 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); - if (IS_CLASS_SIGNATURE(J9UTF8_DATA(preloadClassNameUtf8)[0])) { - /* Strip L/; from object type descriptors */ - preloadClassName = &preloadClassName[1]; - preloadClassLength = preloadClassLength - 2; - + if (J9_ARE_ALL_BITS_SET(romClass->optionalFlags, J9_ROMCLASS_OPTINFO_LOADABLEDESCRIPTORS_ATTRIBUTE)) { + U_32 *numberOfLoadableDescriptorsPtr = getLoadableDescriptorsInfoPtr(romClass); + for (U_32 i = 0; i < *numberOfLoadableDescriptorsPtr; i++) { + J9UTF8 *loadableDescriptorUtf8 = loadableDescriptorAtIndex(numberOfLoadableDescriptorsPtr, i); + /* Use the full descriptor name for array or base type. */ + U_8 *loadableDescriptorName = J9UTF8_DATA(loadableDescriptorUtf8); + U_16 loadableDescriptorLength = J9UTF8_LENGTH(loadableDescriptorUtf8); + if (IS_CLASS_SIGNATURE(loadableDescriptorName[0])) { + /* Strip L/; from object type descriptors. */ + loadableDescriptorName = &loadableDescriptorName[1]; + loadableDescriptorLength -= 2; } internalFindClassUTF8( currentThread, - preloadClassName, - preloadClassLength, + loadableDescriptorName, + loadableDescriptorLength, classLoader, classPreloadFlags & ~J9_FINDCLASS_FLAG_THROW_ON_FAIL); } diff --git a/test/functional/Valhalla/src/org/openj9/test/lworld/ValhallaAttributeTests.java b/test/functional/Valhalla/src/org/openj9/test/lworld/ValhallaAttributeTests.java index 8f557caa2bb..050df5575b7 100644 --- a/test/functional/Valhalla/src/org/openj9/test/lworld/ValhallaAttributeTests.java +++ b/test/functional/Valhalla/src/org/openj9/test/lworld/ValhallaAttributeTests.java @@ -28,70 +28,71 @@ @Test(groups = { "level.sanity" }) public class ValhallaAttributeTests { - class MultiLoadableDescriptorsTest {} + static class MultiLoadableDescriptorsTest {} /* A class may have no more than one LoadableDescriptors attribute. */ @Test(expectedExceptions = java.lang.ClassFormatError.class, expectedExceptionsMessageRegExp = ".*Multiple LoadableDescriptors attributes.*") - static public void testMultipleLoadableDescriptorsAttributes() throws Throwable { + public static void testMultipleLoadableDescriptorsAttributes() throws Throwable { String className = MultiLoadableDescriptorsTest.class.getName(); ValhallaAttributeGenerator.generateClassWithTwoLoadableDescriptorsAttributes( "MultiLoadableDescriptorsAttributes", - new String[]{"L" + className + ";"}, new String[]{"L" + className + ";"} + new String[]{"L" + className + ";"}, + new String[]{"L" + className + ";"} ); } - class LoadableDescriptorsClass {} + static class LoadableDescriptorsClass {} @Test - static public void testLoadableDescriptorsBehavior() throws Throwable { + public static void testLoadableDescriptorsBehavior() throws Throwable { String className = LoadableDescriptorsClass.class.getName(); - /* Verify LoadableDescriptorsClass is not loaded */ + /* Verify LoadableDescriptorsClass is not loaded. */ Assert.assertNull(ValhallaAttributeGenerator.findLoadedTestClass(className)); - /* Generate and load class that preloads LoadableDescriptorsClass */ + /* Generate and load class that preloads LoadableDescriptorsClass. */ ValhallaAttributeGenerator.generateClassWithLoadableDescriptorsAttribute( "LoadableDescriptorsBehavior", new String[]{"L" + className + ";"} ); - /* Verify that LoadableDescriptorsClass is loaded */ + /* Verify that LoadableDescriptorsClass is loaded. */ Assert.assertNotNull(ValhallaAttributeGenerator.findLoadedTestClass(className)); } - value class LoadableDescriptorsValueClass {} + static value class LoadableDescriptorsValueClass {} @Test - static public void testLoadableDescriptorsValueClassBehavior() throws Throwable { + public static void testLoadableDescriptorsValueClassBehavior() throws Throwable { String className = LoadableDescriptorsValueClass.class.getName(); - /* Verify LoadableDescriptorsValueClass is not loaded */ + /* Verify LoadableDescriptorsValueClass is not loaded. */ Assert.assertNull(ValhallaAttributeGenerator.findLoadedTestClass(className)); - /* Generate and load class that preloads LoadableDescriptorsClass */ + /* Generate and load class that preloads LoadableDescriptorsClass. */ ValhallaAttributeGenerator.generateClassWithLoadableDescriptorsAttribute( "LoadableDescriptorsValueClassBehavior", new String[]{"L" + className + ";"} ); - /* Verify that LoadableDescriptorsValueClass is loaded */ + /* Verify that LoadableDescriptorsValueClass is loaded. */ Assert.assertNotNull(ValhallaAttributeGenerator.findLoadedTestClass(className)); } - class LoadableDescriptorsArrayClass {} + static class LoadableDescriptorsArrayClass {} @Test - static public void testLoadableDescriptorsArrayBehavior() throws Throwable { + public static void testLoadableDescriptorsArrayBehavior() throws Throwable { String className = LoadableDescriptorsArrayClass.class.getName(); - /* Verify LoadableDescriptorsArrayClass is not loaded */ + /* Verify LoadableDescriptorsArrayClass is not loaded. */ Assert.assertNull(ValhallaAttributeGenerator.findLoadedTestClass(className)); - /* Generate and load class that preloads LoadableDescriptorsClass */ + /* Generate and load class that preloads LoadableDescriptorsClass. */ ValhallaAttributeGenerator.generateClassWithLoadableDescriptorsAttribute( "testLoadableDescriptorsArrayBehavior", new String[]{"[L" + className + ";"} ); - /* Verify that LoadableDescriptorsClass is loaded */ + /* Verify that LoadableDescriptorsClass is loaded. */ Assert.assertNotNull(ValhallaAttributeGenerator.findLoadedTestClass(className)); } /* A class may have no more than one ImplicitCreation attribute. */ @Test(expectedExceptions = java.lang.ClassFormatError.class, expectedExceptionsMessageRegExp = ".*Multiple ImplicitCreation attributes.*") - static public void testMultipleImplicitCreationAttributes() throws Throwable { + public static void testMultipleImplicitCreationAttributes() throws Throwable { ValhallaAttributeGenerator.generateClassWithTwoImplicitCreationAttributes("MultiImplicitCreationAttributes"); } @@ -99,25 +100,25 @@ static public void testMultipleImplicitCreationAttributes() throws Throwable { * In other words any non value class. */ @Test(expectedExceptions = java.lang.ClassFormatError.class, expectedExceptionsMessageRegExp = ".*The ImplicitCreation attribute is only allowed in a non-abstract value class.*") - static public void testNonValueTypeClassWithImplicitCreationAttribute() throws Throwable { + public static void testNonValueTypeClassWithImplicitCreationAttribute() throws Throwable { ValhallaAttributeGenerator.generateNonValueTypeClassWithImplicitCreationAttribute("NonValueTypeImplicitCreationAttribute"); } - /* There must be no more than one NullRestricted attribute in the attributes table of a field_info structure */ + /* There must be no more than one NullRestricted attribute in the attributes table of a field_info structure. */ @Test(expectedExceptions = java.lang.ClassFormatError.class, expectedExceptionsMessageRegExp = ".*Multiple NullRestricted attributes present.*") - static public void testMultipleNullRestrictedAttributes() throws Throwable { + public static void testMultipleNullRestrictedAttributes() throws Throwable { ValhallaAttributeGenerator.generateFieldWithMultipleNullRestrictedAttributes("TestMultipleNullRestrictedAttributes", "TestMultipleNullRestrictedAttributesField"); } /* There must not be a NullRestricted attribute in the attributes table of a field_info structure whose descriptor_index references a primitive type. */ @Test(expectedExceptions = java.lang.ClassFormatError.class, expectedExceptionsMessageRegExp = ".*A field with a primitive type cannot have a NullRestricted attribute.*") - static public void testNullRestrictedNotAllowedInPrimitiveField() throws Throwable { + public static void testNullRestrictedNotAllowedInPrimitiveField() throws Throwable { ValhallaAttributeGenerator.generateNullRestrictedAttributeInPrimitiveField("TestNullRestrictedNotAllowedInPrimitiveField"); } - /* There must not be a NullRestricted attribute in the attributes table of a field_info structure whose descriptor_index references an array type */ + /* There must not be a NullRestricted attribute in the attributes table of a field_info structure whose descriptor_index references an array type. */ @Test(expectedExceptions = java.lang.ClassFormatError.class, expectedExceptionsMessageRegExp = ".*A field with an array type cannot have a NullRestricted attribute.*") - static public void testNullRestrictedNotAllowedInArrayTypeField() throws Throwable { + public static void testNullRestrictedNotAllowedInArrayTypeField() throws Throwable { ValhallaAttributeGenerator.generateNullRestrictedAttributeInArrayField("TestNullRestrictedNotAllowedInArrayTypeField", "TestNullRestrictedNotAllowedInArrayTypeFieldField"); } @@ -125,7 +126,7 @@ static public void testNullRestrictedNotAllowedInArrayTypeField() throws Throwab * Failure for non-static fields should occur during class creation. */ @Test(expectedExceptions = java.lang.IncompatibleClassChangeError.class, expectedExceptionsMessageRegExp = ".*An instance field with a NullRestricted attribute must be in a value class with an implicit constructor.*") - static public void testNullRestrictedFieldMustBeInValueClass() throws Throwable { + public static void testNullRestrictedFieldMustBeInValueClass() throws Throwable { ValhallaAttributeGenerator.generateNullRestrictedAttributeInIdentityClass(false, "TestNullRestrictedFieldMustBeInValueClass", "TestNullRestrictedFieldMustBeInValueClassField"); } @@ -133,7 +134,7 @@ static public void testNullRestrictedFieldMustBeInValueClass() throws Throwable * Failure for non-static fields should occur during class creation. */ @Test(expectedExceptions = java.lang.IncompatibleClassChangeError.class, expectedExceptionsMessageRegExp = ".*An instance field with a NullRestricted attribute must be in a value class with an implicit constructor.*") - static public void testNullRestrictedFieldClassMustHaveImplicitCreation() throws Throwable { + public static void testNullRestrictedFieldClassMustHaveImplicitCreation() throws Throwable { ValhallaAttributeGenerator.generateNullRestrictedAttributeInValueClassWithoutIC(false, "TestNullRestrictedFieldClassMustHaveImplicitCreation", "TestNullRestrictedFieldClassMustHaveImplicitCreationField"); } @@ -141,7 +142,7 @@ static public void testNullRestrictedFieldClassMustHaveImplicitCreation() throws * Failure for non-static fields should occur during class creation. */ @Test(expectedExceptions = java.lang.IncompatibleClassChangeError.class, expectedExceptionsMessageRegExp = ".*An instance field with a NullRestricted attribute must be in a value class with an implicit constructor.*") - static public void testNullRestrictedFieldWhereImplicitCreationHasNoDefaultFlag() throws Throwable { + public static void testNullRestrictedFieldWhereImplicitCreationHasNoDefaultFlag() throws Throwable { ValhallaAttributeGenerator.generateNullRestrictedFieldWhereICHasNoDefaultFlag(false, "TestNullRestrictedAttributeWhereImplicitCreationHasNoDefaultFlag", "TestNullRestrictedAttributeWhereImplicitCreationHasNoDefaultFlagField"); } @@ -149,7 +150,7 @@ static public void testNullRestrictedFieldWhereImplicitCreationHasNoDefaultFlag( * Static fields should fail during the preparation stage of linking. */ @Test(expectedExceptions = java.lang.IncompatibleClassChangeError.class, expectedExceptionsMessageRegExp = ".*A static field with a NullRestricted attribute must be in a value class with an implicit constructor.*") - static public void testStaticNullRestrictedFieldMustBeInValueClass() throws Throwable { + public static void testStaticNullRestrictedFieldMustBeInValueClass() throws Throwable { Class c = ValhallaAttributeGenerator.generateNullRestrictedAttributeInIdentityClass(true, "TestStaticNullRestrictedFieldMustBeInValueClass", "TestStaticNullRestrictedFieldMustBeInValueClassField"); c.newInstance(); } @@ -158,7 +159,7 @@ static public void testStaticNullRestrictedFieldMustBeInValueClass() throws Thro * Static fields should fail during the preparation stage of linking. */ @Test(expectedExceptions = java.lang.IncompatibleClassChangeError.class, expectedExceptionsMessageRegExp = ".*A static field with a NullRestricted attribute must be in a value class with an implicit constructor.*") - static public void testStaticNullRestrictedFieldClassMustHaveImplicitCreation() throws Throwable { + public static void testStaticNullRestrictedFieldClassMustHaveImplicitCreation() throws Throwable { Class c = ValhallaAttributeGenerator.generateNullRestrictedAttributeInValueClassWithoutIC(true, "TestStaticNullRestrictedFieldClassMustHaveImplicitCreation", "TestStaticNullRestrictedFieldClassMustHaveImplicitCreationField"); c.newInstance(); } @@ -167,33 +168,33 @@ static public void testStaticNullRestrictedFieldClassMustHaveImplicitCreation() * Static fields should fail during the preparation stage of linking. */ @Test(expectedExceptions = java.lang.IncompatibleClassChangeError.class, expectedExceptionsMessageRegExp = ".*A static field with a NullRestricted attribute must be in a value class with an implicit constructor.*") - static public void testStaticNullRestrictedFieldWhereImplicitCreationHasNoDefaultFlag() throws Throwable { + public static void testStaticNullRestrictedFieldWhereImplicitCreationHasNoDefaultFlag() throws Throwable { Class c = ValhallaAttributeGenerator.generateNullRestrictedFieldWhereICHasNoDefaultFlag(true, "TestStaticNullRestrictedAttributeWhereImplicitCreationHasNoDefaultFlag", "TestStaticNullRestrictedAttributeWhereImplicitCreationHasNoDefaultFlagField"); c.newInstance(); } @Test - static public void testPutFieldNullToValueTypeField() throws Throwable { + public static void testPutFieldNullToValueTypeField() throws Throwable { Class c = ValhallaAttributeGenerator.generatePutFieldNullToField("TestPutFieldNullToValueTypeField", "TestPutFieldNullToValueTypeFieldField", false); c.newInstance(); } - static public Class testPutFieldNullToNullRestrictedFieldClass = null; - static public Class testPutStaticNullToNullRestrictedFieldClass = null; + public static Class testPutFieldNullToNullRestrictedFieldClass = null; + public static Class testPutStaticNullToNullRestrictedFieldClass = null; @Test(priority=1) - static public void testCreateTestPutFieldNullToNullRestrictedField() throws Throwable { + public static void testCreateTestPutFieldNullToNullRestrictedField() throws Throwable { testPutFieldNullToNullRestrictedFieldClass = ValhallaAttributeGenerator.generatePutFieldNullToField("TestPutFieldNullToNullRestrictedField", "TestPutFieldNullToNullRestrictedFieldField", true); } /* Instance field with NullRestricted attribute cannot be set to null. */ @Test(priority=2, invocationCount=2, expectedExceptions = java.lang.NullPointerException.class) - static public void testPutFieldNullToNullRestrictedField() throws Throwable { + public static void testPutFieldNullToNullRestrictedField() throws Throwable { testPutFieldNullToNullRestrictedFieldClass.newInstance(); } @Test(priority=1) - static public void testCreateTestPutStaticNullToNullRestrictedField() throws Throwable { + public static void testCreateTestPutStaticNullToNullRestrictedField() throws Throwable { testPutStaticNullToNullRestrictedFieldClass = ValhallaAttributeGenerator.generatePutStaticNullToNullRestrictedField("TestPutStaticNullToNullRestrictedField", "TestPutStaticNullToNullRestrictedFieldField"); } @@ -204,7 +205,7 @@ static public void testCreateTestPutStaticNullToNullRestrictedField() throws Thr * Since value fields are implicitly final this will always be the case. */ @Test(priority=2, invocationCount=2) - static public void testPutStaticNullToNullRestrictedField() throws Throwable { + public static void testPutStaticNullToNullRestrictedField() throws Throwable { try { testPutStaticNullToNullRestrictedFieldClass.newInstance(); } catch(java.lang.ExceptionInInitializerError e) { @@ -231,9 +232,9 @@ static value class ImplicitClass { } } - /* Test to verify JVM_IsImplicitlyConstructibleClass */ + /* Test to verify JVM_IsImplicitlyConstructibleClass. */ @Test - static public void testValueClassIsImplicitlyConstructible() { + public static void testValueClassIsImplicitlyConstructible() { ImplicitClass ic = (ImplicitClass)jdk.internal.value.ValueClass.zeroInstance(ImplicitClass.class); } @@ -244,9 +245,9 @@ static value class NonImplicitClass { } } - /* Test to verify JVM_IsImplicitlyConstructibleClass */ + /* Test to verify JVM_IsImplicitlyConstructibleClass. */ @Test(expectedExceptions = IllegalArgumentException.class) - static public void testValueClassIsImplicitlyConstructible2() { + public static void testValueClassIsImplicitlyConstructible2() { jdk.internal.value.ValueClass.zeroInstance(NonImplicitClass.class); } } diff --git a/test/functional/Valhalla/src/org/openj9/test/lworld/ValhallaUtils.java b/test/functional/Valhalla/src/org/openj9/test/lworld/ValhallaUtils.java index 8949f97f488..4259ca809ca 100644 --- a/test/functional/Valhalla/src/org/openj9/test/lworld/ValhallaUtils.java +++ b/test/functional/Valhalla/src/org/openj9/test/lworld/ValhallaUtils.java @@ -39,7 +39,7 @@ public class ValhallaUtils { static final int ACC_DEFAULT = 0x1; static final int ACC_NON_ATOMIC = 0x2; - final static class LoadableDescriptorsAttribute extends Attribute { + static final class LoadableDescriptorsAttribute extends Attribute { private final String[] classes; public LoadableDescriptorsAttribute(String[] classes) { @@ -73,7 +73,7 @@ public ByteVector write(ClassWriter cw, byte[] code, int len, int maxStack, int } } - final static class ImplicitCreationAttribute extends Attribute { + static final class ImplicitCreationAttribute extends Attribute { private final int flags; public ImplicitCreationAttribute() { @@ -106,7 +106,7 @@ public ByteVector write(ClassWriter cw, byte[] code, int len, int maxStack, int } } - final static class NullRestrictedAttribute extends Attribute { + static final class NullRestrictedAttribute extends Attribute { public NullRestrictedAttribute() { super("NullRestricted"); }