classFileParser.hpp revision 1879
5fc50ecb8dc8ef74adfc1c1f0d4e144d7f4d8faestoddard/*
4ed92248676a091e0d73db61773d9059b36d0861stoddard * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
4ed92248676a091e0d73db61773d9059b36d0861stoddard * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4ed92248676a091e0d73db61773d9059b36d0861stoddard *
4ed92248676a091e0d73db61773d9059b36d0861stoddard * This code is free software; you can redistribute it and/or modify it
4ed92248676a091e0d73db61773d9059b36d0861stoddard * under the terms of the GNU General Public License version 2 only, as
4ed92248676a091e0d73db61773d9059b36d0861stoddard * published by the Free Software Foundation.
4ed92248676a091e0d73db61773d9059b36d0861stoddard *
4ed92248676a091e0d73db61773d9059b36d0861stoddard * This code is distributed in the hope that it will be useful, but WITHOUT
4ed92248676a091e0d73db61773d9059b36d0861stoddard * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
b4b458e66e24979631466a69c4bae3090a7e50fewrowe * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
4ed92248676a091e0d73db61773d9059b36d0861stoddard * version 2 for more details (a copy is included in the LICENSE file that
fa29e798c69385995c601ddfe75cbd5cf29244efwrowe * accompanied this code).
4ed92248676a091e0d73db61773d9059b36d0861stoddard *
fa29e798c69385995c601ddfe75cbd5cf29244efwrowe * You should have received a copy of the GNU General Public License version
071646a05417cc437fcffec9512588f75bd39a03wrowe * 2 along with this work; if not, write to the Free Software Foundation,
fa29e798c69385995c601ddfe75cbd5cf29244efwrowe * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6b441c81aae632befd971e634b4a36780c71d18ewrowe *
fa29e798c69385995c601ddfe75cbd5cf29244efwrowe * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9d134be9b7d1d6f0f9e910346a8075dac77b3d69ianh * or visit www.oracle.com if you need additional information or have any
fa29e798c69385995c601ddfe75cbd5cf29244efwrowe * questions.
4ed92248676a091e0d73db61773d9059b36d0861stoddard *
ea0acbc141b3ca2ef21666bd23bfea9af9a758aawrowe */
9d134be9b7d1d6f0f9e910346a8075dac77b3d69ianh
fa29e798c69385995c601ddfe75cbd5cf29244efwrowe#ifndef SHARE_VM_CLASSFILE_CLASSFILEPARSER_HPP
bcd36d1522403b4387451f8a17a528e632915e8dwrowe#define SHARE_VM_CLASSFILE_CLASSFILEPARSER_HPP
bcd36d1522403b4387451f8a17a528e632915e8dwrowe
4ed92248676a091e0d73db61773d9059b36d0861stoddard#include "classfile/classFileStream.hpp"
9cef38b3a87190d0c4dcd5b389573418af9de73cwrowe#include "memory/resourceArea.hpp"
a8f3504993ae9a401b6fc87c7a00b716b112e3d0wrowe#include "oops/oop.inline.hpp"
e237b51d2e7a72b7f636f67ed4a9f5fe30f56375wrowe#include "oops/typeArrayOop.hpp"
b56ce33e3fe5670a4562de222c60ade06fe1bce0wrowe#include "runtime/handles.inline.hpp"
b56ce33e3fe5670a4562de222c60ade06fe1bce0wrowe#include "utilities/accessFlags.hpp"
b56ce33e3fe5670a4562de222c60ade06fe1bce0wrowe
0ea0379ff6438182ac3c9d8f108deb3c82210319wrowe// Parser for for .class files
6173077ec421fe85891d4b914c87175beb0a9293wrowe//
c71d15c4b41b9d89e90e936d49b4e5a6db19244ewrowe// The bytes describing the class file structure is read from a Stream object
6173077ec421fe85891d4b914c87175beb0a9293wrowe
6173077ec421fe85891d4b914c87175beb0a9293wroweclass ClassFileParser VALUE_OBJ_CLASS_SPEC {
c71d15c4b41b9d89e90e936d49b4e5a6db19244ewrowe private:
6173077ec421fe85891d4b914c87175beb0a9293wrowe bool _need_verify;
6173077ec421fe85891d4b914c87175beb0a9293wrowe bool _relax_verify;
b4b458e66e24979631466a69c4bae3090a7e50fewrowe u2 _major_version;
945f023c83c2d18bf5145a5b9af48fc3216fbef6wrowe u2 _minor_version;
a8f3504993ae9a401b6fc87c7a00b716b112e3d0wrowe symbolHandle _class_name;
a8f3504993ae9a401b6fc87c7a00b716b112e3d0wrowe KlassHandle _host_klass;
6166dacd3c3d034394c1f8c131919ea7452835a7wrowe GrowableArray<Handle>* _cp_patches; // overrides for CP entries
a8f3504993ae9a401b6fc87c7a00b716b112e3d0wrowe
a8f3504993ae9a401b6fc87c7a00b716b112e3d0wrowe bool _has_finalizer;
a8f3504993ae9a401b6fc87c7a00b716b112e3d0wrowe bool _has_empty_finalizer;
a8f3504993ae9a401b6fc87c7a00b716b112e3d0wrowe bool _has_vanilla_constructor;
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe
b4b458e66e24979631466a69c4bae3090a7e50fewrowe enum { fixed_buffer_size = 128 };
945f023c83c2d18bf5145a5b9af48fc3216fbef6wrowe u_char linenumbertable_buffer[fixed_buffer_size];
a8f3504993ae9a401b6fc87c7a00b716b112e3d0wrowe
fa3f183306fa2ec98249f2afec904d403643a015wrowe ClassFileStream* _stream; // Actual input stream
a8f3504993ae9a401b6fc87c7a00b716b112e3d0wrowe
743aeb835754aadabaec38c00742899668eb9dd1wrowe enum { LegalClass, LegalField, LegalMethod }; // used to verify unqualified names
fa3f183306fa2ec98249f2afec904d403643a015wrowe
a78b700fa90213df137e4178a9bd9c81aadd39d3wrowe // Accessors
b56ce33e3fe5670a4562de222c60ade06fe1bce0wrowe ClassFileStream* stream() { return _stream; }
b56ce33e3fe5670a4562de222c60ade06fe1bce0wrowe void set_stream(ClassFileStream* st) { _stream = st; }
b56ce33e3fe5670a4562de222c60ade06fe1bce0wrowe
945f023c83c2d18bf5145a5b9af48fc3216fbef6wrowe // Constant pool parsing
549b1f3d6860ae792e6a8c8d3a483140bdb857a5wrowe void parse_constant_pool_entries(constantPoolHandle cp, int length, TRAPS);
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe
743aeb835754aadabaec38c00742899668eb9dd1wrowe constantPoolHandle parse_constant_pool(TRAPS);
945f023c83c2d18bf5145a5b9af48fc3216fbef6wrowe
945f023c83c2d18bf5145a5b9af48fc3216fbef6wrowe static int start_operand_group(GrowableArray<int>* &operands, int op_count, TRAPS);
a8f3504993ae9a401b6fc87c7a00b716b112e3d0wrowe static void store_operand_array(GrowableArray<int>* operands, constantPoolHandle cp, TRAPS);
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe // Interface parsing
b4b458e66e24979631466a69c4bae3090a7e50fewrowe objArrayHandle parse_interfaces(constantPoolHandle cp,
9cef38b3a87190d0c4dcd5b389573418af9de73cwrowe int length,
9cef38b3a87190d0c4dcd5b389573418af9de73cwrowe Handle class_loader,
9cef38b3a87190d0c4dcd5b389573418af9de73cwrowe Handle protection_domain,
9cef38b3a87190d0c4dcd5b389573418af9de73cwrowe symbolHandle class_name,
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe TRAPS);
9cef38b3a87190d0c4dcd5b389573418af9de73cwrowe
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe // Field parsing
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe void parse_field_attributes(constantPoolHandle cp, u2 attributes_count,
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe bool is_static, u2 signature_index,
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe u2* constantvalue_index_addr,
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe bool* is_synthetic_addr,
92fb4b4faaea055db085fc0864950c2a5edd0de2jwoolley u2* generic_signature_index_addr,
92fb4b4faaea055db085fc0864950c2a5edd0de2jwoolley typeArrayHandle* field_annotations, TRAPS);
fa3f183306fa2ec98249f2afec904d403643a015wrowe typeArrayHandle parse_fields(constantPoolHandle cp, bool is_interface,
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe struct FieldAllocationCount *fac,
b56ce33e3fe5670a4562de222c60ade06fe1bce0wrowe objArrayHandle* fields_annotations, TRAPS);
b56ce33e3fe5670a4562de222c60ade06fe1bce0wrowe
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe // Method parsing
549b1f3d6860ae792e6a8c8d3a483140bdb857a5wrowe methodHandle parse_method(constantPoolHandle cp, bool is_interface,
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe AccessFlags* promoted_flags,
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe typeArrayHandle* method_annotations,
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe typeArrayHandle* method_parameter_annotations,
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe typeArrayHandle* method_default_annotations,
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe TRAPS);
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe objArrayHandle parse_methods (constantPoolHandle cp, bool is_interface,
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe AccessFlags* promoted_flags,
9cef38b3a87190d0c4dcd5b389573418af9de73cwrowe bool* has_final_method,
9cef38b3a87190d0c4dcd5b389573418af9de73cwrowe objArrayOop* methods_annotations_oop,
6a5b8f7bd9abe819babda806a7245a31cd0dd2fbwrowe objArrayOop* methods_parameter_annotations_oop,
6a5b8f7bd9abe819babda806a7245a31cd0dd2fbwrowe objArrayOop* methods_default_annotations_oop,
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe TRAPS);
a8f3504993ae9a401b6fc87c7a00b716b112e3d0wrowe typeArrayHandle sort_methods (objArrayHandle methods,
a8f3504993ae9a401b6fc87c7a00b716b112e3d0wrowe objArrayHandle methods_annotations,
4ed92248676a091e0d73db61773d9059b36d0861stoddard objArrayHandle methods_parameter_annotations,
071646a05417cc437fcffec9512588f75bd39a03wrowe objArrayHandle methods_default_annotations,
9cef38b3a87190d0c4dcd5b389573418af9de73cwrowe TRAPS);
9cef38b3a87190d0c4dcd5b389573418af9de73cwrowe typeArrayHandle parse_exception_table(u4 code_length, u4 exception_table_length,
9cef38b3a87190d0c4dcd5b389573418af9de73cwrowe constantPoolHandle cp, TRAPS);
9cef38b3a87190d0c4dcd5b389573418af9de73cwrowe void parse_linenumber_table(
fa29e798c69385995c601ddfe75cbd5cf29244efwrowe u4 code_attribute_length, u4 code_length,
f397bb616fba8b3a5a9b3c57a5c89ad0e254b673mturk CompressedLineNumberWriteStream** write_stream, TRAPS);
9d134be9b7d1d6f0f9e910346a8075dac77b3d69ianh u2* parse_localvariable_table(u4 code_length, u2 max_locals, u4 code_attribute_length,
6b441c81aae632befd971e634b4a36780c71d18ewrowe constantPoolHandle cp, u2* localvariable_table_length,
6b441c81aae632befd971e634b4a36780c71d18ewrowe bool isLVTT, TRAPS);
6b441c81aae632befd971e634b4a36780c71d18ewrowe u2* parse_checked_exceptions(u2* checked_exceptions_length, u4 method_attribute_length,
9cef38b3a87190d0c4dcd5b389573418af9de73cwrowe constantPoolHandle cp, TRAPS);
9cef38b3a87190d0c4dcd5b389573418af9de73cwrowe void parse_type_array(u2 array_length, u4 code_length, u4* u1_index, u4* u2_index,
9cef38b3a87190d0c4dcd5b389573418af9de73cwrowe u1* u1_array, u2* u2_array, constantPoolHandle cp, TRAPS);
9cef38b3a87190d0c4dcd5b389573418af9de73cwrowe typeArrayOop parse_stackmap_table(u4 code_attribute_length, TRAPS);
9cef38b3a87190d0c4dcd5b389573418af9de73cwrowe
9cef38b3a87190d0c4dcd5b389573418af9de73cwrowe // Classfile attribute parsing
6b441c81aae632befd971e634b4a36780c71d18ewrowe void parse_classfile_sourcefile_attribute(constantPoolHandle cp, instanceKlassHandle k, TRAPS);
6b441c81aae632befd971e634b4a36780c71d18ewrowe void parse_classfile_source_debug_extension_attribute(constantPoolHandle cp,
6b441c81aae632befd971e634b4a36780c71d18ewrowe instanceKlassHandle k, int length, TRAPS);
9cef38b3a87190d0c4dcd5b389573418af9de73cwrowe u2 parse_classfile_inner_classes_attribute(constantPoolHandle cp,
ea0acbc141b3ca2ef21666bd23bfea9af9a758aawrowe instanceKlassHandle k, TRAPS);
ea0acbc141b3ca2ef21666bd23bfea9af9a758aawrowe void parse_classfile_attributes(constantPoolHandle cp, instanceKlassHandle k, TRAPS);
9cef38b3a87190d0c4dcd5b389573418af9de73cwrowe void parse_classfile_synthetic_attribute(constantPoolHandle cp, instanceKlassHandle k, TRAPS);
9cef38b3a87190d0c4dcd5b389573418af9de73cwrowe void parse_classfile_signature_attribute(constantPoolHandle cp, instanceKlassHandle k, TRAPS);
fa29e798c69385995c601ddfe75cbd5cf29244efwrowe
4ed92248676a091e0d73db61773d9059b36d0861stoddard // Annotations handling
50feafa397d01128b8cf94ad1602d3d78e1a4169wrowe typeArrayHandle assemble_annotations(u1* runtime_visible_annotations,
50feafa397d01128b8cf94ad1602d3d78e1a4169wrowe int runtime_visible_annotations_length,
ea0acbc141b3ca2ef21666bd23bfea9af9a758aawrowe u1* runtime_invisible_annotations,
ea0acbc141b3ca2ef21666bd23bfea9af9a758aawrowe int runtime_invisible_annotations_length, TRAPS);
50feafa397d01128b8cf94ad1602d3d78e1a4169wrowe
ea0acbc141b3ca2ef21666bd23bfea9af9a758aawrowe // Final setup
ea0acbc141b3ca2ef21666bd23bfea9af9a758aawrowe unsigned int compute_oop_map_count(instanceKlassHandle super,
ea0acbc141b3ca2ef21666bd23bfea9af9a758aawrowe unsigned int nonstatic_oop_count,
ea0acbc141b3ca2ef21666bd23bfea9af9a758aawrowe int first_nonstatic_oop_offset);
50feafa397d01128b8cf94ad1602d3d78e1a4169wrowe void fill_oop_maps(instanceKlassHandle k,
50feafa397d01128b8cf94ad1602d3d78e1a4169wrowe unsigned int nonstatic_oop_map_count,
98086904a5df1d6127b49bf06af39f23ff844889wrowe int* nonstatic_oop_offsets,
98086904a5df1d6127b49bf06af39f23ff844889wrowe unsigned int* nonstatic_oop_counts);
b4b458e66e24979631466a69c4bae3090a7e50fewrowe void set_precomputed_flags(instanceKlassHandle k);
b4b458e66e24979631466a69c4bae3090a7e50fewrowe objArrayHandle compute_transitive_interfaces(instanceKlassHandle super,
b4b458e66e24979631466a69c4bae3090a7e50fewrowe objArrayHandle local_ifs, TRAPS);
b4b458e66e24979631466a69c4bae3090a7e50fewrowe
b4b458e66e24979631466a69c4bae3090a7e50fewrowe // Special handling for certain classes.
4ed92248676a091e0d73db61773d9059b36d0861stoddard // Add the "discovered" field to java.lang.ref.Reference if
549b1f3d6860ae792e6a8c8d3a483140bdb857a5wrowe // it does not exist.
4ed92248676a091e0d73db61773d9059b36d0861stoddard void java_lang_ref_Reference_fix_pre(typeArrayHandle* fields_ptr,
4ed92248676a091e0d73db61773d9059b36d0861stoddard constantPoolHandle cp, FieldAllocationCount *fac_ptr, TRAPS);
549b1f3d6860ae792e6a8c8d3a483140bdb857a5wrowe // Adjust the field allocation counts for java.lang.Class to add
4ed92248676a091e0d73db61773d9059b36d0861stoddard // fake fields.
4ed92248676a091e0d73db61773d9059b36d0861stoddard void java_lang_Class_fix_pre(objArrayHandle* methods_ptr,
549b1f3d6860ae792e6a8c8d3a483140bdb857a5wrowe FieldAllocationCount *fac_ptr, TRAPS);
4ed92248676a091e0d73db61773d9059b36d0861stoddard // Adjust the next_nonstatic_oop_offset to place the fake fields
4ed92248676a091e0d73db61773d9059b36d0861stoddard // before any Java fields.
549b1f3d6860ae792e6a8c8d3a483140bdb857a5wrowe void java_lang_Class_fix_post(int* next_nonstatic_oop_offset);
4ed92248676a091e0d73db61773d9059b36d0861stoddard // Adjust the field allocation counts for java.dyn.MethodHandle to add
945f023c83c2d18bf5145a5b9af48fc3216fbef6wrowe // a fake address (void*) field.
90f3e85cc3332e202aa198786798709fc55505d9wrowe void java_dyn_MethodHandle_fix_pre(constantPoolHandle cp,
b4b458e66e24979631466a69c4bae3090a7e50fewrowe typeArrayHandle fields,
b4b458e66e24979631466a69c4bae3090a7e50fewrowe FieldAllocationCount *fac_ptr, TRAPS);
945f023c83c2d18bf5145a5b9af48fc3216fbef6wrowe
14d27a22a8fdb25e6e82d8af853a63bd4c6bd894wrowe // Format checker methods
945f023c83c2d18bf5145a5b9af48fc3216fbef6wrowe void classfile_parse_error(const char* msg, TRAPS);
b4b458e66e24979631466a69c4bae3090a7e50fewrowe void classfile_parse_error(const char* msg, int index, TRAPS);
50feafa397d01128b8cf94ad1602d3d78e1a4169wrowe void classfile_parse_error(const char* msg, const char *name, TRAPS);
4ed92248676a091e0d73db61773d9059b36d0861stoddard void classfile_parse_error(const char* msg, int index, const char *name, TRAPS);
4ed92248676a091e0d73db61773d9059b36d0861stoddard inline void guarantee_property(bool b, const char* msg, TRAPS) {
50feafa397d01128b8cf94ad1602d3d78e1a4169wrowe if (!b) { classfile_parse_error(msg, CHECK); }
4ed92248676a091e0d73db61773d9059b36d0861stoddard }
4ed92248676a091e0d73db61773d9059b36d0861stoddard
4ed92248676a091e0d73db61773d9059b36d0861stoddard inline void assert_property(bool b, const char* msg, TRAPS) {
0b64c3e5c7379284f90efc7193f16b373df39fe1wrowe#ifdef ASSERT
1e83c8de3aa48b316b28057d53995272baf1260cwrowe if (!b) { fatal(msg); }
1e83c8de3aa48b316b28057d53995272baf1260cwrowe#endif
4ed92248676a091e0d73db61773d9059b36d0861stoddard }
0ea0379ff6438182ac3c9d8f108deb3c82210319wrowe
0ea0379ff6438182ac3c9d8f108deb3c82210319wrowe inline void check_property(bool property, const char* msg, int index, TRAPS) {
0ea0379ff6438182ac3c9d8f108deb3c82210319wrowe if (_need_verify) {
d7f2b79379c5a3b849bf3d5dacf7180805ecba1fwrowe guarantee_property(property, msg, index, CHECK);
ea0acbc141b3ca2ef21666bd23bfea9af9a758aawrowe } else {
d7f2b79379c5a3b849bf3d5dacf7180805ecba1fwrowe assert_property(property, msg, CHECK);
d7f2b79379c5a3b849bf3d5dacf7180805ecba1fwrowe }
d7f2b79379c5a3b849bf3d5dacf7180805ecba1fwrowe }
ea0acbc141b3ca2ef21666bd23bfea9af9a758aawrowe
d7f2b79379c5a3b849bf3d5dacf7180805ecba1fwrowe inline void check_property(bool property, const char* msg, TRAPS) {
d7f2b79379c5a3b849bf3d5dacf7180805ecba1fwrowe if (_need_verify) {
ea0acbc141b3ca2ef21666bd23bfea9af9a758aawrowe guarantee_property(property, msg, CHECK);
d7f2b79379c5a3b849bf3d5dacf7180805ecba1fwrowe } else {
d7f2b79379c5a3b849bf3d5dacf7180805ecba1fwrowe assert_property(property, msg, CHECK);
d7f2b79379c5a3b849bf3d5dacf7180805ecba1fwrowe }
d7f2b79379c5a3b849bf3d5dacf7180805ecba1fwrowe }
06bd11dc20356466f38185ddb47fc798b4508d5fwrowe
1e83c8de3aa48b316b28057d53995272baf1260cwrowe inline void guarantee_property(bool b, const char* msg, int index, TRAPS) {
1e83c8de3aa48b316b28057d53995272baf1260cwrowe if (!b) { classfile_parse_error(msg, index, CHECK); }
1e83c8de3aa48b316b28057d53995272baf1260cwrowe }
1e83c8de3aa48b316b28057d53995272baf1260cwrowe inline void guarantee_property(bool b, const char* msg, const char *name, TRAPS) {
0b64c3e5c7379284f90efc7193f16b373df39fe1wrowe if (!b) { classfile_parse_error(msg, name, CHECK); }
0b64c3e5c7379284f90efc7193f16b373df39fe1wrowe }
1e83c8de3aa48b316b28057d53995272baf1260cwrowe inline void guarantee_property(bool b, const char* msg, int index, const char *name, TRAPS) {
1e83c8de3aa48b316b28057d53995272baf1260cwrowe if (!b) { classfile_parse_error(msg, index, name, CHECK); }
c3200c488bb3f941a88d5bed94abef0f46946bd3wrowe }
0b64c3e5c7379284f90efc7193f16b373df39fe1wrowe
1e83c8de3aa48b316b28057d53995272baf1260cwrowe void throwIllegalSignature(
4ed92248676a091e0d73db61773d9059b36d0861stoddard const char* type, symbolHandle name, symbolHandle sig, TRAPS);
1e83c8de3aa48b316b28057d53995272baf1260cwrowe
14d27a22a8fdb25e6e82d8af853a63bd4c6bd894wrowe bool is_supported_version(u2 major, u2 minor);
6a5b8f7bd9abe819babda806a7245a31cd0dd2fbwrowe bool has_illegal_visibility(jint flags);
6a5b8f7bd9abe819babda806a7245a31cd0dd2fbwrowe
6a5b8f7bd9abe819babda806a7245a31cd0dd2fbwrowe void verify_constantvalue(int constantvalue_index, int signature_index, constantPoolHandle cp, TRAPS);
6a5b8f7bd9abe819babda806a7245a31cd0dd2fbwrowe void verify_legal_utf8(const unsigned char* buffer, int length, TRAPS);
9106bbba512da6e81bb4feb268bbd17435354d79wrowe void verify_legal_class_name(symbolHandle name, TRAPS);
9106bbba512da6e81bb4feb268bbd17435354d79wrowe void verify_legal_field_name(symbolHandle name, TRAPS);
9106bbba512da6e81bb4feb268bbd17435354d79wrowe void verify_legal_method_name(symbolHandle name, TRAPS);
0b64c3e5c7379284f90efc7193f16b373df39fe1wrowe void verify_legal_field_signature(symbolHandle fieldname, symbolHandle signature, TRAPS);
f71283367c234bf49ddc8ba7b23d3d3829db0d8dmturk int verify_legal_method_signature(symbolHandle methodname, symbolHandle signature, TRAPS);
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe void verify_legal_class_modifiers(jint flags, TRAPS);
1a1462ebfd091853d54071a693fc7ad4c5573f8awrowe void verify_legal_field_modifiers(jint flags, bool is_interface, TRAPS);
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe void verify_legal_method_modifiers(jint flags, bool is_interface, symbolHandle name, TRAPS);
bc21ce13cec2409c8fdb7122154636b2df97715ajerenkrantz bool verify_unqualified_name(char* name, unsigned int length, int type);
34e753c9dba1e821f54f0d4179f8774f854123eecolm char* skip_over_field_name(char* name, bool slash_ok, unsigned int length);
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe char* skip_over_field_signature(char* signature, bool void_ok, unsigned int length, TRAPS);
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe bool is_anonymous() {
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe assert(AnonymousClasses || _host_klass.is_null(), "");
ac19b3a64a76401bc7e4e378b51c245a7e8516a5mturk return _host_klass.not_null();
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe }
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe bool has_cp_patch_at(int index) {
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe assert(AnonymousClasses, "");
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe assert(index >= 0, "oob");
6a5b8f7bd9abe819babda806a7245a31cd0dd2fbwrowe return (_cp_patches != NULL
0b64c3e5c7379284f90efc7193f16b373df39fe1wrowe && index < _cp_patches->length()
1e83c8de3aa48b316b28057d53995272baf1260cwrowe && _cp_patches->adr_at(index)->not_null());
1e83c8de3aa48b316b28057d53995272baf1260cwrowe }
1e83c8de3aa48b316b28057d53995272baf1260cwrowe Handle cp_patch_at(int index) {
0b64c3e5c7379284f90efc7193f16b373df39fe1wrowe assert(has_cp_patch_at(index), "oob");
bf03ef02d5f0f64ee0e91f3c4007154897d4dd34mturk return _cp_patches->at(index);
1e83c8de3aa48b316b28057d53995272baf1260cwrowe }
bf03ef02d5f0f64ee0e91f3c4007154897d4dd34mturk Handle clear_cp_patch_at(int index) {
bf03ef02d5f0f64ee0e91f3c4007154897d4dd34mturk Handle patch = cp_patch_at(index);
0b64c3e5c7379284f90efc7193f16b373df39fe1wrowe _cp_patches->at_put(index, Handle());
0b64c3e5c7379284f90efc7193f16b373df39fe1wrowe assert(!has_cp_patch_at(index), "");
1e83c8de3aa48b316b28057d53995272baf1260cwrowe return patch;
0b64c3e5c7379284f90efc7193f16b373df39fe1wrowe }
0b64c3e5c7379284f90efc7193f16b373df39fe1wrowe void patch_constant_pool(constantPoolHandle cp, int index, Handle patch, TRAPS);
1e83c8de3aa48b316b28057d53995272baf1260cwrowe
0b64c3e5c7379284f90efc7193f16b373df39fe1wrowe // Wrapper for constantTag.is_klass_[or_]reference.
0f488df653e7e8cf4ee0006a3138f9474ca1d375wrowe // In older versions of the VM, klassOops cannot sneak into early phases of
538b2b76902ad0b42b4fb2c8ace94bf74d8100cewrowe // constant pool construction, but in later versions they can.
538b2b76902ad0b42b4fb2c8ace94bf74d8100cewrowe // %%% Let's phase out the old is_klass_reference.
538b2b76902ad0b42b4fb2c8ace94bf74d8100cewrowe bool is_klass_reference(constantPoolHandle cp, int index) {
b6546cf6d01472a9bf658fa50b096c76314cbbf7stoddard return ((LinkWellKnownClasses || AnonymousClasses)
92fb4b4faaea055db085fc0864950c2a5edd0de2jwoolley ? cp->tag_at(index).is_klass_or_reference()
175ab758dce807990c2cfd281ffced0dd8f7d2f4nd : cp->tag_at(index).is_klass_reference());
92e403ad9206eea8af7bd426fd1a19d531816d83wrowe }
58b8ccdd4dbf4b314e016de6eeebfe45be45451end
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe public:
60f8e9cbbfc2d757c71db17a35acb8566eebc0dawrowe // Constructor
255d4d329b2d41e4ac0c3ade5cfe528a078ef682wrowe ClassFileParser(ClassFileStream* st) { set_stream(st); }
1e83c8de3aa48b316b28057d53995272baf1260cwrowe
1e83c8de3aa48b316b28057d53995272baf1260cwrowe // Parse .class file and return new klassOop. The klassOop is not hooked up
0b64c3e5c7379284f90efc7193f16b373df39fe1wrowe // to the system dictionary or any other structures, so a .class file can
1e83c8de3aa48b316b28057d53995272baf1260cwrowe // be loaded several times if desired.
1e83c8de3aa48b316b28057d53995272baf1260cwrowe // The system dictionary hookup is done by the caller.
1e83c8de3aa48b316b28057d53995272baf1260cwrowe //
1e83c8de3aa48b316b28057d53995272baf1260cwrowe // "parsed_name" is updated by this method, and is the name found
1e83c8de3aa48b316b28057d53995272baf1260cwrowe // while parsing the stream.
1e83c8de3aa48b316b28057d53995272baf1260cwrowe instanceKlassHandle parseClassFile(symbolHandle name,
1e83c8de3aa48b316b28057d53995272baf1260cwrowe Handle class_loader,
1e83c8de3aa48b316b28057d53995272baf1260cwrowe Handle protection_domain,
1e83c8de3aa48b316b28057d53995272baf1260cwrowe symbolHandle& parsed_name,
1e83c8de3aa48b316b28057d53995272baf1260cwrowe bool verify,
1e83c8de3aa48b316b28057d53995272baf1260cwrowe TRAPS) {
24b0a59507af2a3621f586fa2a2aafc3640aa3d2nd KlassHandle no_host_klass;
5a51653135041ee35b24fa67453bff4e9f8e3591wrowe return parseClassFile(name, class_loader, protection_domain, no_host_klass, NULL, parsed_name, verify, THREAD);
0b64c3e5c7379284f90efc7193f16b373df39fe1wrowe }
0b64c3e5c7379284f90efc7193f16b373df39fe1wrowe instanceKlassHandle parseClassFile(symbolHandle name,
1e83c8de3aa48b316b28057d53995272baf1260cwrowe Handle class_loader,
1e83c8de3aa48b316b28057d53995272baf1260cwrowe Handle protection_domain,
1e83c8de3aa48b316b28057d53995272baf1260cwrowe KlassHandle host_klass,
0e6bee8eb9112f77eb50766e58424afac61104d9wrowe GrowableArray<Handle>* cp_patches,
1e83c8de3aa48b316b28057d53995272baf1260cwrowe symbolHandle& parsed_name,
1e83c8de3aa48b316b28057d53995272baf1260cwrowe bool verify,
1e83c8de3aa48b316b28057d53995272baf1260cwrowe TRAPS);
1e83c8de3aa48b316b28057d53995272baf1260cwrowe
995f5596d461cdd916f9ae5b7b4dcd27efbc3c2fwrowe // Verifier checks
0b64c3e5c7379284f90efc7193f16b373df39fe1wrowe static void check_super_class_access(instanceKlassHandle this_klass, TRAPS);
0b64c3e5c7379284f90efc7193f16b373df39fe1wrowe static void check_super_interface_access(instanceKlassHandle this_klass, TRAPS);
1e83c8de3aa48b316b28057d53995272baf1260cwrowe static void check_final_method_override(instanceKlassHandle this_klass, TRAPS);
1e83c8de3aa48b316b28057d53995272baf1260cwrowe static void check_illegal_static_method(instanceKlassHandle this_klass, TRAPS);
1e83c8de3aa48b316b28057d53995272baf1260cwrowe};
1e83c8de3aa48b316b28057d53995272baf1260cwrowe
3ea7933c5a74b8d8d54ec2689190a865a0689420wrowe#endif // SHARE_VM_CLASSFILE_CLASSFILEPARSER_HPP
1e83c8de3aa48b316b28057d53995272baf1260cwrowe