comparison src/share/vm/classfile/verifier.cpp @ 20204:d22136881b85

Merge
author robm
date Thu, 17 Jul 2014 18:03:26 +0100
parents ce8f6bb717c9 d6fcbd1e1075
children d14a18794c90
comparison
equal deleted inserted replaced
20203:4ca77b815015 20204:d22136881b85
631 631
632 // Scan the byte code linearly from the start to the end 632 // Scan the byte code linearly from the start to the end
633 bool no_control_flow = false; // Set to true when there is no direct control 633 bool no_control_flow = false; // Set to true when there is no direct control
634 // flow from current instruction to the next 634 // flow from current instruction to the next
635 // instruction in sequence 635 // instruction in sequence
636
637 set_furthest_jump(0);
638
636 Bytecodes::Code opcode; 639 Bytecodes::Code opcode;
637 while (!bcs.is_last_bytecode()) { 640 while (!bcs.is_last_bytecode()) {
638 // Check for recursive re-verification before each bytecode. 641 // Check for recursive re-verification before each bytecode.
639 if (was_recursively_verified()) return; 642 if (was_recursively_verified()) return;
640 643
2246 TypeOrigin::implicit(ref_class_type), 2249 TypeOrigin::implicit(ref_class_type),
2247 TypeOrigin::implicit(current_type())), 2250 TypeOrigin::implicit(current_type())),
2248 "Bad <init> method call"); 2251 "Bad <init> method call");
2249 return; 2252 return;
2250 } 2253 }
2254
2255 // Make sure that this call is not jumped over.
2256 if (bci < furthest_jump()) {
2257 verify_error(ErrorContext::bad_code(bci),
2258 "Bad <init> method call from inside of a branch");
2259 return;
2260 }
2261
2262 // Make sure that this call is not done from within a TRY block because
2263 // that can result in returning an incomplete object. Simply checking
2264 // (bci >= start_pc) also ensures that this call is not done after a TRY
2265 // block. That is also illegal because this call must be the first Java
2266 // statement in the constructor.
2267 ExceptionTable exhandlers(_method());
2268 int exlength = exhandlers.length();
2269 for(int i = 0; i < exlength; i++) {
2270 if (bci >= exhandlers.start_pc(i)) {
2271 verify_error(ErrorContext::bad_code(bci),
2272 "Bad <init> method call from after the start of a try block");
2273 return;
2274 }
2275 }
2276
2251 current_frame->initialize_object(type, current_type()); 2277 current_frame->initialize_object(type, current_type());
2252 *this_uninit = true; 2278 *this_uninit = true;
2253 } else if (type.is_uninitialized()) { 2279 } else if (type.is_uninitialized()) {
2254 u2 new_offset = type.bci(); 2280 u2 new_offset = type.bci();
2255 address new_bcp = bcs->bcp() - bci + new_offset; 2281 address new_bcp = bcs->bcp() - bci + new_offset;
2281 if (name_in_supers(ref_class_type.name(), current_class())) { 2307 if (name_in_supers(ref_class_type.name(), current_class())) {
2282 Klass* ref_klass = load_class( 2308 Klass* ref_klass = load_class(
2283 ref_class_type.name(), CHECK_VERIFY(this)); 2309 ref_class_type.name(), CHECK_VERIFY(this));
2284 Method* m = InstanceKlass::cast(ref_klass)->uncached_lookup_method( 2310 Method* m = InstanceKlass::cast(ref_klass)->uncached_lookup_method(
2285 vmSymbols::object_initializer_name(), 2311 vmSymbols::object_initializer_name(),
2286 cp->signature_ref_at(bcs->get_index_u2()), 2312 cp->signature_ref_at(bcs->get_index_u2()), Klass::normal);
2287 Klass::normal); 2313 // Do nothing if method is not found. Let resolution detect the error.
2288 instanceKlassHandle mh(THREAD, m->method_holder()); 2314 if (m != NULL) {
2289 if (m->is_protected() && !mh->is_same_class_package(_klass())) { 2315 instanceKlassHandle mh(THREAD, m->method_holder());
2290 bool assignable = current_type().is_assignable_from( 2316 if (m->is_protected() && !mh->is_same_class_package(_klass())) {
2291 objectref_type, this, CHECK_VERIFY(this)); 2317 bool assignable = current_type().is_assignable_from(
2292 if (!assignable) { 2318 objectref_type, this, CHECK_VERIFY(this));
2293 verify_error(ErrorContext::bad_type(bci, 2319 if (!assignable) {
2294 TypeOrigin::cp(new_class_index, objectref_type), 2320 verify_error(ErrorContext::bad_type(bci,
2295 TypeOrigin::implicit(current_type())), 2321 TypeOrigin::cp(new_class_index, objectref_type),
2296 "Bad access to protected <init> method"); 2322 TypeOrigin::implicit(current_type())),
2297 return; 2323 "Bad access to protected <init> method");
2324 return;
2325 }
2298 } 2326 }
2299 } 2327 }
2300 } 2328 }
2301 current_frame->initialize_object(type, new_class_type); 2329 current_frame->initialize_object(type, new_class_type);
2302 } else { 2330 } else {