annotate src/share/vm/classfile/classFileParser.hpp @ 12927:a7683f72df68

8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only Summary: Added _resolved_klasses; moved _resolved_references to ConstantPoolCache, etc. Reviewed-by: coleenp, lfoltan, simonis, aph
author iklam
date Fri, 03 Mar 2017 23:08:35 -0800
parents 79c9ae2cd749
children dc6b2e52b5ea 4b93e1b1d5b7
rev   line source
duke@0 1 /*
hseigel@12784 2 * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
duke@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@0 4 *
duke@0 5 * This code is free software; you can redistribute it and/or modify it
duke@0 6 * under the terms of the GNU General Public License version 2 only, as
duke@0 7 * published by the Free Software Foundation.
duke@0 8 *
duke@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@0 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@0 13 * accompanied this code).
duke@0 14 *
duke@0 15 * You should have received a copy of the GNU General Public License version
duke@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@0 18 *
trims@1472 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1472 20 * or visit www.oracle.com if you need additional information or have any
trims@1472 21 * questions.
duke@0 22 *
duke@0 23 */
duke@0 24
stefank@1879 25 #ifndef SHARE_VM_CLASSFILE_CLASSFILEPARSER_HPP
stefank@1879 26 #define SHARE_VM_CLASSFILE_CLASSFILEPARSER_HPP
stefank@1879 27
mgronlun@9684 28 #include "memory/referenceType.hpp"
mgronlun@9684 29 #include "runtime/handles.inline.hpp"
stefank@7898 30 #include "oops/constantPool.hpp"
stefank@1879 31 #include "oops/typeArrayOop.hpp"
stefank@1879 32 #include "utilities/accessFlags.hpp"
stefank@1879 33
mgronlun@9684 34 class Annotations;
mgronlun@9684 35 template <typename T>
mgronlun@9684 36 class Array;
mgronlun@9684 37 class ClassFileStream;
mgronlun@9684 38 class ClassLoaderData;
stefank@7898 39 class CompressedLineNumberWriteStream;
mgronlun@9684 40 class ConstMethod;
stefank@7898 41 class FieldInfo;
mgronlun@9684 42 template <typename T>
mgronlun@9684 43 class GrowableArray;
mgronlun@9684 44 class InstanceKlass;
mgronlun@9684 45 class Symbol;
mgronlun@9684 46 class TempNewSymbol;
never@2702 47
duke@0 48 // Parser for for .class files
duke@0 49 //
duke@0 50 // The bytes describing the class file structure is read from a Stream object
duke@0 51
duke@0 52 class ClassFileParser VALUE_OBJ_CLASS_SPEC {
mgronlun@9684 53
mgronlun@9684 54 class ClassAnnotationCollector;
mgronlun@9684 55 class FieldAllocationCount;
mgronlun@9684 56 class FieldAnnotationCollector;
mgronlun@9684 57 class FieldLayoutInfo;
mgronlun@9684 58
mgronlun@9684 59 public:
mgronlun@9684 60 // The ClassFileParser has an associated "publicity" level
mgronlun@9684 61 // It is used to control which subsystems (if any)
mgronlun@9684 62 // will observe the parsing (logging, events, tracing).
mgronlun@9684 63 // Default level is "BROADCAST", which is equivalent to
mgronlun@9684 64 // a "public" parsing attempt.
mgronlun@9684 65 //
mgronlun@9684 66 // "INTERNAL" level should be entirely private to the
mgronlun@9684 67 // caller - this allows for internal reuse of ClassFileParser
mgronlun@9684 68 //
mgronlun@9684 69 enum Publicity {
mgronlun@9684 70 INTERNAL,
mgronlun@9684 71 BROADCAST,
mgronlun@9684 72 NOF_PUBLICITY_LEVELS
mgronlun@9684 73 };
mgronlun@9684 74
alanb@12388 75 enum { LegalClass, LegalField, LegalMethod }; // used to verify unqualified names
alanb@10420 76
duke@0 77 private:
mgronlun@9684 78 const ClassFileStream* _stream; // Actual input stream
mgronlun@9684 79 const Symbol* _requested_name;
mgronlun@9684 80 Symbol* _class_name;
mgronlun@9684 81 mutable ClassLoaderData* _loader_data;
hseigel@11946 82 const InstanceKlass* _host_klass;
mgronlun@9684 83 GrowableArray<Handle>* _cp_patches; // overrides for CP entries
iklam@12927 84 int _num_patched_klasses;
iklam@12927 85 int _max_num_patched_klasses;
iklam@12927 86 int _orig_cp_size;
iklam@12927 87 int _first_patched_klass_resolved_index;
mgronlun@9684 88
mgronlun@9684 89 // Metadata created before the instance klass is created. Must be deallocated
mgronlun@9684 90 // if not transferred to the InstanceKlass upon successful class loading
mgronlun@9684 91 // in which case these pointers have been set to NULL.
mgronlun@9684 92 const InstanceKlass* _super_klass;
mgronlun@9684 93 ConstantPool* _cp;
mgronlun@9684 94 Array<u2>* _fields;
mgronlun@9684 95 Array<Method*>* _methods;
mgronlun@9684 96 Array<u2>* _inner_classes;
mgronlun@9684 97 Array<Klass*>* _local_interfaces;
mgronlun@9684 98 Array<Klass*>* _transitive_interfaces;
mgronlun@9684 99 Annotations* _combined_annotations;
mgronlun@9684 100 AnnotationArray* _annotations;
mgronlun@9684 101 AnnotationArray* _type_annotations;
mgronlun@9684 102 Array<AnnotationArray*>* _fields_annotations;
mgronlun@9684 103 Array<AnnotationArray*>* _fields_type_annotations;
mgronlun@9684 104 InstanceKlass* _klass; // InstanceKlass* once created.
mgronlun@9684 105 InstanceKlass* _klass_to_deallocate; // an InstanceKlass* to be destroyed
mgronlun@9684 106
mgronlun@9684 107 ClassAnnotationCollector* _parsed_annotations;
mgronlun@9684 108 FieldAllocationCount* _fac;
mgronlun@9684 109 FieldLayoutInfo* _field_info;
mgronlun@9684 110 const intArray* _method_ordering;
mgronlun@9684 111 GrowableArray<Method*>* _all_mirandas;
mgronlun@9684 112
mgronlun@9684 113 enum { fixed_buffer_size = 128 };
mgronlun@9684 114 u_char _linenumbertable_buffer[fixed_buffer_size];
mgronlun@9684 115
mgronlun@9684 116 // Size of Java vtable (in words)
mgronlun@9684 117 int _vtable_size;
mgronlun@9684 118 int _itable_size;
mgronlun@9684 119
mgronlun@9684 120 int _num_miranda_methods;
mgronlun@9684 121
mgronlun@9684 122 ReferenceType _rt;
mgronlun@9684 123 Handle _protection_domain;
mgronlun@9684 124 AccessFlags _access_flags;
mgronlun@9684 125
mgronlun@9684 126 // for tracing and notifications
mgronlun@9684 127 Publicity _pub_level;
mgronlun@9684 128
hseigel@12784 129 // Used to keep track of whether a constant pool item 19 or 20 is found. These
hseigel@12784 130 // correspond to CONSTANT_Module and CONSTANT_Package tags and are not allowed
hseigel@12784 131 // in regular class files. For class file version >= 53, a CFE cannot be thrown
hseigel@12784 132 // immediately when these are seen because a NCDFE must be thrown if the class's
hseigel@12784 133 // access_flags have ACC_MODULE set. But, the access_flags haven't been looked
hseigel@12784 134 // at yet. So, the bad constant pool item is cached here. A value of zero
hseigel@12784 135 // means that no constant pool item 19 or 20 was found.
hseigel@12784 136 short _bad_constant_seen;
hseigel@12784 137
mgronlun@9684 138 // class attributes parsed before the instance klass is created:
mgronlun@9684 139 bool _synthetic_flag;
mgronlun@9684 140 int _sde_length;
mgronlun@9684 141 const char* _sde_buffer;
mgronlun@9684 142 u2 _sourcefile_index;
mgronlun@9684 143 u2 _generic_signature_index;
mgronlun@9684 144
mgronlun@9684 145 u2 _major_version;
mgronlun@9684 146 u2 _minor_version;
mgronlun@9684 147 u2 _this_class_index;
mgronlun@9684 148 u2 _super_class_index;
mgronlun@9684 149 u2 _itfs_len;
mgronlun@9684 150 u2 _java_fields_count;
mgronlun@9684 151
duke@0 152 bool _need_verify;
duke@0 153 bool _relax_verify;
mgronlun@9684 154
dholmes@12122 155 bool _has_nonstatic_concrete_methods;
dholmes@12122 156 bool _declares_nonstatic_concrete_methods;
mgronlun@9684 157 bool _has_final_method;
duke@0 158
jrose@3491 159 // precomputed flags
duke@0 160 bool _has_finalizer;
duke@0 161 bool _has_empty_finalizer;
duke@0 162 bool _has_vanilla_constructor;
jrose@3491 163 int _max_bootstrap_specifier_index; // detects BSS values
duke@0 164
mgronlun@9684 165 void parse_stream(const ClassFileStream* const stream, TRAPS);
coleenp@4284 166
mgronlun@9684 167 void post_process_parsed_stream(const ClassFileStream* const stream,
mgronlun@9684 168 ConstantPool* cp,
mgronlun@9684 169 TRAPS);
mgronlun@9684 170
hseigel@11946 171 void prepend_host_package_name(const InstanceKlass* host_klass, TRAPS);
hseigel@11946 172 void fix_anonymous_class_name(TRAPS);
hseigel@11946 173
alanb@10420 174 void fill_instance_klass(InstanceKlass* ik, bool cf_changed_in_CFLH, TRAPS);
mgronlun@9684 175 void set_klass(InstanceKlass* instance);
jrose@3491 176
hseigel@12784 177 void set_class_bad_constant_seen(short bad_constant);
hseigel@12784 178 short class_bad_constant_seen() { return _bad_constant_seen; }
jiangli@5100 179 void set_class_synthetic_flag(bool x) { _synthetic_flag = x; }
jiangli@5100 180 void set_class_sourcefile_index(u2 x) { _sourcefile_index = x; }
jiangli@5100 181 void set_class_generic_signature_index(u2 x) { _generic_signature_index = x; }
mgronlun@9684 182 void set_class_sde_buffer(const char* x, int len) { _sde_buffer = x; _sde_length = len; }
coleenp@4284 183
stefank@7525 184 void create_combined_annotations(TRAPS);
mgronlun@9684 185 void apply_parsed_class_attributes(InstanceKlass* k); // update k
mgronlun@9684 186 void apply_parsed_class_metadata(InstanceKlass* k, int fields_count, TRAPS);
mgronlun@9684 187 void clear_class_metadata();
duke@0 188
duke@0 189 // Constant pool parsing
mgronlun@9684 190 void parse_constant_pool_entries(const ClassFileStream* const stream,
mgronlun@9684 191 ConstantPool* cp,
mgronlun@9684 192 const int length,
mgronlun@9684 193 TRAPS);
duke@0 194
mgronlun@9684 195 void parse_constant_pool(const ClassFileStream* const cfs,
mgronlun@9684 196 ConstantPool* const cp,
mgronlun@9684 197 const int length,
mgronlun@9684 198 TRAPS);
duke@0 199
duke@0 200 // Interface parsing
mgronlun@9684 201 void parse_interfaces(const ClassFileStream* const stream,
mgronlun@9684 202 const int itfs_len,
mgronlun@9684 203 ConstantPool* const cp,
dholmes@12122 204 bool* has_nonstatic_concrete_methods,
mgronlun@9684 205 TRAPS);
duke@0 206
mgronlun@9684 207 const InstanceKlass* parse_super_class(ConstantPool* const cp,
mgronlun@9684 208 const int super_class_index,
mgronlun@9684 209 const bool need_verify,
mgronlun@9684 210 TRAPS);
mgronlun@9684 211
duke@0 212 // Field parsing
mgronlun@9684 213 void parse_field_attributes(const ClassFileStream* const cfs,
mgronlun@9684 214 u2 attributes_count,
mgronlun@9684 215 bool is_static,
mgronlun@9684 216 u2 signature_index,
mgronlun@9684 217 u2* const constantvalue_index_addr,
mgronlun@9684 218 bool* const is_synthetic_addr,
mgronlun@9684 219 u2* const generic_signature_index_addr,
jrose@3491 220 FieldAnnotationCollector* parsed_annotations,
jrose@3491 221 TRAPS);
duke@0 222
mgronlun@9684 223 void parse_fields(const ClassFileStream* const cfs,
mgronlun@9684 224 bool is_interface,
mgronlun@9684 225 FieldAllocationCount* const fac,
mgronlun@9684 226 ConstantPool* cp,
mgronlun@9684 227 const int cp_size,
mgronlun@9684 228 u2* const java_fields_count_ptr,
mgronlun@9684 229 TRAPS);
jwilhelm@3995 230
duke@0 231 // Method parsing
mgronlun@9684 232 Method* parse_method(const ClassFileStream* const cfs,
mgronlun@9684 233 bool is_interface,
mgronlun@9684 234 const ConstantPool* cp,
mgronlun@9684 235 AccessFlags* const promoted_flags,
mgronlun@9684 236 TRAPS);
coleenp@4284 237
mgronlun@9684 238 void parse_methods(const ClassFileStream* const cfs,
mgronlun@9684 239 bool is_interface,
mgronlun@9684 240 AccessFlags* const promoted_flags,
mgronlun@9684 241 bool* const has_final_method,
dholmes@12122 242 bool* const declares_nonstatic_concrete_methods,
mgronlun@9684 243 TRAPS);
mgronlun@9684 244
mgronlun@9684 245 const u2* parse_exception_table(const ClassFileStream* const stream,
mgronlun@9684 246 u4 code_length,
mgronlun@9684 247 u4 exception_table_length,
mgronlun@9684 248 TRAPS);
mgronlun@9684 249
mgronlun@9684 250 void parse_linenumber_table(u4 code_attribute_length,
mgronlun@9684 251 u4 code_length,
mgronlun@9684 252 CompressedLineNumberWriteStream**const write_stream,
mgronlun@9684 253 TRAPS);
mgronlun@9684 254
mgronlun@9684 255 const u2* parse_localvariable_table(const ClassFileStream* const cfs,
mgronlun@9684 256 u4 code_length,
mgronlun@9684 257 u2 max_locals,
mgronlun@9684 258 u4 code_attribute_length,
mgronlun@9684 259 u2* const localvariable_table_length,
mgronlun@9684 260 bool isLVTT,
mgronlun@9684 261 TRAPS);
mgronlun@9684 262
mgronlun@9684 263 const u2* parse_checked_exceptions(const ClassFileStream* const cfs,
mgronlun@9684 264 u2* const checked_exceptions_length,
mgronlun@9684 265 u4 method_attribute_length,
mgronlun@9684 266 TRAPS);
mgronlun@9684 267
mgronlun@9684 268 void parse_type_array(u2 array_length,
mgronlun@9684 269 u4 code_length,
mgronlun@9684 270 u4* const u1_index,
mgronlun@9684 271 u4* const u2_index,
mgronlun@9684 272 u1* const u1_array,
mgronlun@9684 273 u2* const u2_array,
mgronlun@9684 274 TRAPS);
duke@0 275
duke@0 276 // Classfile attribute parsing
mgronlun@9684 277 u2 parse_generic_signature_attribute(const ClassFileStream* const cfs, TRAPS);
mgronlun@9684 278 void parse_classfile_sourcefile_attribute(const ClassFileStream* const cfs, TRAPS);
mgronlun@9684 279 void parse_classfile_source_debug_extension_attribute(const ClassFileStream* const cfs,
mgronlun@9684 280 int length,
mgronlun@9684 281 TRAPS);
mgronlun@9684 282
mgronlun@9684 283 u2 parse_classfile_inner_classes_attribute(const ClassFileStream* const cfs,
mgronlun@9684 284 const u1* const inner_classes_attribute_start,
jiangli@3235 285 bool parsed_enclosingmethod_attribute,
jiangli@3235 286 u2 enclosing_method_class_index,
jiangli@3235 287 u2 enclosing_method_method_index,
jrose@3491 288 TRAPS);
mgronlun@9684 289
mgronlun@9684 290 void parse_classfile_attributes(const ClassFileStream* const cfs,
mgronlun@9684 291 ConstantPool* cp,
mgronlun@9684 292 ClassAnnotationCollector* parsed_annotations,
jrose@3491 293 TRAPS);
mgronlun@9684 294
coleenp@4284 295 void parse_classfile_synthetic_attribute(TRAPS);
mgronlun@9684 296 void parse_classfile_signature_attribute(const ClassFileStream* const cfs, TRAPS);
mgronlun@9684 297 void parse_classfile_bootstrap_methods_attribute(const ClassFileStream* const cfs,
mgronlun@9684 298 ConstantPool* cp,
mgronlun@9684 299 u4 attribute_length,
mgronlun@9684 300 TRAPS);
duke@0 301
duke@0 302 // Annotations handling
mgronlun@9684 303 AnnotationArray* assemble_annotations(const u1* const runtime_visible_annotations,
coleenp@3707 304 int runtime_visible_annotations_length,
mgronlun@9684 305 const u1* const runtime_invisible_annotations,
mgronlun@9684 306 int runtime_invisible_annotations_length,
mgronlun@9684 307 TRAPS);
duke@0 308
mgronlun@9684 309 void set_precomputed_flags(InstanceKlass* k);
duke@0 310
duke@0 311 // Format checker methods
mgronlun@9684 312 void classfile_parse_error(const char* msg, TRAPS) const;
mgronlun@9684 313 void classfile_parse_error(const char* msg, int index, TRAPS) const;
mgronlun@9684 314 void classfile_parse_error(const char* msg, const char *name, TRAPS) const;
mgronlun@9684 315 void classfile_parse_error(const char* msg,
mgronlun@9684 316 int index,
mgronlun@9684 317 const char *name,
mgronlun@9684 318 TRAPS) const;
shshahma@12658 319 void classfile_parse_error(const char* msg,
shshahma@12658 320 const char* name,
shshahma@12658 321 const char* signature,
shshahma@12658 322 TRAPS) const;
mgronlun@9684 323
mgronlun@9684 324 inline void guarantee_property(bool b, const char* msg, TRAPS) const {
duke@0 325 if (!b) { classfile_parse_error(msg, CHECK); }
duke@0 326 }
duke@0 327
mgronlun@9684 328 void report_assert_property_failure(const char* msg, TRAPS) const PRODUCT_RETURN;
mgronlun@9684 329 void report_assert_property_failure(const char* msg, int index, TRAPS) const PRODUCT_RETURN;
stefank@7898 330
mgronlun@9684 331 inline void assert_property(bool b, const char* msg, TRAPS) const {
duke@0 332 #ifdef ASSERT
hseigel@4544 333 if (!b) {
stefank@7898 334 report_assert_property_failure(msg, THREAD);
hseigel@4544 335 }
hseigel@4544 336 #endif
hseigel@4544 337 }
hseigel@4544 338
mgronlun@9684 339 inline void assert_property(bool b, const char* msg, int index, TRAPS) const {
hseigel@4544 340 #ifdef ASSERT
hseigel@4544 341 if (!b) {
stefank@7898 342 report_assert_property_failure(msg, index, THREAD);
hseigel@4544 343 }
duke@0 344 #endif
duke@0 345 }
duke@0 346
mgronlun@9684 347 inline void check_property(bool property,
mgronlun@9684 348 const char* msg,
mgronlun@9684 349 int index,
mgronlun@9684 350 TRAPS) const {
duke@0 351 if (_need_verify) {
duke@0 352 guarantee_property(property, msg, index, CHECK);
duke@0 353 } else {
hseigel@4544 354 assert_property(property, msg, index, CHECK);
duke@0 355 }
duke@0 356 }
duke@0 357
mgronlun@9684 358 inline void check_property(bool property, const char* msg, TRAPS) const {
duke@0 359 if (_need_verify) {
duke@0 360 guarantee_property(property, msg, CHECK);
duke@0 361 } else {
duke@0 362 assert_property(property, msg, CHECK);
duke@0 363 }
duke@0 364 }
duke@0 365
mgronlun@9684 366 inline void guarantee_property(bool b,
mgronlun@9684 367 const char* msg,
mgronlun@9684 368 int index,
mgronlun@9684 369 TRAPS) const {
duke@0 370 if (!b) { classfile_parse_error(msg, index, CHECK); }
duke@0 371 }
mgronlun@9684 372
mgronlun@9684 373 inline void guarantee_property(bool b,
mgronlun@9684 374 const char* msg,
mgronlun@9684 375 const char *name,
mgronlun@9684 376 TRAPS) const {
duke@0 377 if (!b) { classfile_parse_error(msg, name, CHECK); }
duke@0 378 }
mgronlun@9684 379
mgronlun@9684 380 inline void guarantee_property(bool b,
mgronlun@9684 381 const char* msg,
mgronlun@9684 382 int index,
mgronlun@9684 383 const char *name,
mgronlun@9684 384 TRAPS) const {
duke@0 385 if (!b) { classfile_parse_error(msg, index, name, CHECK); }
duke@0 386 }
duke@0 387
mgronlun@9684 388 void throwIllegalSignature(const char* type,
mgronlun@9684 389 const Symbol* name,
mgronlun@9684 390 const Symbol* sig,
mgronlun@9684 391 TRAPS) const;
kamg@1506 392
mgronlun@9684 393 void verify_constantvalue(const ConstantPool* const cp,
mgronlun@9684 394 int constantvalue_index,
mgronlun@9684 395 int signature_index,
mgronlun@9684 396 TRAPS) const;
duke@0 397
mgronlun@9684 398 void verify_legal_utf8(const unsigned char* buffer, int length, TRAPS) const;
mgronlun@9684 399 void verify_legal_class_name(const Symbol* name, TRAPS) const;
mgronlun@9684 400 void verify_legal_field_name(const Symbol* name, TRAPS) const;
mgronlun@9684 401 void verify_legal_method_name(const Symbol* name, TRAPS) const;
duke@0 402
mgronlun@9684 403 void verify_legal_field_signature(const Symbol* fieldname,
mgronlun@9684 404 const Symbol* signature,
mgronlun@9684 405 TRAPS) const;
mgronlun@9684 406 int verify_legal_method_signature(const Symbol* methodname,
mgronlun@9684 407 const Symbol* signature,
mgronlun@9684 408 TRAPS) const;
mgronlun@9684 409
mgronlun@9684 410 void verify_legal_class_modifiers(jint flags, TRAPS) const;
mgronlun@9684 411 void verify_legal_field_modifiers(jint flags, bool is_interface, TRAPS) const;
mgronlun@9684 412 void verify_legal_method_modifiers(jint flags,
mgronlun@9684 413 bool is_interface,
mgronlun@9684 414 const Symbol* name,
mgronlun@9684 415 TRAPS) const;
mgronlun@9684 416
mgronlun@9684 417 const char* skip_over_field_signature(const char* signature,
mgronlun@9684 418 bool void_ok,
mgronlun@9684 419 unsigned int length,
mgronlun@9684 420 TRAPS) const;
mgronlun@9684 421
mgronlun@9684 422 bool has_cp_patch_at(int index) const {
jrose@431 423 assert(index >= 0, "oob");
jrose@431 424 return (_cp_patches != NULL
jrose@431 425 && index < _cp_patches->length()
jrose@431 426 && _cp_patches->adr_at(index)->not_null());
jrose@431 427 }
mgronlun@9684 428
mgronlun@9684 429 Handle cp_patch_at(int index) const {
jrose@431 430 assert(has_cp_patch_at(index), "oob");
jrose@431 431 return _cp_patches->at(index);
jrose@431 432 }
mgronlun@9684 433
jrose@431 434 Handle clear_cp_patch_at(int index) {
jrose@431 435 Handle patch = cp_patch_at(index);
jrose@431 436 _cp_patches->at_put(index, Handle());
jrose@431 437 assert(!has_cp_patch_at(index), "");
jrose@431 438 return patch;
jrose@431 439 }
mgronlun@9684 440
iklam@12927 441 void patch_class(ConstantPool* cp, int class_index, Klass* k, Symbol* name);
mgronlun@9684 442 void patch_constant_pool(ConstantPool* cp,
mgronlun@9684 443 int index,
mgronlun@9684 444 Handle patch,
mgronlun@9684 445 TRAPS);
jrose@431 446
jrose@431 447 // Wrapper for constantTag.is_klass_[or_]reference.
coleenp@3602 448 // In older versions of the VM, Klass*s cannot sneak into early phases of
jrose@431 449 // constant pool construction, but in later versions they can.
jrose@431 450 // %%% Let's phase out the old is_klass_reference.
mgronlun@9684 451 bool valid_klass_reference_at(int index) const {
mgronlun@9684 452 return _cp->is_within_bounds(index) &&
mgronlun@9684 453 _cp->tag_at(index).is_klass_or_reference();
coleenp@4284 454 }
coleenp@4284 455
coleenp@4284 456 // Checks that the cpool index is in range and is a utf8
mgronlun@9684 457 bool valid_symbol_at(int cpool_index) const {
mgronlun@9684 458 return _cp->is_within_bounds(cpool_index) &&
mgronlun@9684 459 _cp->tag_at(cpool_index).is_utf8();
jrose@431 460 }
jrose@431 461
mgronlun@9684 462 void copy_localvariable_table(const ConstMethod* cm,
mgronlun@9684 463 int lvt_cnt,
mgronlun@9684 464 u2* const localvariable_table_length,
mgronlun@9684 465 const u2**const localvariable_table_start,
coleenp@4137 466 int lvtt_cnt,
mgronlun@9684 467 u2* const localvariable_type_table_length,
mgronlun@9684 468 const u2** const localvariable_type_table_start,
coleenp@4137 469 TRAPS);
coleenp@4137 470
coleenp@4284 471 void copy_method_annotations(ConstMethod* cm,
mgronlun@9684 472 const u1* runtime_visible_annotations,
coleenp@4137 473 int runtime_visible_annotations_length,
mgronlun@9684 474 const u1* runtime_invisible_annotations,
coleenp@4137 475 int runtime_invisible_annotations_length,
mgronlun@9684 476 const u1* runtime_visible_parameter_annotations,
coleenp@4137 477 int runtime_visible_parameter_annotations_length,
mgronlun@9684 478 const u1* runtime_invisible_parameter_annotations,
coleenp@4137 479 int runtime_invisible_parameter_annotations_length,
mgronlun@9684 480 const u1* runtime_visible_type_annotations,
coleenp@4137 481 int runtime_visible_type_annotations_length,
mgronlun@9684 482 const u1* runtime_invisible_type_annotations,
coleenp@4137 483 int runtime_invisible_type_annotations_length,
mgronlun@9684 484 const u1* annotation_default,
coleenp@4137 485 int annotation_default_length,
coleenp@4137 486 TRAPS);
coleenp@4137 487
coleenp@4284 488 // lays out fields in class and returns the total oopmap count
mgronlun@9684 489 void layout_fields(ConstantPool* cp,
mgronlun@9684 490 const FieldAllocationCount* fac,
mgronlun@9684 491 const ClassAnnotationCollector* parsed_annotations,
mgronlun@9684 492 FieldLayoutInfo* info,
mgronlun@9684 493 TRAPS);
coleenp@4284 494
duke@0 495 public:
mgronlun@9684 496 ClassFileParser(ClassFileStream* stream,
mgronlun@9684 497 Symbol* name,
mgronlun@9684 498 ClassLoaderData* loader_data,
mgronlun@9684 499 Handle protection_domain,
hseigel@11946 500 const InstanceKlass* host_klass,
mgronlun@9684 501 GrowableArray<Handle>* cp_patches,
mgronlun@9684 502 Publicity pub_level,
mgronlun@9684 503 TRAPS);
mgronlun@9684 504
coleenp@4284 505 ~ClassFileParser();
duke@0 506
alanb@10420 507 InstanceKlass* create_instance_klass(bool cf_changed_in_CFLH, TRAPS);
duke@0 508
mgronlun@9684 509 const ClassFileStream* clone_stream() const;
mgronlun@9684 510
mgronlun@9684 511 void set_klass_to_deallocate(InstanceKlass* klass);
mgronlun@9684 512
mgronlun@9684 513 int static_field_size() const;
mgronlun@9684 514 int total_oop_map_count() const;
mgronlun@9684 515 jint layout_size() const;
mgronlun@9684 516
mgronlun@9684 517 int vtable_size() const { return _vtable_size; }
mgronlun@9684 518 int itable_size() const { return _itable_size; }
mgronlun@9684 519
mgronlun@9684 520 u2 this_class_index() const { return _this_class_index; }
mgronlun@9684 521 u2 super_class_index() const { return _super_class_index; }
mgronlun@9684 522
mgronlun@9684 523 bool is_anonymous() const { return _host_klass != NULL; }
mgronlun@9684 524 bool is_interface() const { return _access_flags.is_interface(); }
mgronlun@9684 525
hseigel@11946 526 const InstanceKlass* host_klass() const { return _host_klass; }
mgronlun@9684 527 const GrowableArray<Handle>* cp_patches() const { return _cp_patches; }
mgronlun@9684 528 ClassLoaderData* loader_data() const { return _loader_data; }
mgronlun@9684 529 const Symbol* class_name() const { return _class_name; }
mgronlun@9684 530 const Klass* super_klass() const { return _super_klass; }
mgronlun@9684 531
mgronlun@9684 532 ReferenceType reference_type() const { return _rt; }
mgronlun@9684 533 AccessFlags access_flags() const { return _access_flags; }
mgronlun@9684 534
mgronlun@9684 535 bool is_internal() const { return INTERNAL == _pub_level; }
mgronlun@9684 536
alanb@10420 537 static bool verify_unqualified_name(const char* name, unsigned int length, int type);
acorn@11664 538
acorn@11664 539 #ifdef ASSERT
acorn@11664 540 static bool is_internal_format(Symbol* class_name);
acorn@11664 541 #endif
acorn@11664 542
duke@0 543 };
stefank@1879 544
stefank@1879 545 #endif // SHARE_VM_CLASSFILE_CLASSFILEPARSER_HPP