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