160 return false; |
160 return false; |
161 } |
161 } |
162 return (strncmp(str + (str_len - str_to_find_len), str_to_find, str_to_find_len) == 0); |
162 return (strncmp(str + (str_len - str_to_find_len), str_to_find, str_to_find_len) == 0); |
163 } |
163 } |
164 |
164 |
|
165 // Used to obtain the package name from a fully qualified class name. |
|
166 // It is the responsibility of the caller to establish a ResourceMark. |
|
167 const char* ClassLoader::package_from_name(const char* const class_name, bool* bad_class_name) { |
|
168 if (class_name == NULL) { |
|
169 if (bad_class_name != NULL) { |
|
170 *bad_class_name = true; |
|
171 } |
|
172 return NULL; |
|
173 } |
|
174 |
|
175 if (bad_class_name != NULL) { |
|
176 *bad_class_name = false; |
|
177 } |
|
178 |
|
179 const char* const last_slash = strrchr(class_name, '/'); |
|
180 if (last_slash == NULL) { |
|
181 // No package name |
|
182 return NULL; |
|
183 } |
|
184 |
|
185 char* class_name_ptr = (char*) class_name; |
|
186 // Skip over '['s |
|
187 if (*class_name_ptr == '[') { |
|
188 do { |
|
189 class_name_ptr++; |
|
190 } while (*class_name_ptr == '['); |
|
191 |
|
192 // Fully qualified class names should not contain a 'L'. |
|
193 // Set bad_class_name to true to indicate that the package name |
|
194 // could not be obtained due to an error condition. |
|
195 // In this situation, is_same_class_package returns false. |
|
196 if (*class_name_ptr == 'L') { |
|
197 if (bad_class_name != NULL) { |
|
198 *bad_class_name = true; |
|
199 } |
|
200 return NULL; |
|
201 } |
|
202 } |
|
203 |
|
204 int length = last_slash - class_name_ptr; |
|
205 |
|
206 // A class name could have just the slash character in the name. |
|
207 if (length <= 0) { |
|
208 // No package name |
|
209 if (bad_class_name != NULL) { |
|
210 *bad_class_name = true; |
|
211 } |
|
212 return NULL; |
|
213 } |
|
214 |
|
215 // drop name after last slash (including slash) |
|
216 // Ex., "java/lang/String.class" => "java/lang" |
|
217 char* pkg_name = NEW_RESOURCE_ARRAY(char, length + 1); |
|
218 strncpy(pkg_name, class_name_ptr, length); |
|
219 *(pkg_name+length) = '\0'; |
|
220 |
|
221 return (const char *)pkg_name; |
|
222 } |
165 |
223 |
166 MetaIndex::MetaIndex(char** meta_package_names, int num_meta_package_names) { |
224 MetaIndex::MetaIndex(char** meta_package_names, int num_meta_package_names) { |
167 if (num_meta_package_names == 0) { |
225 if (num_meta_package_names == 0) { |
168 _meta_package_names = NULL; |
226 _meta_package_names = NULL; |
169 _num_meta_package_names = 0; |
227 _num_meta_package_names = 0; |
1132 if (DumpSharedSpaces) { |
1190 if (DumpSharedSpaces) { |
1133 tty->print_cr("Preload Error: Failed to load %s", class_name); |
1191 tty->print_cr("Preload Error: Failed to load %s", class_name); |
1134 } |
1192 } |
1135 return h; |
1193 return h; |
1136 } |
1194 } |
|
1195 |
|
1196 #if INCLUDE_JFR |
|
1197 { |
|
1198 InstanceKlass* ik = result(); |
|
1199 ON_KLASS_CREATION(ik, parser, THREAD); |
|
1200 result = instanceKlassHandle(ik); |
|
1201 } |
|
1202 #endif |
|
1203 |
1137 h = context.record_result(classpath_index, e, result, THREAD); |
1204 h = context.record_result(classpath_index, e, result, THREAD); |
1138 } else { |
1205 } else { |
1139 if (DumpSharedSpaces) { |
1206 if (DumpSharedSpaces) { |
1140 tty->print_cr("Preload Warning: Cannot find %s", class_name); |
1207 tty->print_cr("Preload Warning: Cannot find %s", class_name); |
1141 } |
1208 } |