Thu, 20 Mar 2014 11:36:40 -0700
8037167: Better method signature resolution
Reviewed-by: mschoene, hseigel, lfoltan
src/share/vm/classfile/classFileParser.cpp | file | annotate | diff | comparison | revisions | |
src/share/vm/classfile/classFileParser.hpp | file | annotate | diff | comparison | revisions |
1.1 --- a/src/share/vm/classfile/classFileParser.cpp Thu Mar 20 10:06:22 2014 -0700 1.2 +++ b/src/share/vm/classfile/classFileParser.cpp Thu Mar 20 11:36:40 2014 -0700 1.3 @@ -931,7 +931,7 @@ 1.4 "Wrong size %u for field's Signature attribute in class file %s", 1.5 attribute_length, CHECK); 1.6 } 1.7 - generic_signature_index = cfs->get_u2(CHECK); 1.8 + generic_signature_index = parse_generic_signature_attribute(CHECK); 1.9 } else if (attribute_name == vmSymbols::tag_runtime_visible_annotations()) { 1.10 runtime_visible_annotations_length = attribute_length; 1.11 runtime_visible_annotations = cfs->get_u1_buffer(); 1.12 @@ -2305,8 +2305,7 @@ 1.13 "Invalid Signature attribute length %u in class file %s", 1.14 method_attribute_length, CHECK_(nullHandle)); 1.15 } 1.16 - cfs->guarantee_more(2, CHECK_(nullHandle)); // generic_signature_index 1.17 - generic_signature_index = cfs->get_u2_fast(); 1.18 + generic_signature_index = parse_generic_signature_attribute(CHECK_(nullHandle)); 1.19 } else if (method_attribute_name == vmSymbols::tag_runtime_visible_annotations()) { 1.20 runtime_visible_annotations_length = method_attribute_length; 1.21 runtime_visible_annotations = cfs->get_u1_buffer(); 1.22 @@ -2616,6 +2615,17 @@ 1.23 return method_ordering; 1.24 } 1.25 1.26 +// Parse generic_signature attribute for methods and fields 1.27 +u2 ClassFileParser::parse_generic_signature_attribute(TRAPS) { 1.28 + ClassFileStream* cfs = stream(); 1.29 + cfs->guarantee_more(2, CHECK_0); // generic_signature_index 1.30 + u2 generic_signature_index = cfs->get_u2_fast(); 1.31 + check_property( 1.32 + valid_symbol_at(generic_signature_index), 1.33 + "Invalid Signature attribute at constant pool index %u in class file %s", 1.34 + generic_signature_index, CHECK_0); 1.35 + return generic_signature_index; 1.36 +} 1.37 1.38 void ClassFileParser::parse_classfile_sourcefile_attribute(TRAPS) { 1.39 ClassFileStream* cfs = stream();
2.1 --- a/src/share/vm/classfile/classFileParser.hpp Thu Mar 20 10:06:22 2014 -0700 2.2 +++ b/src/share/vm/classfile/classFileParser.hpp Thu Mar 20 11:36:40 2014 -0700 2.3 @@ -1,5 +1,5 @@ 2.4 /* 2.5 - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 2.6 + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. 2.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.8 * 2.9 * This code is free software; you can redistribute it and/or modify it 2.10 @@ -266,6 +266,7 @@ 2.11 u1* parse_stackmap_table(u4 code_attribute_length, TRAPS); 2.12 2.13 // Classfile attribute parsing 2.14 + u2 parse_generic_signature_attribute(TRAPS); 2.15 void parse_classfile_sourcefile_attribute(TRAPS); 2.16 void parse_classfile_source_debug_extension_attribute(int length, TRAPS); 2.17 u2 parse_classfile_inner_classes_attribute(u1* inner_classes_attribute_start,