src/share/vm/classfile/javaClasses.hpp

Tue, 09 Oct 2012 07:41:27 +0200

author
rbackman
date
Tue, 09 Oct 2012 07:41:27 +0200
changeset 4151
6e5a59a8e4a7
parent 4037
da91efe96a93
child 4267
bd7a7ce2e264
child 4278
070d523b96a7
permissions
-rw-r--r--

Merge

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

mercurial