mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8005994: Method annotations are allocated unnecessarily during class file parsing
Also reviewed by: vitalyd@gmail.com Reviewed-by: coleenp, acorn
This commit is contained in:
parent
67fc68ea7f
commit
9d65c6d24f
2 changed files with 34 additions and 20 deletions
|
@ -2475,27 +2475,39 @@ Array<Method*>* ClassFileParser::parse_methods(ClassLoaderData* loader_data,
|
||||||
*has_default_methods = true;
|
*has_default_methods = true;
|
||||||
}
|
}
|
||||||
methods->at_put(index, method());
|
methods->at_put(index, method());
|
||||||
|
|
||||||
|
if (method_annotations != NULL) {
|
||||||
if (*methods_annotations == NULL) {
|
if (*methods_annotations == NULL) {
|
||||||
*methods_annotations =
|
*methods_annotations =
|
||||||
MetadataFactory::new_array<AnnotationArray*>(loader_data, length, NULL, CHECK_NULL);
|
MetadataFactory::new_array<AnnotationArray*>(loader_data, length, NULL, CHECK_NULL);
|
||||||
}
|
}
|
||||||
(*methods_annotations)->at_put(index, method_annotations);
|
(*methods_annotations)->at_put(index, method_annotations);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (method_parameter_annotations != NULL) {
|
||||||
if (*methods_parameter_annotations == NULL) {
|
if (*methods_parameter_annotations == NULL) {
|
||||||
*methods_parameter_annotations =
|
*methods_parameter_annotations =
|
||||||
MetadataFactory::new_array<AnnotationArray*>(loader_data, length, NULL, CHECK_NULL);
|
MetadataFactory::new_array<AnnotationArray*>(loader_data, length, NULL, CHECK_NULL);
|
||||||
}
|
}
|
||||||
(*methods_parameter_annotations)->at_put(index, method_parameter_annotations);
|
(*methods_parameter_annotations)->at_put(index, method_parameter_annotations);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (method_default_annotations != NULL) {
|
||||||
if (*methods_default_annotations == NULL) {
|
if (*methods_default_annotations == NULL) {
|
||||||
*methods_default_annotations =
|
*methods_default_annotations =
|
||||||
MetadataFactory::new_array<AnnotationArray*>(loader_data, length, NULL, CHECK_NULL);
|
MetadataFactory::new_array<AnnotationArray*>(loader_data, length, NULL, CHECK_NULL);
|
||||||
}
|
}
|
||||||
(*methods_default_annotations)->at_put(index, method_default_annotations);
|
(*methods_default_annotations)->at_put(index, method_default_annotations);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (method_type_annotations != NULL) {
|
||||||
if (*methods_type_annotations == NULL) {
|
if (*methods_type_annotations == NULL) {
|
||||||
*methods_type_annotations =
|
*methods_type_annotations =
|
||||||
MetadataFactory::new_array<AnnotationArray*>(loader_data, length, NULL, CHECK_NULL);
|
MetadataFactory::new_array<AnnotationArray*>(loader_data, length, NULL, CHECK_NULL);
|
||||||
}
|
}
|
||||||
(*methods_type_annotations)->at_put(index, method_type_annotations);
|
(*methods_type_annotations)->at_put(index, method_type_annotations);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (_need_verify && length > 1) {
|
if (_need_verify && length > 1) {
|
||||||
// Check duplicated methods
|
// Check duplicated methods
|
||||||
|
@ -3309,8 +3321,7 @@ instanceKlassHandle ClassFileParser::parseClassFile(Symbol* name,
|
||||||
bool has_final_method = false;
|
bool has_final_method = false;
|
||||||
AccessFlags promoted_flags;
|
AccessFlags promoted_flags;
|
||||||
promoted_flags.set_flags(0);
|
promoted_flags.set_flags(0);
|
||||||
// These need to be oop pointers because they are allocated lazily
|
|
||||||
// inside parse_methods inside a nested HandleMark
|
|
||||||
Array<AnnotationArray*>* methods_annotations = NULL;
|
Array<AnnotationArray*>* methods_annotations = NULL;
|
||||||
Array<AnnotationArray*>* methods_parameter_annotations = NULL;
|
Array<AnnotationArray*>* methods_parameter_annotations = NULL;
|
||||||
Array<AnnotationArray*>* methods_default_annotations = NULL;
|
Array<AnnotationArray*>* methods_default_annotations = NULL;
|
||||||
|
|
|
@ -1582,10 +1582,13 @@ JVM_ENTRY(jbyteArray, JVM_GetClassTypeAnnotations(JNIEnv *env, jclass cls))
|
||||||
if (!java_lang_Class::is_primitive(JNIHandles::resolve(cls))) {
|
if (!java_lang_Class::is_primitive(JNIHandles::resolve(cls))) {
|
||||||
Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve(cls));
|
Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve(cls));
|
||||||
if (k->oop_is_instance()) {
|
if (k->oop_is_instance()) {
|
||||||
typeArrayOop a = Annotations::make_java_array(InstanceKlass::cast(k)->type_annotations()->class_annotations(), CHECK_NULL);
|
Annotations* type_annotations = InstanceKlass::cast(k)->type_annotations();
|
||||||
|
if (type_annotations != NULL) {
|
||||||
|
typeArrayOop a = Annotations::make_java_array(type_annotations->class_annotations(), CHECK_NULL);
|
||||||
return (jbyteArray) JNIHandles::make_local(env, a);
|
return (jbyteArray) JNIHandles::make_local(env, a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
JVM_END
|
JVM_END
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue