@@ -8777,6 +8777,19 @@ freeClassNativeMemory(J9HookInterface** hook, UDATA eventNum, void* eventData, v
87778777 J9Class * clazz = data -> clazz ;
87788778 PORT_ACCESS_FROM_JAVAVM (vm );
87798779
8780+ if (NULL != clazz -> jniIDs ) {
8781+ J9ClassLoader * classLoader = clazz -> classLoader ;
8782+ if (J9VM_SHOULD_KEEP_JNIIDS (vm , classLoader )) {
8783+ UDATA size = J9VM_NUM_OF_ENTRIES_IN_CLASS_JNIID_TABLE (clazz -> romClass );
8784+ for (UDATA i = 0 ; i < size ; i ++ ) {
8785+ J9GenericJNIID * id = (J9GenericJNIID * )(clazz -> jniIDs [i ]);
8786+ if (NULL != id ) {
8787+ memset (id , -1 , sizeof (J9GenericJNIID ));
8788+ }
8789+ }
8790+ }
8791+ }
8792+
87808793 /* Free the ID table for this class, but do not free any of the IDs. They will be freed by killing their
87818794 pools when the class loader is unloaded.
87828795 */
@@ -8870,7 +8883,7 @@ vmHookAnonClassesUnload(J9HookInterface** hook, UDATA eventNum, void* eventData,
88708883 J9ClassLoader * classLoader = j9clazz -> classLoader ;
88718884 /* Anon classes are unloaded piecemeal, so clear the map cache where the anon maps may be cached */
88728885 freeMapCaches (classLoader );
8873- if (J9VM_SHOULD_CLEAR_JNIIDS_FOR_ASGCT (vm , classLoader )) {
8886+ if (J9VM_SHOULD_KEEP_JNIIDS (vm , classLoader )) {
88748887 void * * jniIDs = j9clazz -> jniIDs ;
88758888 if (NULL != jniIDs ) {
88768889 UDATA size = J9VM_NUM_OF_ENTRIES_IN_CLASS_JNIID_TABLE (j9clazz -> romClass );
0 commit comments