From 1dc1350e0847356baa2b8c8555d647e87f362903 Mon Sep 17 00:00:00 2001 From: acorn Date: Thu, 20 Mar 2014 11:36:40 -0700 Subject: [PATCH] 8037167: Better method signature resolution Reviewed-by: mschoene, hseigel, lfoltan --- src/share/vm/classfile/classFileParser.cpp | 16 +++++++++++++--- src/share/vm/classfile/classFileParser.hpp | 3 ++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/share/vm/classfile/classFileParser.cpp b/src/share/vm/classfile/classFileParser.cpp index 5a8e90f32..b499ef94c 100644 --- a/src/share/vm/classfile/classFileParser.cpp +++ b/src/share/vm/classfile/classFileParser.cpp @@ -931,7 +931,7 @@ void ClassFileParser::parse_field_attributes(u2 attributes_count, "Wrong size %u for field's Signature attribute in class file %s", attribute_length, CHECK); } - generic_signature_index = cfs->get_u2(CHECK); + generic_signature_index = parse_generic_signature_attribute(CHECK); } else if (attribute_name == vmSymbols::tag_runtime_visible_annotations()) { runtime_visible_annotations_length = attribute_length; runtime_visible_annotations = cfs->get_u1_buffer(); @@ -2305,8 +2305,7 @@ methodHandle ClassFileParser::parse_method(bool is_interface, "Invalid Signature attribute length %u in class file %s", method_attribute_length, CHECK_(nullHandle)); } - cfs->guarantee_more(2, CHECK_(nullHandle)); // generic_signature_index - generic_signature_index = cfs->get_u2_fast(); + generic_signature_index = parse_generic_signature_attribute(CHECK_(nullHandle)); } else if (method_attribute_name == vmSymbols::tag_runtime_visible_annotations()) { runtime_visible_annotations_length = method_attribute_length; runtime_visible_annotations = cfs->get_u1_buffer(); @@ -2616,6 +2615,17 @@ intArray* ClassFileParser::sort_methods(Array* methods) { return method_ordering; } +// Parse generic_signature attribute for methods and fields +u2 ClassFileParser::parse_generic_signature_attribute(TRAPS) { + ClassFileStream* cfs = stream(); + cfs->guarantee_more(2, CHECK_0); // generic_signature_index + u2 generic_signature_index = cfs->get_u2_fast(); + check_property( + valid_symbol_at(generic_signature_index), + "Invalid Signature attribute at constant pool index %u in class file %s", + generic_signature_index, CHECK_0); + return generic_signature_index; +} void ClassFileParser::parse_classfile_sourcefile_attribute(TRAPS) { ClassFileStream* cfs = stream(); diff --git a/src/share/vm/classfile/classFileParser.hpp b/src/share/vm/classfile/classFileParser.hpp index 02a4ce20d..4bffe0fba 100644 --- a/src/share/vm/classfile/classFileParser.hpp +++ b/src/share/vm/classfile/classFileParser.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -266,6 +266,7 @@ class ClassFileParser VALUE_OBJ_CLASS_SPEC { u1* parse_stackmap_table(u4 code_attribute_length, TRAPS); // Classfile attribute parsing + u2 parse_generic_signature_attribute(TRAPS); void parse_classfile_sourcefile_attribute(TRAPS); void parse_classfile_source_debug_extension_attribute(int length, TRAPS); u2 parse_classfile_inner_classes_attribute(u1* inner_classes_attribute_start, -- GitLab