1213
1214
1215 JVM_ENTRY(jobject, JVM_GetStackAccessControlContext(JNIEnv *env, jclass cls))
1216 JVMWrapper("JVM_GetStackAccessControlContext");
1217 if (!UsePrivilegedStack) return NULL;
1218
1219 ResourceMark rm(THREAD);
1220 GrowableArray<oop>* local_array = new GrowableArray<oop>(12);
1221 JvmtiVMObjectAllocEventCollector oam;
1222
1223 // count the protection domains on the execution stack. We collapse
1224 // duplicate consecutive protection domains into a single one, as
1225 // well as stopping when we hit a privileged frame.
1226
1227 oop previous_protection_domain = NULL;
1228 Handle privileged_context(thread, NULL);
1229 bool is_privileged = false;
1230 oop protection_domain = NULL;
1231
1232 // Iterate through Java frames
1233 RegisterMap reg_map(thread);
1234 javaVFrame *vf = thread->last_java_vframe(®_map);
1235 for (; vf != NULL; vf = vf->java_sender()) {
1236 // get method of frame
1237 Method* method = vf->method();
1238
1239 // stop at the first privileged frame
1240 if (method->method_holder() == SystemDictionary::AccessController_klass() &&
1241 method->name() == vmSymbols::executePrivileged_name())
1242 {
1243 // this frame is privileged
1244 is_privileged = true;
1245
1246 javaVFrame *priv = vf; // executePrivileged
1247 javaVFrame *caller_fr = priv->java_sender(); // doPrivileged
1248 caller_fr = caller_fr->java_sender(); // caller
1249
1250 StackValueCollection* locals = priv->locals();
1251 privileged_context = locals->obj_at(1);
1252 Handle caller = locals->obj_at(2);
1253
1254 Klass *caller_klass = java_lang_Class::as_Klass(caller());
1255 protection_domain = caller_klass->protection_domain();
1256 } else {
1257 protection_domain = method->method_holder()->protection_domain();
1258 }
1259
1260 if ((!oopDesc::equals(previous_protection_domain, protection_domain)) && (protection_domain != NULL)) {
1261 local_array->push(protection_domain);
1262 previous_protection_domain = protection_domain;
1263 }
1264
1265 if (is_privileged) break;
1266 }
1267
1268
|
1213
1214
1215 JVM_ENTRY(jobject, JVM_GetStackAccessControlContext(JNIEnv *env, jclass cls))
1216 JVMWrapper("JVM_GetStackAccessControlContext");
1217 if (!UsePrivilegedStack) return NULL;
1218
1219 ResourceMark rm(THREAD);
1220 GrowableArray<oop>* local_array = new GrowableArray<oop>(12);
1221 JvmtiVMObjectAllocEventCollector oam;
1222
1223 // count the protection domains on the execution stack. We collapse
1224 // duplicate consecutive protection domains into a single one, as
1225 // well as stopping when we hit a privileged frame.
1226
1227 oop previous_protection_domain = NULL;
1228 Handle privileged_context(thread, NULL);
1229 bool is_privileged = false;
1230 oop protection_domain = NULL;
1231
1232 // Iterate through Java frames
1233 vframeStream vfst(thread);
1234 for(; !vfst.at_end(); vfst.next()) {
1235 // get method of frame
1236 Method* method = vfst.method();
1237
1238 // stop at the first privileged frame
1239 if (method->method_holder() == SystemDictionary::AccessController_klass() &&
1240 method->name() == vmSymbols::executePrivileged_name())
1241 {
1242 // this frame is privileged
1243 is_privileged = true;
1244
1245 javaVFrame *priv = vfst.asJavaVFrame(); // executePrivileged
1246
1247 StackValueCollection* locals = priv->locals();
1248 privileged_context = locals->obj_at(1);
1249 Handle caller = locals->obj_at(2);
1250
1251 Klass *caller_klass = java_lang_Class::as_Klass(caller());
1252 protection_domain = caller_klass->protection_domain();
1253 } else {
1254 protection_domain = method->method_holder()->protection_domain();
1255 }
1256
1257 if ((!oopDesc::equals(previous_protection_domain, protection_domain)) && (protection_domain != NULL)) {
1258 local_array->push(protection_domain);
1259 previous_protection_domain = protection_domain;
1260 }
1261
1262 if (is_privileged) break;
1263 }
1264
1265
|