@@ -1851,7 +1851,6 @@ JVM_ENTRY(jobjectArray, JVM_GetClassDeclaredFields(JNIEnv *env, jclass ofClass,
1851
1851
}
1852
1852
JVM_END
1853
1853
1854
-
1855
1854
// A class is a record if and only if it is final and a direct subclass of
1856
1855
// java.lang.Record and has a Record attribute; otherwise, it is not a record.
1857
1856
JVM_ENTRY (jboolean, JVM_IsRecord(JNIEnv *env, jclass cls))
@@ -2127,10 +2126,16 @@ JVM_ENTRY(jobjectArray, JVM_GetPermittedSubclasses(JNIEnv* env, jclass current))
2127
2126
Klass* c = java_lang_Class::as_Klass (mirror);
2128
2127
assert (c->is_instance_klass (), " must be" );
2129
2128
InstanceKlass* ik = InstanceKlass::cast (c);
2129
+ ResourceMark rm (THREAD);
2130
+ log_trace (class , sealed)(" Calling GetPermittedSubclasses for %s type %s" ,
2131
+ ik->is_sealed () ? " sealed" : " non-sealed" , ik->external_name ());
2130
2132
if (ik->is_sealed ()) {
2131
2133
JvmtiVMObjectAllocEventCollector oam;
2132
2134
Array<u2>* subclasses = ik->permitted_subclasses ();
2133
2135
int length = subclasses->length ();
2136
+
2137
+ log_trace (class , sealed)(" - sealed class has %d permitted subclasses" , length);
2138
+
2134
2139
objArrayOop r = oopFactory::new_objArray (SystemDictionary::Class_klass (),
2135
2140
length, CHECK_NULL);
2136
2141
objArrayHandle result (THREAD, r);
@@ -2142,14 +2147,24 @@ JVM_ENTRY(jobjectArray, JVM_GetPermittedSubclasses(JNIEnv* env, jclass current))
2142
2147
if (PENDING_EXCEPTION->is_a (SystemDictionary::VirtualMachineError_klass ())) {
2143
2148
return NULL ; // propagate VMEs
2144
2149
}
2150
+ if (log_is_enabled (Trace, class , sealed)) {
2151
+ stringStream ss;
2152
+ char * permitted_subclass = ik->constants ()->klass_name_at (cp_index)->as_C_string ();
2153
+ ss.print (" - resolution of permitted subclass %s failed: " , permitted_subclass);
2154
+ java_lang_Throwable::print (PENDING_EXCEPTION, &ss);
2155
+ log_trace (class , sealed)(" %s" , ss.as_string ());
2156
+ }
2157
+
2145
2158
CLEAR_PENDING_EXCEPTION;
2146
2159
continue ;
2147
2160
}
2148
2161
if (k->is_instance_klass ()) {
2149
2162
result->obj_at_put (count++, k->java_mirror ());
2163
+ log_trace (class , sealed)(" - [%d] = %s" , count, k->external_name ());
2150
2164
}
2151
2165
}
2152
2166
if (count < length) {
2167
+ // we had invalid entries so we need to compact the array
2153
2168
objArrayOop r2 = oopFactory::new_objArray (SystemDictionary::Class_klass (),
2154
2169
count, CHECK_NULL);
2155
2170
objArrayHandle result2 (THREAD, r2);
0 commit comments