author | lfoltan |
Mon, 21 Oct 2019 13:13:16 -0400 | |
changeset 58722 | cba8afa5cfed |
parent 58221 | b73753eff8b7 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
51444
diff
changeset
|
2 |
* Copyright (c) 1997, 2019, 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 |
||
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
51444
diff
changeset
|
25 |
#ifndef SHARE_CLASSFILE_CLASSFILEPARSER_HPP |
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
51444
diff
changeset
|
26 |
#define SHARE_CLASSFILE_CLASSFILEPARSER_HPP |
7397 | 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, |
|
54042
6dd6f988b4e4
8219860: Cleanup ClassFileParser::parse_linenumber_table
redestad
parents:
53705
diff
changeset
|
71 |
BROADCAST |
34666 | 72 |
}; |
73 |
||
42630
ae91fbc4b59f
8170987: Module system implementation refresh (12/2016)
alanb
parents:
41669
diff
changeset
|
74 |
enum { LegalClass, LegalField, LegalMethod }; // used to verify unqualified names |
36508 | 75 |
|
1 | 76 |
private: |
46513
c61eea516a0a
8181377: Capture underlying type for unsafe/unaligned pointers in ClassFileParser
mikael
parents:
46504
diff
changeset
|
77 |
// 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
|
78 |
typedef void unsafe_u2; |
c61eea516a0a
8181377: Capture underlying type for unsafe/unaligned pointers in ClassFileParser
mikael
parents:
46504
diff
changeset
|
79 |
|
34666 | 80 |
const ClassFileStream* _stream; // Actual input stream |
81 |
const Symbol* _requested_name; |
|
82 |
Symbol* _class_name; |
|
83 |
mutable ClassLoaderData* _loader_data; |
|
51444
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
51329
diff
changeset
|
84 |
const InstanceKlass* _unsafe_anonymous_host; |
34666 | 85 |
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
|
86 |
int _num_patched_klasses; |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46352
diff
changeset
|
87 |
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
|
88 |
int _orig_cp_size; |
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46352
diff
changeset
|
89 |
int _first_patched_klass_resolved_index; |
34666 | 90 |
|
91 |
// Metadata created before the instance klass is created. Must be deallocated |
|
92 |
// if not transferred to the InstanceKlass upon successful class loading |
|
93 |
// in which case these pointers have been set to NULL. |
|
94 |
const InstanceKlass* _super_klass; |
|
95 |
ConstantPool* _cp; |
|
96 |
Array<u2>* _fields; |
|
97 |
Array<Method*>* _methods; |
|
98 |
Array<u2>* _inner_classes; |
|
50735
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
99 |
Array<u2>* _nest_members; |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
100 |
u2 _nest_host; |
51329
9c68699bebe5
8208999: Some use of Klass* should be replaced by InstanceKlass*
iklam
parents:
50735
diff
changeset
|
101 |
Array<InstanceKlass*>* _local_interfaces; |
9c68699bebe5
8208999: Some use of Klass* should be replaced by InstanceKlass*
iklam
parents:
50735
diff
changeset
|
102 |
Array<InstanceKlass*>* _transitive_interfaces; |
34666 | 103 |
Annotations* _combined_annotations; |
58221
b73753eff8b7
8066774: Rename the annotations arrays names in ClassFileParser
godin
parents:
54042
diff
changeset
|
104 |
AnnotationArray* _class_annotations; |
b73753eff8b7
8066774: Rename the annotations arrays names in ClassFileParser
godin
parents:
54042
diff
changeset
|
105 |
AnnotationArray* _class_type_annotations; |
34666 | 106 |
Array<AnnotationArray*>* _fields_annotations; |
107 |
Array<AnnotationArray*>* _fields_type_annotations; |
|
108 |
InstanceKlass* _klass; // InstanceKlass* once created. |
|
109 |
InstanceKlass* _klass_to_deallocate; // an InstanceKlass* to be destroyed |
|
110 |
||
111 |
ClassAnnotationCollector* _parsed_annotations; |
|
112 |
FieldAllocationCount* _fac; |
|
113 |
FieldLayoutInfo* _field_info; |
|
114 |
const intArray* _method_ordering; |
|
115 |
GrowableArray<Method*>* _all_mirandas; |
|
116 |
||
117 |
enum { fixed_buffer_size = 128 }; |
|
118 |
u_char _linenumbertable_buffer[fixed_buffer_size]; |
|
119 |
||
120 |
// Size of Java vtable (in words) |
|
121 |
int _vtable_size; |
|
122 |
int _itable_size; |
|
123 |
||
124 |
int _num_miranda_methods; |
|
125 |
||
126 |
ReferenceType _rt; |
|
127 |
Handle _protection_domain; |
|
128 |
AccessFlags _access_flags; |
|
129 |
||
130 |
// for tracing and notifications |
|
131 |
Publicity _pub_level; |
|
132 |
||
44239
fdd97dc2367b
8175383: JVM should throw NCDFE if ACC_MODULE and CONSTANT_Module/Package are set
hseigel
parents:
42630
diff
changeset
|
133 |
// 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
|
134 |
// 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
|
135 |
// 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
|
136 |
// 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
|
137 |
// 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
|
138 |
// 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
|
139 |
// 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
|
140 |
short _bad_constant_seen; |
fdd97dc2367b
8175383: JVM should throw NCDFE if ACC_MODULE and CONSTANT_Module/Package are set
hseigel
parents:
42630
diff
changeset
|
141 |
|
34666 | 142 |
// class attributes parsed before the instance klass is created: |
143 |
bool _synthetic_flag; |
|
144 |
int _sde_length; |
|
145 |
const char* _sde_buffer; |
|
146 |
u2 _sourcefile_index; |
|
147 |
u2 _generic_signature_index; |
|
148 |
||
149 |
u2 _major_version; |
|
150 |
u2 _minor_version; |
|
151 |
u2 _this_class_index; |
|
152 |
u2 _super_class_index; |
|
153 |
u2 _itfs_len; |
|
154 |
u2 _java_fields_count; |
|
155 |
||
1 | 156 |
bool _need_verify; |
157 |
bool _relax_verify; |
|
34666 | 158 |
|
41669
2091069b6851
8081800: AbstractMethodError when evaluating a private method in an interface via debugger
dholmes
parents:
40923
diff
changeset
|
159 |
bool _has_nonstatic_concrete_methods; |
2091069b6851
8081800: AbstractMethodError when evaluating a private method in an interface via debugger
dholmes
parents:
40923
diff
changeset
|
160 |
bool _declares_nonstatic_concrete_methods; |
34666 | 161 |
bool _has_final_method; |
1 | 162 |
|
13291
9de3b1387cb8
6711908: JVM needs direct access to some annotations
jrose
parents:
12267
diff
changeset
|
163 |
// precomputed flags |
1 | 164 |
bool _has_finalizer; |
165 |
bool _has_empty_finalizer; |
|
166 |
bool _has_vanilla_constructor; |
|
13291
9de3b1387cb8
6711908: JVM needs direct access to some annotations
jrose
parents:
12267
diff
changeset
|
167 |
int _max_bootstrap_specifier_index; // detects BSS values |
1 | 168 |
|
34666 | 169 |
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
|
170 |
|
34666 | 171 |
void post_process_parsed_stream(const ClassFileStream* const stream, |
172 |
ConstantPool* cp, |
|
173 |
TRAPS); |
|
174 |
||
51444
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
51329
diff
changeset
|
175 |
void prepend_host_package_name(const InstanceKlass* unsafe_anonymous_host, TRAPS); |
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
51329
diff
changeset
|
176 |
void fix_unsafe_anonymous_class_name(TRAPS); |
40923
10fe1c28b9f6
8058575: IllegalAccessError trying to access package-private class from VM anonymous class
hseigel
parents:
40016
diff
changeset
|
177 |
|
36508 | 178 |
void fill_instance_klass(InstanceKlass* ik, bool cf_changed_in_CFLH, TRAPS); |
34666 | 179 |
void set_klass(InstanceKlass* instance); |
13291
9de3b1387cb8
6711908: JVM needs direct access to some annotations
jrose
parents:
12267
diff
changeset
|
180 |
|
44239
fdd97dc2367b
8175383: JVM should throw NCDFE if ACC_MODULE and CONSTANT_Module/Package are set
hseigel
parents:
42630
diff
changeset
|
181 |
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
|
182 |
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
|
183 |
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
|
184 |
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
|
185 |
void set_class_generic_signature_index(u2 x) { _generic_signature_index = x; } |
34666 | 186 |
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
|
187 |
|
28027
c63d0bb0101c
8065634: Crash in InstanceKlass::clean_method_data when _method is NULL
stefank
parents:
27402
diff
changeset
|
188 |
void create_combined_annotations(TRAPS); |
34666 | 189 |
void apply_parsed_class_attributes(InstanceKlass* k); // update k |
190 |
void apply_parsed_class_metadata(InstanceKlass* k, int fields_count, TRAPS); |
|
191 |
void clear_class_metadata(); |
|
1 | 192 |
|
193 |
// Constant pool parsing |
|
34666 | 194 |
void parse_constant_pool_entries(const ClassFileStream* const stream, |
195 |
ConstantPool* cp, |
|
196 |
const int length, |
|
197 |
TRAPS); |
|
1 | 198 |
|
34666 | 199 |
void parse_constant_pool(const ClassFileStream* const cfs, |
200 |
ConstantPool* const cp, |
|
201 |
const int length, |
|
202 |
TRAPS); |
|
1 | 203 |
|
204 |
// Interface parsing |
|
34666 | 205 |
void parse_interfaces(const ClassFileStream* const stream, |
206 |
const int itfs_len, |
|
207 |
ConstantPool* const cp, |
|
41669
2091069b6851
8081800: AbstractMethodError when evaluating a private method in an interface via debugger
dholmes
parents:
40923
diff
changeset
|
208 |
bool* has_nonstatic_concrete_methods, |
34666 | 209 |
TRAPS); |
1 | 210 |
|
34666 | 211 |
const InstanceKlass* parse_super_class(ConstantPool* const cp, |
212 |
const int super_class_index, |
|
213 |
const bool need_verify, |
|
214 |
TRAPS); |
|
215 |
||
1 | 216 |
// Field parsing |
34666 | 217 |
void parse_field_attributes(const ClassFileStream* const cfs, |
218 |
u2 attributes_count, |
|
219 |
bool is_static, |
|
220 |
u2 signature_index, |
|
221 |
u2* const constantvalue_index_addr, |
|
222 |
bool* const is_synthetic_addr, |
|
223 |
u2* const generic_signature_index_addr, |
|
13291
9de3b1387cb8
6711908: JVM needs direct access to some annotations
jrose
parents:
12267
diff
changeset
|
224 |
FieldAnnotationCollector* parsed_annotations, |
9de3b1387cb8
6711908: JVM needs direct access to some annotations
jrose
parents:
12267
diff
changeset
|
225 |
TRAPS); |
1 | 226 |
|
34666 | 227 |
void parse_fields(const ClassFileStream* const cfs, |
228 |
bool is_interface, |
|
229 |
FieldAllocationCount* const fac, |
|
230 |
ConstantPool* cp, |
|
231 |
const int cp_size, |
|
232 |
u2* const java_fields_count_ptr, |
|
233 |
TRAPS); |
|
15193
8e6b5694267f
8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents:
15097
diff
changeset
|
234 |
|
1 | 235 |
// Method parsing |
34666 | 236 |
Method* parse_method(const ClassFileStream* const cfs, |
237 |
bool is_interface, |
|
238 |
const ConstantPool* cp, |
|
239 |
AccessFlags* const promoted_flags, |
|
240 |
TRAPS); |
|
241 |
||
242 |
void parse_methods(const ClassFileStream* const cfs, |
|
243 |
bool is_interface, |
|
244 |
AccessFlags* const promoted_flags, |
|
245 |
bool* const has_final_method, |
|
41669
2091069b6851
8081800: AbstractMethodError when evaluating a private method in an interface via debugger
dholmes
parents:
40923
diff
changeset
|
246 |
bool* const declares_nonstatic_concrete_methods, |
34666 | 247 |
TRAPS); |
248 |
||
46513
c61eea516a0a
8181377: Capture underlying type for unsafe/unaligned pointers in ClassFileParser
mikael
parents:
46504
diff
changeset
|
249 |
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
|
250 |
u4 code_length, |
c61eea516a0a
8181377: Capture underlying type for unsafe/unaligned pointers in ClassFileParser
mikael
parents:
46504
diff
changeset
|
251 |
u4 exception_table_length, |
c61eea516a0a
8181377: Capture underlying type for unsafe/unaligned pointers in ClassFileParser
mikael
parents:
46504
diff
changeset
|
252 |
TRAPS); |
15935
50da9e5eb858
8003419: NPG: Clean up metadata created during class loading if failure
coleenp
parents:
15601
diff
changeset
|
253 |
|
34666 | 254 |
void parse_linenumber_table(u4 code_attribute_length, |
255 |
u4 code_length, |
|
256 |
CompressedLineNumberWriteStream**const write_stream, |
|
257 |
TRAPS); |
|
258 |
||
46513
c61eea516a0a
8181377: Capture underlying type for unsafe/unaligned pointers in ClassFileParser
mikael
parents:
46504
diff
changeset
|
259 |
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
|
260 |
u4 code_length, |
c61eea516a0a
8181377: Capture underlying type for unsafe/unaligned pointers in ClassFileParser
mikael
parents:
46504
diff
changeset
|
261 |
u2 max_locals, |
c61eea516a0a
8181377: Capture underlying type for unsafe/unaligned pointers in ClassFileParser
mikael
parents:
46504
diff
changeset
|
262 |
u4 code_attribute_length, |
c61eea516a0a
8181377: Capture underlying type for unsafe/unaligned pointers in ClassFileParser
mikael
parents:
46504
diff
changeset
|
263 |
u2* const localvariable_table_length, |
c61eea516a0a
8181377: Capture underlying type for unsafe/unaligned pointers in ClassFileParser
mikael
parents:
46504
diff
changeset
|
264 |
bool isLVTT, |
c61eea516a0a
8181377: Capture underlying type for unsafe/unaligned pointers in ClassFileParser
mikael
parents:
46504
diff
changeset
|
265 |
TRAPS); |
34666 | 266 |
|
46513
c61eea516a0a
8181377: Capture underlying type for unsafe/unaligned pointers in ClassFileParser
mikael
parents:
46504
diff
changeset
|
267 |
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
|
268 |
u2* const checked_exceptions_length, |
c61eea516a0a
8181377: Capture underlying type for unsafe/unaligned pointers in ClassFileParser
mikael
parents:
46504
diff
changeset
|
269 |
u4 method_attribute_length, |
c61eea516a0a
8181377: Capture underlying type for unsafe/unaligned pointers in ClassFileParser
mikael
parents:
46504
diff
changeset
|
270 |
TRAPS); |
34666 | 271 |
|
1 | 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 |
|
50735
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
286 |
u2 parse_classfile_nest_members_attribute(const ClassFileStream* const cfs, |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
287 |
const u1* const nest_members_attribute_start, |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
288 |
TRAPS); |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
49480
diff
changeset
|
289 |
|
34666 | 290 |
void parse_classfile_attributes(const ClassFileStream* const cfs, |
291 |
ConstantPool* cp, |
|
292 |
ClassAnnotationCollector* parsed_annotations, |
|
13291
9de3b1387cb8
6711908: JVM needs direct access to some annotations
jrose
parents:
12267
diff
changeset
|
293 |
TRAPS); |
34666 | 294 |
|
15935
50da9e5eb858
8003419: NPG: Clean up metadata created during class loading if failure
coleenp
parents:
15601
diff
changeset
|
295 |
void parse_classfile_synthetic_attribute(TRAPS); |
34666 | 296 |
void parse_classfile_signature_attribute(const ClassFileStream* const cfs, TRAPS); |
297 |
void parse_classfile_bootstrap_methods_attribute(const ClassFileStream* const cfs, |
|
298 |
ConstantPool* cp, |
|
299 |
u4 attribute_length, |
|
300 |
TRAPS); |
|
1 | 301 |
|
302 |
// Annotations handling |
|
34666 | 303 |
AnnotationArray* assemble_annotations(const u1* const runtime_visible_annotations, |
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
304 |
int runtime_visible_annotations_length, |
34666 | 305 |
const u1* const runtime_invisible_annotations, |
306 |
int runtime_invisible_annotations_length, |
|
307 |
TRAPS); |
|
1 | 308 |
|
34666 | 309 |
void set_precomputed_flags(InstanceKlass* k); |
1 | 310 |
|
311 |
// Format checker methods |
|
34666 | 312 |
void classfile_parse_error(const char* msg, TRAPS) const; |
313 |
void classfile_parse_error(const char* msg, int index, TRAPS) const; |
|
314 |
void classfile_parse_error(const char* msg, const char *name, TRAPS) const; |
|
315 |
void classfile_parse_error(const char* msg, |
|
316 |
int index, |
|
317 |
const char *name, |
|
318 |
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
|
319 |
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
|
320 |
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
|
321 |
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
|
322 |
TRAPS) const; |
34666 | 323 |
|
324 |
inline void guarantee_property(bool b, const char* msg, TRAPS) const { |
|
1 | 325 |
if (!b) { classfile_parse_error(msg, CHECK); } |
326 |
} |
|
327 |
||
34666 | 328 |
void report_assert_property_failure(const char* msg, TRAPS) const PRODUCT_RETURN; |
329 |
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
|
330 |
|
34666 | 331 |
inline void assert_property(bool b, const char* msg, TRAPS) const { |
1 | 332 |
#ifdef ASSERT |
17073
99baa410e207
8012695: Assertion message displays %u and %s text instead of actual values
hseigel
parents:
16692
diff
changeset
|
333 |
if (!b) { |
29201
fee2bbb2ec1d
8073389: Remove the include of resourceArea.hpp from classFileParser.hpp
stefank
parents:
29081
diff
changeset
|
334 |
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
|
335 |
} |
99baa410e207
8012695: Assertion message displays %u and %s text instead of actual values
hseigel
parents:
16692
diff
changeset
|
336 |
#endif |
99baa410e207
8012695: Assertion message displays %u and %s text instead of actual values
hseigel
parents:
16692
diff
changeset
|
337 |
} |
99baa410e207
8012695: Assertion message displays %u and %s text instead of actual values
hseigel
parents:
16692
diff
changeset
|
338 |
|
34666 | 339 |
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
|
340 |
#ifdef ASSERT |
99baa410e207
8012695: Assertion message displays %u and %s text instead of actual values
hseigel
parents:
16692
diff
changeset
|
341 |
if (!b) { |
29201
fee2bbb2ec1d
8073389: Remove the include of resourceArea.hpp from classFileParser.hpp
stefank
parents:
29081
diff
changeset
|
342 |
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
|
343 |
} |
1 | 344 |
#endif |
345 |
} |
|
346 |
||
34666 | 347 |
inline void check_property(bool property, |
348 |
const char* msg, |
|
349 |
int index, |
|
350 |
TRAPS) const { |
|
1 | 351 |
if (_need_verify) { |
352 |
guarantee_property(property, msg, index, CHECK); |
|
353 |
} else { |
|
17073
99baa410e207
8012695: Assertion message displays %u and %s text instead of actual values
hseigel
parents:
16692
diff
changeset
|
354 |
assert_property(property, msg, index, CHECK); |
1 | 355 |
} |
356 |
} |
|
357 |
||
34666 | 358 |
inline void check_property(bool property, const char* msg, TRAPS) const { |
1 | 359 |
if (_need_verify) { |
360 |
guarantee_property(property, msg, CHECK); |
|
361 |
} else { |
|
362 |
assert_property(property, msg, CHECK); |
|
363 |
} |
|
364 |
} |
|
365 |
||
34666 | 366 |
inline void guarantee_property(bool b, |
367 |
const char* msg, |
|
368 |
int index, |
|
369 |
TRAPS) const { |
|
1 | 370 |
if (!b) { classfile_parse_error(msg, index, CHECK); } |
371 |
} |
|
34666 | 372 |
|
373 |
inline void guarantee_property(bool b, |
|
374 |
const char* msg, |
|
375 |
const char *name, |
|
376 |
TRAPS) const { |
|
1 | 377 |
if (!b) { classfile_parse_error(msg, name, CHECK); } |
378 |
} |
|
34666 | 379 |
|
380 |
inline void guarantee_property(bool b, |
|
381 |
const char* msg, |
|
382 |
int index, |
|
383 |
const char *name, |
|
384 |
TRAPS) const { |
|
1 | 385 |
if (!b) { classfile_parse_error(msg, index, name, CHECK); } |
386 |
} |
|
387 |
||
34666 | 388 |
void throwIllegalSignature(const char* type, |
389 |
const Symbol* name, |
|
390 |
const Symbol* sig, |
|
391 |
TRAPS) const; |
|
5709
3b5307e27c1d
6930553: classfile format checker allows invalid method descriptor in CONSTANT_NameAndType_info in some cases
kamg
parents:
3821
diff
changeset
|
392 |
|
34666 | 393 |
void verify_constantvalue(const ConstantPool* const cp, |
394 |
int constantvalue_index, |
|
395 |
int signature_index, |
|
396 |
TRAPS) const; |
|
397 |
||
398 |
void verify_legal_utf8(const unsigned char* buffer, int length, TRAPS) const; |
|
399 |
void verify_legal_class_name(const Symbol* name, TRAPS) const; |
|
400 |
void verify_legal_field_name(const Symbol* name, TRAPS) const; |
|
401 |
void verify_legal_method_name(const Symbol* name, TRAPS) const; |
|
1 | 402 |
|
34666 | 403 |
void verify_legal_field_signature(const Symbol* fieldname, |
404 |
const Symbol* signature, |
|
405 |
TRAPS) const; |
|
406 |
int verify_legal_method_signature(const Symbol* methodname, |
|
407 |
const Symbol* signature, |
|
408 |
TRAPS) const; |
|
1 | 409 |
|
34666 | 410 |
void verify_legal_class_modifiers(jint flags, TRAPS) const; |
411 |
void verify_legal_field_modifiers(jint flags, bool is_interface, TRAPS) const; |
|
412 |
void verify_legal_method_modifiers(jint flags, |
|
413 |
bool is_interface, |
|
414 |
const Symbol* name, |
|
415 |
TRAPS) const; |
|
416 |
||
417 |
const char* skip_over_field_signature(const char* signature, |
|
418 |
bool void_ok, |
|
419 |
unsigned int length, |
|
420 |
TRAPS) const; |
|
421 |
||
422 |
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
|
423 |
assert(index >= 0, "oob"); |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
424 |
return (_cp_patches != NULL |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
425 |
&& index < _cp_patches->length() |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
426 |
&& _cp_patches->adr_at(index)->not_null()); |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
427 |
} |
34666 | 428 |
|
429 |
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
|
430 |
assert(has_cp_patch_at(index), "oob"); |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
431 |
return _cp_patches->at(index); |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
432 |
} |
34666 | 433 |
|
49480
d7df2dd501ce
8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents:
49364
diff
changeset
|
434 |
Handle clear_cp_patch_at(int index); |
34666 | 435 |
|
46427
54713555867e
8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents:
46352
diff
changeset
|
436 |
void patch_class(ConstantPool* cp, int class_index, Klass* k, Symbol* name); |
34666 | 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, |
|
46513
c61eea516a0a
8181377: Capture underlying type for unsafe/unaligned pointers in ClassFileParser
mikael
parents:
46504
diff
changeset
|
460 |
const unsafe_u2** const localvariable_table_start, |
15601 | 461 |
int lvtt_cnt, |
34666 | 462 |
u2* const localvariable_type_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_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 |
|
53705
757e9407bafc
8218593: Symbol leak in prepend_host_package_name
coleenp
parents:
53244
diff
changeset
|
490 |
void update_class_name(Symbol* new_name); |
757e9407bafc
8218593: Symbol leak in prepend_host_package_name
coleenp
parents:
53244
diff
changeset
|
491 |
|
1 | 492 |
public: |
34666 | 493 |
ClassFileParser(ClassFileStream* stream, |
494 |
Symbol* name, |
|
495 |
ClassLoaderData* loader_data, |
|
496 |
Handle protection_domain, |
|
51444
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
51329
diff
changeset
|
497 |
const InstanceKlass* unsafe_anonymous_host, |
34666 | 498 |
GrowableArray<Handle>* cp_patches, |
499 |
Publicity pub_level, |
|
500 |
TRAPS); |
|
501 |
||
15935
50da9e5eb858
8003419: NPG: Clean up metadata created during class loading if failure
coleenp
parents:
15601
diff
changeset
|
502 |
~ClassFileParser(); |
1 | 503 |
|
36508 | 504 |
InstanceKlass* create_instance_klass(bool cf_changed_in_CFLH, TRAPS); |
34666 | 505 |
|
506 |
const ClassFileStream* clone_stream() const; |
|
507 |
||
508 |
void set_klass_to_deallocate(InstanceKlass* klass); |
|
509 |
||
510 |
int static_field_size() const; |
|
511 |
int total_oop_map_count() const; |
|
512 |
jint layout_size() const; |
|
513 |
||
514 |
int vtable_size() const { return _vtable_size; } |
|
515 |
int itable_size() const { return _itable_size; } |
|
1 | 516 |
|
34666 | 517 |
u2 this_class_index() const { return _this_class_index; } |
518 |
||
51444
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
51329
diff
changeset
|
519 |
bool is_unsafe_anonymous() const { return _unsafe_anonymous_host != NULL; } |
34666 | 520 |
bool is_interface() const { return _access_flags.is_interface(); } |
521 |
||
51444
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
51329
diff
changeset
|
522 |
const InstanceKlass* unsafe_anonymous_host() const { return _unsafe_anonymous_host; } |
34666 | 523 |
const GrowableArray<Handle>* cp_patches() const { return _cp_patches; } |
524 |
ClassLoaderData* loader_data() const { return _loader_data; } |
|
525 |
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
|
526 |
const InstanceKlass* super_klass() const { return _super_klass; } |
34666 | 527 |
|
528 |
ReferenceType reference_type() const { return _rt; } |
|
529 |
AccessFlags access_flags() const { return _access_flags; } |
|
530 |
||
531 |
bool is_internal() const { return INTERNAL == _pub_level; } |
|
532 |
||
36508 | 533 |
static bool verify_unqualified_name(const char* name, unsigned int length, int type); |
40016 | 534 |
|
535 |
#ifdef ASSERT |
|
536 |
static bool is_internal_format(Symbol* class_name); |
|
537 |
#endif |
|
538 |
||
1 | 539 |
}; |
7397 | 540 |
|
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
51444
diff
changeset
|
541 |
#endif // SHARE_CLASSFILE_CLASSFILEPARSER_HPP |