Mercurial > hg > truffle
comparison src/share/vm/prims/jvm.cpp @ 6940:18fb7da42534
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
Summary: Change types of above methods and field to InstanceKlass and remove unneeded casts from the source files.
Reviewed-by: dholmes, coleenp, zgu
Contributed-by: harold.seigel@oracle.com
author | coleenp |
---|---|
date | Tue, 06 Nov 2012 15:09:37 -0500 |
parents | d8ce2825b193 |
children | 070d523b96a7 |
comparison
equal
deleted
inserted
replaced
6939:c284cf4781f0 | 6940:18fb7da42534 |
---|---|
123 static void trace_class_resolution_impl(Klass* to_class, TRAPS) { | 123 static void trace_class_resolution_impl(Klass* to_class, TRAPS) { |
124 ResourceMark rm; | 124 ResourceMark rm; |
125 int line_number = -1; | 125 int line_number = -1; |
126 const char * source_file = NULL; | 126 const char * source_file = NULL; |
127 const char * trace = "explicit"; | 127 const char * trace = "explicit"; |
128 Klass* caller = NULL; | 128 InstanceKlass* caller = NULL; |
129 JavaThread* jthread = JavaThread::current(); | 129 JavaThread* jthread = JavaThread::current(); |
130 if (jthread->has_last_Java_frame()) { | 130 if (jthread->has_last_Java_frame()) { |
131 vframeStream vfst(jthread); | 131 vframeStream vfst(jthread); |
132 | 132 |
133 // scan up the stack skipping ClassLoader, AccessController and PrivilegedAction frames | 133 // scan up the stack skipping ClassLoader, AccessController and PrivilegedAction frames |
151 // if this is called from Class.forName0 and that is called from Class.forName, | 151 // if this is called from Class.forName0 and that is called from Class.forName, |
152 // then print the caller of Class.forName. If this is Class.loadClass, then print | 152 // then print the caller of Class.forName. If this is Class.loadClass, then print |
153 // that caller, otherwise keep quiet since this should be picked up elsewhere. | 153 // that caller, otherwise keep quiet since this should be picked up elsewhere. |
154 bool found_it = false; | 154 bool found_it = false; |
155 if (!vfst.at_end() && | 155 if (!vfst.at_end() && |
156 InstanceKlass::cast(vfst.method()->method_holder())->name() == vmSymbols::java_lang_Class() && | 156 vfst.method()->method_holder()->name() == vmSymbols::java_lang_Class() && |
157 vfst.method()->name() == vmSymbols::forName0_name()) { | 157 vfst.method()->name() == vmSymbols::forName0_name()) { |
158 vfst.next(); | 158 vfst.next(); |
159 if (!vfst.at_end() && | 159 if (!vfst.at_end() && |
160 InstanceKlass::cast(vfst.method()->method_holder())->name() == vmSymbols::java_lang_Class() && | 160 vfst.method()->method_holder()->name() == vmSymbols::java_lang_Class() && |
161 vfst.method()->name() == vmSymbols::forName_name()) { | 161 vfst.method()->name() == vmSymbols::forName_name()) { |
162 vfst.next(); | 162 vfst.next(); |
163 found_it = true; | 163 found_it = true; |
164 } | 164 } |
165 } else if (last_caller != NULL && | 165 } else if (last_caller != NULL && |
166 InstanceKlass::cast(last_caller->method_holder())->name() == | 166 last_caller->method_holder()->name() == |
167 vmSymbols::java_lang_ClassLoader() && | 167 vmSymbols::java_lang_ClassLoader() && |
168 (last_caller->name() == vmSymbols::loadClassInternal_name() || | 168 (last_caller->name() == vmSymbols::loadClassInternal_name() || |
169 last_caller->name() == vmSymbols::loadClass_name())) { | 169 last_caller->name() == vmSymbols::loadClass_name())) { |
170 found_it = true; | 170 found_it = true; |
171 } else if (!vfst.at_end()) { | 171 } else if (!vfst.at_end()) { |
180 line_number = vfst.method()->line_number_from_bci(vfst.bci()); | 180 line_number = vfst.method()->line_number_from_bci(vfst.bci()); |
181 if (line_number == -1) { | 181 if (line_number == -1) { |
182 // show method name if it's a native method | 182 // show method name if it's a native method |
183 trace = vfst.method()->name_and_sig_as_C_string(); | 183 trace = vfst.method()->name_and_sig_as_C_string(); |
184 } | 184 } |
185 Symbol* s = InstanceKlass::cast(caller)->source_file_name(); | 185 Symbol* s = caller->source_file_name(); |
186 if (s != NULL) { | 186 if (s != NULL) { |
187 source_file = s->as_C_string(); | 187 source_file = s->as_C_string(); |
188 } | 188 } |
189 } | 189 } |
190 } | 190 } |
191 if (caller != NULL) { | 191 if (caller != NULL) { |
192 if (to_class != caller) { | 192 if (to_class != caller) { |
193 const char * from = Klass::cast(caller)->external_name(); | 193 const char * from = caller->external_name(); |
194 const char * to = Klass::cast(to_class)->external_name(); | 194 const char * to = to_class->external_name(); |
195 // print in a single call to reduce interleaving between threads | 195 // print in a single call to reduce interleaving between threads |
196 if (source_file != NULL) { | 196 if (source_file != NULL) { |
197 tty->print("RESOLVE %s %s %s:%d (%s)\n", from, to, source_file, line_number, trace); | 197 tty->print("RESOLVE %s %s %s:%d (%s)\n", from, to, source_file, line_number, trace); |
198 } else { | 198 } else { |
199 tty->print("RESOLVE %s %s (%s)\n", from, to, trace); | 199 tty->print("RESOLVE %s %s (%s)\n", from, to, trace); |
1226 // this frame is privileged | 1226 // this frame is privileged |
1227 is_privileged = true; | 1227 is_privileged = true; |
1228 privileged_context = Handle(thread, thread->privileged_stack_top()->privileged_context()); | 1228 privileged_context = Handle(thread, thread->privileged_stack_top()->privileged_context()); |
1229 protection_domain = thread->privileged_stack_top()->protection_domain(); | 1229 protection_domain = thread->privileged_stack_top()->protection_domain(); |
1230 } else { | 1230 } else { |
1231 protection_domain = InstanceKlass::cast(method->method_holder())->protection_domain(); | 1231 protection_domain = method->method_holder()->protection_domain(); |
1232 } | 1232 } |
1233 | 1233 |
1234 if ((previous_protection_domain != protection_domain) && (protection_domain != NULL)) { | 1234 if ((previous_protection_domain != protection_domain) && (protection_domain != NULL)) { |
1235 local_array->push(protection_domain); | 1235 local_array->push(protection_domain); |
1236 previous_protection_domain = protection_domain; | 1236 previous_protection_domain = protection_domain; |
3046 bool trusted = is_trusted_frame(thread, &vfst); | 3046 bool trusted = is_trusted_frame(thread, &vfst); |
3047 if (trusted) return NULL; | 3047 if (trusted) return NULL; |
3048 | 3048 |
3049 Method* m = vfst.method(); | 3049 Method* m = vfst.method(); |
3050 if (!m->is_native()) { | 3050 if (!m->is_native()) { |
3051 Klass* holder = m->method_holder(); | 3051 InstanceKlass* holder = m->method_holder(); |
3052 oop loader = InstanceKlass::cast(holder)->class_loader(); | 3052 oop loader = holder->class_loader(); |
3053 if (loader != NULL && !java_lang_ClassLoader::is_trusted_loader(loader)) { | 3053 if (loader != NULL && !java_lang_ClassLoader::is_trusted_loader(loader)) { |
3054 return (jclass) JNIHandles::make_local(env, Klass::cast(holder)->java_mirror()); | 3054 return (jclass) JNIHandles::make_local(env, holder->java_mirror()); |
3055 } | 3055 } |
3056 } | 3056 } |
3057 } | 3057 } |
3058 return NULL; | 3058 return NULL; |
3059 JVM_END | 3059 JVM_END |
3069 bool trusted = is_trusted_frame(thread, &vfst); | 3069 bool trusted = is_trusted_frame(thread, &vfst); |
3070 if (trusted) return NULL; | 3070 if (trusted) return NULL; |
3071 | 3071 |
3072 Method* m = vfst.method(); | 3072 Method* m = vfst.method(); |
3073 if (!m->is_native()) { | 3073 if (!m->is_native()) { |
3074 Klass* holder = m->method_holder(); | 3074 InstanceKlass* holder = m->method_holder(); |
3075 assert(holder->is_klass(), "just checking"); | 3075 assert(holder->is_klass(), "just checking"); |
3076 oop loader = InstanceKlass::cast(holder)->class_loader(); | 3076 oop loader = holder->class_loader(); |
3077 if (loader != NULL && !java_lang_ClassLoader::is_trusted_loader(loader)) { | 3077 if (loader != NULL && !java_lang_ClassLoader::is_trusted_loader(loader)) { |
3078 return JNIHandles::make_local(env, loader); | 3078 return JNIHandles::make_local(env, loader); |
3079 } | 3079 } |
3080 } | 3080 } |
3081 } | 3081 } |
3146 | 3146 |
3147 int depth = 0; | 3147 int depth = 0; |
3148 | 3148 |
3149 for(vframeStream vfst(thread); !vfst.at_end(); vfst.next()) { | 3149 for(vframeStream vfst(thread); !vfst.at_end(); vfst.next()) { |
3150 if (!vfst.method()->is_native()) { | 3150 if (!vfst.method()->is_native()) { |
3151 Klass* holder = vfst.method()->method_holder(); | 3151 InstanceKlass* holder = vfst.method()->method_holder(); |
3152 assert(holder->is_klass(), "just checking"); | 3152 assert(holder->is_klass(), "just checking"); |
3153 if (InstanceKlass::cast(holder)->name() == class_name_sym) { | 3153 if (holder->name() == class_name_sym) { |
3154 return depth; | 3154 return depth; |
3155 } | 3155 } |
3156 depth++; | 3156 depth++; |
3157 } | 3157 } |
3158 } | 3158 } |
3169 bool trusted = is_trusted_frame(thread, &vfst); | 3169 bool trusted = is_trusted_frame(thread, &vfst); |
3170 if (trusted) return -1; | 3170 if (trusted) return -1; |
3171 | 3171 |
3172 Method* m = vfst.method(); | 3172 Method* m = vfst.method(); |
3173 if (!m->is_native()) { | 3173 if (!m->is_native()) { |
3174 Klass* holder = m->method_holder(); | 3174 InstanceKlass* holder = m->method_holder(); |
3175 assert(holder->is_klass(), "just checking"); | 3175 assert(holder->is_klass(), "just checking"); |
3176 oop loader = InstanceKlass::cast(holder)->class_loader(); | 3176 oop loader = holder->class_loader(); |
3177 if (loader != NULL && !java_lang_ClassLoader::is_trusted_loader(loader)) { | 3177 if (loader != NULL && !java_lang_ClassLoader::is_trusted_loader(loader)) { |
3178 return depth; | 3178 return depth; |
3179 } | 3179 } |
3180 depth++; | 3180 depth++; |
3181 } | 3181 } |
3320 | 3320 |
3321 JVM_ENTRY(jobject, JVM_LatestUserDefinedLoader(JNIEnv *env)) | 3321 JVM_ENTRY(jobject, JVM_LatestUserDefinedLoader(JNIEnv *env)) |
3322 for (vframeStream vfst(thread); !vfst.at_end(); vfst.next()) { | 3322 for (vframeStream vfst(thread); !vfst.at_end(); vfst.next()) { |
3323 // UseNewReflection | 3323 // UseNewReflection |
3324 vfst.skip_reflection_related_frames(); // Only needed for 1.4 reflection | 3324 vfst.skip_reflection_related_frames(); // Only needed for 1.4 reflection |
3325 Klass* holder = vfst.method()->method_holder(); | 3325 oop loader = vfst.method()->method_holder()->class_loader(); |
3326 oop loader = InstanceKlass::cast(holder)->class_loader(); | |
3327 if (loader != NULL) { | 3326 if (loader != NULL) { |
3328 return JNIHandles::make_local(env, loader); | 3327 return JNIHandles::make_local(env, loader); |
3329 } | 3328 } |
3330 } | 3329 } |
3331 return NULL; | 3330 return NULL; |
3363 if (curr_klass.is_null()) { | 3362 if (curr_klass.is_null()) { |
3364 for (vframeStream vfst(thread); | 3363 for (vframeStream vfst(thread); |
3365 !vfst.at_end() && loader == NULL; | 3364 !vfst.at_end() && loader == NULL; |
3366 vfst.next()) { | 3365 vfst.next()) { |
3367 if (!vfst.method()->is_native()) { | 3366 if (!vfst.method()->is_native()) { |
3368 Klass* holder = vfst.method()->method_holder(); | 3367 InstanceKlass* holder = vfst.method()->method_holder(); |
3369 loader = InstanceKlass::cast(holder)->class_loader(); | 3368 loader = holder->class_loader(); |
3370 protection_domain = InstanceKlass::cast(holder)->protection_domain(); | 3369 protection_domain = holder->protection_domain(); |
3371 } | 3370 } |
3372 } | 3371 } |
3373 } else { | 3372 } else { |
3374 Klass* curr_klass_oop = java_lang_Class::as_Klass(curr_klass()); | 3373 Klass* curr_klass_oop = java_lang_Class::as_Klass(curr_klass()); |
3375 loader = InstanceKlass::cast(curr_klass_oop)->class_loader(); | 3374 loader = InstanceKlass::cast(curr_klass_oop)->class_loader(); |