src/share/vm/classfile/classFileParser.hpp

Tue, 08 Aug 2017 15:57:29 +0800

author
aoqi
date
Tue, 08 Aug 2017 15:57:29 +0800
changeset 6876
710a3c8b516e
parent 6782
f73af4455d7d
parent 0
f90c822e73f8
child 7535
7ae4e26cb1e0
permissions
-rw-r--r--

merge

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 *
aoqi@0 23 */
aoqi@0 24
aoqi@0 25 #ifndef SHARE_VM_CLASSFILE_CLASSFILEPARSER_HPP
aoqi@0 26 #define SHARE_VM_CLASSFILE_CLASSFILEPARSER_HPP
aoqi@0 27
aoqi@0 28 #include "classfile/classFileStream.hpp"
aoqi@0 29 #include "memory/resourceArea.hpp"
aoqi@0 30 #include "oops/oop.inline.hpp"
aoqi@0 31 #include "oops/typeArrayOop.hpp"
aoqi@0 32 #include "runtime/handles.inline.hpp"
aoqi@0 33 #include "utilities/accessFlags.hpp"
aoqi@0 34 #include "classfile/symbolTable.hpp"
aoqi@0 35
aoqi@0 36 class FieldAllocationCount;
aoqi@0 37 class FieldLayoutInfo;
aoqi@0 38
aoqi@0 39
aoqi@0 40 // Parser for for .class files
aoqi@0 41 //
aoqi@0 42 // The bytes describing the class file structure is read from a Stream object
aoqi@0 43
aoqi@0 44 class ClassFileParser VALUE_OBJ_CLASS_SPEC {
aoqi@0 45 private:
aoqi@0 46 bool _need_verify;
aoqi@0 47 bool _relax_verify;
aoqi@0 48 u2 _major_version;
aoqi@0 49 u2 _minor_version;
aoqi@0 50 Symbol* _class_name;
aoqi@0 51 ClassLoaderData* _loader_data;
aoqi@0 52 KlassHandle _host_klass;
aoqi@0 53 GrowableArray<Handle>* _cp_patches; // overrides for CP entries
aoqi@0 54
aoqi@0 55 // precomputed flags
aoqi@0 56 bool _has_finalizer;
aoqi@0 57 bool _has_empty_finalizer;
aoqi@0 58 bool _has_vanilla_constructor;
aoqi@0 59 int _max_bootstrap_specifier_index; // detects BSS values
aoqi@0 60
aoqi@0 61 // class attributes parsed before the instance klass is created:
aoqi@0 62 bool _synthetic_flag;
aoqi@0 63 int _sde_length;
aoqi@0 64 char* _sde_buffer;
aoqi@0 65 u2 _sourcefile_index;
aoqi@0 66 u2 _generic_signature_index;
aoqi@0 67
aoqi@0 68 // Metadata created before the instance klass is created. Must be deallocated
aoqi@0 69 // if not transferred to the InstanceKlass upon successful class loading
aoqi@0 70 // in which case these pointers have been set to NULL.
aoqi@0 71 instanceKlassHandle _super_klass;
aoqi@0 72 ConstantPool* _cp;
aoqi@0 73 Array<u2>* _fields;
aoqi@0 74 Array<Method*>* _methods;
aoqi@0 75 Array<u2>* _inner_classes;
aoqi@0 76 Array<Klass*>* _local_interfaces;
aoqi@0 77 Array<Klass*>* _transitive_interfaces;
aoqi@0 78 AnnotationArray* _annotations;
aoqi@0 79 AnnotationArray* _type_annotations;
aoqi@0 80 Array<AnnotationArray*>* _fields_annotations;
aoqi@0 81 Array<AnnotationArray*>* _fields_type_annotations;
aoqi@0 82 InstanceKlass* _klass; // InstanceKlass once created.
aoqi@0 83
aoqi@0 84 void set_class_synthetic_flag(bool x) { _synthetic_flag = x; }
aoqi@0 85 void set_class_sourcefile_index(u2 x) { _sourcefile_index = x; }
aoqi@0 86 void set_class_generic_signature_index(u2 x) { _generic_signature_index = x; }
aoqi@0 87 void set_class_sde_buffer(char* x, int len) { _sde_buffer = x; _sde_length = len; }
aoqi@0 88
aoqi@0 89 void init_parsed_class_attributes(ClassLoaderData* loader_data) {
aoqi@0 90 _loader_data = loader_data;
aoqi@0 91 _synthetic_flag = false;
aoqi@0 92 _sourcefile_index = 0;
aoqi@0 93 _generic_signature_index = 0;
aoqi@0 94 _sde_buffer = NULL;
aoqi@0 95 _sde_length = 0;
aoqi@0 96 // initialize the other flags too:
aoqi@0 97 _has_finalizer = _has_empty_finalizer = _has_vanilla_constructor = false;
aoqi@0 98 _max_bootstrap_specifier_index = -1;
aoqi@0 99 clear_class_metadata();
aoqi@0 100 _klass = NULL;
aoqi@0 101 }
aoqi@0 102 void apply_parsed_class_attributes(instanceKlassHandle k); // update k
aoqi@0 103 void apply_parsed_class_metadata(instanceKlassHandle k, int fields_count, TRAPS);
aoqi@0 104 void clear_class_metadata() {
aoqi@0 105 // metadata created before the instance klass is created. Must be
aoqi@0 106 // deallocated if classfile parsing returns an error.
aoqi@0 107 _cp = NULL;
aoqi@0 108 _fields = NULL;
aoqi@0 109 _methods = NULL;
aoqi@0 110 _inner_classes = NULL;
aoqi@0 111 _local_interfaces = NULL;
aoqi@0 112 _transitive_interfaces = NULL;
aoqi@0 113 _annotations = _type_annotations = NULL;
aoqi@0 114 _fields_annotations = _fields_type_annotations = NULL;
aoqi@0 115 }
aoqi@0 116
aoqi@0 117 class AnnotationCollector {
aoqi@0 118 public:
aoqi@0 119 enum Location { _in_field, _in_method, _in_class };
aoqi@0 120 enum ID {
aoqi@0 121 _unknown = 0,
aoqi@0 122 _method_CallerSensitive,
aoqi@0 123 _method_ForceInline,
aoqi@0 124 _method_DontInline,
aoqi@0 125 _method_LambdaForm_Compiled,
aoqi@0 126 _method_LambdaForm_Hidden,
aoqi@0 127 _sun_misc_Contended,
aoqi@0 128 _field_Stable,
aoqi@0 129 _annotation_LIMIT
aoqi@0 130 };
aoqi@0 131 const Location _location;
aoqi@0 132 int _annotations_present;
aoqi@0 133 u2 _contended_group;
aoqi@0 134
aoqi@0 135 AnnotationCollector(Location location)
aoqi@0 136 : _location(location), _annotations_present(0)
aoqi@0 137 {
aoqi@0 138 assert((int)_annotation_LIMIT <= (int)sizeof(_annotations_present) * BitsPerByte, "");
aoqi@0 139 }
aoqi@0 140 // If this annotation name has an ID, report it (or _none).
aoqi@0 141 ID annotation_index(ClassLoaderData* loader_data, Symbol* name);
aoqi@0 142 // Set the annotation name:
aoqi@0 143 void set_annotation(ID id) {
aoqi@0 144 assert((int)id >= 0 && (int)id < (int)_annotation_LIMIT, "oob");
aoqi@0 145 _annotations_present |= nth_bit((int)id);
aoqi@0 146 }
aoqi@0 147
aoqi@0 148 void remove_annotation(ID id) {
aoqi@0 149 assert((int)id >= 0 && (int)id < (int)_annotation_LIMIT, "oob");
aoqi@0 150 _annotations_present &= ~nth_bit((int)id);
aoqi@0 151 }
aoqi@0 152
aoqi@0 153 // Report if the annotation is present.
aoqi@0 154 bool has_any_annotations() const { return _annotations_present != 0; }
aoqi@0 155 bool has_annotation(ID id) const { return (nth_bit((int)id) & _annotations_present) != 0; }
aoqi@0 156
aoqi@0 157 void set_contended_group(u2 group) { _contended_group = group; }
aoqi@0 158 u2 contended_group() const { return _contended_group; }
aoqi@0 159
aoqi@0 160 bool is_contended() const { return has_annotation(_sun_misc_Contended); }
aoqi@0 161
aoqi@0 162 void set_stable(bool stable) { set_annotation(_field_Stable); }
aoqi@0 163 bool is_stable() const { return has_annotation(_field_Stable); }
aoqi@0 164 };
aoqi@0 165
aoqi@0 166 // This class also doubles as a holder for metadata cleanup.
aoqi@0 167 class FieldAnnotationCollector: public AnnotationCollector {
aoqi@0 168 ClassLoaderData* _loader_data;
aoqi@0 169 AnnotationArray* _field_annotations;
aoqi@0 170 AnnotationArray* _field_type_annotations;
aoqi@0 171 public:
aoqi@0 172 FieldAnnotationCollector(ClassLoaderData* loader_data) :
aoqi@0 173 AnnotationCollector(_in_field),
aoqi@0 174 _loader_data(loader_data),
aoqi@0 175 _field_annotations(NULL),
aoqi@0 176 _field_type_annotations(NULL) {}
aoqi@0 177 void apply_to(FieldInfo* f);
aoqi@0 178 ~FieldAnnotationCollector();
aoqi@0 179 AnnotationArray* field_annotations() { return _field_annotations; }
aoqi@0 180 AnnotationArray* field_type_annotations() { return _field_type_annotations; }
aoqi@0 181
aoqi@0 182 void set_field_annotations(AnnotationArray* a) { _field_annotations = a; }
aoqi@0 183 void set_field_type_annotations(AnnotationArray* a) { _field_type_annotations = a; }
aoqi@0 184 };
aoqi@0 185
aoqi@0 186 class MethodAnnotationCollector: public AnnotationCollector {
aoqi@0 187 public:
aoqi@0 188 MethodAnnotationCollector() : AnnotationCollector(_in_method) { }
aoqi@0 189 void apply_to(methodHandle m);
aoqi@0 190 };
aoqi@0 191 class ClassAnnotationCollector: public AnnotationCollector {
aoqi@0 192 public:
aoqi@0 193 ClassAnnotationCollector() : AnnotationCollector(_in_class) { }
aoqi@0 194 void apply_to(instanceKlassHandle k);
aoqi@0 195 };
aoqi@0 196
aoqi@0 197 enum { fixed_buffer_size = 128 };
aoqi@0 198 u_char linenumbertable_buffer[fixed_buffer_size];
aoqi@0 199
aoqi@0 200 ClassFileStream* _stream; // Actual input stream
aoqi@0 201
aoqi@0 202 enum { LegalClass, LegalField, LegalMethod }; // used to verify unqualified names
aoqi@0 203
aoqi@0 204 // Accessors
aoqi@0 205 ClassFileStream* stream() { return _stream; }
aoqi@0 206 void set_stream(ClassFileStream* st) { _stream = st; }
aoqi@0 207
aoqi@0 208 // Constant pool parsing
aoqi@0 209 void parse_constant_pool_entries(int length, TRAPS);
aoqi@0 210
aoqi@0 211 constantPoolHandle parse_constant_pool(TRAPS);
aoqi@0 212
aoqi@0 213 // Interface parsing
aoqi@0 214 Array<Klass*>* parse_interfaces(int length,
aoqi@0 215 Handle protection_domain,
aoqi@0 216 Symbol* class_name,
aoqi@0 217 bool* has_default_methods,
aoqi@0 218 TRAPS);
aoqi@0 219 void record_defined_class_dependencies(instanceKlassHandle defined_klass, TRAPS);
aoqi@0 220
aoqi@0 221 instanceKlassHandle parse_super_class(int super_class_index, TRAPS);
aoqi@0 222 // Field parsing
aoqi@0 223 void parse_field_attributes(u2 attributes_count,
aoqi@0 224 bool is_static, u2 signature_index,
aoqi@0 225 u2* constantvalue_index_addr,
aoqi@0 226 bool* is_synthetic_addr,
aoqi@0 227 u2* generic_signature_index_addr,
aoqi@0 228 FieldAnnotationCollector* parsed_annotations,
aoqi@0 229 TRAPS);
aoqi@0 230 Array<u2>* parse_fields(Symbol* class_name,
aoqi@0 231 bool is_interface,
aoqi@0 232 FieldAllocationCount *fac,
aoqi@0 233 u2* java_fields_count_ptr, TRAPS);
aoqi@0 234
aoqi@0 235 void print_field_layout(Symbol* name,
aoqi@0 236 Array<u2>* fields,
aoqi@0 237 constantPoolHandle cp,
aoqi@0 238 int instance_size,
aoqi@0 239 int instance_fields_start,
aoqi@0 240 int instance_fields_end,
aoqi@0 241 int static_fields_end);
aoqi@0 242
aoqi@0 243 // Method parsing
aoqi@0 244 methodHandle parse_method(bool is_interface,
aoqi@0 245 AccessFlags* promoted_flags,
aoqi@0 246 TRAPS);
aoqi@0 247 Array<Method*>* parse_methods(bool is_interface,
aoqi@0 248 AccessFlags* promoted_flags,
aoqi@0 249 bool* has_final_method,
aoqi@0 250 bool* has_default_method,
aoqi@0 251 TRAPS);
aoqi@0 252 intArray* sort_methods(Array<Method*>* methods);
aoqi@0 253
aoqi@0 254 u2* parse_exception_table(u4 code_length, u4 exception_table_length,
aoqi@0 255 TRAPS);
aoqi@0 256 void parse_linenumber_table(
aoqi@0 257 u4 code_attribute_length, u4 code_length,
aoqi@0 258 CompressedLineNumberWriteStream** write_stream, TRAPS);
aoqi@0 259 u2* parse_localvariable_table(u4 code_length, u2 max_locals, u4 code_attribute_length,
aoqi@0 260 u2* localvariable_table_length,
aoqi@0 261 bool isLVTT, TRAPS);
aoqi@0 262 u2* parse_checked_exceptions(u2* checked_exceptions_length, u4 method_attribute_length,
aoqi@0 263 TRAPS);
aoqi@0 264 void parse_type_array(u2 array_length, u4 code_length, u4* u1_index, u4* u2_index,
aoqi@0 265 u1* u1_array, u2* u2_array, TRAPS);
aoqi@0 266 u1* parse_stackmap_table(u4 code_attribute_length, TRAPS);
aoqi@0 267
aoqi@0 268 // Classfile attribute parsing
aoqi@0 269 u2 parse_generic_signature_attribute(TRAPS);
aoqi@0 270 void parse_classfile_sourcefile_attribute(TRAPS);
aoqi@0 271 void parse_classfile_source_debug_extension_attribute(int length, TRAPS);
aoqi@0 272 u2 parse_classfile_inner_classes_attribute(u1* inner_classes_attribute_start,
aoqi@0 273 bool parsed_enclosingmethod_attribute,
aoqi@0 274 u2 enclosing_method_class_index,
aoqi@0 275 u2 enclosing_method_method_index,
aoqi@0 276 TRAPS);
aoqi@0 277 void parse_classfile_attributes(ClassAnnotationCollector* parsed_annotations,
aoqi@0 278 TRAPS);
aoqi@0 279 void parse_classfile_synthetic_attribute(TRAPS);
aoqi@0 280 void parse_classfile_signature_attribute(TRAPS);
aoqi@0 281 void parse_classfile_bootstrap_methods_attribute(u4 attribute_length, TRAPS);
aoqi@0 282
aoqi@0 283 // Annotations handling
aoqi@0 284 AnnotationArray* assemble_annotations(u1* runtime_visible_annotations,
aoqi@0 285 int runtime_visible_annotations_length,
aoqi@0 286 u1* runtime_invisible_annotations,
aoqi@0 287 int runtime_invisible_annotations_length, TRAPS);
aoqi@0 288 int skip_annotation(u1* buffer, int limit, int index);
aoqi@0 289 int skip_annotation_value(u1* buffer, int limit, int index);
aoqi@0 290 void parse_annotations(u1* buffer, int limit,
aoqi@0 291 /* Results (currently, only one result is supported): */
aoqi@0 292 AnnotationCollector* result,
aoqi@0 293 TRAPS);
aoqi@0 294
aoqi@0 295 // Final setup
aoqi@0 296 unsigned int compute_oop_map_count(instanceKlassHandle super,
aoqi@0 297 unsigned int nonstatic_oop_count,
aoqi@0 298 int first_nonstatic_oop_offset);
aoqi@0 299 void fill_oop_maps(instanceKlassHandle k,
aoqi@0 300 unsigned int nonstatic_oop_map_count,
aoqi@0 301 int* nonstatic_oop_offsets,
aoqi@0 302 unsigned int* nonstatic_oop_counts);
aoqi@0 303 void set_precomputed_flags(instanceKlassHandle k);
aoqi@0 304 Array<Klass*>* compute_transitive_interfaces(instanceKlassHandle super,
aoqi@0 305 Array<Klass*>* local_ifs, TRAPS);
aoqi@0 306
aoqi@0 307 // Format checker methods
aoqi@0 308 void classfile_parse_error(const char* msg, TRAPS);
aoqi@0 309 void classfile_parse_error(const char* msg, int index, TRAPS);
aoqi@0 310 void classfile_parse_error(const char* msg, const char *name, TRAPS);
aoqi@0 311 void classfile_parse_error(const char* msg, int index, const char *name, TRAPS);
aoqi@0 312 inline void guarantee_property(bool b, const char* msg, TRAPS) {
aoqi@0 313 if (!b) { classfile_parse_error(msg, CHECK); }
aoqi@0 314 }
aoqi@0 315
aoqi@0 316 PRAGMA_DIAG_PUSH
aoqi@0 317 PRAGMA_FORMAT_NONLITERAL_IGNORED
aoqi@0 318 inline void assert_property(bool b, const char* msg, TRAPS) {
aoqi@0 319 #ifdef ASSERT
aoqi@0 320 if (!b) {
aoqi@0 321 ResourceMark rm(THREAD);
aoqi@0 322 fatal(err_msg(msg, _class_name->as_C_string()));
aoqi@0 323 }
aoqi@0 324 #endif
aoqi@0 325 }
aoqi@0 326
aoqi@0 327 inline void assert_property(bool b, const char* msg, int index, TRAPS) {
aoqi@0 328 #ifdef ASSERT
aoqi@0 329 if (!b) {
aoqi@0 330 ResourceMark rm(THREAD);
aoqi@0 331 fatal(err_msg(msg, index, _class_name->as_C_string()));
aoqi@0 332 }
aoqi@0 333 #endif
aoqi@0 334 }
aoqi@0 335 PRAGMA_DIAG_POP
aoqi@0 336
aoqi@0 337 inline void check_property(bool property, const char* msg, int index, TRAPS) {
aoqi@0 338 if (_need_verify) {
aoqi@0 339 guarantee_property(property, msg, index, CHECK);
aoqi@0 340 } else {
aoqi@0 341 assert_property(property, msg, index, CHECK);
aoqi@0 342 }
aoqi@0 343 }
aoqi@0 344
aoqi@0 345 inline void check_property(bool property, const char* msg, TRAPS) {
aoqi@0 346 if (_need_verify) {
aoqi@0 347 guarantee_property(property, msg, CHECK);
aoqi@0 348 } else {
aoqi@0 349 assert_property(property, msg, CHECK);
aoqi@0 350 }
aoqi@0 351 }
aoqi@0 352
aoqi@0 353 inline void guarantee_property(bool b, const char* msg, int index, TRAPS) {
aoqi@0 354 if (!b) { classfile_parse_error(msg, index, CHECK); }
aoqi@0 355 }
aoqi@0 356 inline void guarantee_property(bool b, const char* msg, const char *name, TRAPS) {
aoqi@0 357 if (!b) { classfile_parse_error(msg, name, CHECK); }
aoqi@0 358 }
aoqi@0 359 inline void guarantee_property(bool b, const char* msg, int index, const char *name, TRAPS) {
aoqi@0 360 if (!b) { classfile_parse_error(msg, index, name, CHECK); }
aoqi@0 361 }
aoqi@0 362
aoqi@0 363 void throwIllegalSignature(
aoqi@0 364 const char* type, Symbol* name, Symbol* sig, TRAPS);
aoqi@0 365
aoqi@0 366 bool is_supported_version(u2 major, u2 minor);
aoqi@0 367 bool has_illegal_visibility(jint flags);
aoqi@0 368
aoqi@0 369 void verify_constantvalue(int constantvalue_index, int signature_index, TRAPS);
aoqi@0 370 void verify_legal_utf8(const unsigned char* buffer, int length, TRAPS);
aoqi@0 371 void verify_legal_class_name(Symbol* name, TRAPS);
aoqi@0 372 void verify_legal_field_name(Symbol* name, TRAPS);
aoqi@0 373 void verify_legal_method_name(Symbol* name, TRAPS);
aoqi@0 374 void verify_legal_field_signature(Symbol* fieldname, Symbol* signature, TRAPS);
aoqi@0 375 int verify_legal_method_signature(Symbol* methodname, Symbol* signature, TRAPS);
aoqi@0 376 void verify_legal_class_modifiers(jint flags, TRAPS);
aoqi@0 377 void verify_legal_field_modifiers(jint flags, bool is_interface, TRAPS);
aoqi@0 378 void verify_legal_method_modifiers(jint flags, bool is_interface, Symbol* name, TRAPS);
aoqi@0 379 bool verify_unqualified_name(char* name, unsigned int length, int type);
aoqi@0 380 char* skip_over_field_name(char* name, bool slash_ok, unsigned int length);
aoqi@0 381 char* skip_over_field_signature(char* signature, bool void_ok, unsigned int length, TRAPS);
aoqi@0 382
aoqi@0 383 bool is_anonymous() {
aoqi@0 384 assert(EnableInvokeDynamic || _host_klass.is_null(), "");
aoqi@0 385 return _host_klass.not_null();
aoqi@0 386 }
aoqi@0 387 bool has_cp_patch_at(int index) {
aoqi@0 388 assert(EnableInvokeDynamic, "");
aoqi@0 389 assert(index >= 0, "oob");
aoqi@0 390 return (_cp_patches != NULL
aoqi@0 391 && index < _cp_patches->length()
aoqi@0 392 && _cp_patches->adr_at(index)->not_null());
aoqi@0 393 }
aoqi@0 394 Handle cp_patch_at(int index) {
aoqi@0 395 assert(has_cp_patch_at(index), "oob");
aoqi@0 396 return _cp_patches->at(index);
aoqi@0 397 }
aoqi@0 398 Handle clear_cp_patch_at(int index) {
aoqi@0 399 Handle patch = cp_patch_at(index);
aoqi@0 400 _cp_patches->at_put(index, Handle());
aoqi@0 401 assert(!has_cp_patch_at(index), "");
aoqi@0 402 return patch;
aoqi@0 403 }
aoqi@0 404 void patch_constant_pool(constantPoolHandle cp, int index, Handle patch, TRAPS);
aoqi@0 405
aoqi@0 406 // Wrapper for constantTag.is_klass_[or_]reference.
aoqi@0 407 // In older versions of the VM, Klass*s cannot sneak into early phases of
aoqi@0 408 // constant pool construction, but in later versions they can.
aoqi@0 409 // %%% Let's phase out the old is_klass_reference.
aoqi@0 410 bool valid_klass_reference_at(int index) {
aoqi@0 411 return _cp->is_within_bounds(index) &&
aoqi@0 412 (EnableInvokeDynamic
aoqi@0 413 ? _cp->tag_at(index).is_klass_or_reference()
aoqi@0 414 : _cp->tag_at(index).is_klass_reference());
aoqi@0 415 }
aoqi@0 416
aoqi@0 417 // Checks that the cpool index is in range and is a utf8
aoqi@0 418 bool valid_symbol_at(int cpool_index) {
aoqi@0 419 return (_cp->is_within_bounds(cpool_index) &&
aoqi@0 420 _cp->tag_at(cpool_index).is_utf8());
aoqi@0 421 }
aoqi@0 422
aoqi@0 423 void copy_localvariable_table(ConstMethod* cm, int lvt_cnt,
aoqi@0 424 u2* localvariable_table_length,
aoqi@0 425 u2** localvariable_table_start,
aoqi@0 426 int lvtt_cnt,
aoqi@0 427 u2* localvariable_type_table_length,
aoqi@0 428 u2** localvariable_type_table_start,
aoqi@0 429 TRAPS);
aoqi@0 430
aoqi@0 431 void copy_method_annotations(ConstMethod* cm,
aoqi@0 432 u1* runtime_visible_annotations,
aoqi@0 433 int runtime_visible_annotations_length,
aoqi@0 434 u1* runtime_invisible_annotations,
aoqi@0 435 int runtime_invisible_annotations_length,
aoqi@0 436 u1* runtime_visible_parameter_annotations,
aoqi@0 437 int runtime_visible_parameter_annotations_length,
aoqi@0 438 u1* runtime_invisible_parameter_annotations,
aoqi@0 439 int runtime_invisible_parameter_annotations_length,
aoqi@0 440 u1* runtime_visible_type_annotations,
aoqi@0 441 int runtime_visible_type_annotations_length,
aoqi@0 442 u1* runtime_invisible_type_annotations,
aoqi@0 443 int runtime_invisible_type_annotations_length,
aoqi@0 444 u1* annotation_default,
aoqi@0 445 int annotation_default_length,
aoqi@0 446 TRAPS);
aoqi@0 447
aoqi@0 448 // lays out fields in class and returns the total oopmap count
aoqi@0 449 void layout_fields(Handle class_loader, FieldAllocationCount* fac,
aoqi@0 450 ClassAnnotationCollector* parsed_annotations,
aoqi@0 451 FieldLayoutInfo* info, TRAPS);
aoqi@0 452
aoqi@0 453 public:
aoqi@0 454 // Constructor
aoqi@0 455 ClassFileParser(ClassFileStream* st) { set_stream(st); }
aoqi@0 456 ~ClassFileParser();
aoqi@0 457
aoqi@0 458 // Parse .class file and return new Klass*. The Klass* is not hooked up
aoqi@0 459 // to the system dictionary or any other structures, so a .class file can
aoqi@0 460 // be loaded several times if desired.
aoqi@0 461 // The system dictionary hookup is done by the caller.
aoqi@0 462 //
aoqi@0 463 // "parsed_name" is updated by this method, and is the name found
aoqi@0 464 // while parsing the stream.
aoqi@0 465 instanceKlassHandle parseClassFile(Symbol* name,
aoqi@0 466 ClassLoaderData* loader_data,
aoqi@0 467 Handle protection_domain,
aoqi@0 468 TempNewSymbol& parsed_name,
aoqi@0 469 bool verify,
aoqi@0 470 TRAPS) {
aoqi@0 471 KlassHandle no_host_klass;
aoqi@0 472 return parseClassFile(name, loader_data, protection_domain, no_host_klass, NULL, parsed_name, verify, THREAD);
aoqi@0 473 }
aoqi@0 474 instanceKlassHandle parseClassFile(Symbol* name,
aoqi@0 475 ClassLoaderData* loader_data,
aoqi@0 476 Handle protection_domain,
aoqi@0 477 KlassHandle host_klass,
aoqi@0 478 GrowableArray<Handle>* cp_patches,
aoqi@0 479 TempNewSymbol& parsed_name,
aoqi@0 480 bool verify,
aoqi@0 481 TRAPS);
aoqi@0 482
aoqi@0 483 // Verifier checks
aoqi@0 484 static void check_super_class_access(instanceKlassHandle this_klass, TRAPS);
aoqi@0 485 static void check_super_interface_access(instanceKlassHandle this_klass, TRAPS);
aoqi@0 486 static void check_final_method_override(instanceKlassHandle this_klass, TRAPS);
aoqi@0 487 static void check_illegal_static_method(instanceKlassHandle this_klass, TRAPS);
aoqi@0 488 };
aoqi@0 489
aoqi@0 490 #endif // SHARE_VM_CLASSFILE_CLASSFILEPARSER_HPP

mercurial