src/share/vm/classfile/classFileParser.hpp

Thu, 12 Oct 2017 21:27:07 +0800

author
aoqi
date
Thu, 12 Oct 2017 21:27:07 +0800
changeset 7535
7ae4e26cb1e0
parent 7417
0fa1f71a905b
parent 6876
710a3c8b516e
child 7994
04ff2f6cd0eb
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;
stefank@7417 78 Annotations* _combined_annotations;
aoqi@0 79 AnnotationArray* _annotations;
aoqi@0 80 AnnotationArray* _type_annotations;
aoqi@0 81 Array<AnnotationArray*>* _fields_annotations;
aoqi@0 82 Array<AnnotationArray*>* _fields_type_annotations;
aoqi@0 83 InstanceKlass* _klass; // InstanceKlass once created.
aoqi@0 84
aoqi@0 85 void set_class_synthetic_flag(bool x) { _synthetic_flag = x; }
aoqi@0 86 void set_class_sourcefile_index(u2 x) { _sourcefile_index = x; }
aoqi@0 87 void set_class_generic_signature_index(u2 x) { _generic_signature_index = x; }
aoqi@0 88 void set_class_sde_buffer(char* x, int len) { _sde_buffer = x; _sde_length = len; }
aoqi@0 89
stefank@7417 90 void create_combined_annotations(TRAPS);
stefank@7417 91
aoqi@0 92 void init_parsed_class_attributes(ClassLoaderData* loader_data) {
aoqi@0 93 _loader_data = loader_data;
aoqi@0 94 _synthetic_flag = false;
aoqi@0 95 _sourcefile_index = 0;
aoqi@0 96 _generic_signature_index = 0;
aoqi@0 97 _sde_buffer = NULL;
aoqi@0 98 _sde_length = 0;
aoqi@0 99 // initialize the other flags too:
aoqi@0 100 _has_finalizer = _has_empty_finalizer = _has_vanilla_constructor = false;
aoqi@0 101 _max_bootstrap_specifier_index = -1;
aoqi@0 102 clear_class_metadata();
aoqi@0 103 _klass = NULL;
aoqi@0 104 }
aoqi@0 105 void apply_parsed_class_attributes(instanceKlassHandle k); // update k
aoqi@0 106 void apply_parsed_class_metadata(instanceKlassHandle k, int fields_count, TRAPS);
aoqi@0 107 void clear_class_metadata() {
aoqi@0 108 // metadata created before the instance klass is created. Must be
aoqi@0 109 // deallocated if classfile parsing returns an error.
aoqi@0 110 _cp = NULL;
aoqi@0 111 _fields = NULL;
aoqi@0 112 _methods = NULL;
aoqi@0 113 _inner_classes = NULL;
aoqi@0 114 _local_interfaces = NULL;
aoqi@0 115 _transitive_interfaces = NULL;
stefank@7417 116 _combined_annotations = NULL;
aoqi@0 117 _annotations = _type_annotations = NULL;
aoqi@0 118 _fields_annotations = _fields_type_annotations = NULL;
aoqi@0 119 }
aoqi@0 120
aoqi@0 121 class AnnotationCollector {
aoqi@0 122 public:
aoqi@0 123 enum Location { _in_field, _in_method, _in_class };
aoqi@0 124 enum ID {
aoqi@0 125 _unknown = 0,
aoqi@0 126 _method_CallerSensitive,
aoqi@0 127 _method_ForceInline,
aoqi@0 128 _method_DontInline,
aoqi@0 129 _method_LambdaForm_Compiled,
aoqi@0 130 _method_LambdaForm_Hidden,
aoqi@0 131 _sun_misc_Contended,
aoqi@0 132 _field_Stable,
aoqi@0 133 _annotation_LIMIT
aoqi@0 134 };
aoqi@0 135 const Location _location;
aoqi@0 136 int _annotations_present;
aoqi@0 137 u2 _contended_group;
aoqi@0 138
aoqi@0 139 AnnotationCollector(Location location)
aoqi@0 140 : _location(location), _annotations_present(0)
aoqi@0 141 {
aoqi@0 142 assert((int)_annotation_LIMIT <= (int)sizeof(_annotations_present) * BitsPerByte, "");
aoqi@0 143 }
aoqi@0 144 // If this annotation name has an ID, report it (or _none).
aoqi@0 145 ID annotation_index(ClassLoaderData* loader_data, Symbol* name);
aoqi@0 146 // Set the annotation name:
aoqi@0 147 void set_annotation(ID id) {
aoqi@0 148 assert((int)id >= 0 && (int)id < (int)_annotation_LIMIT, "oob");
aoqi@0 149 _annotations_present |= nth_bit((int)id);
aoqi@0 150 }
aoqi@0 151
aoqi@0 152 void remove_annotation(ID id) {
aoqi@0 153 assert((int)id >= 0 && (int)id < (int)_annotation_LIMIT, "oob");
aoqi@0 154 _annotations_present &= ~nth_bit((int)id);
aoqi@0 155 }
aoqi@0 156
aoqi@0 157 // Report if the annotation is present.
aoqi@0 158 bool has_any_annotations() const { return _annotations_present != 0; }
aoqi@0 159 bool has_annotation(ID id) const { return (nth_bit((int)id) & _annotations_present) != 0; }
aoqi@0 160
aoqi@0 161 void set_contended_group(u2 group) { _contended_group = group; }
aoqi@0 162 u2 contended_group() const { return _contended_group; }
aoqi@0 163
aoqi@0 164 bool is_contended() const { return has_annotation(_sun_misc_Contended); }
aoqi@0 165
aoqi@0 166 void set_stable(bool stable) { set_annotation(_field_Stable); }
aoqi@0 167 bool is_stable() const { return has_annotation(_field_Stable); }
aoqi@0 168 };
aoqi@0 169
aoqi@0 170 // This class also doubles as a holder for metadata cleanup.
aoqi@0 171 class FieldAnnotationCollector: public AnnotationCollector {
aoqi@0 172 ClassLoaderData* _loader_data;
aoqi@0 173 AnnotationArray* _field_annotations;
aoqi@0 174 AnnotationArray* _field_type_annotations;
aoqi@0 175 public:
aoqi@0 176 FieldAnnotationCollector(ClassLoaderData* loader_data) :
aoqi@0 177 AnnotationCollector(_in_field),
aoqi@0 178 _loader_data(loader_data),
aoqi@0 179 _field_annotations(NULL),
aoqi@0 180 _field_type_annotations(NULL) {}
aoqi@0 181 void apply_to(FieldInfo* f);
aoqi@0 182 ~FieldAnnotationCollector();
aoqi@0 183 AnnotationArray* field_annotations() { return _field_annotations; }
aoqi@0 184 AnnotationArray* field_type_annotations() { return _field_type_annotations; }
aoqi@0 185
aoqi@0 186 void set_field_annotations(AnnotationArray* a) { _field_annotations = a; }
aoqi@0 187 void set_field_type_annotations(AnnotationArray* a) { _field_type_annotations = a; }
aoqi@0 188 };
aoqi@0 189
aoqi@0 190 class MethodAnnotationCollector: public AnnotationCollector {
aoqi@0 191 public:
aoqi@0 192 MethodAnnotationCollector() : AnnotationCollector(_in_method) { }
aoqi@0 193 void apply_to(methodHandle m);
aoqi@0 194 };
aoqi@0 195 class ClassAnnotationCollector: public AnnotationCollector {
aoqi@0 196 public:
aoqi@0 197 ClassAnnotationCollector() : AnnotationCollector(_in_class) { }
aoqi@0 198 void apply_to(instanceKlassHandle k);
aoqi@0 199 };
aoqi@0 200
aoqi@0 201 enum { fixed_buffer_size = 128 };
aoqi@0 202 u_char linenumbertable_buffer[fixed_buffer_size];
aoqi@0 203
aoqi@0 204 ClassFileStream* _stream; // Actual input stream
aoqi@0 205
aoqi@0 206 enum { LegalClass, LegalField, LegalMethod }; // used to verify unqualified names
aoqi@0 207
aoqi@0 208 // Accessors
aoqi@0 209 ClassFileStream* stream() { return _stream; }
aoqi@0 210 void set_stream(ClassFileStream* st) { _stream = st; }
aoqi@0 211
aoqi@0 212 // Constant pool parsing
aoqi@0 213 void parse_constant_pool_entries(int length, TRAPS);
aoqi@0 214
aoqi@0 215 constantPoolHandle parse_constant_pool(TRAPS);
aoqi@0 216
aoqi@0 217 // Interface parsing
aoqi@0 218 Array<Klass*>* parse_interfaces(int length,
aoqi@0 219 Handle protection_domain,
aoqi@0 220 Symbol* class_name,
aoqi@0 221 bool* has_default_methods,
aoqi@0 222 TRAPS);
aoqi@0 223 void record_defined_class_dependencies(instanceKlassHandle defined_klass, TRAPS);
aoqi@0 224
aoqi@0 225 instanceKlassHandle parse_super_class(int super_class_index, TRAPS);
aoqi@0 226 // Field parsing
aoqi@0 227 void parse_field_attributes(u2 attributes_count,
aoqi@0 228 bool is_static, u2 signature_index,
aoqi@0 229 u2* constantvalue_index_addr,
aoqi@0 230 bool* is_synthetic_addr,
aoqi@0 231 u2* generic_signature_index_addr,
aoqi@0 232 FieldAnnotationCollector* parsed_annotations,
aoqi@0 233 TRAPS);
aoqi@0 234 Array<u2>* parse_fields(Symbol* class_name,
aoqi@0 235 bool is_interface,
aoqi@0 236 FieldAllocationCount *fac,
aoqi@0 237 u2* java_fields_count_ptr, TRAPS);
aoqi@0 238
aoqi@0 239 void print_field_layout(Symbol* name,
aoqi@0 240 Array<u2>* fields,
aoqi@0 241 constantPoolHandle cp,
aoqi@0 242 int instance_size,
aoqi@0 243 int instance_fields_start,
aoqi@0 244 int instance_fields_end,
aoqi@0 245 int static_fields_end);
aoqi@0 246
aoqi@0 247 // Method parsing
aoqi@0 248 methodHandle parse_method(bool is_interface,
aoqi@0 249 AccessFlags* promoted_flags,
aoqi@0 250 TRAPS);
aoqi@0 251 Array<Method*>* parse_methods(bool is_interface,
aoqi@0 252 AccessFlags* promoted_flags,
aoqi@0 253 bool* has_final_method,
acorn@7290 254 bool* declares_default_methods,
aoqi@0 255 TRAPS);
aoqi@0 256 intArray* sort_methods(Array<Method*>* methods);
aoqi@0 257
aoqi@0 258 u2* parse_exception_table(u4 code_length, u4 exception_table_length,
aoqi@0 259 TRAPS);
aoqi@0 260 void parse_linenumber_table(
aoqi@0 261 u4 code_attribute_length, u4 code_length,
aoqi@0 262 CompressedLineNumberWriteStream** write_stream, TRAPS);
aoqi@0 263 u2* parse_localvariable_table(u4 code_length, u2 max_locals, u4 code_attribute_length,
aoqi@0 264 u2* localvariable_table_length,
aoqi@0 265 bool isLVTT, TRAPS);
aoqi@0 266 u2* parse_checked_exceptions(u2* checked_exceptions_length, u4 method_attribute_length,
aoqi@0 267 TRAPS);
aoqi@0 268 void parse_type_array(u2 array_length, u4 code_length, u4* u1_index, u4* u2_index,
aoqi@0 269 u1* u1_array, u2* u2_array, TRAPS);
aoqi@0 270 u1* parse_stackmap_table(u4 code_attribute_length, TRAPS);
aoqi@0 271
aoqi@0 272 // Classfile attribute parsing
aoqi@0 273 u2 parse_generic_signature_attribute(TRAPS);
aoqi@0 274 void parse_classfile_sourcefile_attribute(TRAPS);
aoqi@0 275 void parse_classfile_source_debug_extension_attribute(int length, TRAPS);
aoqi@0 276 u2 parse_classfile_inner_classes_attribute(u1* inner_classes_attribute_start,
aoqi@0 277 bool parsed_enclosingmethod_attribute,
aoqi@0 278 u2 enclosing_method_class_index,
aoqi@0 279 u2 enclosing_method_method_index,
aoqi@0 280 TRAPS);
aoqi@0 281 void parse_classfile_attributes(ClassAnnotationCollector* parsed_annotations,
aoqi@0 282 TRAPS);
aoqi@0 283 void parse_classfile_synthetic_attribute(TRAPS);
aoqi@0 284 void parse_classfile_signature_attribute(TRAPS);
aoqi@0 285 void parse_classfile_bootstrap_methods_attribute(u4 attribute_length, TRAPS);
aoqi@0 286
aoqi@0 287 // Annotations handling
aoqi@0 288 AnnotationArray* assemble_annotations(u1* runtime_visible_annotations,
aoqi@0 289 int runtime_visible_annotations_length,
aoqi@0 290 u1* runtime_invisible_annotations,
aoqi@0 291 int runtime_invisible_annotations_length, TRAPS);
aoqi@0 292 int skip_annotation(u1* buffer, int limit, int index);
aoqi@0 293 int skip_annotation_value(u1* buffer, int limit, int index);
aoqi@0 294 void parse_annotations(u1* buffer, int limit,
aoqi@0 295 /* Results (currently, only one result is supported): */
aoqi@0 296 AnnotationCollector* result,
aoqi@0 297 TRAPS);
aoqi@0 298
aoqi@0 299 // Final setup
aoqi@0 300 unsigned int compute_oop_map_count(instanceKlassHandle super,
aoqi@0 301 unsigned int nonstatic_oop_count,
aoqi@0 302 int first_nonstatic_oop_offset);
aoqi@0 303 void fill_oop_maps(instanceKlassHandle k,
aoqi@0 304 unsigned int nonstatic_oop_map_count,
aoqi@0 305 int* nonstatic_oop_offsets,
aoqi@0 306 unsigned int* nonstatic_oop_counts);
aoqi@0 307 void set_precomputed_flags(instanceKlassHandle k);
aoqi@0 308 Array<Klass*>* compute_transitive_interfaces(instanceKlassHandle super,
aoqi@0 309 Array<Klass*>* local_ifs, TRAPS);
aoqi@0 310
aoqi@0 311 // Format checker methods
aoqi@0 312 void classfile_parse_error(const char* msg, TRAPS);
aoqi@0 313 void classfile_parse_error(const char* msg, int index, TRAPS);
aoqi@0 314 void classfile_parse_error(const char* msg, const char *name, TRAPS);
aoqi@0 315 void classfile_parse_error(const char* msg, int index, const char *name, TRAPS);
aoqi@0 316 inline void guarantee_property(bool b, const char* msg, TRAPS) {
aoqi@0 317 if (!b) { classfile_parse_error(msg, CHECK); }
aoqi@0 318 }
aoqi@0 319
aoqi@0 320 PRAGMA_DIAG_PUSH
aoqi@0 321 PRAGMA_FORMAT_NONLITERAL_IGNORED
aoqi@0 322 inline void assert_property(bool b, const char* msg, TRAPS) {
aoqi@0 323 #ifdef ASSERT
aoqi@0 324 if (!b) {
aoqi@0 325 ResourceMark rm(THREAD);
aoqi@0 326 fatal(err_msg(msg, _class_name->as_C_string()));
aoqi@0 327 }
aoqi@0 328 #endif
aoqi@0 329 }
aoqi@0 330
aoqi@0 331 inline void assert_property(bool b, const char* msg, int index, TRAPS) {
aoqi@0 332 #ifdef ASSERT
aoqi@0 333 if (!b) {
aoqi@0 334 ResourceMark rm(THREAD);
aoqi@0 335 fatal(err_msg(msg, index, _class_name->as_C_string()));
aoqi@0 336 }
aoqi@0 337 #endif
aoqi@0 338 }
aoqi@0 339 PRAGMA_DIAG_POP
aoqi@0 340
aoqi@0 341 inline void check_property(bool property, const char* msg, int index, TRAPS) {
aoqi@0 342 if (_need_verify) {
aoqi@0 343 guarantee_property(property, msg, index, CHECK);
aoqi@0 344 } else {
aoqi@0 345 assert_property(property, msg, index, CHECK);
aoqi@0 346 }
aoqi@0 347 }
aoqi@0 348
aoqi@0 349 inline void check_property(bool property, const char* msg, TRAPS) {
aoqi@0 350 if (_need_verify) {
aoqi@0 351 guarantee_property(property, msg, CHECK);
aoqi@0 352 } else {
aoqi@0 353 assert_property(property, msg, CHECK);
aoqi@0 354 }
aoqi@0 355 }
aoqi@0 356
aoqi@0 357 inline void guarantee_property(bool b, const char* msg, int index, TRAPS) {
aoqi@0 358 if (!b) { classfile_parse_error(msg, index, CHECK); }
aoqi@0 359 }
aoqi@0 360 inline void guarantee_property(bool b, const char* msg, const char *name, TRAPS) {
aoqi@0 361 if (!b) { classfile_parse_error(msg, name, CHECK); }
aoqi@0 362 }
aoqi@0 363 inline void guarantee_property(bool b, const char* msg, int index, const char *name, TRAPS) {
aoqi@0 364 if (!b) { classfile_parse_error(msg, index, name, CHECK); }
aoqi@0 365 }
aoqi@0 366
aoqi@0 367 void throwIllegalSignature(
aoqi@0 368 const char* type, Symbol* name, Symbol* sig, TRAPS);
aoqi@0 369
aoqi@0 370 bool is_supported_version(u2 major, u2 minor);
aoqi@0 371 bool has_illegal_visibility(jint flags);
aoqi@0 372
aoqi@0 373 void verify_constantvalue(int constantvalue_index, int signature_index, TRAPS);
aoqi@0 374 void verify_legal_utf8(const unsigned char* buffer, int length, TRAPS);
aoqi@0 375 void verify_legal_class_name(Symbol* name, TRAPS);
aoqi@0 376 void verify_legal_field_name(Symbol* name, TRAPS);
aoqi@0 377 void verify_legal_method_name(Symbol* name, TRAPS);
aoqi@0 378 void verify_legal_field_signature(Symbol* fieldname, Symbol* signature, TRAPS);
aoqi@0 379 int verify_legal_method_signature(Symbol* methodname, Symbol* signature, TRAPS);
aoqi@0 380 void verify_legal_class_modifiers(jint flags, TRAPS);
aoqi@0 381 void verify_legal_field_modifiers(jint flags, bool is_interface, TRAPS);
aoqi@0 382 void verify_legal_method_modifiers(jint flags, bool is_interface, Symbol* name, TRAPS);
aoqi@0 383 bool verify_unqualified_name(char* name, unsigned int length, int type);
aoqi@0 384 char* skip_over_field_name(char* name, bool slash_ok, unsigned int length);
aoqi@0 385 char* skip_over_field_signature(char* signature, bool void_ok, unsigned int length, TRAPS);
aoqi@0 386
aoqi@0 387 bool is_anonymous() {
aoqi@0 388 assert(EnableInvokeDynamic || _host_klass.is_null(), "");
aoqi@0 389 return _host_klass.not_null();
aoqi@0 390 }
aoqi@0 391 bool has_cp_patch_at(int index) {
aoqi@0 392 assert(EnableInvokeDynamic, "");
aoqi@0 393 assert(index >= 0, "oob");
aoqi@0 394 return (_cp_patches != NULL
aoqi@0 395 && index < _cp_patches->length()
aoqi@0 396 && _cp_patches->adr_at(index)->not_null());
aoqi@0 397 }
aoqi@0 398 Handle cp_patch_at(int index) {
aoqi@0 399 assert(has_cp_patch_at(index), "oob");
aoqi@0 400 return _cp_patches->at(index);
aoqi@0 401 }
aoqi@0 402 Handle clear_cp_patch_at(int index) {
aoqi@0 403 Handle patch = cp_patch_at(index);
aoqi@0 404 _cp_patches->at_put(index, Handle());
aoqi@0 405 assert(!has_cp_patch_at(index), "");
aoqi@0 406 return patch;
aoqi@0 407 }
aoqi@0 408 void patch_constant_pool(constantPoolHandle cp, int index, Handle patch, TRAPS);
aoqi@0 409
aoqi@0 410 // Wrapper for constantTag.is_klass_[or_]reference.
aoqi@0 411 // In older versions of the VM, Klass*s cannot sneak into early phases of
aoqi@0 412 // constant pool construction, but in later versions they can.
aoqi@0 413 // %%% Let's phase out the old is_klass_reference.
aoqi@0 414 bool valid_klass_reference_at(int index) {
aoqi@0 415 return _cp->is_within_bounds(index) &&
aoqi@0 416 (EnableInvokeDynamic
aoqi@0 417 ? _cp->tag_at(index).is_klass_or_reference()
aoqi@0 418 : _cp->tag_at(index).is_klass_reference());
aoqi@0 419 }
aoqi@0 420
aoqi@0 421 // Checks that the cpool index is in range and is a utf8
aoqi@0 422 bool valid_symbol_at(int cpool_index) {
aoqi@0 423 return (_cp->is_within_bounds(cpool_index) &&
aoqi@0 424 _cp->tag_at(cpool_index).is_utf8());
aoqi@0 425 }
aoqi@0 426
aoqi@0 427 void copy_localvariable_table(ConstMethod* cm, int lvt_cnt,
aoqi@0 428 u2* localvariable_table_length,
aoqi@0 429 u2** localvariable_table_start,
aoqi@0 430 int lvtt_cnt,
aoqi@0 431 u2* localvariable_type_table_length,
aoqi@0 432 u2** localvariable_type_table_start,
aoqi@0 433 TRAPS);
aoqi@0 434
aoqi@0 435 void copy_method_annotations(ConstMethod* cm,
aoqi@0 436 u1* runtime_visible_annotations,
aoqi@0 437 int runtime_visible_annotations_length,
aoqi@0 438 u1* runtime_invisible_annotations,
aoqi@0 439 int runtime_invisible_annotations_length,
aoqi@0 440 u1* runtime_visible_parameter_annotations,
aoqi@0 441 int runtime_visible_parameter_annotations_length,
aoqi@0 442 u1* runtime_invisible_parameter_annotations,
aoqi@0 443 int runtime_invisible_parameter_annotations_length,
aoqi@0 444 u1* runtime_visible_type_annotations,
aoqi@0 445 int runtime_visible_type_annotations_length,
aoqi@0 446 u1* runtime_invisible_type_annotations,
aoqi@0 447 int runtime_invisible_type_annotations_length,
aoqi@0 448 u1* annotation_default,
aoqi@0 449 int annotation_default_length,
aoqi@0 450 TRAPS);
aoqi@0 451
aoqi@0 452 // lays out fields in class and returns the total oopmap count
aoqi@0 453 void layout_fields(Handle class_loader, FieldAllocationCount* fac,
aoqi@0 454 ClassAnnotationCollector* parsed_annotations,
aoqi@0 455 FieldLayoutInfo* info, TRAPS);
aoqi@0 456
aoqi@0 457 public:
aoqi@0 458 // Constructor
aoqi@0 459 ClassFileParser(ClassFileStream* st) { set_stream(st); }
aoqi@0 460 ~ClassFileParser();
aoqi@0 461
aoqi@0 462 // Parse .class file and return new Klass*. The Klass* is not hooked up
aoqi@0 463 // to the system dictionary or any other structures, so a .class file can
aoqi@0 464 // be loaded several times if desired.
aoqi@0 465 // The system dictionary hookup is done by the caller.
aoqi@0 466 //
aoqi@0 467 // "parsed_name" is updated by this method, and is the name found
aoqi@0 468 // while parsing the stream.
aoqi@0 469 instanceKlassHandle parseClassFile(Symbol* name,
aoqi@0 470 ClassLoaderData* loader_data,
aoqi@0 471 Handle protection_domain,
aoqi@0 472 TempNewSymbol& parsed_name,
aoqi@0 473 bool verify,
aoqi@0 474 TRAPS) {
aoqi@0 475 KlassHandle no_host_klass;
aoqi@0 476 return parseClassFile(name, loader_data, protection_domain, no_host_klass, NULL, parsed_name, verify, THREAD);
aoqi@0 477 }
aoqi@0 478 instanceKlassHandle parseClassFile(Symbol* name,
aoqi@0 479 ClassLoaderData* loader_data,
aoqi@0 480 Handle protection_domain,
aoqi@0 481 KlassHandle host_klass,
aoqi@0 482 GrowableArray<Handle>* cp_patches,
aoqi@0 483 TempNewSymbol& parsed_name,
aoqi@0 484 bool verify,
aoqi@0 485 TRAPS);
aoqi@0 486
aoqi@0 487 // Verifier checks
aoqi@0 488 static void check_super_class_access(instanceKlassHandle this_klass, TRAPS);
aoqi@0 489 static void check_super_interface_access(instanceKlassHandle this_klass, TRAPS);
aoqi@0 490 static void check_final_method_override(instanceKlassHandle this_klass, TRAPS);
aoqi@0 491 static void check_illegal_static_method(instanceKlassHandle this_klass, TRAPS);
aoqi@0 492 };
aoqi@0 493
aoqi@0 494 #endif // SHARE_VM_CLASSFILE_CLASSFILEPARSER_HPP

mercurial