comparison src/share/vm/classfile/verifier.cpp @ 18007:364b73402247

Merge
author asaha
date Thu, 22 May 2014 11:09:06 -0700
parents 386dd1c71858 b5ae226b7516
children f73af4455d7d
comparison
equal deleted inserted replaced
17920:382a82b0a3e7 18007:364b73402247
630 630
631 // Scan the byte code linearly from the start to the end 631 // Scan the byte code linearly from the start to the end
632 bool no_control_flow = false; // Set to true when there is no direct control 632 bool no_control_flow = false; // Set to true when there is no direct control
633 // flow from current instruction to the next 633 // flow from current instruction to the next
634 // instruction in sequence 634 // instruction in sequence
635
636 set_furthest_jump(0);
637
635 Bytecodes::Code opcode; 638 Bytecodes::Code opcode;
636 while (!bcs.is_last_bytecode()) { 639 while (!bcs.is_last_bytecode()) {
637 // Check for recursive re-verification before each bytecode. 640 // Check for recursive re-verification before each bytecode.
638 if (was_recursively_verified()) return; 641 if (was_recursively_verified()) return;
639 642
2243 TypeOrigin::implicit(ref_class_type), 2246 TypeOrigin::implicit(ref_class_type),
2244 TypeOrigin::implicit(current_type())), 2247 TypeOrigin::implicit(current_type())),
2245 "Bad <init> method call"); 2248 "Bad <init> method call");
2246 return; 2249 return;
2247 } 2250 }
2251
2252 // Make sure that this call is not jumped over.
2253 if (bci < furthest_jump()) {
2254 verify_error(ErrorContext::bad_code(bci),
2255 "Bad <init> method call from inside of a branch");
2256 return;
2257 }
2258
2259 // Make sure that this call is not done from within a TRY block because
2260 // that can result in returning an incomplete object. Simply checking
2261 // (bci >= start_pc) also ensures that this call is not done after a TRY
2262 // block. That is also illegal because this call must be the first Java
2263 // statement in the constructor.
2264 ExceptionTable exhandlers(_method());
2265 int exlength = exhandlers.length();
2266 for(int i = 0; i < exlength; i++) {
2267 if (bci >= exhandlers.start_pc(i)) {
2268 verify_error(ErrorContext::bad_code(bci),
2269 "Bad <init> method call from after the start of a try block");
2270 return;
2271 }
2272 }
2273
2248 current_frame->initialize_object(type, current_type()); 2274 current_frame->initialize_object(type, current_type());
2249 *this_uninit = true; 2275 *this_uninit = true;
2250 } else if (type.is_uninitialized()) { 2276 } else if (type.is_uninitialized()) {
2251 u2 new_offset = type.bci(); 2277 u2 new_offset = type.bci();
2252 address new_bcp = bcs->bcp() - bci + new_offset; 2278 address new_bcp = bcs->bcp() - bci + new_offset;
2278 if (name_in_supers(ref_class_type.name(), current_class())) { 2304 if (name_in_supers(ref_class_type.name(), current_class())) {
2279 Klass* ref_klass = load_class( 2305 Klass* ref_klass = load_class(
2280 ref_class_type.name(), CHECK_VERIFY(this)); 2306 ref_class_type.name(), CHECK_VERIFY(this));
2281 Method* m = InstanceKlass::cast(ref_klass)->uncached_lookup_method( 2307 Method* m = InstanceKlass::cast(ref_klass)->uncached_lookup_method(
2282 vmSymbols::object_initializer_name(), 2308 vmSymbols::object_initializer_name(),
2283 cp->signature_ref_at(bcs->get_index_u2()), 2309 cp->signature_ref_at(bcs->get_index_u2()), Klass::normal);
2284 Klass::normal); 2310 if (m == NULL) {
2311 verify_error(ErrorContext::bad_code(bci),
2312 "Call to missing <init> method");
2313 return;
2314 }
2285 instanceKlassHandle mh(THREAD, m->method_holder()); 2315 instanceKlassHandle mh(THREAD, m->method_holder());
2286 if (m->is_protected() && !mh->is_same_class_package(_klass())) { 2316 if (m->is_protected() && !mh->is_same_class_package(_klass())) {
2287 bool assignable = current_type().is_assignable_from( 2317 bool assignable = current_type().is_assignable_from(
2288 objectref_type, this, CHECK_VERIFY(this)); 2318 objectref_type, this, CHECK_VERIFY(this));
2289 if (!assignable) { 2319 if (!assignable) {