62 |
62 |
63 static void trace_class_resolution_impl(klassOop to_class, TRAPS) { |
63 static void trace_class_resolution_impl(klassOop to_class, TRAPS) { |
64 ResourceMark rm; |
64 ResourceMark rm; |
65 int line_number = -1; |
65 int line_number = -1; |
66 const char * source_file = NULL; |
66 const char * source_file = NULL; |
|
67 const char * trace = "explicit"; |
67 klassOop caller = NULL; |
68 klassOop caller = NULL; |
68 JavaThread* jthread = JavaThread::current(); |
69 JavaThread* jthread = JavaThread::current(); |
69 if (jthread->has_last_Java_frame()) { |
70 if (jthread->has_last_Java_frame()) { |
70 vframeStream vfst(jthread); |
71 vframeStream vfst(jthread); |
71 |
72 |
105 instanceKlass::cast(last_caller->method_holder())->name() == |
106 instanceKlass::cast(last_caller->method_holder())->name() == |
106 vmSymbols::java_lang_ClassLoader() && |
107 vmSymbols::java_lang_ClassLoader() && |
107 (last_caller->name() == vmSymbols::loadClassInternal_name() || |
108 (last_caller->name() == vmSymbols::loadClassInternal_name() || |
108 last_caller->name() == vmSymbols::loadClass_name())) { |
109 last_caller->name() == vmSymbols::loadClass_name())) { |
109 found_it = true; |
110 found_it = true; |
|
111 } else if (!vfst.at_end()) { |
|
112 if (vfst.method()->is_native()) { |
|
113 // JNI call |
|
114 found_it = true; |
|
115 } |
110 } |
116 } |
111 if (found_it && !vfst.at_end()) { |
117 if (found_it && !vfst.at_end()) { |
112 // found the caller |
118 // found the caller |
113 caller = vfst.method()->method_holder(); |
119 caller = vfst.method()->method_holder(); |
114 line_number = vfst.method()->line_number_from_bci(vfst.bci()); |
120 line_number = vfst.method()->line_number_from_bci(vfst.bci()); |
115 symbolOop s = instanceKlass::cast(vfst.method()->method_holder())->source_file_name(); |
121 if (line_number == -1) { |
|
122 // show method name if it's a native method |
|
123 trace = vfst.method()->name_and_sig_as_C_string(); |
|
124 } |
|
125 symbolOop s = instanceKlass::cast(caller)->source_file_name(); |
116 if (s != NULL) { |
126 if (s != NULL) { |
117 source_file = s->as_C_string(); |
127 source_file = s->as_C_string(); |
118 } |
128 } |
119 } |
129 } |
120 } |
130 } |
122 if (to_class != caller) { |
132 if (to_class != caller) { |
123 const char * from = Klass::cast(caller)->external_name(); |
133 const char * from = Klass::cast(caller)->external_name(); |
124 const char * to = Klass::cast(to_class)->external_name(); |
134 const char * to = Klass::cast(to_class)->external_name(); |
125 // print in a single call to reduce interleaving between threads |
135 // print in a single call to reduce interleaving between threads |
126 if (source_file != NULL) { |
136 if (source_file != NULL) { |
127 tty->print("RESOLVE %s %s %s:%d (explicit)\n", from, to, source_file, line_number); |
137 tty->print("RESOLVE %s %s %s:%d (%s)\n", from, to, source_file, line_number, trace); |
128 } else { |
138 } else { |
129 tty->print("RESOLVE %s %s (explicit)\n", from, to); |
139 tty->print("RESOLVE %s %s (%s)\n", from, to, trace); |
130 } |
140 } |
131 } |
141 } |
132 } |
142 } |
133 } |
143 } |
134 |
144 |
135 static void trace_class_resolution(klassOop to_class) { |
145 void trace_class_resolution(klassOop to_class) { |
136 EXCEPTION_MARK; |
146 EXCEPTION_MARK; |
137 trace_class_resolution_impl(to_class, THREAD); |
147 trace_class_resolution_impl(to_class, THREAD); |
138 if (HAS_PENDING_EXCEPTION) { |
148 if (HAS_PENDING_EXCEPTION) { |
139 CLEAR_PENDING_EXCEPTION; |
149 CLEAR_PENDING_EXCEPTION; |
140 } |
150 } |
3211 loader = instanceKlass::cast(curr_klass_oop)->class_loader(); |
3221 loader = instanceKlass::cast(curr_klass_oop)->class_loader(); |
3212 protection_domain = instanceKlass::cast(curr_klass_oop)->protection_domain(); |
3222 protection_domain = instanceKlass::cast(curr_klass_oop)->protection_domain(); |
3213 } |
3223 } |
3214 Handle h_loader(THREAD, loader); |
3224 Handle h_loader(THREAD, loader); |
3215 Handle h_prot (THREAD, protection_domain); |
3225 Handle h_prot (THREAD, protection_domain); |
3216 return find_class_from_class_loader(env, name, true, h_loader, h_prot, |
3226 jclass result = find_class_from_class_loader(env, name, true, h_loader, h_prot, |
3217 false, thread); |
3227 false, thread); |
|
3228 if (TraceClassResolution && result != NULL) { |
|
3229 trace_class_resolution(java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(result))); |
|
3230 } |
|
3231 return result; |
3218 JVM_END |
3232 JVM_END |
3219 |
3233 |
3220 |
3234 |
3221 // Array /////////////////////////////////////////////////////////////////////////////////////////// |
3235 // Array /////////////////////////////////////////////////////////////////////////////////////////// |
3222 |
3236 |