author | simonis |
Tue, 19 Jun 2018 09:43:53 +0200 | |
changeset 50625 | d9753e3db0c6 |
parent 49480 | d7df2dd501ce |
child 50735 | 2f2af62dfac7 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
49364
601146c66cad
8173070: Remove ValueObj class for allocation subclassing for runtime code
coleenp
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 1997, 2018, 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" |
49480
d7df2dd501ce
8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents:
49364
diff
changeset
|
29 |
#include "oops/annotations.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 |
||
49364
601146c66cad
8173070: Remove ValueObj class for allocation subclassing for runtime code
coleenp
parents:
47216
diff
changeset
|
52 |
class ClassFileParser { |
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: |
46513
c61eea516a0a
8181377: Capture underlying type for unsafe/unaligned pointers in ClassFileParser
mikael
parents:
46504
diff
changeset
|
78 |
// Potentially unaligned pointer to various 16-bit entries in the class file |
c61eea516a0a
8181377: Capture underlying type for unsafe/unaligned pointers in ClassFileParser
mikael
parents:
46504
diff
changeset
|
79 |
typedef void unsafe_u2; |
c61eea516a0a
8181377: Capture underlying type for unsafe/unaligned pointers in ClassFileParser
mikael
parents:
46504
diff
changeset
|
80 |
|
34666 | 81 |
const ClassFileStream* _stream; // Actual input stream |
82 |
const Symbol* _requested_name; |
|
83 |
Symbol* _class_name; |
|
84 |
mutable ClassLoaderData* _loader_data; |
|
40923
10fe1c28b9f6
8058575: IllegalAccessError trying to access package-private class from VM anonymous class
hseigel
parents:
40016
diff
changeset
|
85 |
const InstanceKlass* _host_klass; |
34666 | 86 |
GrowableArray<Handle>* _cp_patches; // overrides for CP entries |
46427
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46352
diff
changeset
|
87 |
int _num_patched_klasses; |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46352
diff
changeset
|
88 |
int _max_num_patched_klasses; |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46352
diff
changeset
|
89 |
int _orig_cp_size; |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46352
diff
changeset
|
90 |
int _first_patched_klass_resolved_index; |
34666 | 91 |
|
92 |
// Metadata created before the instance klass is created. Must be deallocated |
|
93 |
// if not transferred to the InstanceKlass upon successful class loading |
|
94 |
// in which case these pointers have been set to NULL. |
|
95 |
const InstanceKlass* _super_klass; |
|
96 |
ConstantPool* _cp; |
|
97 |
Array<u2>* _fields; |
|
98 |
Array<Method*>* _methods; |
|
99 |
Array<u2>* _inner_classes; |
|
100 |
Array<Klass*>* _local_interfaces; |
|
101 |
Array<Klass*>* _transitive_interfaces; |
|
102 |
Annotations* _combined_annotations; |
|
103 |
AnnotationArray* _annotations; |
|
104 |
AnnotationArray* _type_annotations; |
|
105 |
Array<AnnotationArray*>* _fields_annotations; |
|
106 |
Array<AnnotationArray*>* _fields_type_annotations; |
|
107 |
InstanceKlass* _klass; // InstanceKlass* once created. |
|
108 |
InstanceKlass* _klass_to_deallocate; // an InstanceKlass* to be destroyed |
|
109 |
||
110 |
ClassAnnotationCollector* _parsed_annotations; |
|
111 |
FieldAllocationCount* _fac; |
|
112 |
FieldLayoutInfo* _field_info; |
|
113 |
const intArray* _method_ordering; |
|
114 |
GrowableArray<Method*>* _all_mirandas; |
|
115 |
||
116 |
enum { fixed_buffer_size = 128 }; |
|
117 |
u_char _linenumbertable_buffer[fixed_buffer_size]; |
|
118 |
||
119 |
// Size of Java vtable (in words) |
|
120 |
int _vtable_size; |
|
121 |
int _itable_size; |
|
122 |
||
123 |
int _num_miranda_methods; |
|
124 |
||
125 |
ReferenceType _rt; |
|
126 |
Handle _protection_domain; |
|
127 |
AccessFlags _access_flags; |
|
128 |
||
129 |
// for tracing and notifications |
|
130 |
Publicity _pub_level; |
|
131 |
||
44239
fdd97dc2367b
8175383: JVM should throw NCDFE if ACC_MODULE and CONSTANT_Module/Package are set
hseigel
parents:
42630
diff
changeset
|
132 |
// 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
|
133 |
// 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
|
134 |
// 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
|
135 |
// 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
|
136 |
// 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
|
137 |
// 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
|
138 |
// 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
|
139 |
short _bad_constant_seen; |
fdd97dc2367b
8175383: JVM should throw NCDFE if ACC_MODULE and CONSTANT_Module/Package are set
hseigel
parents:
42630
diff
changeset
|
140 |
|
34666 | 141 |
// class attributes parsed before the instance klass is created: |
142 |
bool _synthetic_flag; |
|
143 |
int _sde_length; |
|
144 |
const char* _sde_buffer; |
|
145 |
u2 _sourcefile_index; |
|
146 |
u2 _generic_signature_index; |
|
147 |
||
148 |
u2 _major_version; |
|
149 |
u2 _minor_version; |
|
150 |
u2 _this_class_index; |
|
151 |
u2 _super_class_index; |
|
152 |
u2 _itfs_len; |
|
153 |
u2 _java_fields_count; |
|
154 |
||
1 | 155 |
bool _need_verify; |
156 |
bool _relax_verify; |
|
34666 | 157 |
|
41669
2091069b6851
8081800: AbstractMethodError when evaluating a private method in an interface via debugger
dholmes
parents:
40923
diff
changeset
|
158 |
bool _has_nonstatic_concrete_methods; |
2091069b6851
8081800: AbstractMethodError when evaluating a private method in an interface via debugger
dholmes
parents:
40923
diff
changeset
|
159 |
bool _declares_nonstatic_concrete_methods; |
34666 | 160 |
bool _has_final_method; |
1 | 161 |
|
13291
9de3b1387cb8
6711908: JVM needs direct access to some annotations
jrose
parents:
12267
diff
changeset
|
162 |
// precomputed flags |
1 | 163 |
bool _has_finalizer; |
164 |
bool _has_empty_finalizer; |
|
165 |
bool _has_vanilla_constructor; |
|
13291
9de3b1387cb8
6711908: JVM needs direct access to some annotations
jrose
parents:
12267
diff
changeset
|
166 |
int _max_bootstrap_specifier_index; // detects BSS values |
1 | 167 |
|
34666 | 168 |
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
|
169 |
|
34666 | 170 |
void post_process_parsed_stream(const ClassFileStream* const stream, |
171 |
ConstantPool* cp, |
|
172 |
TRAPS); |
|
173 |
||
40923
10fe1c28b9f6
8058575: IllegalAccessError trying to access package-private class from VM anonymous class
hseigel
parents:
40016
diff
changeset
|
174 |
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
|
175 |
void fix_anonymous_class_name(TRAPS); |
10fe1c28b9f6
8058575: IllegalAccessError trying to access package-private class from VM anonymous class
hseigel
parents:
40016
diff
changeset
|
176 |
|
36508 | 177 |
void fill_instance_klass(InstanceKlass* ik, bool cf_changed_in_CFLH, TRAPS); |
34666 | 178 |
void set_klass(InstanceKlass* instance); |
13291
9de3b1387cb8
6711908: JVM needs direct access to some annotations
jrose
parents:
12267
diff
changeset
|
179 |
|
44239
fdd97dc2367b
8175383: JVM should throw NCDFE if ACC_MODULE and CONSTANT_Module/Package are set
hseigel
parents:
42630
diff
changeset
|
180 |
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
|
181 |
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
|
182 |
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
|
183 |
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
|
184 |
void set_class_generic_signature_index(u2 x) { _generic_signature_index = x; } |
34666 | 185 |
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
|
186 |
|
28027
c63d0bb0101c
8065634: Crash in InstanceKlass::clean_method_data when _method is NULL
stefank
parents:
27402
diff
changeset
|
187 |
void create_combined_annotations(TRAPS); |
34666 | 188 |
void apply_parsed_class_attributes(InstanceKlass* k); // update k |
189 |
void apply_parsed_class_metadata(InstanceKlass* k, int fields_count, TRAPS); |
|
190 |
void clear_class_metadata(); |
|
1 | 191 |
|
192 |
// Constant pool parsing |
|
34666 | 193 |
void parse_constant_pool_entries(const ClassFileStream* const stream, |
194 |
ConstantPool* cp, |
|
195 |
const int length, |
|
196 |
TRAPS); |
|
1 | 197 |
|
34666 | 198 |
void parse_constant_pool(const ClassFileStream* const cfs, |
199 |
ConstantPool* const cp, |
|
200 |
const int length, |
|
201 |
TRAPS); |
|
1 | 202 |
|
203 |
// Interface parsing |
|
34666 | 204 |
void parse_interfaces(const ClassFileStream* const stream, |
205 |
const int itfs_len, |
|
206 |
ConstantPool* const cp, |
|
41669
2091069b6851
8081800: AbstractMethodError when evaluating a private method in an interface via debugger
dholmes
parents:
40923
diff
changeset
|
207 |
bool* has_nonstatic_concrete_methods, |
34666 | 208 |
TRAPS); |
1 | 209 |
|
34666 | 210 |
const InstanceKlass* parse_super_class(ConstantPool* const cp, |
211 |
const int super_class_index, |
|
212 |
const bool need_verify, |
|
213 |
TRAPS); |
|
214 |
||
1 | 215 |
// Field parsing |
34666 | 216 |
void parse_field_attributes(const ClassFileStream* const cfs, |
217 |
u2 attributes_count, |
|
218 |
bool is_static, |
|
219 |
u2 signature_index, |
|
220 |
u2* const constantvalue_index_addr, |
|
221 |
bool* const is_synthetic_addr, |
|
222 |
u2* const generic_signature_index_addr, |
|
13291
9de3b1387cb8
6711908: JVM needs direct access to some annotations
jrose
parents:
12267
diff
changeset
|
223 |
FieldAnnotationCollector* parsed_annotations, |
9de3b1387cb8
6711908: JVM needs direct access to some annotations
jrose
parents:
12267
diff
changeset
|
224 |
TRAPS); |
1 | 225 |
|
34666 | 226 |
void parse_fields(const ClassFileStream* const cfs, |
227 |
bool is_interface, |
|
228 |
FieldAllocationCount* const fac, |
|
229 |
ConstantPool* cp, |
|
230 |
const int cp_size, |
|
231 |
u2* const java_fields_count_ptr, |
|
232 |
TRAPS); |
|
15193
8e6b5694267f
8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents:
15097
diff
changeset
|
233 |
|
1 | 234 |
// Method parsing |
34666 | 235 |
Method* parse_method(const ClassFileStream* const cfs, |
236 |
bool is_interface, |
|
237 |
const ConstantPool* cp, |
|
238 |
AccessFlags* const promoted_flags, |
|
239 |
TRAPS); |
|
240 |
||
241 |
void parse_methods(const ClassFileStream* const cfs, |
|
242 |
bool is_interface, |
|
243 |
AccessFlags* const promoted_flags, |
|
244 |
bool* const has_final_method, |
|
41669
2091069b6851
8081800: AbstractMethodError when evaluating a private method in an interface via debugger
dholmes
parents:
40923
diff
changeset
|
245 |
bool* const declares_nonstatic_concrete_methods, |
34666 | 246 |
TRAPS); |
247 |
||
46513
c61eea516a0a
8181377: Capture underlying type for unsafe/unaligned pointers in ClassFileParser
mikael
parents:
46504
diff
changeset
|
248 |
const unsafe_u2* parse_exception_table(const ClassFileStream* const stream, |
c61eea516a0a
8181377: Capture underlying type for unsafe/unaligned pointers in ClassFileParser
mikael
parents:
46504
diff
changeset
|
249 |
u4 code_length, |
c61eea516a0a
8181377: Capture underlying type for unsafe/unaligned pointers in ClassFileParser
mikael
parents:
46504
diff
changeset
|
250 |
u4 exception_table_length, |
c61eea516a0a
8181377: Capture underlying type for unsafe/unaligned pointers in ClassFileParser
mikael
parents:
46504
diff
changeset
|
251 |
TRAPS); |
15935
50da9e5eb858
8003419: NPG: Clean up metadata created during class loading if failure
coleenp
parents:
15601
diff
changeset
|
252 |
|
34666 | 253 |
void parse_linenumber_table(u4 code_attribute_length, |
254 |
u4 code_length, |
|
255 |
CompressedLineNumberWriteStream**const write_stream, |
|
256 |
TRAPS); |
|
257 |
||
46513
c61eea516a0a
8181377: Capture underlying type for unsafe/unaligned pointers in ClassFileParser
mikael
parents:
46504
diff
changeset
|
258 |
const unsafe_u2* parse_localvariable_table(const ClassFileStream* const cfs, |
c61eea516a0a
8181377: Capture underlying type for unsafe/unaligned pointers in ClassFileParser
mikael
parents:
46504
diff
changeset
|
259 |
u4 code_length, |
c61eea516a0a
8181377: Capture underlying type for unsafe/unaligned pointers in ClassFileParser
mikael
parents:
46504
diff
changeset
|
260 |
u2 max_locals, |
c61eea516a0a
8181377: Capture underlying type for unsafe/unaligned pointers in ClassFileParser
mikael
parents:
46504
diff
changeset
|
261 |
u4 code_attribute_length, |
c61eea516a0a
8181377: Capture underlying type for unsafe/unaligned pointers in ClassFileParser
mikael
parents:
46504
diff
changeset
|
262 |
u2* const localvariable_table_length, |
c61eea516a0a
8181377: Capture underlying type for unsafe/unaligned pointers in ClassFileParser
mikael
parents:
46504
diff
changeset
|
263 |
bool isLVTT, |
c61eea516a0a
8181377: Capture underlying type for unsafe/unaligned pointers in ClassFileParser
mikael
parents:
46504
diff
changeset
|
264 |
TRAPS); |
34666 | 265 |
|
46513
c61eea516a0a
8181377: Capture underlying type for unsafe/unaligned pointers in ClassFileParser
mikael
parents:
46504
diff
changeset
|
266 |
const unsafe_u2* parse_checked_exceptions(const ClassFileStream* const cfs, |
c61eea516a0a
8181377: Capture underlying type for unsafe/unaligned pointers in ClassFileParser
mikael
parents:
46504
diff
changeset
|
267 |
u2* const checked_exceptions_length, |
c61eea516a0a
8181377: Capture underlying type for unsafe/unaligned pointers in ClassFileParser
mikael
parents:
46504
diff
changeset
|
268 |
u4 method_attribute_length, |
c61eea516a0a
8181377: Capture underlying type for unsafe/unaligned pointers in ClassFileParser
mikael
parents:
46504
diff
changeset
|
269 |
TRAPS); |
34666 | 270 |
|
271 |
void parse_type_array(u2 array_length, |
|
272 |
u4 code_length, |
|
273 |
u4* const u1_index, |
|
274 |
u4* const u2_index, |
|
275 |
u1* const u1_array, |
|
276 |
u2* const u2_array, |
|
277 |
TRAPS); |
|
1 | 278 |
|
279 |
// Classfile attribute parsing |
|
34666 | 280 |
u2 parse_generic_signature_attribute(const ClassFileStream* const cfs, TRAPS); |
281 |
void parse_classfile_sourcefile_attribute(const ClassFileStream* const cfs, TRAPS); |
|
282 |
void parse_classfile_source_debug_extension_attribute(const ClassFileStream* const cfs, |
|
283 |
int length, |
|
284 |
TRAPS); |
|
285 |
||
286 |
u2 parse_classfile_inner_classes_attribute(const ClassFileStream* const cfs, |
|
287 |
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
|
288 |
bool parsed_enclosingmethod_attribute, |
6a9cfc59a18a
7109878: The instanceKlass EnclosingMethhod attribute fields can be folded into the _inner_class field.
jiangli
parents:
11412
diff
changeset
|
289 |
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
|
290 |
u2 enclosing_method_method_index, |
13291
9de3b1387cb8
6711908: JVM needs direct access to some annotations
jrose
parents:
12267
diff
changeset
|
291 |
TRAPS); |
34666 | 292 |
|
293 |
void parse_classfile_attributes(const ClassFileStream* const cfs, |
|
294 |
ConstantPool* cp, |
|
295 |
ClassAnnotationCollector* parsed_annotations, |
|
13291
9de3b1387cb8
6711908: JVM needs direct access to some annotations
jrose
parents:
12267
diff
changeset
|
296 |
TRAPS); |
34666 | 297 |
|
15935
50da9e5eb858
8003419: NPG: Clean up metadata created during class loading if failure
coleenp
parents:
15601
diff
changeset
|
298 |
void parse_classfile_synthetic_attribute(TRAPS); |
34666 | 299 |
void parse_classfile_signature_attribute(const ClassFileStream* const cfs, TRAPS); |
300 |
void parse_classfile_bootstrap_methods_attribute(const ClassFileStream* const cfs, |
|
301 |
ConstantPool* cp, |
|
302 |
u4 attribute_length, |
|
303 |
TRAPS); |
|
1 | 304 |
|
305 |
// Annotations handling |
|
34666 | 306 |
AnnotationArray* assemble_annotations(const u1* const runtime_visible_annotations, |
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
307 |
int runtime_visible_annotations_length, |
34666 | 308 |
const u1* const runtime_invisible_annotations, |
309 |
int runtime_invisible_annotations_length, |
|
310 |
TRAPS); |
|
1 | 311 |
|
34666 | 312 |
void set_precomputed_flags(InstanceKlass* k); |
1 | 313 |
|
314 |
// Format checker methods |
|
34666 | 315 |
void classfile_parse_error(const char* msg, TRAPS) const; |
316 |
void classfile_parse_error(const char* msg, int index, TRAPS) const; |
|
317 |
void classfile_parse_error(const char* msg, const char *name, TRAPS) const; |
|
318 |
void classfile_parse_error(const char* msg, |
|
319 |
int index, |
|
320 |
const char *name, |
|
321 |
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
|
322 |
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
|
323 |
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
|
324 |
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
|
325 |
TRAPS) const; |
34666 | 326 |
|
327 |
inline void guarantee_property(bool b, const char* msg, TRAPS) const { |
|
1 | 328 |
if (!b) { classfile_parse_error(msg, CHECK); } |
329 |
} |
|
330 |
||
34666 | 331 |
void report_assert_property_failure(const char* msg, TRAPS) const PRODUCT_RETURN; |
332 |
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
|
333 |
|
34666 | 334 |
inline void assert_property(bool b, const char* msg, TRAPS) const { |
1 | 335 |
#ifdef ASSERT |
17073
99baa410e207
8012695: Assertion message displays %u and %s text instead of actual values
hseigel
parents:
16692
diff
changeset
|
336 |
if (!b) { |
29201
fee2bbb2ec1d
8073389: Remove the include of resourceArea.hpp from classFileParser.hpp
stefank
parents:
29081
diff
changeset
|
337 |
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
|
338 |
} |
99baa410e207
8012695: Assertion message displays %u and %s text instead of actual values
hseigel
parents:
16692
diff
changeset
|
339 |
#endif |
99baa410e207
8012695: Assertion message displays %u and %s text instead of actual values
hseigel
parents:
16692
diff
changeset
|
340 |
} |
99baa410e207
8012695: Assertion message displays %u and %s text instead of actual values
hseigel
parents:
16692
diff
changeset
|
341 |
|
34666 | 342 |
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
|
343 |
#ifdef ASSERT |
99baa410e207
8012695: Assertion message displays %u and %s text instead of actual values
hseigel
parents:
16692
diff
changeset
|
344 |
if (!b) { |
29201
fee2bbb2ec1d
8073389: Remove the include of resourceArea.hpp from classFileParser.hpp
stefank
parents:
29081
diff
changeset
|
345 |
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
|
346 |
} |
1 | 347 |
#endif |
348 |
} |
|
349 |
||
34666 | 350 |
inline void check_property(bool property, |
351 |
const char* msg, |
|
352 |
int index, |
|
353 |
TRAPS) const { |
|
1 | 354 |
if (_need_verify) { |
355 |
guarantee_property(property, msg, index, CHECK); |
|
356 |
} else { |
|
17073
99baa410e207
8012695: Assertion message displays %u and %s text instead of actual values
hseigel
parents:
16692
diff
changeset
|
357 |
assert_property(property, msg, index, CHECK); |
1 | 358 |
} |
359 |
} |
|
360 |
||
34666 | 361 |
inline void check_property(bool property, const char* msg, TRAPS) const { |
1 | 362 |
if (_need_verify) { |
363 |
guarantee_property(property, msg, CHECK); |
|
364 |
} else { |
|
365 |
assert_property(property, msg, CHECK); |
|
366 |
} |
|
367 |
} |
|
368 |
||
34666 | 369 |
inline void guarantee_property(bool b, |
370 |
const char* msg, |
|
371 |
int index, |
|
372 |
TRAPS) const { |
|
1 | 373 |
if (!b) { classfile_parse_error(msg, index, CHECK); } |
374 |
} |
|
34666 | 375 |
|
376 |
inline void guarantee_property(bool b, |
|
377 |
const char* msg, |
|
378 |
const char *name, |
|
379 |
TRAPS) const { |
|
1 | 380 |
if (!b) { classfile_parse_error(msg, name, CHECK); } |
381 |
} |
|
34666 | 382 |
|
383 |
inline void guarantee_property(bool b, |
|
384 |
const char* msg, |
|
385 |
int index, |
|
386 |
const char *name, |
|
387 |
TRAPS) const { |
|
1 | 388 |
if (!b) { classfile_parse_error(msg, index, name, CHECK); } |
389 |
} |
|
390 |
||
34666 | 391 |
void throwIllegalSignature(const char* type, |
392 |
const Symbol* name, |
|
393 |
const Symbol* sig, |
|
394 |
TRAPS) const; |
|
5709
3b5307e27c1d
6930553: classfile format checker allows invalid method descriptor in CONSTANT_NameAndType_info in some cases
kamg
parents:
3821
diff
changeset
|
395 |
|
34666 | 396 |
void verify_constantvalue(const ConstantPool* const cp, |
397 |
int constantvalue_index, |
|
398 |
int signature_index, |
|
399 |
TRAPS) const; |
|
400 |
||
401 |
void verify_legal_utf8(const unsigned char* buffer, int length, TRAPS) const; |
|
402 |
void verify_legal_class_name(const Symbol* name, TRAPS) const; |
|
403 |
void verify_legal_field_name(const Symbol* name, TRAPS) const; |
|
404 |
void verify_legal_method_name(const Symbol* name, TRAPS) const; |
|
1 | 405 |
|
34666 | 406 |
void verify_legal_field_signature(const Symbol* fieldname, |
407 |
const Symbol* signature, |
|
408 |
TRAPS) const; |
|
409 |
int verify_legal_method_signature(const Symbol* methodname, |
|
410 |
const Symbol* signature, |
|
411 |
TRAPS) const; |
|
1 | 412 |
|
34666 | 413 |
void verify_legal_class_modifiers(jint flags, TRAPS) const; |
414 |
void verify_legal_field_modifiers(jint flags, bool is_interface, TRAPS) const; |
|
415 |
void verify_legal_method_modifiers(jint flags, |
|
416 |
bool is_interface, |
|
417 |
const Symbol* name, |
|
418 |
TRAPS) const; |
|
419 |
||
420 |
const char* skip_over_field_signature(const char* signature, |
|
421 |
bool void_ok, |
|
422 |
unsigned int length, |
|
423 |
TRAPS) const; |
|
424 |
||
425 |
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
|
426 |
assert(index >= 0, "oob"); |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
427 |
return (_cp_patches != NULL |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
428 |
&& index < _cp_patches->length() |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
429 |
&& _cp_patches->adr_at(index)->not_null()); |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
430 |
} |
34666 | 431 |
|
432 |
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
|
433 |
assert(has_cp_patch_at(index), "oob"); |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
434 |
return _cp_patches->at(index); |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
435 |
} |
34666 | 436 |
|
49480
d7df2dd501ce
8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents:
49364
diff
changeset
|
437 |
Handle clear_cp_patch_at(int index); |
34666 | 438 |
|
46427
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46352
diff
changeset
|
439 |
void patch_class(ConstantPool* cp, int class_index, Klass* k, Symbol* name); |
34666 | 440 |
void patch_constant_pool(ConstantPool* cp, |
441 |
int index, |
|
442 |
Handle patch, |
|
443 |
TRAPS); |
|
1550
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
444 |
|
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
445 |
// Wrapper for constantTag.is_klass_[or_]reference. |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
446 |
// 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
|
447 |
// 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
|
448 |
// %%% Let's phase out the old is_klass_reference. |
34666 | 449 |
bool valid_klass_reference_at(int index) const { |
450 |
return _cp->is_within_bounds(index) && |
|
451 |
_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
|
452 |
} |
50da9e5eb858
8003419: NPG: Clean up metadata created during class loading if failure
coleenp
parents:
15601
diff
changeset
|
453 |
|
50da9e5eb858
8003419: NPG: Clean up metadata created during class loading if failure
coleenp
parents:
15601
diff
changeset
|
454 |
// Checks that the cpool index is in range and is a utf8 |
34666 | 455 |
bool valid_symbol_at(int cpool_index) const { |
456 |
return _cp->is_within_bounds(cpool_index) && |
|
457 |
_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
|
458 |
} |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
459 |
|
34666 | 460 |
void copy_localvariable_table(const ConstMethod* cm, |
461 |
int lvt_cnt, |
|
462 |
u2* const localvariable_table_length, |
|
46513
c61eea516a0a
8181377: Capture underlying type for unsafe/unaligned pointers in ClassFileParser
mikael
parents:
46504
diff
changeset
|
463 |
const unsafe_u2** const localvariable_table_start, |
15601 | 464 |
int lvtt_cnt, |
34666 | 465 |
u2* const localvariable_type_table_length, |
46513
c61eea516a0a
8181377: Capture underlying type for unsafe/unaligned pointers in ClassFileParser
mikael
parents:
46504
diff
changeset
|
466 |
const unsafe_u2** const localvariable_type_table_start, |
15601 | 467 |
TRAPS); |
468 |
||
15935
50da9e5eb858
8003419: NPG: Clean up metadata created during class loading if failure
coleenp
parents:
15601
diff
changeset
|
469 |
void copy_method_annotations(ConstMethod* cm, |
34666 | 470 |
const u1* runtime_visible_annotations, |
15601 | 471 |
int runtime_visible_annotations_length, |
34666 | 472 |
const u1* runtime_invisible_annotations, |
15601 | 473 |
int runtime_invisible_annotations_length, |
34666 | 474 |
const u1* runtime_visible_parameter_annotations, |
15601 | 475 |
int runtime_visible_parameter_annotations_length, |
34666 | 476 |
const u1* runtime_invisible_parameter_annotations, |
15601 | 477 |
int runtime_invisible_parameter_annotations_length, |
34666 | 478 |
const u1* runtime_visible_type_annotations, |
15601 | 479 |
int runtime_visible_type_annotations_length, |
34666 | 480 |
const u1* runtime_invisible_type_annotations, |
15601 | 481 |
int runtime_invisible_type_annotations_length, |
34666 | 482 |
const u1* annotation_default, |
15601 | 483 |
int annotation_default_length, |
484 |
TRAPS); |
|
485 |
||
15935
50da9e5eb858
8003419: NPG: Clean up metadata created during class loading if failure
coleenp
parents:
15601
diff
changeset
|
486 |
// lays out fields in class and returns the total oopmap count |
34666 | 487 |
void layout_fields(ConstantPool* cp, |
488 |
const FieldAllocationCount* fac, |
|
489 |
const ClassAnnotationCollector* parsed_annotations, |
|
490 |
FieldLayoutInfo* info, |
|
491 |
TRAPS); |
|
15935
50da9e5eb858
8003419: NPG: Clean up metadata created during class loading if failure
coleenp
parents:
15601
diff
changeset
|
492 |
|
1 | 493 |
public: |
34666 | 494 |
ClassFileParser(ClassFileStream* stream, |
495 |
Symbol* name, |
|
496 |
ClassLoaderData* loader_data, |
|
497 |
Handle protection_domain, |
|
40923
10fe1c28b9f6
8058575: IllegalAccessError trying to access package-private class from VM anonymous class
hseigel
parents:
40016
diff
changeset
|
498 |
const InstanceKlass* host_klass, |
34666 | 499 |
GrowableArray<Handle>* cp_patches, |
500 |
Publicity pub_level, |
|
501 |
TRAPS); |
|
502 |
||
15935
50da9e5eb858
8003419: NPG: Clean up metadata created during class loading if failure
coleenp
parents:
15601
diff
changeset
|
503 |
~ClassFileParser(); |
1 | 504 |
|
36508 | 505 |
InstanceKlass* create_instance_klass(bool cf_changed_in_CFLH, TRAPS); |
34666 | 506 |
|
507 |
const ClassFileStream* clone_stream() const; |
|
508 |
||
509 |
void set_klass_to_deallocate(InstanceKlass* klass); |
|
510 |
||
511 |
int static_field_size() const; |
|
512 |
int total_oop_map_count() const; |
|
513 |
jint layout_size() const; |
|
514 |
||
515 |
int vtable_size() const { return _vtable_size; } |
|
516 |
int itable_size() const { return _itable_size; } |
|
1 | 517 |
|
34666 | 518 |
u2 this_class_index() const { return _this_class_index; } |
519 |
u2 super_class_index() const { return _super_class_index; } |
|
520 |
||
521 |
bool is_anonymous() const { return _host_klass != NULL; } |
|
522 |
bool is_interface() const { return _access_flags.is_interface(); } |
|
523 |
||
40923
10fe1c28b9f6
8058575: IllegalAccessError trying to access package-private class from VM anonymous class
hseigel
parents:
40016
diff
changeset
|
524 |
const InstanceKlass* host_klass() const { return _host_klass; } |
34666 | 525 |
const GrowableArray<Handle>* cp_patches() const { return _cp_patches; } |
526 |
ClassLoaderData* loader_data() const { return _loader_data; } |
|
527 |
const Symbol* class_name() const { return _class_name; } |
|
49480
d7df2dd501ce
8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents:
49364
diff
changeset
|
528 |
const InstanceKlass* super_klass() const { return _super_klass; } |
34666 | 529 |
|
530 |
ReferenceType reference_type() const { return _rt; } |
|
531 |
AccessFlags access_flags() const { return _access_flags; } |
|
532 |
||
533 |
bool is_internal() const { return INTERNAL == _pub_level; } |
|
534 |
||
36508 | 535 |
static bool verify_unqualified_name(const char* name, unsigned int length, int type); |
40016 | 536 |
|
537 |
#ifdef ASSERT |
|
538 |
static bool is_internal_format(Symbol* class_name); |
|
539 |
#endif |
|
540 |
||
1 | 541 |
}; |
7397 | 542 |
|
543 |
#endif // SHARE_VM_CLASSFILE_CLASSFILEPARSER_HPP |