@@ -165,46 +165,43 @@ void LambdaFormInvokers::regenerate_holder_classes(TRAPS) {
165
165
assert (h_bytes != NULL , " Class bytes is NULL" );
166
166
167
167
char *class_name = java_lang_String::as_utf8_string (h_name ());
168
- int len = h_bytes->length ();
169
- // make a copy of class bytes so GC will not affect us.
170
- char *buf = NEW_RESOURCE_ARRAY (char , len);
171
- memcpy (buf, (char *)h_bytes->byte_at_addr (0 ), len);
172
- ClassFileStream st ((u1*)buf, len, NULL , ClassFileStream::verify);
173
- regenerate_class (class_name, st, CHECK);
174
- }
175
- }
176
-
177
- // check if a class name is a species
178
- bool is_a_species (const char * species_name) {
179
- log_info (cds)(" Checking class %s" , species_name);
180
- if (strstr (species_name, " java/lang/invoke/BoundMethodHandle$Species_" ) != nullptr ) {
181
- return true ;
168
+ if (strstr (class_name, " java/lang/invoke/BoundMethodHandle$Species_" ) != nullptr ) {
169
+ // The species classes are already loaded into the system dictionary
170
+ // during the execution of CDS.generateLambdaFormHolderClasses(). No
171
+ // need to regenerate.
172
+ TempNewSymbol class_name_sym = SymbolTable::new_symbol (class_name);
173
+ Klass* klass = SystemDictionary::resolve_or_null (class_name_sym, THREAD);
174
+ assert (klass != NULL , " must already be loaded" );
175
+ if (!klass->is_shared () && klass->shared_classpath_index () < 0 ) {
176
+ // Fake it, so that it will be included into the archive.
177
+ klass->set_shared_classpath_index (0 );
178
+ // Set the "generated" bit, so it won't interfere with JVMTI.
179
+ // See SystemDictionaryShared::find_builtin_class().
180
+ klass->set_is_generated_shared_class ();
181
+ }
182
+ } else {
183
+ int len = h_bytes->length ();
184
+ // make a copy of class bytes so GC will not affect us.
185
+ char *buf = NEW_RESOURCE_ARRAY (char , len);
186
+ memcpy (buf, (char *)h_bytes->byte_at_addr (0 ), len);
187
+ ClassFileStream st ((u1*)buf, len, NULL , ClassFileStream::verify);
188
+ regenerate_class (class_name, st, CHECK);
189
+ }
182
190
}
183
- return false ;
184
191
}
185
192
186
- void LambdaFormInvokers::regenerate_class (char * name, ClassFileStream& st, TRAPS) {
187
- Symbol* class_name = SymbolTable::new_symbol ((const char *)name);
188
- // the class must exist
189
- Klass* klass = SystemDictionary::resolve_or_null (class_name, THREAD);
190
- if (klass == NULL ) {
191
- log_info (cds)(" Class %s not present, skip" , name);
192
- return ;
193
- }
194
- // the species is shared in base archive, skip it.
195
- if (klass->is_regenerated () && is_a_species (name)) {
196
- log_info (cds)(" Skip regenerating for shared %s" , name);
197
- return ;
198
- }
199
-
193
+ void LambdaFormInvokers::regenerate_class (char * class_name, ClassFileStream& st, TRAPS) {
194
+ TempNewSymbol class_name_sym = SymbolTable::new_symbol (class_name);
195
+ Klass* klass = SystemDictionary::resolve_or_null (class_name_sym, THREAD);
196
+ assert (klass != NULL , " must exist" );
200
197
assert (klass->is_instance_klass (), " Should be" );
201
198
202
199
ClassLoaderData* cld = ClassLoaderData::the_null_class_loader_data ();
203
200
Handle protection_domain;
204
201
ClassLoadInfo cl_info (protection_domain);
205
202
206
203
InstanceKlass* result = KlassFactory::create_from_stream (&st,
207
- class_name ,
204
+ class_name_sym ,
208
205
cld,
209
206
cl_info,
210
207
CHECK);
@@ -220,11 +217,11 @@ void LambdaFormInvokers::regenerate_class(char* name, ClassFileStream& st, TRAPS
220
217
MetaspaceShared::try_link_class (THREAD, result);
221
218
assert (!HAS_PENDING_EXCEPTION, " Invariant" );
222
219
223
- result->set_regenerated (); // mark for regenerated
220
+ result->set_is_generated_shared_class ();
224
221
SystemDictionaryShared::set_excluded (InstanceKlass::cast (klass)); // exclude the existing class from dump
225
222
SystemDictionaryShared::init_dumptime_info (result);
226
223
log_info (cds, lambda)(" Regenerated class %s, old: " INTPTR_FORMAT " new: " INTPTR_FORMAT,
227
- name , p2i (klass), p2i (result));
224
+ class_name , p2i (klass), p2i (result));
228
225
}
229
226
230
227
void LambdaFormInvokers::dump_static_archive_invokers () {
0 commit comments