Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/share/classfile/javaClasses.hpp
40949 views
1
/*
2
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
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
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*
23
*/
24
25
#ifndef SHARE_CLASSFILE_JAVACLASSES_HPP
26
#define SHARE_CLASSFILE_JAVACLASSES_HPP
27
28
#include "classfile/vmClasses.hpp"
29
#include "oops/oop.hpp"
30
#include "oops/instanceKlass.hpp"
31
#include "oops/symbol.hpp"
32
#include "runtime/os.hpp"
33
#include "utilities/vmEnums.hpp"
34
35
class RecordComponent;
36
37
// Interface for manipulating the basic Java classes.
38
39
#define BASIC_JAVA_CLASSES_DO_PART1(f) \
40
f(java_lang_Class) \
41
f(java_lang_String) \
42
f(java_lang_ref_Reference) \
43
//end
44
45
#define BASIC_JAVA_CLASSES_DO_PART2(f) \
46
f(java_lang_System) \
47
f(java_lang_ClassLoader) \
48
f(java_lang_Throwable) \
49
f(java_lang_Thread) \
50
f(java_lang_ThreadGroup) \
51
f(java_lang_InternalError) \
52
f(java_lang_AssertionStatusDirectives) \
53
f(java_lang_ref_SoftReference) \
54
f(java_lang_invoke_MethodHandle) \
55
f(java_lang_invoke_DirectMethodHandle) \
56
f(java_lang_invoke_MemberName) \
57
f(java_lang_invoke_ResolvedMethodName) \
58
f(java_lang_invoke_LambdaForm) \
59
f(java_lang_invoke_MethodType) \
60
f(java_lang_invoke_CallSite) \
61
f(java_lang_invoke_ConstantCallSite) \
62
f(java_lang_invoke_MethodHandleNatives_CallSiteContext) \
63
f(java_security_AccessControlContext) \
64
f(java_lang_reflect_AccessibleObject) \
65
f(java_lang_reflect_Method) \
66
f(java_lang_reflect_Constructor) \
67
f(java_lang_reflect_Field) \
68
f(java_lang_reflect_RecordComponent) \
69
f(java_nio_Buffer) \
70
f(reflect_ConstantPool) \
71
f(reflect_UnsafeStaticFieldAccessorImpl) \
72
f(java_lang_reflect_Parameter) \
73
f(java_lang_Module) \
74
f(java_lang_StackTraceElement) \
75
f(java_lang_StackFrameInfo) \
76
f(java_lang_LiveStackFrameInfo) \
77
f(java_util_concurrent_locks_AbstractOwnableSynchronizer) \
78
f(jdk_internal_invoke_NativeEntryPoint) \
79
f(jdk_internal_misc_UnsafeConstants) \
80
f(java_lang_boxing_object) \
81
f(vector_VectorPayload) \
82
//end
83
84
#define BASIC_JAVA_CLASSES_DO(f) \
85
BASIC_JAVA_CLASSES_DO_PART1(f) \
86
BASIC_JAVA_CLASSES_DO_PART2(f)
87
88
#define CHECK_INIT(offset) assert(offset != 0, "should be initialized"); return offset;
89
90
// Interface to java.lang.Object objects
91
92
class java_lang_Object : AllStatic {
93
public:
94
static void register_natives(TRAPS);
95
};
96
97
// Interface to java.lang.String objects
98
99
// The flags field is a collection of bits representing boolean values used
100
// internally by the VM.
101
#define STRING_INJECTED_FIELDS(macro) \
102
macro(java_lang_String, flags, byte_signature, false)
103
104
class java_lang_String : AllStatic {
105
private:
106
static int _value_offset;
107
static int _hash_offset;
108
static int _hashIsZero_offset;
109
static int _coder_offset;
110
static int _flags_offset;
111
112
static bool _initialized;
113
114
static Handle basic_create(int length, bool byte_arr, TRAPS);
115
116
static inline void set_coder(oop string, jbyte coder);
117
118
// Bitmasks for values in the injected flags field.
119
static const uint8_t _deduplication_forbidden_mask = 1 << 0;
120
static const uint8_t _deduplication_requested_mask = 1 << 1;
121
122
static int flags_offset() { CHECK_INIT(_flags_offset); }
123
// Return the address of the injected flags field.
124
static inline uint8_t* flags_addr(oop java_string);
125
// Test whether the designated bit of the injected flags field is set.
126
static inline bool is_flag_set(oop java_string, uint8_t flag_mask);
127
// Atomically test and set the designated bit of the injected flags field,
128
// returning true if the bit was already set.
129
static bool test_and_set_flag(oop java_string, uint8_t flag_mask);
130
131
public:
132
133
// Coders
134
enum Coder {
135
CODER_LATIN1 = 0,
136
CODER_UTF16 = 1
137
};
138
139
static void compute_offsets();
140
static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
141
142
// Instance creation
143
static Handle create_from_unicode(const jchar* unicode, int len, TRAPS);
144
static oop create_oop_from_unicode(const jchar* unicode, int len, TRAPS);
145
static Handle create_from_str(const char* utf8_str, TRAPS);
146
static oop create_oop_from_str(const char* utf8_str, TRAPS);
147
static Handle create_from_symbol(Symbol* symbol, TRAPS);
148
static Handle create_from_platform_dependent_str(const char* str, TRAPS);
149
static Handle char_converter(Handle java_string, jchar from_char, jchar to_char, TRAPS);
150
151
static void set_compact_strings(bool value);
152
153
static int value_offset() { CHECK_INIT(_value_offset); }
154
static int coder_offset() { CHECK_INIT(_coder_offset); }
155
156
static inline void set_value_raw(oop string, typeArrayOop buffer);
157
static inline void set_value(oop string, typeArrayOop buffer);
158
159
// Set the deduplication_forbidden flag true. This flag is sticky; once
160
// set it never gets cleared. This is set when a String is interned in
161
// the StringTable, to prevent string deduplication from changing the
162
// String's value array.
163
static inline void set_deduplication_forbidden(oop java_string);
164
165
// Test and set the deduplication_requested flag. Returns the old value
166
// of the flag. This flag is sticky; once set it never gets cleared.
167
// Some GCs may use this flag when deciding whether to request
168
// deduplication of a String, to avoid multiple requests for the same
169
// object.
170
static inline bool test_and_set_deduplication_requested(oop java_string);
171
172
// Accessors
173
static inline typeArrayOop value(oop java_string);
174
static inline typeArrayOop value_no_keepalive(oop java_string);
175
static inline bool hash_is_set(oop string);
176
static inline bool is_latin1(oop java_string);
177
static inline bool deduplication_forbidden(oop java_string);
178
static inline bool deduplication_requested(oop java_string);
179
static inline int length(oop java_string);
180
static inline int length(oop java_string, typeArrayOop string_value);
181
static int utf8_length(oop java_string);
182
static int utf8_length(oop java_string, typeArrayOop string_value);
183
184
// String converters
185
static char* as_utf8_string(oop java_string);
186
static char* as_utf8_string(oop java_string, int& length);
187
static char* as_utf8_string_full(oop java_string, char* buf, int buflen, int& length);
188
static char* as_utf8_string(oop java_string, char* buf, int buflen);
189
static char* as_utf8_string(oop java_string, int start, int len);
190
static char* as_utf8_string(oop java_string, typeArrayOop value, char* buf, int buflen);
191
static char* as_utf8_string(oop java_string, typeArrayOop value, int start, int len, char* buf, int buflen);
192
static char* as_platform_dependent_str(Handle java_string, TRAPS);
193
static jchar* as_unicode_string(oop java_string, int& length, TRAPS);
194
static jchar* as_unicode_string_or_null(oop java_string, int& length);
195
// produce an ascii string with all other values quoted using \u####
196
static char* as_quoted_ascii(oop java_string);
197
198
// Compute the hash value for a java.lang.String object which would
199
// contain the characters passed in.
200
//
201
// As the hash value used by the String object itself, in
202
// String.hashCode(). This value is normally calculated in Java code
203
// in the String.hashCode method(), but is precomputed for String
204
// objects in the shared archive file.
205
// hash P(31) from Kernighan & Ritchie
206
//
207
// For this reason, THIS ALGORITHM MUST MATCH String.hashCode().
208
static unsigned int hash_code(const jchar* s, int len) {
209
unsigned int h = 0;
210
while (len-- > 0) {
211
h = 31*h + (unsigned int) *s;
212
s++;
213
}
214
return h;
215
}
216
217
static unsigned int hash_code(const jbyte* s, int len) {
218
unsigned int h = 0;
219
while (len-- > 0) {
220
h = 31*h + (((unsigned int) *s) & 0xFF);
221
s++;
222
}
223
return h;
224
}
225
226
static unsigned int hash_code(oop java_string);
227
228
static bool equals(oop java_string, const jchar* chars, int len);
229
static bool equals(oop str1, oop str2);
230
static inline bool value_equals(typeArrayOop str_value1, typeArrayOop str_value2);
231
232
// Conversion between '.' and '/' formats
233
static Handle externalize_classname(Handle java_string, TRAPS) {
234
return char_converter(java_string, JVM_SIGNATURE_SLASH, JVM_SIGNATURE_DOT, THREAD);
235
}
236
237
// Conversion
238
static Symbol* as_symbol(oop java_string);
239
static Symbol* as_symbol_or_null(oop java_string);
240
241
// Testers
242
static bool is_instance(oop obj);
243
static inline bool is_instance_inlined(oop obj);
244
245
// Debugging
246
static void print(oop java_string, outputStream* st);
247
friend class JavaClasses;
248
friend class StringTable;
249
};
250
251
252
// Interface to java.lang.Class objects
253
254
#define CLASS_INJECTED_FIELDS(macro) \
255
macro(java_lang_Class, klass, intptr_signature, false) \
256
macro(java_lang_Class, array_klass, intptr_signature, false) \
257
macro(java_lang_Class, oop_size, int_signature, false) \
258
macro(java_lang_Class, static_oop_field_count, int_signature, false) \
259
macro(java_lang_Class, protection_domain, object_signature, false) \
260
macro(java_lang_Class, signers, object_signature, false) \
261
macro(java_lang_Class, source_file, object_signature, false) \
262
263
class java_lang_Class : AllStatic {
264
friend class VMStructs;
265
friend class JVMCIVMStructs;
266
267
private:
268
269
// The fake offsets are added by the class loader when java.lang.Class is loaded
270
271
static int _klass_offset;
272
static int _array_klass_offset;
273
274
static int _oop_size_offset;
275
static int _static_oop_field_count_offset;
276
277
static int _protection_domain_offset;
278
static int _init_lock_offset;
279
static int _signers_offset;
280
static int _class_loader_offset;
281
static int _module_offset;
282
static int _component_mirror_offset;
283
static int _name_offset;
284
static int _source_file_offset;
285
static int _classData_offset;
286
static int _classRedefinedCount_offset;
287
288
static bool _offsets_computed;
289
290
static GrowableArray<Klass*>* _fixup_mirror_list;
291
static GrowableArray<Klass*>* _fixup_module_field_list;
292
293
static void set_init_lock(oop java_class, oop init_lock);
294
static void set_protection_domain(oop java_class, oop protection_domain);
295
static void set_class_loader(oop java_class, oop class_loader);
296
static void set_component_mirror(oop java_class, oop comp_mirror);
297
static void initialize_mirror_fields(Klass* k, Handle mirror, Handle protection_domain,
298
Handle classData, TRAPS);
299
static void set_mirror_module_field(JavaThread* current, Klass* K, Handle mirror, Handle module);
300
public:
301
static void allocate_fixup_lists();
302
static void compute_offsets();
303
304
// Instance creation
305
static void create_mirror(Klass* k, Handle class_loader, Handle module,
306
Handle protection_domain, Handle classData, TRAPS);
307
static void fixup_mirror(Klass* k, TRAPS);
308
static oop create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS);
309
static void update_archived_primitive_mirror_native_pointers(oop archived_mirror) NOT_CDS_JAVA_HEAP_RETURN;
310
static void update_archived_mirror_native_pointers(oop archived_mirror) NOT_CDS_JAVA_HEAP_RETURN;
311
312
// Archiving
313
static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
314
static void archive_basic_type_mirrors() NOT_CDS_JAVA_HEAP_RETURN;
315
static oop archive_mirror(Klass* k) NOT_CDS_JAVA_HEAP_RETURN_(NULL);
316
static oop process_archived_mirror(Klass* k, oop mirror, oop archived_mirror)
317
NOT_CDS_JAVA_HEAP_RETURN_(NULL);
318
static bool restore_archived_mirror(Klass *k, Handle class_loader, Handle module,
319
Handle protection_domain,
320
TRAPS) NOT_CDS_JAVA_HEAP_RETURN_(false);
321
322
static void fixup_module_field(Klass* k, Handle module);
323
324
// Conversion
325
static Klass* as_Klass(oop java_class);
326
static Klass* as_Klass_raw(oop java_class);
327
static void set_klass(oop java_class, Klass* klass);
328
static BasicType as_BasicType(oop java_class, Klass** reference_klass = NULL);
329
static Symbol* as_signature(oop java_class, bool intern_if_not_found);
330
static void print_signature(oop java_class, outputStream *st);
331
static const char* as_external_name(oop java_class);
332
// Testing
333
static bool is_instance(oop obj);
334
335
static bool is_primitive(oop java_class);
336
static BasicType primitive_type(oop java_class);
337
static oop primitive_mirror(BasicType t);
338
// JVM_NewArray support
339
static Klass* array_klass_acquire(oop java_class);
340
static void release_set_array_klass(oop java_class, Klass* klass);
341
// compiler support for class operations
342
static int klass_offset() { CHECK_INIT(_klass_offset); }
343
static int array_klass_offset() { CHECK_INIT(_array_klass_offset); }
344
// Support for classRedefinedCount field
345
static int classRedefinedCount(oop the_class_mirror);
346
static void set_classRedefinedCount(oop the_class_mirror, int value);
347
348
// Support for embedded per-class oops
349
static oop protection_domain(oop java_class);
350
static oop init_lock(oop java_class);
351
static void clear_init_lock(oop java_class) {
352
set_init_lock(java_class, NULL);
353
}
354
static oop component_mirror(oop java_class);
355
static objArrayOop signers(oop java_class);
356
static void set_signers(oop java_class, objArrayOop signers);
357
static oop class_data(oop java_class);
358
static void set_class_data(oop java_class, oop classData);
359
360
static int component_mirror_offset() { return _component_mirror_offset; }
361
362
static oop class_loader(oop java_class);
363
static void set_module(oop java_class, oop module);
364
static oop module(oop java_class);
365
366
static oop name(Handle java_class, TRAPS);
367
368
static oop source_file(oop java_class);
369
static void set_source_file(oop java_class, oop source_file);
370
371
static int oop_size(oop java_class);
372
static int oop_size_raw(oop java_class);
373
static void set_oop_size(HeapWord* java_class, int size);
374
static int static_oop_field_count(oop java_class);
375
static int static_oop_field_count_raw(oop java_class);
376
static void set_static_oop_field_count(oop java_class, int size);
377
378
static GrowableArray<Klass*>* fixup_mirror_list() {
379
return _fixup_mirror_list;
380
}
381
static void set_fixup_mirror_list(GrowableArray<Klass*>* v) {
382
_fixup_mirror_list = v;
383
}
384
385
static GrowableArray<Klass*>* fixup_module_field_list() {
386
return _fixup_module_field_list;
387
}
388
static void set_fixup_module_field_list(GrowableArray<Klass*>* v) {
389
_fixup_module_field_list = v;
390
}
391
392
// Debugging
393
friend class JavaClasses;
394
};
395
396
// Interface to java.lang.Thread objects
397
398
class java_lang_Thread : AllStatic {
399
private:
400
// Note that for this class the layout changed between JDK1.2 and JDK1.3,
401
// so we compute the offsets at startup rather than hard-wiring them.
402
static int _name_offset;
403
static int _group_offset;
404
static int _contextClassLoader_offset;
405
static int _inheritedAccessControlContext_offset;
406
static int _priority_offset;
407
static int _eetop_offset;
408
static int _interrupted_offset;
409
static int _daemon_offset;
410
static int _stillborn_offset;
411
static int _stackSize_offset;
412
static int _tid_offset;
413
static int _thread_status_offset;
414
static int _park_blocker_offset;
415
416
static void compute_offsets();
417
418
public:
419
static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
420
421
// Returns the JavaThread associated with the thread obj
422
static JavaThread* thread(oop java_thread);
423
// Set JavaThread for instance
424
static void set_thread(oop java_thread, JavaThread* thread);
425
// Interrupted status
426
static bool interrupted(oop java_thread);
427
static void set_interrupted(oop java_thread, bool val);
428
// Name
429
static oop name(oop java_thread);
430
static void set_name(oop java_thread, oop name);
431
// Priority
432
static ThreadPriority priority(oop java_thread);
433
static void set_priority(oop java_thread, ThreadPriority priority);
434
// Thread group
435
static oop threadGroup(oop java_thread);
436
// Stillborn
437
static bool is_stillborn(oop java_thread);
438
static void set_stillborn(oop java_thread);
439
// Alive (NOTE: this is not really a field, but provides the correct
440
// definition without doing a Java call)
441
static bool is_alive(oop java_thread);
442
// Daemon
443
static bool is_daemon(oop java_thread);
444
static void set_daemon(oop java_thread);
445
// Context ClassLoader
446
static oop context_class_loader(oop java_thread);
447
// Control context
448
static oop inherited_access_control_context(oop java_thread);
449
// Stack size hint
450
static jlong stackSize(oop java_thread);
451
// Thread ID
452
static jlong thread_id(oop java_thread);
453
454
// Blocker object responsible for thread parking
455
static oop park_blocker(oop java_thread);
456
457
// Write thread status info to threadStatus field of java.lang.Thread.
458
static void set_thread_status(oop java_thread_oop, JavaThreadStatus status);
459
// Read thread status info from threadStatus field of java.lang.Thread.
460
static JavaThreadStatus get_thread_status(oop java_thread_oop);
461
462
static const char* thread_status_name(oop java_thread_oop);
463
464
// Debugging
465
friend class JavaClasses;
466
};
467
468
// Interface to java.lang.ThreadGroup objects
469
470
class java_lang_ThreadGroup : AllStatic {
471
private:
472
static int _parent_offset;
473
static int _name_offset;
474
static int _threads_offset;
475
static int _groups_offset;
476
static int _maxPriority_offset;
477
static int _destroyed_offset;
478
static int _daemon_offset;
479
static int _nthreads_offset;
480
static int _ngroups_offset;
481
482
static void compute_offsets();
483
484
public:
485
static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
486
487
// parent ThreadGroup
488
static oop parent(oop java_thread_group);
489
// name
490
static const char* name(oop java_thread_group);
491
// ("name as oop" accessor is not necessary)
492
// Number of threads in group
493
static int nthreads(oop java_thread_group);
494
// threads
495
static objArrayOop threads(oop java_thread_group);
496
// Number of threads in group
497
static int ngroups(oop java_thread_group);
498
// groups
499
static objArrayOop groups(oop java_thread_group);
500
// maxPriority in group
501
static ThreadPriority maxPriority(oop java_thread_group);
502
// Destroyed
503
static bool is_destroyed(oop java_thread_group);
504
// Daemon
505
static bool is_daemon(oop java_thread_group);
506
// Debugging
507
friend class JavaClasses;
508
};
509
510
511
512
// Interface to java.lang.Throwable objects
513
514
class java_lang_Throwable: AllStatic {
515
friend class BacktraceBuilder;
516
friend class BacktraceIterator;
517
518
private:
519
// Trace constants
520
enum {
521
trace_methods_offset = 0,
522
trace_bcis_offset = 1,
523
trace_mirrors_offset = 2,
524
trace_names_offset = 3,
525
trace_next_offset = 4,
526
trace_hidden_offset = 5,
527
trace_size = 6,
528
trace_chunk_size = 32
529
};
530
531
static int _backtrace_offset;
532
static int _detailMessage_offset;
533
static int _stackTrace_offset;
534
static int _depth_offset;
535
static int _cause_offset;
536
static int _static_unassigned_stacktrace_offset;
537
538
// StackTrace (programmatic access, new since 1.4)
539
static void clear_stacktrace(oop throwable);
540
// Stacktrace (post JDK 1.7.0 to allow immutability protocol to be followed)
541
static void set_stacktrace(oop throwable, oop st_element_array);
542
static oop unassigned_stacktrace();
543
544
public:
545
// Backtrace
546
static oop backtrace(oop throwable);
547
static void set_backtrace(oop throwable, oop value);
548
static int depth(oop throwable);
549
static void set_depth(oop throwable, int value);
550
static int get_detailMessage_offset() { CHECK_INIT(_detailMessage_offset); }
551
// Message
552
static oop message(oop throwable);
553
static oop cause(oop throwable);
554
static void set_message(oop throwable, oop value);
555
static Symbol* detail_message(oop throwable);
556
static void print_stack_element(outputStream *st, Method* method, int bci);
557
558
static void compute_offsets();
559
static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
560
561
// Allocate space for backtrace (created but stack trace not filled in)
562
static void allocate_backtrace(Handle throwable, TRAPS);
563
// Fill in current stack trace for throwable with preallocated backtrace (no GC)
564
static void fill_in_stack_trace_of_preallocated_backtrace(Handle throwable);
565
// Fill in current stack trace, can cause GC
566
static void fill_in_stack_trace(Handle throwable, const methodHandle& method, TRAPS);
567
static void fill_in_stack_trace(Handle throwable, const methodHandle& method = methodHandle());
568
// Programmatic access to stack trace
569
static void get_stack_trace_elements(Handle throwable, objArrayHandle stack_trace, TRAPS);
570
// Printing
571
static void print(oop throwable, outputStream* st);
572
static void print_stack_trace(Handle throwable, outputStream* st);
573
static void java_printStackTrace(Handle throwable, TRAPS);
574
// Debugging
575
friend class JavaClasses;
576
// Gets the method and bci of the top frame (TOS). Returns false if this failed.
577
static bool get_top_method_and_bci(oop throwable, Method** method, int* bci);
578
};
579
580
581
// Interface to java.lang.reflect.AccessibleObject objects
582
583
class java_lang_reflect_AccessibleObject: AllStatic {
584
private:
585
// Note that to reduce dependencies on the JDK we compute these
586
// offsets at run-time.
587
static int _override_offset;
588
589
static void compute_offsets();
590
591
public:
592
static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
593
594
// Accessors
595
static jboolean override(oop reflect);
596
static void set_override(oop reflect, jboolean value);
597
598
// Debugging
599
friend class JavaClasses;
600
};
601
602
603
// Interface to java.lang.reflect.Method objects
604
605
class java_lang_reflect_Method : public java_lang_reflect_AccessibleObject {
606
private:
607
// Note that to reduce dependencies on the JDK we compute these
608
// offsets at run-time.
609
static int _clazz_offset;
610
static int _name_offset;
611
static int _returnType_offset;
612
static int _parameterTypes_offset;
613
static int _exceptionTypes_offset;
614
static int _slot_offset;
615
static int _modifiers_offset;
616
static int _signature_offset;
617
static int _annotations_offset;
618
static int _parameter_annotations_offset;
619
static int _annotation_default_offset;
620
621
static void compute_offsets();
622
public:
623
static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
624
625
// Allocation
626
static Handle create(TRAPS);
627
628
// Accessors
629
static oop clazz(oop reflect);
630
static void set_clazz(oop reflect, oop value);
631
632
static void set_name(oop method, oop value);
633
634
static oop return_type(oop method);
635
static void set_return_type(oop method, oop value);
636
637
static oop parameter_types(oop method);
638
static void set_parameter_types(oop method, oop value);
639
640
static int slot(oop reflect);
641
static void set_slot(oop reflect, int value);
642
643
static void set_exception_types(oop method, oop value);
644
static void set_modifiers(oop method, int value);
645
static void set_signature(oop method, oop value);
646
static void set_annotations(oop method, oop value);
647
static void set_parameter_annotations(oop method, oop value);
648
static void set_annotation_default(oop method, oop value);
649
650
// Debugging
651
friend class JavaClasses;
652
};
653
654
655
// Interface to java.lang.reflect.Constructor objects
656
657
class java_lang_reflect_Constructor : public java_lang_reflect_AccessibleObject {
658
private:
659
// Note that to reduce dependencies on the JDK we compute these
660
// offsets at run-time.
661
static int _clazz_offset;
662
static int _parameterTypes_offset;
663
static int _exceptionTypes_offset;
664
static int _slot_offset;
665
static int _modifiers_offset;
666
static int _signature_offset;
667
static int _annotations_offset;
668
static int _parameter_annotations_offset;
669
670
static void compute_offsets();
671
public:
672
static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
673
674
// Allocation
675
static Handle create(TRAPS);
676
677
// Accessors
678
static oop clazz(oop reflect);
679
static void set_clazz(oop reflect, oop value);
680
681
static oop parameter_types(oop constructor);
682
static void set_parameter_types(oop constructor, oop value);
683
684
static int slot(oop reflect);
685
static void set_slot(oop reflect, int value);
686
687
static void set_exception_types(oop constructor, oop value);
688
static void set_modifiers(oop constructor, int value);
689
static void set_signature(oop constructor, oop value);
690
static void set_annotations(oop constructor, oop value);
691
static void set_parameter_annotations(oop method, oop value);
692
693
// Debugging
694
friend class JavaClasses;
695
};
696
697
698
// Interface to java.lang.reflect.Field objects
699
700
class java_lang_reflect_Field : public java_lang_reflect_AccessibleObject {
701
private:
702
// Note that to reduce dependencies on the JDK we compute these
703
// offsets at run-time.
704
static int _clazz_offset;
705
static int _name_offset;
706
static int _type_offset;
707
static int _slot_offset;
708
static int _modifiers_offset;
709
static int _trusted_final_offset;
710
static int _signature_offset;
711
static int _annotations_offset;
712
713
static void compute_offsets();
714
715
public:
716
static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
717
718
// Allocation
719
static Handle create(TRAPS);
720
721
// Accessors
722
static oop clazz(oop reflect);
723
static void set_clazz(oop reflect, oop value);
724
725
static oop name(oop field);
726
static void set_name(oop field, oop value);
727
728
static oop type(oop field);
729
static void set_type(oop field, oop value);
730
731
static int slot(oop reflect);
732
static void set_slot(oop reflect, int value);
733
734
static int modifiers(oop field);
735
static void set_modifiers(oop field, int value);
736
737
static void set_trusted_final(oop field);
738
739
static void set_signature(oop constructor, oop value);
740
static void set_annotations(oop constructor, oop value);
741
742
// Debugging
743
friend class JavaClasses;
744
};
745
746
class java_lang_reflect_Parameter {
747
private:
748
// Note that to reduce dependencies on the JDK we compute these
749
// offsets at run-time.
750
static int _name_offset;
751
static int _modifiers_offset;
752
static int _index_offset;
753
static int _executable_offset;
754
755
static void compute_offsets();
756
757
public:
758
static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
759
760
// Allocation
761
static Handle create(TRAPS);
762
763
// Accessors
764
static oop name(oop field);
765
static void set_name(oop field, oop value);
766
767
static int index(oop reflect);
768
static void set_index(oop reflect, int value);
769
770
static int modifiers(oop reflect);
771
static void set_modifiers(oop reflect, int value);
772
773
static oop executable(oop constructor);
774
static void set_executable(oop constructor, oop value);
775
776
friend class JavaClasses;
777
};
778
779
#define MODULE_INJECTED_FIELDS(macro) \
780
macro(java_lang_Module, module_entry, intptr_signature, false)
781
782
class java_lang_Module {
783
private:
784
static int _loader_offset;
785
static int _name_offset;
786
static int _module_entry_offset;
787
788
static void compute_offsets();
789
790
public:
791
static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
792
793
// Allocation
794
static Handle create(Handle loader, Handle module_name, TRAPS);
795
796
// Testers
797
static bool is_instance(oop obj);
798
799
// Accessors
800
static oop loader(oop module);
801
static void set_loader(oop module, oop value);
802
803
static oop name(oop module);
804
static void set_name(oop module, oop value);
805
806
static ModuleEntry* module_entry(oop module);
807
static ModuleEntry* module_entry_raw(oop module);
808
static void set_module_entry(oop module, ModuleEntry* module_entry);
809
810
friend class JavaClasses;
811
};
812
813
// Interface to jdk.internal.reflect.ConstantPool objects
814
class reflect_ConstantPool {
815
private:
816
// Note that to reduce dependencies on the JDK we compute these
817
// offsets at run-time.
818
static int _oop_offset;
819
820
static void compute_offsets();
821
822
public:
823
static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
824
825
// Allocation
826
static Handle create(TRAPS);
827
828
// Accessors
829
static void set_cp(oop reflect, ConstantPool* value);
830
static int oop_offset() { CHECK_INIT(_oop_offset); }
831
832
static ConstantPool* get_cp(oop reflect);
833
834
// Debugging
835
friend class JavaClasses;
836
};
837
838
// Interface to jdk.internal.reflect.UnsafeStaticFieldAccessorImpl objects
839
class reflect_UnsafeStaticFieldAccessorImpl {
840
private:
841
static int _base_offset;
842
static void compute_offsets();
843
844
public:
845
static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
846
847
static int base_offset() { CHECK_INIT(_base_offset); }
848
849
// Debugging
850
friend class JavaClasses;
851
};
852
853
// Interface to java.lang primitive type boxing objects:
854
// - java.lang.Boolean
855
// - java.lang.Character
856
// - java.lang.Float
857
// - java.lang.Double
858
// - java.lang.Byte
859
// - java.lang.Short
860
// - java.lang.Integer
861
// - java.lang.Long
862
863
// This could be separated out into 8 individual classes.
864
865
class java_lang_boxing_object: AllStatic {
866
private:
867
static int _value_offset;
868
static int _long_value_offset;
869
870
static void compute_offsets();
871
static oop initialize_and_allocate(BasicType type, TRAPS);
872
public:
873
// Allocation. Returns a boxed value, or NULL for invalid type.
874
static oop create(BasicType type, jvalue* value, TRAPS);
875
// Accessors. Returns the basic type being boxed, or T_ILLEGAL for invalid oop.
876
static BasicType get_value(oop box, jvalue* value);
877
static BasicType set_value(oop box, jvalue* value);
878
static BasicType basic_type(oop box);
879
static bool is_instance(oop box) { return basic_type(box) != T_ILLEGAL; }
880
static bool is_instance(oop box, BasicType type) { return basic_type(box) == type; }
881
static void print(oop box, outputStream* st) { jvalue value; print(get_value(box, &value), &value, st); }
882
static void print(BasicType type, jvalue* value, outputStream* st);
883
884
static int value_offset(BasicType type) {
885
return is_double_word_type(type) ? _long_value_offset : _value_offset;
886
}
887
888
static void serialize_offsets(SerializeClosure* f);
889
890
// Debugging
891
friend class JavaClasses;
892
};
893
894
895
896
// Interface to java.lang.ref.Reference objects
897
898
class java_lang_ref_Reference: AllStatic {
899
static int _referent_offset;
900
static int _queue_offset;
901
static int _next_offset;
902
static int _discovered_offset;
903
904
static bool _offsets_initialized;
905
906
public:
907
// Accessors
908
static inline oop weak_referent_no_keepalive(oop ref);
909
static inline oop phantom_referent_no_keepalive(oop ref);
910
static inline oop unknown_referent_no_keepalive(oop ref);
911
static inline void clear_referent(oop ref);
912
static inline HeapWord* referent_addr_raw(oop ref);
913
static inline oop next(oop ref);
914
static inline void set_next(oop ref, oop value);
915
static inline void set_next_raw(oop ref, oop value);
916
static inline HeapWord* next_addr_raw(oop ref);
917
static inline oop discovered(oop ref);
918
static inline void set_discovered(oop ref, oop value);
919
static inline void set_discovered_raw(oop ref, oop value);
920
static inline HeapWord* discovered_addr_raw(oop ref);
921
static bool is_referent_field(oop obj, ptrdiff_t offset);
922
static inline bool is_final(oop ref);
923
static inline bool is_phantom(oop ref);
924
925
static int referent_offset() { CHECK_INIT(_referent_offset); }
926
static int queue_offset() { CHECK_INIT(_queue_offset); }
927
static int next_offset() { CHECK_INIT(_next_offset); }
928
static int discovered_offset() { CHECK_INIT(_discovered_offset); }
929
930
static void compute_offsets();
931
static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
932
};
933
934
935
// Interface to java.lang.ref.SoftReference objects
936
937
class java_lang_ref_SoftReference: public java_lang_ref_Reference {
938
static int _timestamp_offset;
939
static int _static_clock_offset;
940
941
public:
942
// Accessors
943
static jlong timestamp(oop ref);
944
945
// Accessors for statics
946
static jlong clock();
947
static void set_clock(jlong value);
948
949
static void compute_offsets();
950
static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
951
};
952
953
// Interface to java.lang.invoke.MethodHandle objects
954
955
class java_lang_invoke_MethodHandle: AllStatic {
956
friend class JavaClasses;
957
958
private:
959
static int _type_offset; // the MethodType of this MH
960
static int _form_offset; // the LambdaForm of this MH
961
962
static void compute_offsets();
963
964
public:
965
static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
966
967
// Accessors
968
static oop type(oop mh);
969
static void set_type(oop mh, oop mtype);
970
971
static oop form(oop mh);
972
static void set_form(oop mh, oop lform);
973
974
// Testers
975
static bool is_subclass(Klass* klass) {
976
return klass->is_subclass_of(vmClasses::MethodHandle_klass());
977
}
978
static bool is_instance(oop obj);
979
980
// Accessors for code generation:
981
static int type_offset() { CHECK_INIT(_type_offset); }
982
static int form_offset() { CHECK_INIT(_form_offset); }
983
};
984
985
// Interface to java.lang.invoke.DirectMethodHandle objects
986
987
class java_lang_invoke_DirectMethodHandle: AllStatic {
988
friend class JavaClasses;
989
990
private:
991
static int _member_offset; // the MemberName of this DMH
992
993
static void compute_offsets();
994
995
public:
996
static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
997
998
// Accessors
999
static oop member(oop mh);
1000
1001
// Testers
1002
static bool is_subclass(Klass* klass) {
1003
return klass->is_subclass_of(vmClasses::DirectMethodHandle_klass());
1004
}
1005
static bool is_instance(oop obj);
1006
1007
// Accessors for code generation:
1008
static int member_offset() { CHECK_INIT(_member_offset); }
1009
};
1010
1011
// Interface to java.lang.invoke.LambdaForm objects
1012
// (These are a private interface for managing adapter code generation.)
1013
1014
class java_lang_invoke_LambdaForm: AllStatic {
1015
friend class JavaClasses;
1016
1017
private:
1018
static int _vmentry_offset; // type is MemberName
1019
1020
static void compute_offsets();
1021
1022
public:
1023
static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1024
1025
// Accessors
1026
static oop vmentry(oop lform);
1027
1028
// Testers
1029
static bool is_subclass(Klass* klass) {
1030
return vmClasses::LambdaForm_klass() != NULL &&
1031
klass->is_subclass_of(vmClasses::LambdaForm_klass());
1032
}
1033
static bool is_instance(oop obj);
1034
1035
// Accessors for code generation:
1036
static int vmentry_offset() { CHECK_INIT(_vmentry_offset); }
1037
};
1038
1039
// Interface to java.lang.invoke.NativeEntryPoint objects
1040
// (These are a private interface for managing adapter code generation.)
1041
1042
class jdk_internal_invoke_NativeEntryPoint: AllStatic {
1043
friend class JavaClasses;
1044
1045
private:
1046
static int _shadow_space_offset;
1047
static int _argMoves_offset;
1048
static int _returnMoves_offset;
1049
static int _need_transition_offset;
1050
static int _method_type_offset;
1051
static int _name_offset;
1052
1053
static void compute_offsets();
1054
1055
public:
1056
static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1057
1058
// Accessors
1059
static jint shadow_space(oop entry);
1060
static oop argMoves(oop entry);
1061
static oop returnMoves(oop entry);
1062
static jboolean need_transition(oop entry);
1063
static oop method_type(oop entry);
1064
static oop name(oop entry);
1065
1066
// Testers
1067
static bool is_subclass(Klass* klass) {
1068
return vmClasses::NativeEntryPoint_klass() != NULL &&
1069
klass->is_subclass_of(vmClasses::NativeEntryPoint_klass());
1070
}
1071
static bool is_instance(oop obj);
1072
1073
// Accessors for code generation:
1074
static int shadow_space_offset_in_bytes() { return _shadow_space_offset; }
1075
static int argMoves_offset_in_bytes() { return _argMoves_offset; }
1076
static int returnMoves_offset_in_bytes() { return _returnMoves_offset; }
1077
static int need_transition_offset_in_bytes() { return _need_transition_offset; }
1078
static int method_type_offset_in_bytes() { return _method_type_offset; }
1079
static int name_offset_in_bytes() { return _name_offset; }
1080
};
1081
1082
// Interface to java.lang.invoke.MemberName objects
1083
// (These are a private interface for Java code to query the class hierarchy.)
1084
1085
#define RESOLVEDMETHOD_INJECTED_FIELDS(macro) \
1086
macro(java_lang_invoke_ResolvedMethodName, vmholder, object_signature, false) \
1087
macro(java_lang_invoke_ResolvedMethodName, vmtarget, intptr_signature, false)
1088
1089
class java_lang_invoke_ResolvedMethodName : AllStatic {
1090
friend class JavaClasses;
1091
1092
static int _vmtarget_offset;
1093
static int _vmholder_offset;
1094
1095
static void compute_offsets();
1096
public:
1097
static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1098
1099
static int vmtarget_offset() { CHECK_INIT(_vmtarget_offset); }
1100
1101
static Method* vmtarget(oop resolved_method);
1102
static void set_vmtarget(oop resolved_method, Method* method);
1103
1104
static void set_vmholder(oop resolved_method, oop holder);
1105
1106
// find or create resolved member name
1107
static oop find_resolved_method(const methodHandle& m, TRAPS);
1108
1109
static bool is_instance(oop resolved_method);
1110
};
1111
1112
1113
#define MEMBERNAME_INJECTED_FIELDS(macro) \
1114
macro(java_lang_invoke_MemberName, vmindex, intptr_signature, false)
1115
1116
1117
class java_lang_invoke_MemberName: AllStatic {
1118
friend class JavaClasses;
1119
1120
private:
1121
// From java.lang.invoke.MemberName:
1122
// private Class<?> clazz; // class in which the method is defined
1123
// private String name; // may be null if not yet materialized
1124
// private Object type; // may be null if not yet materialized
1125
// private int flags; // modifier bits; see reflect.Modifier
1126
// private ResolvedMethodName method; // holds VM-specific target value
1127
// private intptr_t vmindex; // member index within class or interface
1128
static int _clazz_offset;
1129
static int _name_offset;
1130
static int _type_offset;
1131
static int _flags_offset;
1132
static int _method_offset;
1133
static int _vmindex_offset;
1134
1135
static void compute_offsets();
1136
1137
public:
1138
static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1139
// Accessors
1140
static oop clazz(oop mname);
1141
static void set_clazz(oop mname, oop clazz);
1142
1143
static oop type(oop mname);
1144
static void set_type(oop mname, oop type);
1145
1146
static oop name(oop mname);
1147
static void set_name(oop mname, oop name);
1148
1149
static int flags(oop mname);
1150
static void set_flags(oop mname, int flags);
1151
1152
// Link through ResolvedMethodName field to get Method*
1153
static Method* vmtarget(oop mname);
1154
static void set_method(oop mname, oop method);
1155
1156
static intptr_t vmindex(oop mname);
1157
static void set_vmindex(oop mname, intptr_t index);
1158
1159
// Testers
1160
static bool is_subclass(Klass* klass) {
1161
return klass->is_subclass_of(vmClasses::MemberName_klass());
1162
}
1163
static bool is_instance(oop obj);
1164
1165
static bool is_method(oop obj);
1166
1167
// Relevant integer codes (keep these in synch. with MethodHandleNatives.Constants):
1168
enum {
1169
MN_IS_METHOD = 0x00010000, // method (not constructor)
1170
MN_IS_CONSTRUCTOR = 0x00020000, // constructor
1171
MN_IS_FIELD = 0x00040000, // field
1172
MN_IS_TYPE = 0x00080000, // nested type
1173
MN_CALLER_SENSITIVE = 0x00100000, // @CallerSensitive annotation detected
1174
MN_TRUSTED_FINAL = 0x00200000, // trusted final field
1175
MN_REFERENCE_KIND_SHIFT = 24, // refKind
1176
MN_REFERENCE_KIND_MASK = 0x0F000000 >> MN_REFERENCE_KIND_SHIFT,
1177
// The SEARCH_* bits are not for MN.flags but for the matchFlags argument of MHN.getMembers:
1178
MN_SEARCH_SUPERCLASSES = 0x00100000, // walk super classes
1179
MN_SEARCH_INTERFACES = 0x00200000, // walk implemented interfaces
1180
MN_NESTMATE_CLASS = 0x00000001,
1181
MN_HIDDEN_CLASS = 0x00000002,
1182
MN_STRONG_LOADER_LINK = 0x00000004,
1183
MN_ACCESS_VM_ANNOTATIONS = 0x00000008,
1184
// Lookup modes
1185
MN_MODULE_MODE = 0x00000010,
1186
MN_UNCONDITIONAL_MODE = 0x00000020,
1187
MN_TRUSTED_MODE = -1
1188
};
1189
1190
// Accessors for code generation:
1191
static int clazz_offset() { CHECK_INIT(_clazz_offset); }
1192
static int type_offset() { CHECK_INIT(_type_offset); }
1193
static int flags_offset() { CHECK_INIT(_flags_offset); }
1194
static int method_offset() { CHECK_INIT(_method_offset); }
1195
static int vmindex_offset() { CHECK_INIT(_vmindex_offset); }
1196
};
1197
1198
1199
// Interface to java.lang.invoke.MethodType objects
1200
1201
class java_lang_invoke_MethodType: AllStatic {
1202
friend class JavaClasses;
1203
1204
private:
1205
static int _rtype_offset;
1206
static int _ptypes_offset;
1207
1208
static void compute_offsets();
1209
1210
public:
1211
static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1212
// Accessors
1213
static oop rtype(oop mt);
1214
static objArrayOop ptypes(oop mt);
1215
1216
static oop ptype(oop mt, int index);
1217
static int ptype_count(oop mt);
1218
1219
static int ptype_slot_count(oop mt); // extra counts for long/double
1220
static int rtype_slot_count(oop mt); // extra counts for long/double
1221
1222
static Symbol* as_signature(oop mt, bool intern_if_not_found);
1223
static void print_signature(oop mt, outputStream* st);
1224
1225
static bool is_instance(oop obj);
1226
1227
static bool equals(oop mt1, oop mt2);
1228
1229
// Accessors for code generation:
1230
static int rtype_offset() { CHECK_INIT(_rtype_offset); }
1231
static int ptypes_offset() { CHECK_INIT(_ptypes_offset); }
1232
};
1233
1234
1235
// Interface to java.lang.invoke.CallSite objects
1236
1237
class java_lang_invoke_CallSite: AllStatic {
1238
friend class JavaClasses;
1239
1240
private:
1241
static int _target_offset;
1242
static int _context_offset;
1243
1244
static void compute_offsets();
1245
1246
public:
1247
static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1248
// Accessors
1249
static oop target( oop site);
1250
static void set_target( oop site, oop target);
1251
static void set_target_volatile( oop site, oop target);
1252
1253
static oop context_no_keepalive(oop site);
1254
1255
// Testers
1256
static bool is_subclass(Klass* klass) {
1257
return klass->is_subclass_of(vmClasses::CallSite_klass());
1258
}
1259
static bool is_instance(oop obj);
1260
1261
// Accessors for code generation:
1262
static int target_offset() { CHECK_INIT(_target_offset); }
1263
static int context_offset() { CHECK_INIT(_context_offset); }
1264
};
1265
1266
// Interface to java.lang.invoke.ConstantCallSite objects
1267
1268
class java_lang_invoke_ConstantCallSite: AllStatic {
1269
friend class JavaClasses;
1270
1271
private:
1272
static int _is_frozen_offset;
1273
1274
static void compute_offsets();
1275
1276
public:
1277
static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1278
// Accessors
1279
static jboolean is_frozen(oop site);
1280
1281
// Testers
1282
static bool is_subclass(Klass* klass) {
1283
return klass->is_subclass_of(vmClasses::ConstantCallSite_klass());
1284
}
1285
static bool is_instance(oop obj);
1286
};
1287
1288
// Interface to java.lang.invoke.MethodHandleNatives$CallSiteContext objects
1289
1290
#define CALLSITECONTEXT_INJECTED_FIELDS(macro) \
1291
macro(java_lang_invoke_MethodHandleNatives_CallSiteContext, vmdependencies, intptr_signature, false) \
1292
macro(java_lang_invoke_MethodHandleNatives_CallSiteContext, last_cleanup, long_signature, false)
1293
1294
class DependencyContext;
1295
1296
class java_lang_invoke_MethodHandleNatives_CallSiteContext : AllStatic {
1297
friend class JavaClasses;
1298
1299
private:
1300
static int _vmdependencies_offset;
1301
static int _last_cleanup_offset;
1302
1303
static void compute_offsets();
1304
1305
public:
1306
static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1307
// Accessors
1308
static DependencyContext vmdependencies(oop context);
1309
1310
// Testers
1311
static bool is_subclass(Klass* klass) {
1312
return klass->is_subclass_of(vmClasses::Context_klass());
1313
}
1314
static bool is_instance(oop obj);
1315
};
1316
1317
// Interface to java.security.AccessControlContext objects
1318
1319
class java_security_AccessControlContext: AllStatic {
1320
private:
1321
// Note that for this class the layout changed between JDK1.2 and JDK1.3,
1322
// so we compute the offsets at startup rather than hard-wiring them.
1323
static int _context_offset;
1324
static int _privilegedContext_offset;
1325
static int _isPrivileged_offset;
1326
static int _isAuthorized_offset;
1327
1328
static void compute_offsets();
1329
public:
1330
static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1331
static oop create(objArrayHandle context, bool isPrivileged, Handle privileged_context, TRAPS);
1332
1333
// Debugging/initialization
1334
friend class JavaClasses;
1335
};
1336
1337
1338
// Interface to java.lang.ClassLoader objects
1339
1340
#define CLASSLOADER_INJECTED_FIELDS(macro) \
1341
macro(java_lang_ClassLoader, loader_data, intptr_signature, false)
1342
1343
class java_lang_ClassLoader : AllStatic {
1344
private:
1345
static int _loader_data_offset;
1346
static int _parent_offset;
1347
static int _parallelCapable_offset;
1348
static int _name_offset;
1349
static int _nameAndId_offset;
1350
static int _unnamedModule_offset;
1351
1352
static void compute_offsets();
1353
1354
public:
1355
static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1356
1357
static ClassLoaderData* loader_data_acquire(oop loader);
1358
static ClassLoaderData* loader_data_raw(oop loader);
1359
static void release_set_loader_data(oop loader, ClassLoaderData* new_data);
1360
1361
static oop parent(oop loader);
1362
static oop name(oop loader);
1363
static oop nameAndId(oop loader);
1364
static bool isAncestor(oop loader, oop cl);
1365
1366
// Support for parallelCapable field
1367
static bool parallelCapable(oop the_class_mirror);
1368
1369
static bool is_trusted_loader(oop loader);
1370
1371
// Return true if this is one of the class loaders associated with
1372
// the generated bytecodes for reflection.
1373
static bool is_reflection_class_loader(oop loader);
1374
1375
// Fix for 4474172
1376
static oop non_reflection_class_loader(oop loader);
1377
1378
// Testers
1379
static bool is_subclass(Klass* klass) {
1380
return klass->is_subclass_of(vmClasses::ClassLoader_klass());
1381
}
1382
static bool is_instance(oop obj);
1383
1384
static oop unnamedModule(oop loader);
1385
1386
// Debugging
1387
friend class JavaClasses;
1388
};
1389
1390
1391
// Interface to java.lang.System objects
1392
1393
class java_lang_System : AllStatic {
1394
private:
1395
static int _static_in_offset;
1396
static int _static_out_offset;
1397
static int _static_err_offset;
1398
static int _static_security_offset;
1399
static int _static_allow_security_offset;
1400
static int _static_never_offset;
1401
1402
public:
1403
static int in_offset() { CHECK_INIT(_static_in_offset); }
1404
static int out_offset() { CHECK_INIT(_static_out_offset); }
1405
static int err_offset() { CHECK_INIT(_static_err_offset); }
1406
static bool allow_security_manager();
1407
static bool has_security_manager();
1408
1409
static void compute_offsets();
1410
static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1411
1412
// Debugging
1413
friend class JavaClasses;
1414
};
1415
1416
1417
// Interface to java.lang.StackTraceElement objects
1418
1419
class java_lang_StackTraceElement: AllStatic {
1420
private:
1421
static int _declaringClassObject_offset;
1422
static int _classLoaderName_offset;
1423
static int _moduleName_offset;
1424
static int _moduleVersion_offset;
1425
static int _declaringClass_offset;
1426
static int _methodName_offset;
1427
static int _fileName_offset;
1428
static int _lineNumber_offset;
1429
1430
// Setters
1431
static void set_classLoaderName(oop element, oop value);
1432
static void set_moduleName(oop element, oop value);
1433
static void set_moduleVersion(oop element, oop value);
1434
static void set_declaringClass(oop element, oop value);
1435
static void set_methodName(oop element, oop value);
1436
static void set_fileName(oop element, oop value);
1437
static void set_lineNumber(oop element, int value);
1438
static void set_declaringClassObject(oop element, oop value);
1439
1440
static void decode_file_and_line(Handle java_mirror, InstanceKlass* holder, int version,
1441
const methodHandle& method, int bci,
1442
Symbol*& source, oop& source_file, int& line_number, TRAPS);
1443
1444
public:
1445
// Create an instance of StackTraceElement
1446
static oop create(const methodHandle& method, int bci, TRAPS);
1447
1448
static void fill_in(Handle element, InstanceKlass* holder, const methodHandle& method,
1449
int version, int bci, Symbol* name, TRAPS);
1450
1451
static void compute_offsets();
1452
static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1453
1454
#if INCLUDE_JVMCI
1455
static void decode(const methodHandle& method, int bci, Symbol*& fileName, int& lineNumber, TRAPS);
1456
#endif
1457
1458
// Debugging
1459
friend class JavaClasses;
1460
};
1461
1462
1463
class Backtrace: AllStatic {
1464
public:
1465
// Helper backtrace functions to store bci|version together.
1466
static int merge_bci_and_version(int bci, int version);
1467
static int merge_mid_and_cpref(int mid, int cpref);
1468
static int bci_at(unsigned int merged);
1469
static int version_at(unsigned int merged);
1470
static int mid_at(unsigned int merged);
1471
static int cpref_at(unsigned int merged);
1472
static int get_line_number(Method* method, int bci);
1473
static Symbol* get_source_file_name(InstanceKlass* holder, int version);
1474
1475
// Debugging
1476
friend class JavaClasses;
1477
};
1478
1479
// Interface to java.lang.StackFrameInfo objects
1480
1481
#define STACKFRAMEINFO_INJECTED_FIELDS(macro) \
1482
macro(java_lang_StackFrameInfo, version, short_signature, false)
1483
1484
class java_lang_StackFrameInfo: AllStatic {
1485
private:
1486
static int _memberName_offset;
1487
static int _bci_offset;
1488
static int _version_offset;
1489
1490
static Method* get_method(Handle stackFrame, InstanceKlass* holder, TRAPS);
1491
1492
public:
1493
// Setters
1494
static void set_method_and_bci(Handle stackFrame, const methodHandle& method, int bci, TRAPS);
1495
static void set_bci(oop info, int value);
1496
1497
static void set_version(oop info, short value);
1498
1499
static void compute_offsets();
1500
static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1501
1502
static void to_stack_trace_element(Handle stackFrame, Handle stack_trace_element, TRAPS);
1503
1504
// Debugging
1505
friend class JavaClasses;
1506
};
1507
1508
class java_lang_LiveStackFrameInfo: AllStatic {
1509
private:
1510
static int _monitors_offset;
1511
static int _locals_offset;
1512
static int _operands_offset;
1513
static int _mode_offset;
1514
1515
public:
1516
static void set_monitors(oop info, oop value);
1517
static void set_locals(oop info, oop value);
1518
static void set_operands(oop info, oop value);
1519
static void set_mode(oop info, int value);
1520
1521
static void compute_offsets();
1522
static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1523
1524
// Debugging
1525
friend class JavaClasses;
1526
};
1527
1528
// Interface to java.lang.reflect.RecordComponent objects
1529
1530
class java_lang_reflect_RecordComponent: AllStatic {
1531
private:
1532
static int _clazz_offset;
1533
static int _name_offset;
1534
static int _type_offset;
1535
static int _accessor_offset;
1536
static int _signature_offset;
1537
static int _annotations_offset;
1538
static int _typeAnnotations_offset;
1539
1540
// Setters
1541
static void set_clazz(oop element, oop value);
1542
static void set_name(oop element, oop value);
1543
static void set_type(oop element, oop value);
1544
static void set_accessor(oop element, oop value);
1545
static void set_signature(oop element, oop value);
1546
static void set_annotations(oop element, oop value);
1547
static void set_typeAnnotations(oop element, oop value);
1548
1549
public:
1550
// Create an instance of RecordComponent
1551
static oop create(InstanceKlass* holder, RecordComponent* component, TRAPS);
1552
1553
static void compute_offsets();
1554
static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1555
1556
// Debugging
1557
friend class JavaClasses;
1558
};
1559
1560
1561
// Interface to java.lang.AssertionStatusDirectives objects
1562
1563
class java_lang_AssertionStatusDirectives: AllStatic {
1564
private:
1565
static int _classes_offset;
1566
static int _classEnabled_offset;
1567
static int _packages_offset;
1568
static int _packageEnabled_offset;
1569
static int _deflt_offset;
1570
1571
public:
1572
// Setters
1573
static void set_classes(oop obj, oop val);
1574
static void set_classEnabled(oop obj, oop val);
1575
static void set_packages(oop obj, oop val);
1576
static void set_packageEnabled(oop obj, oop val);
1577
static void set_deflt(oop obj, bool val);
1578
1579
static void compute_offsets();
1580
static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1581
1582
// Debugging
1583
friend class JavaClasses;
1584
};
1585
1586
1587
class java_nio_Buffer: AllStatic {
1588
private:
1589
static int _limit_offset;
1590
1591
public:
1592
static int limit_offset() { CHECK_INIT(_limit_offset); }
1593
static void compute_offsets();
1594
static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1595
};
1596
1597
class java_util_concurrent_locks_AbstractOwnableSynchronizer : AllStatic {
1598
private:
1599
static int _owner_offset;
1600
public:
1601
static void compute_offsets();
1602
static oop get_owner_threadObj(oop obj);
1603
static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1604
};
1605
1606
// Interface to jdk.internal.misc.UnsafeConsants
1607
1608
class jdk_internal_misc_UnsafeConstants : AllStatic {
1609
public:
1610
static void set_unsafe_constants();
1611
static void compute_offsets() { }
1612
static void serialize_offsets(SerializeClosure* f) { }
1613
};
1614
1615
// Interface to jdk.internal.vm.vector.VectorSupport.VectorPayload objects
1616
1617
class vector_VectorPayload : AllStatic {
1618
private:
1619
static int _payload_offset;
1620
public:
1621
static void set_payload(oop o, oop val);
1622
1623
static void compute_offsets();
1624
static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1625
1626
// Testers
1627
static bool is_subclass(Klass* klass) {
1628
return klass->is_subclass_of(vmClasses::vector_VectorPayload_klass());
1629
}
1630
static bool is_instance(oop obj);
1631
};
1632
1633
class java_lang_Integer : AllStatic {
1634
public:
1635
static jint value(oop obj);
1636
};
1637
1638
class java_lang_Long : AllStatic {
1639
public:
1640
static jlong value(oop obj);
1641
};
1642
1643
class java_lang_Character : AllStatic {
1644
public:
1645
static jchar value(oop obj);
1646
};
1647
1648
class java_lang_Short : AllStatic {
1649
public:
1650
static jshort value(oop obj);
1651
};
1652
1653
class java_lang_Byte : AllStatic {
1654
public:
1655
static jbyte value(oop obj);
1656
};
1657
1658
class java_lang_Boolean : AllStatic {
1659
private:
1660
static int _static_TRUE_offset;
1661
static int _static_FALSE_offset;
1662
public:
1663
static Symbol* symbol();
1664
static void compute_offsets(InstanceKlass* k);
1665
static oop get_TRUE(InstanceKlass *k);
1666
static oop get_FALSE(InstanceKlass *k);
1667
static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1668
static jboolean value(oop obj);
1669
};
1670
1671
class java_lang_Integer_IntegerCache : AllStatic {
1672
private:
1673
static int _static_cache_offset;
1674
public:
1675
static Symbol* symbol();
1676
static void compute_offsets(InstanceKlass* k);
1677
static objArrayOop cache(InstanceKlass *k);
1678
static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1679
};
1680
1681
class java_lang_Long_LongCache : AllStatic {
1682
private:
1683
static int _static_cache_offset;
1684
public:
1685
static Symbol* symbol();
1686
static void compute_offsets(InstanceKlass* k);
1687
static objArrayOop cache(InstanceKlass *k);
1688
static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1689
};
1690
1691
class java_lang_Character_CharacterCache : AllStatic {
1692
private:
1693
static int _static_cache_offset;
1694
public:
1695
static Symbol* symbol();
1696
static void compute_offsets(InstanceKlass* k);
1697
static objArrayOop cache(InstanceKlass *k);
1698
static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1699
};
1700
1701
class java_lang_Short_ShortCache : AllStatic {
1702
private:
1703
static int _static_cache_offset;
1704
public:
1705
static Symbol* symbol();
1706
static void compute_offsets(InstanceKlass* k);
1707
static objArrayOop cache(InstanceKlass *k);
1708
static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1709
};
1710
1711
class java_lang_Byte_ByteCache : AllStatic {
1712
private:
1713
static int _static_cache_offset;
1714
public:
1715
static Symbol* symbol();
1716
static void compute_offsets(InstanceKlass* k);
1717
static objArrayOop cache(InstanceKlass *k);
1718
static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1719
};
1720
1721
1722
// Interface to java.lang.InternalError objects
1723
1724
#define INTERNALERROR_INJECTED_FIELDS(macro) \
1725
macro(java_lang_InternalError, during_unsafe_access, bool_signature, false)
1726
1727
class java_lang_InternalError : AllStatic {
1728
private:
1729
static int _during_unsafe_access_offset;
1730
public:
1731
static jboolean during_unsafe_access(oop internal_error);
1732
static void set_during_unsafe_access(oop internal_error);
1733
static void compute_offsets();
1734
static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1735
};
1736
1737
// Use to declare fields that need to be injected into Java classes
1738
// for the JVM to use. The name_index and signature_index are
1739
// declared in vmSymbols. The may_be_java flag is used to declare
1740
// fields that might already exist in Java but should be injected if
1741
// they don't. Otherwise the field is unconditionally injected and
1742
// the JVM uses the injected one. This is to ensure that name
1743
// collisions don't occur. In general may_be_java should be false
1744
// unless there's a good reason.
1745
1746
class InjectedField {
1747
public:
1748
const vmClassID klass_id;
1749
const vmSymbolID name_index;
1750
const vmSymbolID signature_index;
1751
const bool may_be_java;
1752
1753
1754
Klass* klass() const { return vmClasses::klass_at(klass_id); }
1755
Symbol* name() const { return lookup_symbol(name_index); }
1756
Symbol* signature() const { return lookup_symbol(signature_index); }
1757
1758
int compute_offset();
1759
1760
// Find the Symbol for this index
1761
static Symbol* lookup_symbol(vmSymbolID symbol_index) {
1762
return Symbol::vm_symbol_at(symbol_index);
1763
}
1764
};
1765
1766
#define DECLARE_INJECTED_FIELD_ENUM(klass, name, signature, may_be_java) \
1767
klass##_##name##_enum,
1768
1769
#define ALL_INJECTED_FIELDS(macro) \
1770
STRING_INJECTED_FIELDS(macro) \
1771
CLASS_INJECTED_FIELDS(macro) \
1772
CLASSLOADER_INJECTED_FIELDS(macro) \
1773
RESOLVEDMETHOD_INJECTED_FIELDS(macro) \
1774
MEMBERNAME_INJECTED_FIELDS(macro) \
1775
CALLSITECONTEXT_INJECTED_FIELDS(macro) \
1776
STACKFRAMEINFO_INJECTED_FIELDS(macro) \
1777
MODULE_INJECTED_FIELDS(macro) \
1778
INTERNALERROR_INJECTED_FIELDS(macro)
1779
1780
1781
// Interface to hard-coded offset checking
1782
1783
class JavaClasses : AllStatic {
1784
private:
1785
1786
static InjectedField _injected_fields[];
1787
1788
static bool check_offset(const char *klass_name, int offset, const char *field_name, const char* field_sig) PRODUCT_RETURN0;
1789
public:
1790
enum InjectedFieldID {
1791
ALL_INJECTED_FIELDS(DECLARE_INJECTED_FIELD_ENUM)
1792
MAX_enum
1793
};
1794
1795
static int compute_injected_offset(InjectedFieldID id);
1796
1797
static void compute_offsets();
1798
static void check_offsets() PRODUCT_RETURN;
1799
static void serialize_offsets(SerializeClosure* soc) NOT_CDS_RETURN;
1800
static InjectedField* get_injected(Symbol* class_name, int* field_count);
1801
static bool is_supported_for_archiving(oop obj) NOT_CDS_JAVA_HEAP_RETURN_(false);
1802
};
1803
1804
#undef DECLARE_INJECTED_FIELD_ENUM
1805
1806
#undef CHECK_INIT
1807
#endif // SHARE_CLASSFILE_JAVACLASSES_HPP
1808
1809