src/share/vm/classfile/javaClasses.hpp

Wed, 09 Jul 2014 22:37:48 -0400

author
coleenp
date
Wed, 09 Jul 2014 22:37:48 -0400
changeset 9970
f614bd5c9561
parent 9314
46ab61b0758b
child 10015
eb7ce841ccec
permissions
-rw-r--r--

8048933: -XX:+TraceExceptions output should include the message
Summary: Add the exception detail message to the tracing output
Reviewed-by: minqi, dholmes

duke@435 1 /*
kbarrett@9099 2 * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #ifndef SHARE_VM_CLASSFILE_JAVACLASSES_HPP
stefank@2314 26 #define SHARE_VM_CLASSFILE_JAVACLASSES_HPP
stefank@2314 27
stefank@2314 28 #include "classfile/systemDictionary.hpp"
stefank@2314 29 #include "jvmtifiles/jvmti.h"
stefank@2314 30 #include "oops/oop.hpp"
stefank@2314 31 #include "runtime/os.hpp"
stefank@2314 32 #include "utilities/utf8.hpp"
stefank@2314 33
duke@435 34 // Interface for manipulating the basic Java classes.
duke@435 35 //
duke@435 36 // All dependencies on layout of actual Java classes should be kept here.
duke@435 37 // If the layout of any of the classes above changes the offsets must be adjusted.
duke@435 38 //
duke@435 39 // For most classes we hardwire the offsets for performance reasons. In certain
duke@435 40 // cases (e.g. java.security.AccessControlContext) we compute the offsets at
duke@435 41 // startup since the layout here differs between JDK1.2 and JDK1.3.
duke@435 42 //
duke@435 43 // Note that fields (static and non-static) are arranged with oops before non-oops
duke@435 44 // on a per class basis. The offsets below have to reflect this ordering.
duke@435 45 //
duke@435 46 // When editing the layouts please update the check_offset verification code
duke@435 47 // correspondingly. The names in the enums must be identical to the actual field
duke@435 48 // names in order for the verification code to work.
duke@435 49
duke@435 50
duke@435 51 // Interface to java.lang.String objects
duke@435 52
duke@435 53 class java_lang_String : AllStatic {
duke@435 54 private:
duke@435 55 static int value_offset;
duke@435 56 static int offset_offset;
duke@435 57 static int count_offset;
duke@435 58 static int hash_offset;
duke@435 59
kvn@3760 60 static bool initialized;
kvn@3760 61
coleenp@4037 62 static Handle basic_create(int length, TRAPS);
duke@435 63
kvn@3760 64 static void set_offset(oop string, int offset) {
kvn@3760 65 assert(initialized, "Must be initialized");
kvn@3760 66 if (offset_offset > 0) {
kvn@3760 67 string->int_field_put(offset_offset, offset);
kvn@3760 68 }
kvn@3760 69 }
kvn@3760 70 static void set_count( oop string, int count) {
kvn@3760 71 assert(initialized, "Must be initialized");
kvn@3760 72 if (count_offset > 0) {
kvn@3760 73 string->int_field_put(count_offset, count);
kvn@3760 74 }
kvn@3760 75 }
duke@435 76
duke@435 77 public:
kvn@3760 78 static void compute_offsets();
kvn@3760 79
duke@435 80 // Instance creation
duke@435 81 static Handle create_from_unicode(jchar* unicode, int len, TRAPS);
duke@435 82 static oop create_oop_from_unicode(jchar* unicode, int len, TRAPS);
duke@435 83 static Handle create_from_str(const char* utf8_str, TRAPS);
duke@435 84 static oop create_oop_from_str(const char* utf8_str, TRAPS);
coleenp@2497 85 static Handle create_from_symbol(Symbol* symbol, TRAPS);
duke@435 86 static Handle create_from_platform_dependent_str(const char* str, TRAPS);
duke@435 87 static Handle char_converter(Handle java_string, jchar from_char, jchar to_char, TRAPS);
duke@435 88
kvn@3760 89 static bool has_offset_field() {
kvn@3760 90 assert(initialized, "Must be initialized");
kvn@3760 91 return (offset_offset > 0);
kvn@3760 92 }
kvn@3760 93
kvn@3760 94 static bool has_count_field() {
kvn@3760 95 assert(initialized, "Must be initialized");
kvn@3760 96 return (count_offset > 0);
kvn@3760 97 }
kvn@3760 98
kvn@3760 99 static bool has_hash_field() {
kvn@3760 100 assert(initialized, "Must be initialized");
kvn@3760 101 return (hash_offset > 0);
kvn@3760 102 }
kvn@3760 103
kvn@3760 104 static int value_offset_in_bytes() {
kvn@3760 105 assert(initialized && (value_offset > 0), "Must be initialized");
kvn@3760 106 return value_offset;
kvn@3760 107 }
kvn@3760 108 static int count_offset_in_bytes() {
kvn@3760 109 assert(initialized && (count_offset > 0), "Must be initialized");
kvn@3760 110 return count_offset;
kvn@3760 111 }
kvn@3760 112 static int offset_offset_in_bytes() {
kvn@3760 113 assert(initialized && (offset_offset > 0), "Must be initialized");
kvn@3760 114 return offset_offset;
kvn@3760 115 }
kvn@3760 116 static int hash_offset_in_bytes() {
kvn@3760 117 assert(initialized && (hash_offset > 0), "Must be initialized");
kvn@3760 118 return hash_offset;
kvn@3760 119 }
duke@435 120
pliden@6413 121 static void set_value(oop string, typeArrayOop buffer) {
pliden@6413 122 assert(initialized && (value_offset > 0), "Must be initialized");
pliden@6413 123 string->obj_field_put(value_offset, (oop)buffer);
pliden@6413 124 }
pliden@6413 125 static void set_hash(oop string, unsigned int hash) {
pliden@6413 126 assert(initialized && (hash_offset > 0), "Must be initialized");
pliden@6413 127 string->int_field_put(hash_offset, hash);
pliden@6413 128 }
pliden@6413 129
duke@435 130 // Accessors
duke@435 131 static typeArrayOop value(oop java_string) {
kvn@3760 132 assert(initialized && (value_offset > 0), "Must be initialized");
duke@435 133 assert(is_instance(java_string), "must be java_string");
duke@435 134 return (typeArrayOop) java_string->obj_field(value_offset);
duke@435 135 }
pliden@6413 136 static unsigned int hash(oop java_string) {
pliden@6413 137 assert(initialized && (hash_offset > 0), "Must be initialized");
pliden@6413 138 assert(is_instance(java_string), "must be java_string");
pliden@6413 139 return java_string->int_field(hash_offset);
pliden@6413 140 }
duke@435 141 static int offset(oop java_string) {
kvn@3760 142 assert(initialized, "Must be initialized");
duke@435 143 assert(is_instance(java_string), "must be java_string");
kvn@3760 144 if (offset_offset > 0) {
kvn@3760 145 return java_string->int_field(offset_offset);
kvn@3760 146 } else {
kvn@3760 147 return 0;
kvn@3760 148 }
duke@435 149 }
duke@435 150 static int length(oop java_string) {
kvn@3760 151 assert(initialized, "Must be initialized");
duke@435 152 assert(is_instance(java_string), "must be java_string");
kvn@3760 153 if (count_offset > 0) {
kvn@3760 154 return java_string->int_field(count_offset);
kvn@3760 155 } else {
kvn@3760 156 return ((typeArrayOop)java_string->obj_field(value_offset))->length();
kvn@3760 157 }
duke@435 158 }
duke@435 159 static int utf8_length(oop java_string);
duke@435 160
duke@435 161 // String converters
duke@435 162 static char* as_utf8_string(oop java_string);
sla@2331 163 static char* as_utf8_string(oop java_string, char* buf, int buflen);
duke@435 164 static char* as_utf8_string(oop java_string, int start, int len);
coleenp@457 165 static char* as_platform_dependent_str(Handle java_string, TRAPS);
hseigel@4987 166 static jchar* as_unicode_string(oop java_string, int& length, TRAPS);
minqi@4267 167 // produce an ascii string with all other values quoted using \u####
minqi@4267 168 static char* as_quoted_ascii(oop java_string);
duke@435 169
never@2700 170 // Compute the hash value for a java.lang.String object which would
coleenp@3865 171 // contain the characters passed in.
never@2700 172 //
coleenp@3865 173 // As the hash value used by the String object itself, in
coleenp@3865 174 // String.hashCode(). This value is normally calculated in Java code
coleenp@3865 175 // in the String.hashCode method(), but is precomputed for String
coleenp@3865 176 // objects in the shared archive file.
coleenp@3865 177 // hash P(31) from Kernighan & Ritchie
never@2700 178 //
brutisso@4335 179 // For this reason, THIS ALGORITHM MUST MATCH String.hashCode().
brutisso@4335 180 template <typename T> static unsigned int hash_code(T* s, int len) {
never@2700 181 unsigned int h = 0;
never@2700 182 while (len-- > 0) {
never@2700 183 h = 31*h + (unsigned int) *s;
never@2700 184 s++;
never@2700 185 }
never@2700 186 return h;
never@2700 187 }
brutisso@4335 188 static unsigned int hash_code(oop java_string);
coleenp@3865 189
coleenp@3865 190 // This is the string hash code used by the StringTable, which may be
brutisso@4335 191 // the same as String.hashCode or an alternate hash code.
never@2700 192 static unsigned int hash_string(oop java_string);
never@2700 193
duke@435 194 static bool equals(oop java_string, jchar* chars, int len);
dcubed@5743 195 static bool equals(oop str1, oop str2);
duke@435 196
duke@435 197 // Conversion between '.' and '/' formats
duke@435 198 static Handle externalize_classname(Handle java_string, TRAPS) { return char_converter(java_string, '/', '.', THREAD); }
duke@435 199 static Handle internalize_classname(Handle java_string, TRAPS) { return char_converter(java_string, '.', '/', THREAD); }
duke@435 200
duke@435 201 // Conversion
coleenp@2497 202 static Symbol* as_symbol(Handle java_string, TRAPS);
coleenp@2497 203 static Symbol* as_symbol_or_null(oop java_string);
duke@435 204
duke@435 205 // Testers
duke@435 206 static bool is_instance(oop obj) {
never@1577 207 return obj != NULL && obj->klass() == SystemDictionary::String_klass();
duke@435 208 }
duke@435 209
duke@435 210 // Debugging
stefank@6975 211 static void print(oop java_string, outputStream* st);
duke@435 212 friend class JavaClasses;
duke@435 213 };
duke@435 214
duke@435 215
duke@435 216 // Interface to java.lang.Class objects
duke@435 217
never@3137 218 #define CLASS_INJECTED_FIELDS(macro) \
coleenp@4037 219 macro(java_lang_Class, klass, intptr_signature, false) \
coleenp@4037 220 macro(java_lang_Class, array_klass, intptr_signature, false) \
never@3137 221 macro(java_lang_Class, oop_size, int_signature, false) \
coleenp@5176 222 macro(java_lang_Class, static_oop_field_count, int_signature, false) \
coleenp@5176 223 macro(java_lang_Class, protection_domain, object_signature, false) \
coleenp@5176 224 macro(java_lang_Class, init_lock, object_signature, false) \
coleenp@5176 225 macro(java_lang_Class, signers, object_signature, false)
never@3137 226
duke@435 227 class java_lang_Class : AllStatic {
never@3137 228 friend class VMStructs;
never@3137 229
duke@435 230 private:
duke@435 231 // The fake offsets are added by the class loader when java.lang.Class is loaded
duke@435 232
never@3137 233 static int _klass_offset;
never@3137 234 static int _array_klass_offset;
duke@435 235
never@3137 236 static int _oop_size_offset;
never@3137 237 static int _static_oop_field_count_offset;
duke@435 238
coleenp@5176 239 static int _protection_domain_offset;
coleenp@5176 240 static int _init_lock_offset;
coleenp@5176 241 static int _signers_offset;
coleenp@7129 242 static int _class_loader_offset;
coleenp@5176 243
duke@435 244 static bool offsets_computed;
duke@435 245 static int classRedefinedCount_offset;
coleenp@7129 246
coleenp@4037 247 static GrowableArray<Klass*>* _fixup_mirror_list;
duke@435 248
coleenp@5176 249 static void set_init_lock(oop java_class, oop init_lock);
hseigel@5372 250 static void set_protection_domain(oop java_class, oop protection_domain);
coleenp@7129 251 static void set_class_loader(oop java_class, oop class_loader);
coleenp@6626 252 static void initialize_mirror_fields(KlassHandle k, Handle mirror, Handle protection_domain, TRAPS);
duke@435 253 public:
never@3137 254 static void compute_offsets();
never@3137 255
duke@435 256 // Instance creation
coleenp@7129 257 static void create_mirror(KlassHandle k, Handle class_loader,
coleenp@7129 258 Handle protection_domain, TRAPS);
never@2658 259 static void fixup_mirror(KlassHandle k, TRAPS);
duke@435 260 static oop create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS);
duke@435 261 // Conversion
coleenp@4037 262 static Klass* as_Klass(oop java_class);
coleenp@4037 263 static void set_klass(oop java_class, Klass* klass);
coleenp@4037 264 static BasicType as_BasicType(oop java_class, Klass** reference_klass = NULL);
jrose@1145 265 static BasicType as_BasicType(oop java_class, KlassHandle* reference_klass) {
coleenp@4037 266 Klass* refk_oop = NULL;
jrose@1145 267 BasicType result = as_BasicType(java_class, &refk_oop);
jrose@1145 268 (*reference_klass) = KlassHandle(refk_oop);
jrose@1145 269 return result;
jrose@1145 270 }
coleenp@2497 271 static Symbol* as_signature(oop java_class, bool intern_if_not_found, TRAPS);
jrose@1100 272 static void print_signature(oop java_class, outputStream *st);
vkempik@8060 273 static const char* as_external_name(oop java_class);
duke@435 274 // Testing
jrose@567 275 static bool is_instance(oop obj) {
never@1577 276 return obj != NULL && obj->klass() == SystemDictionary::Class_klass();
jrose@567 277 }
duke@435 278 static bool is_primitive(oop java_class);
duke@435 279 static BasicType primitive_type(oop java_class);
duke@435 280 static oop primitive_mirror(BasicType t);
duke@435 281 // JVM_NewArray support
coleenp@4037 282 static Klass* array_klass(oop java_class);
coleenp@4037 283 static void set_array_klass(oop java_class, Klass* klass);
duke@435 284 // compiler support for class operations
never@3137 285 static int klass_offset_in_bytes() { return _klass_offset; }
never@3137 286 static int array_klass_offset_in_bytes() { return _array_klass_offset; }
duke@435 287 // Support for classRedefinedCount field
duke@435 288 static int classRedefinedCount(oop the_class_mirror);
duke@435 289 static void set_classRedefinedCount(oop the_class_mirror, int value);
never@2658 290
coleenp@5176 291 // Support for embedded per-class oops
coleenp@5176 292 static oop protection_domain(oop java_class);
coleenp@5176 293 static oop init_lock(oop java_class);
coleenp@5176 294 static objArrayOop signers(oop java_class);
coleenp@5176 295 static void set_signers(oop java_class, objArrayOop signers);
coleenp@5176 296
coleenp@7129 297 static oop class_loader(oop java_class);
coleenp@7129 298
never@2658 299 static int oop_size(oop java_class);
never@2658 300 static void set_oop_size(oop java_class, int size);
never@2658 301 static int static_oop_field_count(oop java_class);
never@2658 302 static void set_static_oop_field_count(oop java_class, int size);
never@2658 303
coleenp@4037 304 static GrowableArray<Klass*>* fixup_mirror_list() {
coleenp@4037 305 return _fixup_mirror_list;
coleenp@4037 306 }
coleenp@4037 307 static void set_fixup_mirror_list(GrowableArray<Klass*>* v) {
coleenp@4037 308 _fixup_mirror_list = v;
coleenp@4037 309 }
duke@435 310 // Debugging
duke@435 311 friend class JavaClasses;
coleenp@4037 312 friend class InstanceKlass; // verification code accesses offsets
duke@435 313 friend class ClassFileParser; // access to number_of_fake_fields
duke@435 314 };
duke@435 315
duke@435 316 // Interface to java.lang.Thread objects
duke@435 317
duke@435 318 class java_lang_Thread : AllStatic {
duke@435 319 private:
duke@435 320 // Note that for this class the layout changed between JDK1.2 and JDK1.3,
duke@435 321 // so we compute the offsets at startup rather than hard-wiring them.
duke@435 322 static int _name_offset;
duke@435 323 static int _group_offset;
duke@435 324 static int _contextClassLoader_offset;
duke@435 325 static int _inheritedAccessControlContext_offset;
duke@435 326 static int _priority_offset;
duke@435 327 static int _eetop_offset;
duke@435 328 static int _daemon_offset;
duke@435 329 static int _stillborn_offset;
duke@435 330 static int _stackSize_offset;
duke@435 331 static int _tid_offset;
duke@435 332 static int _thread_status_offset;
duke@435 333 static int _park_blocker_offset;
duke@435 334 static int _park_event_offset ;
duke@435 335
duke@435 336 static void compute_offsets();
duke@435 337
duke@435 338 public:
duke@435 339 // Instance creation
duke@435 340 static oop create();
duke@435 341 // Returns the JavaThread associated with the thread obj
duke@435 342 static JavaThread* thread(oop java_thread);
duke@435 343 // Set JavaThread for instance
duke@435 344 static void set_thread(oop java_thread, JavaThread* thread);
duke@435 345 // Name
shade@8288 346 static oop name(oop java_thread);
shade@8288 347 static void set_name(oop java_thread, oop name);
duke@435 348 // Priority
duke@435 349 static ThreadPriority priority(oop java_thread);
duke@435 350 static void set_priority(oop java_thread, ThreadPriority priority);
duke@435 351 // Thread group
duke@435 352 static oop threadGroup(oop java_thread);
duke@435 353 // Stillborn
duke@435 354 static bool is_stillborn(oop java_thread);
duke@435 355 static void set_stillborn(oop java_thread);
duke@435 356 // Alive (NOTE: this is not really a field, but provides the correct
duke@435 357 // definition without doing a Java call)
duke@435 358 static bool is_alive(oop java_thread);
duke@435 359 // Daemon
duke@435 360 static bool is_daemon(oop java_thread);
duke@435 361 static void set_daemon(oop java_thread);
duke@435 362 // Context ClassLoader
duke@435 363 static oop context_class_loader(oop java_thread);
duke@435 364 // Control context
duke@435 365 static oop inherited_access_control_context(oop java_thread);
duke@435 366 // Stack size hint
duke@435 367 static jlong stackSize(oop java_thread);
duke@435 368 // Thread ID
duke@435 369 static jlong thread_id(oop java_thread);
duke@435 370
duke@435 371 // Blocker object responsible for thread parking
duke@435 372 static oop park_blocker(oop java_thread);
duke@435 373
duke@435 374 // Pointer to type-stable park handler, encoded as jlong.
duke@435 375 // Should be set when apparently null
duke@435 376 // For details, see unsafe.cpp Unsafe_Unpark
duke@435 377 static jlong park_event(oop java_thread);
duke@435 378 static bool set_park_event(oop java_thread, jlong ptr);
duke@435 379
duke@435 380 // Java Thread Status for JVMTI and M&M use.
duke@435 381 // This thread status info is saved in threadStatus field of
duke@435 382 // java.lang.Thread java class.
duke@435 383 enum ThreadStatus {
duke@435 384 NEW = 0,
duke@435 385 RUNNABLE = JVMTI_THREAD_STATE_ALIVE + // runnable / running
duke@435 386 JVMTI_THREAD_STATE_RUNNABLE,
duke@435 387 SLEEPING = JVMTI_THREAD_STATE_ALIVE + // Thread.sleep()
duke@435 388 JVMTI_THREAD_STATE_WAITING +
duke@435 389 JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT +
duke@435 390 JVMTI_THREAD_STATE_SLEEPING,
duke@435 391 IN_OBJECT_WAIT = JVMTI_THREAD_STATE_ALIVE + // Object.wait()
duke@435 392 JVMTI_THREAD_STATE_WAITING +
duke@435 393 JVMTI_THREAD_STATE_WAITING_INDEFINITELY +
duke@435 394 JVMTI_THREAD_STATE_IN_OBJECT_WAIT,
duke@435 395 IN_OBJECT_WAIT_TIMED = JVMTI_THREAD_STATE_ALIVE + // Object.wait(long)
duke@435 396 JVMTI_THREAD_STATE_WAITING +
duke@435 397 JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT +
duke@435 398 JVMTI_THREAD_STATE_IN_OBJECT_WAIT,
duke@435 399 PARKED = JVMTI_THREAD_STATE_ALIVE + // LockSupport.park()
duke@435 400 JVMTI_THREAD_STATE_WAITING +
duke@435 401 JVMTI_THREAD_STATE_WAITING_INDEFINITELY +
duke@435 402 JVMTI_THREAD_STATE_PARKED,
duke@435 403 PARKED_TIMED = JVMTI_THREAD_STATE_ALIVE + // LockSupport.park(long)
duke@435 404 JVMTI_THREAD_STATE_WAITING +
duke@435 405 JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT +
duke@435 406 JVMTI_THREAD_STATE_PARKED,
duke@435 407 BLOCKED_ON_MONITOR_ENTER = JVMTI_THREAD_STATE_ALIVE + // (re-)entering a synchronization block
duke@435 408 JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER,
duke@435 409 TERMINATED = JVMTI_THREAD_STATE_TERMINATED
duke@435 410 };
duke@435 411 // Write thread status info to threadStatus field of java.lang.Thread.
duke@435 412 static void set_thread_status(oop java_thread_oop, ThreadStatus status);
duke@435 413 // Read thread status info from threadStatus field of java.lang.Thread.
duke@435 414 static ThreadStatus get_thread_status(oop java_thread_oop);
duke@435 415
duke@435 416 static const char* thread_status_name(oop java_thread_oop);
duke@435 417
duke@435 418 // Debugging
duke@435 419 friend class JavaClasses;
duke@435 420 };
duke@435 421
duke@435 422 // Interface to java.lang.ThreadGroup objects
duke@435 423
duke@435 424 class java_lang_ThreadGroup : AllStatic {
duke@435 425 private:
duke@435 426 static int _parent_offset;
duke@435 427 static int _name_offset;
duke@435 428 static int _threads_offset;
duke@435 429 static int _groups_offset;
duke@435 430 static int _maxPriority_offset;
duke@435 431 static int _destroyed_offset;
duke@435 432 static int _daemon_offset;
duke@435 433 static int _vmAllowSuspension_offset;
duke@435 434 static int _nthreads_offset;
duke@435 435 static int _ngroups_offset;
duke@435 436
duke@435 437 static void compute_offsets();
duke@435 438
duke@435 439 public:
duke@435 440 // parent ThreadGroup
duke@435 441 static oop parent(oop java_thread_group);
duke@435 442 // name
duke@435 443 static typeArrayOop name(oop java_thread_group);
duke@435 444 // ("name as oop" accessor is not necessary)
duke@435 445 // Number of threads in group
duke@435 446 static int nthreads(oop java_thread_group);
duke@435 447 // threads
duke@435 448 static objArrayOop threads(oop java_thread_group);
duke@435 449 // Number of threads in group
duke@435 450 static int ngroups(oop java_thread_group);
duke@435 451 // groups
duke@435 452 static objArrayOop groups(oop java_thread_group);
duke@435 453 // maxPriority in group
duke@435 454 static ThreadPriority maxPriority(oop java_thread_group);
duke@435 455 // Destroyed
duke@435 456 static bool is_destroyed(oop java_thread_group);
duke@435 457 // Daemon
duke@435 458 static bool is_daemon(oop java_thread_group);
duke@435 459 // vmAllowSuspension
duke@435 460 static bool is_vmAllowSuspension(oop java_thread_group);
duke@435 461 // Debugging
duke@435 462 friend class JavaClasses;
duke@435 463 };
duke@435 464
duke@435 465
duke@435 466
duke@435 467 // Interface to java.lang.Throwable objects
duke@435 468
duke@435 469 class java_lang_Throwable: AllStatic {
duke@435 470 friend class BacktraceBuilder;
duke@435 471
duke@435 472 private:
duke@435 473 // Offsets
duke@435 474 enum {
duke@435 475 hc_backtrace_offset = 0,
duke@435 476 hc_detailMessage_offset = 1,
duke@435 477 hc_cause_offset = 2, // New since 1.4
duke@435 478 hc_stackTrace_offset = 3 // New since 1.4
duke@435 479 };
dholmes@3018 480 enum {
dholmes@3018 481 hc_static_unassigned_stacktrace_offset = 0 // New since 1.7
dholmes@3018 482 };
duke@435 483 // Trace constants
duke@435 484 enum {
duke@435 485 trace_methods_offset = 0,
duke@435 486 trace_bcis_offset = 1,
coleenp@4037 487 trace_mirrors_offset = 2,
sspitsyn@7683 488 trace_cprefs_offset = 3,
sspitsyn@7683 489 trace_next_offset = 4,
sspitsyn@7683 490 trace_size = 5,
duke@435 491 trace_chunk_size = 32
duke@435 492 };
duke@435 493
duke@435 494 static int backtrace_offset;
duke@435 495 static int detailMessage_offset;
duke@435 496 static int cause_offset;
duke@435 497 static int stackTrace_offset;
dholmes@3018 498 static int static_unassigned_stacktrace_offset;
duke@435 499
duke@435 500 // Printing
sspitsyn@7683 501 static char* print_stack_element_to_buffer(Handle mirror, int method, int version, int bci, int cpref);
duke@435 502 // StackTrace (programmatic access, new since 1.4)
duke@435 503 static void clear_stacktrace(oop throwable);
duke@435 504 // No stack trace available
duke@435 505 static const char* no_stack_trace_message();
dholmes@3018 506 // Stacktrace (post JDK 1.7.0 to allow immutability protocol to be followed)
dholmes@3018 507 static void set_stacktrace(oop throwable, oop st_element_array);
dholmes@3018 508 static oop unassigned_stacktrace();
duke@435 509
duke@435 510 public:
duke@435 511 // Backtrace
duke@435 512 static oop backtrace(oop throwable);
duke@435 513 static void set_backtrace(oop throwable, oop value);
duke@435 514 // Needed by JVMTI to filter out this internal field.
duke@435 515 static int get_backtrace_offset() { return backtrace_offset;}
duke@435 516 static int get_detailMessage_offset() { return detailMessage_offset;}
duke@435 517 // Message
duke@435 518 static oop message(oop throwable);
duke@435 519 static oop message(Handle throwable);
duke@435 520 static void set_message(oop throwable, oop value);
coleenp@9970 521 static Symbol* detail_message(oop throwable);
coleenp@4466 522 static void print_stack_element(outputStream *st, Handle mirror, int method,
sspitsyn@7683 523 int version, int bci, int cpref);
coleenp@4466 524 static void print_stack_element(outputStream *st, methodHandle method, int bci);
duke@435 525 static void print_stack_usage(Handle stream);
duke@435 526
duke@435 527 // Allocate space for backtrace (created but stack trace not filled in)
duke@435 528 static void allocate_backtrace(Handle throwable, TRAPS);
duke@435 529 // Fill in current stack trace for throwable with preallocated backtrace (no GC)
duke@435 530 static void fill_in_stack_trace_of_preallocated_backtrace(Handle throwable);
duke@435 531 // Fill in current stack trace, can cause GC
coleenp@2804 532 static void fill_in_stack_trace(Handle throwable, methodHandle method, TRAPS);
coleenp@2804 533 static void fill_in_stack_trace(Handle throwable, methodHandle method = methodHandle());
duke@435 534 // Programmatic access to stack trace
duke@435 535 static oop get_stack_trace_element(oop throwable, int index, TRAPS);
duke@435 536 static int get_stack_trace_depth(oop throwable, TRAPS);
duke@435 537 // Printing
duke@435 538 static void print(oop throwable, outputStream* st);
duke@435 539 static void print(Handle throwable, outputStream* st);
duke@435 540 static void print_stack_trace(oop throwable, outputStream* st);
duke@435 541 // Debugging
duke@435 542 friend class JavaClasses;
duke@435 543 };
duke@435 544
duke@435 545
duke@435 546 // Interface to java.lang.reflect.AccessibleObject objects
duke@435 547
duke@435 548 class java_lang_reflect_AccessibleObject: AllStatic {
duke@435 549 private:
duke@435 550 // Note that to reduce dependencies on the JDK we compute these
duke@435 551 // offsets at run-time.
duke@435 552 static int override_offset;
duke@435 553
duke@435 554 static void compute_offsets();
duke@435 555
duke@435 556 public:
duke@435 557 // Accessors
duke@435 558 static jboolean override(oop reflect);
duke@435 559 static void set_override(oop reflect, jboolean value);
duke@435 560
duke@435 561 // Debugging
duke@435 562 friend class JavaClasses;
duke@435 563 };
duke@435 564
duke@435 565
duke@435 566 // Interface to java.lang.reflect.Method objects
duke@435 567
duke@435 568 class java_lang_reflect_Method : public java_lang_reflect_AccessibleObject {
duke@435 569 private:
duke@435 570 // Note that to reduce dependencies on the JDK we compute these
duke@435 571 // offsets at run-time.
duke@435 572 static int clazz_offset;
duke@435 573 static int name_offset;
duke@435 574 static int returnType_offset;
duke@435 575 static int parameterTypes_offset;
duke@435 576 static int exceptionTypes_offset;
duke@435 577 static int slot_offset;
duke@435 578 static int modifiers_offset;
duke@435 579 static int signature_offset;
duke@435 580 static int annotations_offset;
duke@435 581 static int parameter_annotations_offset;
duke@435 582 static int annotation_default_offset;
stefank@4393 583 static int type_annotations_offset;
duke@435 584
duke@435 585 static void compute_offsets();
duke@435 586
duke@435 587 public:
duke@435 588 // Allocation
duke@435 589 static Handle create(TRAPS);
duke@435 590
duke@435 591 // Accessors
duke@435 592 static oop clazz(oop reflect);
duke@435 593 static void set_clazz(oop reflect, oop value);
duke@435 594
duke@435 595 static oop name(oop method);
duke@435 596 static void set_name(oop method, oop value);
duke@435 597
duke@435 598 static oop return_type(oop method);
duke@435 599 static void set_return_type(oop method, oop value);
duke@435 600
duke@435 601 static oop parameter_types(oop method);
duke@435 602 static void set_parameter_types(oop method, oop value);
duke@435 603
duke@435 604 static oop exception_types(oop method);
duke@435 605 static void set_exception_types(oop method, oop value);
duke@435 606
duke@435 607 static int slot(oop reflect);
duke@435 608 static void set_slot(oop reflect, int value);
duke@435 609
duke@435 610 static int modifiers(oop method);
duke@435 611 static void set_modifiers(oop method, int value);
duke@435 612
duke@435 613 static bool has_signature_field();
duke@435 614 static oop signature(oop method);
duke@435 615 static void set_signature(oop method, oop value);
duke@435 616
duke@435 617 static bool has_annotations_field();
duke@435 618 static oop annotations(oop method);
duke@435 619 static void set_annotations(oop method, oop value);
duke@435 620
duke@435 621 static bool has_parameter_annotations_field();
duke@435 622 static oop parameter_annotations(oop method);
duke@435 623 static void set_parameter_annotations(oop method, oop value);
duke@435 624
duke@435 625 static bool has_annotation_default_field();
duke@435 626 static oop annotation_default(oop method);
duke@435 627 static void set_annotation_default(oop method, oop value);
duke@435 628
stefank@4393 629 static bool has_type_annotations_field();
stefank@4393 630 static oop type_annotations(oop method);
stefank@4393 631 static void set_type_annotations(oop method, oop value);
stefank@4393 632
duke@435 633 // Debugging
duke@435 634 friend class JavaClasses;
duke@435 635 };
duke@435 636
duke@435 637
duke@435 638 // Interface to java.lang.reflect.Constructor objects
duke@435 639
duke@435 640 class java_lang_reflect_Constructor : public java_lang_reflect_AccessibleObject {
duke@435 641 private:
duke@435 642 // Note that to reduce dependencies on the JDK we compute these
duke@435 643 // offsets at run-time.
duke@435 644 static int clazz_offset;
duke@435 645 static int parameterTypes_offset;
duke@435 646 static int exceptionTypes_offset;
duke@435 647 static int slot_offset;
duke@435 648 static int modifiers_offset;
duke@435 649 static int signature_offset;
duke@435 650 static int annotations_offset;
duke@435 651 static int parameter_annotations_offset;
stefank@4393 652 static int type_annotations_offset;
duke@435 653
duke@435 654 static void compute_offsets();
duke@435 655
duke@435 656 public:
duke@435 657 // Allocation
duke@435 658 static Handle create(TRAPS);
duke@435 659
duke@435 660 // Accessors
duke@435 661 static oop clazz(oop reflect);
duke@435 662 static void set_clazz(oop reflect, oop value);
duke@435 663
duke@435 664 static oop parameter_types(oop constructor);
duke@435 665 static void set_parameter_types(oop constructor, oop value);
duke@435 666
duke@435 667 static oop exception_types(oop constructor);
duke@435 668 static void set_exception_types(oop constructor, oop value);
duke@435 669
duke@435 670 static int slot(oop reflect);
duke@435 671 static void set_slot(oop reflect, int value);
duke@435 672
duke@435 673 static int modifiers(oop constructor);
duke@435 674 static void set_modifiers(oop constructor, int value);
duke@435 675
duke@435 676 static bool has_signature_field();
duke@435 677 static oop signature(oop constructor);
duke@435 678 static void set_signature(oop constructor, oop value);
duke@435 679
duke@435 680 static bool has_annotations_field();
duke@435 681 static oop annotations(oop constructor);
duke@435 682 static void set_annotations(oop constructor, oop value);
duke@435 683
duke@435 684 static bool has_parameter_annotations_field();
duke@435 685 static oop parameter_annotations(oop method);
duke@435 686 static void set_parameter_annotations(oop method, oop value);
duke@435 687
stefank@4393 688 static bool has_type_annotations_field();
stefank@4393 689 static oop type_annotations(oop constructor);
stefank@4393 690 static void set_type_annotations(oop constructor, oop value);
stefank@4393 691
duke@435 692 // Debugging
duke@435 693 friend class JavaClasses;
duke@435 694 };
duke@435 695
duke@435 696
duke@435 697 // Interface to java.lang.reflect.Field objects
duke@435 698
duke@435 699 class java_lang_reflect_Field : public java_lang_reflect_AccessibleObject {
duke@435 700 private:
duke@435 701 // Note that to reduce dependencies on the JDK we compute these
duke@435 702 // offsets at run-time.
duke@435 703 static int clazz_offset;
duke@435 704 static int name_offset;
duke@435 705 static int type_offset;
duke@435 706 static int slot_offset;
duke@435 707 static int modifiers_offset;
duke@435 708 static int signature_offset;
duke@435 709 static int annotations_offset;
stefank@4393 710 static int type_annotations_offset;
duke@435 711
duke@435 712 static void compute_offsets();
duke@435 713
duke@435 714 public:
duke@435 715 // Allocation
duke@435 716 static Handle create(TRAPS);
duke@435 717
duke@435 718 // Accessors
duke@435 719 static oop clazz(oop reflect);
duke@435 720 static void set_clazz(oop reflect, oop value);
duke@435 721
duke@435 722 static oop name(oop field);
duke@435 723 static void set_name(oop field, oop value);
duke@435 724
duke@435 725 static oop type(oop field);
duke@435 726 static void set_type(oop field, oop value);
duke@435 727
duke@435 728 static int slot(oop reflect);
duke@435 729 static void set_slot(oop reflect, int value);
duke@435 730
duke@435 731 static int modifiers(oop field);
duke@435 732 static void set_modifiers(oop field, int value);
duke@435 733
duke@435 734 static bool has_signature_field();
duke@435 735 static oop signature(oop constructor);
duke@435 736 static void set_signature(oop constructor, oop value);
duke@435 737
duke@435 738 static bool has_annotations_field();
duke@435 739 static oop annotations(oop constructor);
duke@435 740 static void set_annotations(oop constructor, oop value);
duke@435 741
duke@435 742 static bool has_parameter_annotations_field();
duke@435 743 static oop parameter_annotations(oop method);
duke@435 744 static void set_parameter_annotations(oop method, oop value);
duke@435 745
duke@435 746 static bool has_annotation_default_field();
duke@435 747 static oop annotation_default(oop method);
duke@435 748 static void set_annotation_default(oop method, oop value);
duke@435 749
stefank@4393 750 static bool has_type_annotations_field();
stefank@4393 751 static oop type_annotations(oop field);
stefank@4393 752 static void set_type_annotations(oop field, oop value);
stefank@4393 753
duke@435 754 // Debugging
duke@435 755 friend class JavaClasses;
duke@435 756 };
duke@435 757
coleenp@4398 758 class java_lang_reflect_Parameter {
coleenp@4398 759 private:
coleenp@4398 760 // Note that to reduce dependencies on the JDK we compute these
coleenp@4398 761 // offsets at run-time.
coleenp@4398 762 static int name_offset;
coleenp@4398 763 static int modifiers_offset;
coleenp@4398 764 static int index_offset;
coleenp@4398 765 static int executable_offset;
coleenp@4398 766
coleenp@4398 767 static void compute_offsets();
coleenp@4398 768
coleenp@4398 769 public:
coleenp@4398 770 // Allocation
coleenp@4398 771 static Handle create(TRAPS);
coleenp@4398 772
coleenp@4398 773 // Accessors
coleenp@4398 774 static oop name(oop field);
coleenp@4398 775 static void set_name(oop field, oop value);
coleenp@4398 776
coleenp@4398 777 static int index(oop reflect);
coleenp@4398 778 static void set_index(oop reflect, int value);
coleenp@4398 779
coleenp@4398 780 static int modifiers(oop reflect);
coleenp@4398 781 static void set_modifiers(oop reflect, int value);
coleenp@4398 782
coleenp@4398 783 static oop executable(oop constructor);
coleenp@4398 784 static void set_executable(oop constructor, oop value);
coleenp@4398 785
coleenp@4398 786 friend class JavaClasses;
coleenp@4398 787 };
coleenp@4398 788
duke@435 789 // Interface to sun.reflect.ConstantPool objects
duke@435 790 class sun_reflect_ConstantPool {
duke@435 791 private:
duke@435 792 // Note that to reduce dependencies on the JDK we compute these
duke@435 793 // offsets at run-time.
coleenp@4037 794 static int _oop_offset;
duke@435 795
duke@435 796 static void compute_offsets();
duke@435 797
duke@435 798 public:
duke@435 799 // Allocation
duke@435 800 static Handle create(TRAPS);
duke@435 801
duke@435 802 // Accessors
coleenp@4037 803 static void set_cp(oop reflect, ConstantPool* value);
coleenp@4037 804 static int oop_offset() {
coleenp@4037 805 return _oop_offset;
duke@435 806 }
duke@435 807
coleenp@4037 808 static ConstantPool* get_cp(oop reflect);
coleenp@4037 809
duke@435 810 // Debugging
duke@435 811 friend class JavaClasses;
duke@435 812 };
duke@435 813
duke@435 814 // Interface to sun.reflect.UnsafeStaticFieldAccessorImpl objects
duke@435 815 class sun_reflect_UnsafeStaticFieldAccessorImpl {
duke@435 816 private:
duke@435 817 static int _base_offset;
duke@435 818 static void compute_offsets();
duke@435 819
duke@435 820 public:
duke@435 821 static int base_offset() {
duke@435 822 return _base_offset;
duke@435 823 }
duke@435 824
duke@435 825 // Debugging
duke@435 826 friend class JavaClasses;
duke@435 827 };
duke@435 828
duke@435 829 // Interface to java.lang primitive type boxing objects:
duke@435 830 // - java.lang.Boolean
duke@435 831 // - java.lang.Character
duke@435 832 // - java.lang.Float
duke@435 833 // - java.lang.Double
duke@435 834 // - java.lang.Byte
duke@435 835 // - java.lang.Short
duke@435 836 // - java.lang.Integer
duke@435 837 // - java.lang.Long
duke@435 838
duke@435 839 // This could be separated out into 8 individual classes.
duke@435 840
duke@435 841 class java_lang_boxing_object: AllStatic {
duke@435 842 private:
duke@435 843 enum {
duke@435 844 hc_value_offset = 0
duke@435 845 };
duke@435 846 static int value_offset;
kvn@600 847 static int long_value_offset;
duke@435 848
jrose@567 849 static oop initialize_and_allocate(BasicType type, TRAPS);
duke@435 850 public:
duke@435 851 // Allocation. Returns a boxed value, or NULL for invalid type.
duke@435 852 static oop create(BasicType type, jvalue* value, TRAPS);
duke@435 853 // Accessors. Returns the basic type being boxed, or T_ILLEGAL for invalid oop.
duke@435 854 static BasicType get_value(oop box, jvalue* value);
duke@435 855 static BasicType set_value(oop box, jvalue* value);
jrose@567 856 static BasicType basic_type(oop box);
jrose@567 857 static bool is_instance(oop box) { return basic_type(box) != T_ILLEGAL; }
jrose@567 858 static bool is_instance(oop box, BasicType type) { return basic_type(box) == type; }
jrose@1100 859 static void print(oop box, outputStream* st) { jvalue value; print(get_value(box, &value), &value, st); }
jrose@1100 860 static void print(BasicType type, jvalue* value, outputStream* st);
duke@435 861
kvn@600 862 static int value_offset_in_bytes(BasicType type) {
kvn@600 863 return ( type == T_LONG || type == T_DOUBLE ) ? long_value_offset :
kvn@600 864 value_offset;
kvn@600 865 }
duke@435 866
duke@435 867 // Debugging
duke@435 868 friend class JavaClasses;
duke@435 869 };
duke@435 870
duke@435 871
duke@435 872
duke@435 873 // Interface to java.lang.ref.Reference objects
duke@435 874
duke@435 875 class java_lang_ref_Reference: AllStatic {
duke@435 876 public:
duke@435 877 enum {
duke@435 878 hc_referent_offset = 0,
duke@435 879 hc_queue_offset = 1,
duke@435 880 hc_next_offset = 2,
duke@435 881 hc_discovered_offset = 3 // Is not last, see SoftRefs.
duke@435 882 };
duke@435 883 enum {
duke@435 884 hc_static_lock_offset = 0,
duke@435 885 hc_static_pending_offset = 1
duke@435 886 };
duke@435 887
duke@435 888 static int referent_offset;
duke@435 889 static int queue_offset;
duke@435 890 static int next_offset;
duke@435 891 static int discovered_offset;
duke@435 892 static int static_lock_offset;
duke@435 893 static int static_pending_offset;
duke@435 894 static int number_of_fake_oop_fields;
duke@435 895
duke@435 896 // Accessors
coleenp@548 897 static oop referent(oop ref) {
coleenp@548 898 return ref->obj_field(referent_offset);
coleenp@548 899 }
coleenp@548 900 static void set_referent(oop ref, oop value) {
coleenp@548 901 ref->obj_field_put(referent_offset, value);
coleenp@548 902 }
coleenp@548 903 static void set_referent_raw(oop ref, oop value) {
twisti@3131 904 ref->obj_field_put_raw(referent_offset, value);
coleenp@548 905 }
coleenp@548 906 static HeapWord* referent_addr(oop ref) {
coleenp@548 907 return ref->obj_field_addr<HeapWord>(referent_offset);
coleenp@548 908 }
coleenp@548 909 static oop next(oop ref) {
coleenp@548 910 return ref->obj_field(next_offset);
coleenp@548 911 }
coleenp@548 912 static void set_next(oop ref, oop value) {
coleenp@548 913 ref->obj_field_put(next_offset, value);
coleenp@548 914 }
coleenp@548 915 static void set_next_raw(oop ref, oop value) {
twisti@3131 916 ref->obj_field_put_raw(next_offset, value);
coleenp@548 917 }
coleenp@548 918 static HeapWord* next_addr(oop ref) {
coleenp@548 919 return ref->obj_field_addr<HeapWord>(next_offset);
coleenp@548 920 }
coleenp@548 921 static oop discovered(oop ref) {
coleenp@548 922 return ref->obj_field(discovered_offset);
coleenp@548 923 }
coleenp@548 924 static void set_discovered(oop ref, oop value) {
coleenp@548 925 ref->obj_field_put(discovered_offset, value);
coleenp@548 926 }
coleenp@548 927 static void set_discovered_raw(oop ref, oop value) {
twisti@3131 928 ref->obj_field_put_raw(discovered_offset, value);
coleenp@548 929 }
coleenp@548 930 static HeapWord* discovered_addr(oop ref) {
coleenp@548 931 return ref->obj_field_addr<HeapWord>(discovered_offset);
coleenp@548 932 }
kbarrett@9099 933 static inline oop queue(oop ref) {
kbarrett@9099 934 return ref->obj_field(queue_offset);
kbarrett@9099 935 }
kbarrett@9099 936 static inline void set_queue(oop ref, oop value) {
kbarrett@9099 937 return ref->obj_field_put(queue_offset, value);
kbarrett@9099 938 }
coleenp@548 939 // Accessors for statics
coleenp@548 940 static oop pending_list_lock();
coleenp@548 941 static oop pending_list();
duke@435 942
coleenp@4037 943 static HeapWord* pending_list_lock_addr();
coleenp@548 944 static HeapWord* pending_list_addr();
duke@435 945 };
duke@435 946
duke@435 947
duke@435 948 // Interface to java.lang.ref.SoftReference objects
duke@435 949
duke@435 950 class java_lang_ref_SoftReference: public java_lang_ref_Reference {
duke@435 951 public:
duke@435 952 enum {
duke@435 953 // The timestamp is a long field and may need to be adjusted for alignment.
kvn@600 954 hc_timestamp_offset = hc_discovered_offset + 1
duke@435 955 };
duke@435 956 enum {
duke@435 957 hc_static_clock_offset = 0
duke@435 958 };
duke@435 959
duke@435 960 static int timestamp_offset;
duke@435 961 static int static_clock_offset;
duke@435 962
duke@435 963 // Accessors
duke@435 964 static jlong timestamp(oop ref);
duke@435 965
duke@435 966 // Accessors for statics
duke@435 967 static jlong clock();
duke@435 968 static void set_clock(jlong value);
duke@435 969 };
duke@435 970
duke@435 971
kbarrett@9099 972 // Interface to java.lang.ref.ReferenceQueue objects
kbarrett@9099 973
kbarrett@9099 974 class java_lang_ref_ReferenceQueue: public AllStatic {
kbarrett@9099 975 public:
kbarrett@9099 976 static int static_NULL_queue_offset;
kbarrett@9099 977 static int static_ENQUEUED_queue_offset;
kbarrett@9099 978
kbarrett@9099 979 // Accessors
kbarrett@9099 980 static oop NULL_queue();
kbarrett@9099 981 static oop ENQUEUED_queue();
kbarrett@9099 982
kbarrett@9099 983 static void compute_offsets();
kbarrett@9099 984 };
kbarrett@9099 985
jrose@2639 986 // Interface to java.lang.invoke.MethodHandle objects
jrose@1145 987
jrose@1145 988 class MethodHandleEntry;
jrose@1145 989
jrose@2639 990 class java_lang_invoke_MethodHandle: AllStatic {
jrose@1145 991 friend class JavaClasses;
jrose@1145 992
jrose@1145 993 private:
twisti@3969 994 static int _type_offset; // the MethodType of this MH
twisti@3969 995 static int _form_offset; // the LambdaForm of this MH
jrose@1145 996
jrose@1145 997 static void compute_offsets();
jrose@1145 998
jrose@1145 999 public:
jrose@1145 1000 // Accessors
jrose@1145 1001 static oop type(oop mh);
jrose@1145 1002 static void set_type(oop mh, oop mtype);
jrose@1145 1003
twisti@3969 1004 static oop form(oop mh);
twisti@3969 1005 static void set_form(oop mh, oop lform);
jrose@1145 1006
jrose@1145 1007 // Testers
coleenp@4037 1008 static bool is_subclass(Klass* klass) {
hseigel@4278 1009 return klass->is_subclass_of(SystemDictionary::MethodHandle_klass());
jrose@1145 1010 }
jrose@1145 1011 static bool is_instance(oop obj) {
jrose@1145 1012 return obj != NULL && is_subclass(obj->klass());
jrose@1145 1013 }
jrose@1145 1014
jrose@1145 1015 // Accessors for code generation:
jrose@1145 1016 static int type_offset_in_bytes() { return _type_offset; }
twisti@3969 1017 static int form_offset_in_bytes() { return _form_offset; }
jrose@1145 1018 };
jrose@1145 1019
sspitsyn@5496 1020 // Interface to java.lang.invoke.DirectMethodHandle objects
sspitsyn@5496 1021
sspitsyn@5496 1022 class java_lang_invoke_DirectMethodHandle: AllStatic {
sspitsyn@5496 1023 friend class JavaClasses;
sspitsyn@5496 1024
sspitsyn@5496 1025 private:
sspitsyn@5496 1026 static int _member_offset; // the MemberName of this DMH
sspitsyn@5496 1027
sspitsyn@5496 1028 static void compute_offsets();
sspitsyn@5496 1029
sspitsyn@5496 1030 public:
sspitsyn@5496 1031 // Accessors
sspitsyn@5496 1032 static oop member(oop mh);
sspitsyn@5496 1033
sspitsyn@5496 1034 // Testers
sspitsyn@5496 1035 static bool is_subclass(Klass* klass) {
sspitsyn@5496 1036 return klass->is_subclass_of(SystemDictionary::DirectMethodHandle_klass());
sspitsyn@5496 1037 }
sspitsyn@5496 1038 static bool is_instance(oop obj) {
sspitsyn@5496 1039 return obj != NULL && is_subclass(obj->klass());
sspitsyn@5496 1040 }
sspitsyn@5496 1041
sspitsyn@5496 1042 // Accessors for code generation:
sspitsyn@5496 1043 static int member_offset_in_bytes() { return _member_offset; }
sspitsyn@5496 1044 };
sspitsyn@5496 1045
twisti@3969 1046 // Interface to java.lang.invoke.LambdaForm objects
twisti@3969 1047 // (These are a private interface for managing adapter code generation.)
never@3137 1048
twisti@3969 1049 class java_lang_invoke_LambdaForm: AllStatic {
jrose@1145 1050 friend class JavaClasses;
jrose@1145 1051
jrose@1145 1052 private:
twisti@3969 1053 static int _vmentry_offset; // type is MemberName
twisti@3969 1054
jrose@1145 1055 static void compute_offsets();
jrose@1145 1056
jrose@1145 1057 public:
jrose@1145 1058 // Accessors
twisti@3969 1059 static oop vmentry(oop lform);
twisti@3969 1060 static void set_vmentry(oop lform, oop invoker);
jrose@1145 1061
jrose@1145 1062 // Testers
coleenp@4037 1063 static bool is_subclass(Klass* klass) {
twisti@3969 1064 return SystemDictionary::LambdaForm_klass() != NULL &&
hseigel@4278 1065 klass->is_subclass_of(SystemDictionary::LambdaForm_klass());
jrose@1145 1066 }
jrose@1145 1067 static bool is_instance(oop obj) {
jrose@1145 1068 return obj != NULL && is_subclass(obj->klass());
jrose@1145 1069 }
jrose@1145 1070
jrose@1145 1071 // Accessors for code generation:
twisti@3969 1072 static int vmentry_offset_in_bytes() { return _vmentry_offset; }
jrose@1145 1073 };
jrose@1145 1074
never@3105 1075
jrose@2639 1076 // Interface to java.lang.invoke.MemberName objects
jrose@1145 1077 // (These are a private interface for Java code to query the class hierarchy.)
jrose@1145 1078
twisti@3969 1079 #define MEMBERNAME_INJECTED_FIELDS(macro) \
coleenp@4037 1080 macro(java_lang_invoke_MemberName, vmloader, object_signature, false) \
twisti@3969 1081 macro(java_lang_invoke_MemberName, vmindex, intptr_signature, false) \
coleenp@4037 1082 macro(java_lang_invoke_MemberName, vmtarget, intptr_signature, false)
never@3137 1083
jrose@2639 1084 class java_lang_invoke_MemberName: AllStatic {
jrose@1145 1085 friend class JavaClasses;
jrose@1145 1086
jrose@1145 1087 private:
jrose@2639 1088 // From java.lang.invoke.MemberName:
jrose@1145 1089 // private Class<?> clazz; // class in which the method is defined
jrose@1145 1090 // private String name; // may be null if not yet materialized
jrose@1145 1091 // private Object type; // may be null if not yet materialized
jrose@1145 1092 // private int flags; // modifier bits; see reflect.Modifier
coleenp@4037 1093 // private intptr vmtarget; // VM-specific target value
twisti@3969 1094 // private intptr_t vmindex; // member index within class or interface
jrose@1145 1095 static int _clazz_offset;
jrose@1145 1096 static int _name_offset;
jrose@1145 1097 static int _type_offset;
jrose@1145 1098 static int _flags_offset;
jrose@1145 1099 static int _vmtarget_offset;
coleenp@4037 1100 static int _vmloader_offset;
jrose@1145 1101 static int _vmindex_offset;
jrose@1145 1102
jrose@1145 1103 static void compute_offsets();
jrose@1145 1104
jrose@1145 1105 public:
jrose@1145 1106 // Accessors
jrose@1145 1107 static oop clazz(oop mname);
jrose@1145 1108 static void set_clazz(oop mname, oop clazz);
jrose@1145 1109
jrose@1145 1110 static oop type(oop mname);
jrose@1145 1111 static void set_type(oop mname, oop type);
jrose@1145 1112
jrose@1145 1113 static oop name(oop mname);
jrose@1145 1114 static void set_name(oop mname, oop name);
jrose@1145 1115
jrose@1145 1116 static int flags(oop mname);
jrose@1145 1117 static void set_flags(oop mname, int flags);
jrose@1145 1118
coleenp@4037 1119 static Metadata* vmtarget(oop mname);
coleenp@4037 1120 static void set_vmtarget(oop mname, Metadata* target);
jrose@1145 1121
twisti@3969 1122 static intptr_t vmindex(oop mname);
twisti@3969 1123 static void set_vmindex(oop mname, intptr_t index);
jrose@1145 1124
jrose@1145 1125 // Testers
coleenp@4037 1126 static bool is_subclass(Klass* klass) {
hseigel@4278 1127 return klass->is_subclass_of(SystemDictionary::MemberName_klass());
jrose@1145 1128 }
jrose@1145 1129 static bool is_instance(oop obj) {
jrose@1145 1130 return obj != NULL && is_subclass(obj->klass());
jrose@1145 1131 }
jrose@1145 1132
coleenp@7391 1133 static bool is_method(oop obj);
coleenp@7391 1134
jrose@1145 1135 // Relevant integer codes (keep these in synch. with MethodHandleNatives.Constants):
jrose@1145 1136 enum {
twisti@4866 1137 MN_IS_METHOD = 0x00010000, // method (not constructor)
twisti@4866 1138 MN_IS_CONSTRUCTOR = 0x00020000, // constructor
twisti@4866 1139 MN_IS_FIELD = 0x00040000, // field
twisti@4866 1140 MN_IS_TYPE = 0x00080000, // nested type
twisti@4866 1141 MN_CALLER_SENSITIVE = 0x00100000, // @CallerSensitive annotation detected
twisti@3969 1142 MN_REFERENCE_KIND_SHIFT = 24, // refKind
twisti@4866 1143 MN_REFERENCE_KIND_MASK = 0x0F000000 >> MN_REFERENCE_KIND_SHIFT,
twisti@3969 1144 // The SEARCH_* bits are not for MN.flags but for the matchFlags argument of MHN.getMembers:
twisti@4866 1145 MN_SEARCH_SUPERCLASSES = 0x00100000, // walk super classes
twisti@4866 1146 MN_SEARCH_INTERFACES = 0x00200000 // walk implemented interfaces
jrose@1145 1147 };
jrose@1145 1148
jrose@1145 1149 // Accessors for code generation:
jrose@1145 1150 static int clazz_offset_in_bytes() { return _clazz_offset; }
jrose@1145 1151 static int type_offset_in_bytes() { return _type_offset; }
jrose@1145 1152 static int name_offset_in_bytes() { return _name_offset; }
jrose@1145 1153 static int flags_offset_in_bytes() { return _flags_offset; }
jrose@1145 1154 static int vmtarget_offset_in_bytes() { return _vmtarget_offset; }
jrose@1145 1155 static int vmindex_offset_in_bytes() { return _vmindex_offset; }
kevinw@8721 1156
kevinw@8721 1157 static bool equals(oop mt1, oop mt2);
jrose@1145 1158 };
jrose@1145 1159
jrose@1145 1160
jrose@2639 1161 // Interface to java.lang.invoke.MethodType objects
jrose@1145 1162
jrose@2639 1163 class java_lang_invoke_MethodType: AllStatic {
jrose@1145 1164 friend class JavaClasses;
jrose@1145 1165
jrose@1145 1166 private:
jrose@1145 1167 static int _rtype_offset;
jrose@1145 1168 static int _ptypes_offset;
jrose@1145 1169
jrose@1145 1170 static void compute_offsets();
jrose@1145 1171
jrose@1145 1172 public:
jrose@1145 1173 // Accessors
jrose@1145 1174 static oop rtype(oop mt);
jrose@1145 1175 static objArrayOop ptypes(oop mt);
jrose@1145 1176
jrose@1145 1177 static oop ptype(oop mt, int index);
twisti@1568 1178 static int ptype_count(oop mt);
jrose@1145 1179
twisti@3969 1180 static int ptype_slot_count(oop mt); // extra counts for long/double
twisti@3969 1181 static int rtype_slot_count(oop mt); // extra counts for long/double
twisti@3969 1182
coleenp@2497 1183 static Symbol* as_signature(oop mt, bool intern_if_not_found, TRAPS);
jrose@1145 1184 static void print_signature(oop mt, outputStream* st);
jrose@1145 1185
jrose@1145 1186 static bool is_instance(oop obj) {
jrose@1145 1187 return obj != NULL && obj->klass() == SystemDictionary::MethodType_klass();
jrose@1145 1188 }
jrose@1145 1189
jrose@2982 1190 static bool equals(oop mt1, oop mt2);
jrose@2982 1191
jrose@1145 1192 // Accessors for code generation:
jrose@1145 1193 static int rtype_offset_in_bytes() { return _rtype_offset; }
jrose@1145 1194 static int ptypes_offset_in_bytes() { return _ptypes_offset; }
jrose@1145 1195 };
jrose@1145 1196
jrose@1145 1197
jrose@2639 1198 // Interface to java.lang.invoke.CallSite objects
jrose@1161 1199
jrose@2639 1200 class java_lang_invoke_CallSite: AllStatic {
jrose@1161 1201 friend class JavaClasses;
jrose@1161 1202
jrose@1161 1203 private:
jrose@1161 1204 static int _target_offset;
jrose@1161 1205
jrose@1161 1206 static void compute_offsets();
jrose@1161 1207
jrose@1161 1208 public:
jrose@1161 1209 // Accessors
twisti@3131 1210 static oop target( oop site) { return site->obj_field( _target_offset); }
twisti@3131 1211 static void set_target( oop site, oop target) { site->obj_field_put( _target_offset, target); }
jrose@1161 1212
lfoltan@9314 1213 static volatile oop target_volatile(oop site) { return oop((oopDesc *)(site->obj_field_volatile(_target_offset))); }
twisti@3131 1214 static void set_target_volatile(oop site, oop target) { site->obj_field_put_volatile(_target_offset, target); }
jrose@1862 1215
twisti@1570 1216 // Testers
coleenp@4037 1217 static bool is_subclass(Klass* klass) {
hseigel@4278 1218 return klass->is_subclass_of(SystemDictionary::CallSite_klass());
twisti@1570 1219 }
twisti@1570 1220 static bool is_instance(oop obj) {
twisti@1570 1221 return obj != NULL && is_subclass(obj->klass());
twisti@1570 1222 }
twisti@1570 1223
jrose@1161 1224 // Accessors for code generation:
jrose@1161 1225 static int target_offset_in_bytes() { return _target_offset; }
jrose@1161 1226 };
jrose@1145 1227
jrose@1145 1228
duke@435 1229 // Interface to java.security.AccessControlContext objects
duke@435 1230
duke@435 1231 class java_security_AccessControlContext: AllStatic {
duke@435 1232 private:
duke@435 1233 // Note that for this class the layout changed between JDK1.2 and JDK1.3,
duke@435 1234 // so we compute the offsets at startup rather than hard-wiring them.
duke@435 1235 static int _context_offset;
duke@435 1236 static int _privilegedContext_offset;
duke@435 1237 static int _isPrivileged_offset;
mullan@5242 1238 static int _isAuthorized_offset;
duke@435 1239
duke@435 1240 static void compute_offsets();
duke@435 1241 public:
duke@435 1242 static oop create(objArrayHandle context, bool isPrivileged, Handle privileged_context, TRAPS);
duke@435 1243
mullan@5242 1244 static bool is_authorized(Handle context);
mullan@5242 1245
duke@435 1246 // Debugging/initialization
duke@435 1247 friend class JavaClasses;
duke@435 1248 };
duke@435 1249
duke@435 1250
duke@435 1251 // Interface to java.lang.ClassLoader objects
duke@435 1252
coleenp@4037 1253 #define CLASSLOADER_INJECTED_FIELDS(macro) \
coleenp@4304 1254 macro(java_lang_ClassLoader, loader_data, intptr_signature, false)
coleenp@4037 1255
duke@435 1256 class java_lang_ClassLoader : AllStatic {
duke@435 1257 private:
coleenp@4037 1258 // The fake offsets are added by the class loader when java.lang.Class is loaded
duke@435 1259 enum {
duke@435 1260 hc_parent_offset = 0
duke@435 1261 };
coleenp@4037 1262 static int _loader_data_offset;
never@3137 1263 static bool offsets_computed;
duke@435 1264 static int parent_offset;
never@3137 1265 static int parallelCapable_offset;
never@3137 1266
coleenp@4037 1267 public:
never@3137 1268 static void compute_offsets();
duke@435 1269
coleenp@4037 1270 static ClassLoaderData** loader_data_addr(oop loader);
coleenp@4037 1271 static ClassLoaderData* loader_data(oop loader);
coleenp@4037 1272
duke@435 1273 static oop parent(oop loader);
twisti@3969 1274 static bool isAncestor(oop loader, oop cl);
duke@435 1275
never@3137 1276 // Support for parallelCapable field
never@3137 1277 static bool parallelCapable(oop the_class_mirror);
never@3137 1278
duke@435 1279 static bool is_trusted_loader(oop loader);
duke@435 1280
duke@435 1281 // Fix for 4474172
duke@435 1282 static oop non_reflection_class_loader(oop loader);
duke@435 1283
twisti@3969 1284 // Testers
coleenp@4037 1285 static bool is_subclass(Klass* klass) {
hseigel@4278 1286 return klass->is_subclass_of(SystemDictionary::ClassLoader_klass());
twisti@3969 1287 }
twisti@3969 1288 static bool is_instance(oop obj) {
twisti@3969 1289 return obj != NULL && is_subclass(obj->klass());
twisti@3969 1290 }
twisti@3969 1291
duke@435 1292 // Debugging
duke@435 1293 friend class JavaClasses;
coleenp@4037 1294 friend class ClassFileParser; // access to number_of_fake_fields
duke@435 1295 };
duke@435 1296
duke@435 1297
duke@435 1298 // Interface to java.lang.System objects
duke@435 1299
duke@435 1300 class java_lang_System : AllStatic {
duke@435 1301 private:
duke@435 1302 enum {
duke@435 1303 hc_static_in_offset = 0,
duke@435 1304 hc_static_out_offset = 1,
mullan@5242 1305 hc_static_err_offset = 2,
mullan@5242 1306 hc_static_security_offset = 3
duke@435 1307 };
duke@435 1308
duke@435 1309 static int static_in_offset;
duke@435 1310 static int static_out_offset;
duke@435 1311 static int static_err_offset;
mullan@5242 1312 static int static_security_offset;
duke@435 1313
duke@435 1314 public:
duke@435 1315 static int in_offset_in_bytes();
duke@435 1316 static int out_offset_in_bytes();
duke@435 1317 static int err_offset_in_bytes();
duke@435 1318
mullan@5242 1319 static bool has_security_manager();
mullan@5242 1320
duke@435 1321 // Debugging
duke@435 1322 friend class JavaClasses;
duke@435 1323 };
duke@435 1324
duke@435 1325
duke@435 1326 // Interface to java.lang.StackTraceElement objects
duke@435 1327
duke@435 1328 class java_lang_StackTraceElement: AllStatic {
duke@435 1329 private:
duke@435 1330 enum {
duke@435 1331 hc_declaringClass_offset = 0,
duke@435 1332 hc_methodName_offset = 1,
duke@435 1333 hc_fileName_offset = 2,
duke@435 1334 hc_lineNumber_offset = 3
duke@435 1335 };
duke@435 1336
duke@435 1337 static int declaringClass_offset;
duke@435 1338 static int methodName_offset;
duke@435 1339 static int fileName_offset;
duke@435 1340 static int lineNumber_offset;
duke@435 1341
duke@435 1342 public:
duke@435 1343 // Setters
duke@435 1344 static void set_declaringClass(oop element, oop value);
duke@435 1345 static void set_methodName(oop element, oop value);
duke@435 1346 static void set_fileName(oop element, oop value);
duke@435 1347 static void set_lineNumber(oop element, int value);
duke@435 1348
duke@435 1349 // Create an instance of StackTraceElement
sspitsyn@7683 1350 static oop create(Handle mirror, int method, int version, int bci, int cpref, TRAPS);
coleenp@4466 1351 static oop create(methodHandle method, int bci, TRAPS);
duke@435 1352
duke@435 1353 // Debugging
duke@435 1354 friend class JavaClasses;
duke@435 1355 };
duke@435 1356
duke@435 1357
duke@435 1358 // Interface to java.lang.AssertionStatusDirectives objects
duke@435 1359
duke@435 1360 class java_lang_AssertionStatusDirectives: AllStatic {
duke@435 1361 private:
duke@435 1362 enum {
duke@435 1363 hc_classes_offset,
duke@435 1364 hc_classEnabled_offset,
duke@435 1365 hc_packages_offset,
duke@435 1366 hc_packageEnabled_offset,
duke@435 1367 hc_deflt_offset
duke@435 1368 };
duke@435 1369
duke@435 1370 static int classes_offset;
duke@435 1371 static int classEnabled_offset;
duke@435 1372 static int packages_offset;
duke@435 1373 static int packageEnabled_offset;
duke@435 1374 static int deflt_offset;
duke@435 1375
duke@435 1376 public:
duke@435 1377 // Setters
duke@435 1378 static void set_classes(oop obj, oop val);
duke@435 1379 static void set_classEnabled(oop obj, oop val);
duke@435 1380 static void set_packages(oop obj, oop val);
duke@435 1381 static void set_packageEnabled(oop obj, oop val);
duke@435 1382 static void set_deflt(oop obj, bool val);
duke@435 1383 // Debugging
duke@435 1384 friend class JavaClasses;
duke@435 1385 };
duke@435 1386
duke@435 1387
duke@435 1388 class java_nio_Buffer: AllStatic {
duke@435 1389 private:
duke@435 1390 static int _limit_offset;
duke@435 1391
duke@435 1392 public:
duke@435 1393 static int limit_offset();
duke@435 1394 static void compute_offsets();
duke@435 1395 };
duke@435 1396
duke@435 1397 class java_util_concurrent_locks_AbstractOwnableSynchronizer : AllStatic {
duke@435 1398 private:
duke@435 1399 static int _owner_offset;
duke@435 1400 public:
duke@435 1401 static void initialize(TRAPS);
duke@435 1402 static oop get_owner_threadObj(oop obj);
duke@435 1403 };
duke@435 1404
never@3137 1405 // Use to declare fields that need to be injected into Java classes
never@3137 1406 // for the JVM to use. The name_index and signature_index are
never@3137 1407 // declared in vmSymbols. The may_be_java flag is used to declare
never@3137 1408 // fields that might already exist in Java but should be injected if
never@3137 1409 // they don't. Otherwise the field is unconditionally injected and
never@3137 1410 // the JVM uses the injected one. This is to ensure that name
never@3137 1411 // collisions don't occur. In general may_be_java should be false
never@3137 1412 // unless there's a good reason.
never@3137 1413
never@3137 1414 class InjectedField {
never@3137 1415 public:
never@3137 1416 const SystemDictionary::WKID klass_id;
never@3137 1417 const vmSymbols::SID name_index;
never@3137 1418 const vmSymbols::SID signature_index;
never@3137 1419 const bool may_be_java;
never@3137 1420
never@3137 1421
coleenp@4037 1422 Klass* klass() const { return SystemDictionary::well_known_klass(klass_id); }
never@3137 1423 Symbol* name() const { return lookup_symbol(name_index); }
never@3137 1424 Symbol* signature() const { return lookup_symbol(signature_index); }
never@3137 1425
never@3137 1426 int compute_offset();
never@3137 1427
never@3137 1428 // Find the Symbol for this index
never@3137 1429 static Symbol* lookup_symbol(int symbol_index) {
never@3137 1430 return vmSymbols::symbol_at((vmSymbols::SID)symbol_index);
never@3137 1431 }
never@3137 1432 };
never@3137 1433
never@3137 1434 #define DECLARE_INJECTED_FIELD_ENUM(klass, name, signature, may_be_java) \
never@3137 1435 klass##_##name##_enum,
never@3137 1436
never@3137 1437 #define ALL_INJECTED_FIELDS(macro) \
never@3137 1438 CLASS_INJECTED_FIELDS(macro) \
coleenp@4037 1439 CLASSLOADER_INJECTED_FIELDS(macro) \
twisti@3969 1440 MEMBERNAME_INJECTED_FIELDS(macro)
never@3137 1441
duke@435 1442 // Interface to hard-coded offset checking
duke@435 1443
duke@435 1444 class JavaClasses : AllStatic {
duke@435 1445 private:
never@3137 1446
never@3137 1447 static InjectedField _injected_fields[];
never@3137 1448
duke@435 1449 static bool check_offset(const char *klass_name, int offset, const char *field_name, const char* field_sig) PRODUCT_RETURN0;
duke@435 1450 static bool check_static_offset(const char *klass_name, int hardcoded_offset, const char *field_name, const char* field_sig) PRODUCT_RETURN0;
jrose@567 1451 static bool check_constant(const char *klass_name, int constant, const char *field_name, const char* field_sig) PRODUCT_RETURN0;
never@3137 1452
duke@435 1453 public:
never@3137 1454 enum InjectedFieldID {
never@3137 1455 ALL_INJECTED_FIELDS(DECLARE_INJECTED_FIELD_ENUM)
never@3137 1456 MAX_enum
never@3137 1457 };
never@3137 1458
never@3137 1459 static int compute_injected_offset(InjectedFieldID id);
never@3137 1460
duke@435 1461 static void compute_hard_coded_offsets();
duke@435 1462 static void compute_offsets();
duke@435 1463 static void check_offsets() PRODUCT_RETURN;
never@3137 1464
never@3137 1465 static InjectedField* get_injected(Symbol* class_name, int* field_count);
duke@435 1466 };
stefank@2314 1467
never@3137 1468 #undef DECLARE_INJECTED_FIELD_ENUM
never@3137 1469
stefank@2314 1470 #endif // SHARE_VM_CLASSFILE_JAVACLASSES_HPP

mercurial