comparison src/share/vm/classfile/verifier.cpp @ 1570:de91a2f25c7e

6956164: nightly regressions from 6939207 Summary: Fix errors in 6939207. Reviewed-by: kvn
author jrose
date Thu, 27 May 2010 09:54:07 -0700
parents ab102d5d923e
children e9ff18c4ace7
comparison
equal deleted inserted replaced
1569:f9a202dd8899 1570:de91a2f25c7e
252 252
253 objArrayHandle methods(THREAD, _klass->methods()); 253 objArrayHandle methods(THREAD, _klass->methods());
254 int num_methods = methods->length(); 254 int num_methods = methods->length();
255 255
256 for (int index = 0; index < num_methods; index++) { 256 for (int index = 0; index < num_methods; index++) {
257 // Check for recursive re-verification before each method.
258 if (was_recursively_verified()) return;
259
257 methodOop m = (methodOop)methods->obj_at(index); 260 methodOop m = (methodOop)methods->obj_at(index);
258 if (m->is_native() || m->is_abstract()) { 261 if (m->is_native() || m->is_abstract()) {
259 // If m is native or abstract, skip it. It is checked in class file 262 // If m is native or abstract, skip it. It is checked in class file
260 // parser that methods do not override a final method. 263 // parser that methods do not override a final method.
261 continue; 264 continue;
262 } 265 }
263 verify_method(methodHandle(THREAD, m), CHECK_VERIFY(this)); 266 verify_method(methodHandle(THREAD, m), CHECK_VERIFY(this));
267 }
268
269 if (_verify_verbose || TraceClassInitialization) {
270 if (was_recursively_verified())
271 tty->print_cr("Recursive verification detected for: %s",
272 _klass->external_name());
264 } 273 }
265 } 274 }
266 275
267 void ClassVerifier::verify_method(methodHandle m, TRAPS) { 276 void ClassVerifier::verify_method(methodHandle m, TRAPS) {
268 ResourceMark rm(THREAD); 277 ResourceMark rm(THREAD);
324 bool no_control_flow = false; // Set to true when there is no direct control 333 bool no_control_flow = false; // Set to true when there is no direct control
325 // flow from current instruction to the next 334 // flow from current instruction to the next
326 // instruction in sequence 335 // instruction in sequence
327 Bytecodes::Code opcode; 336 Bytecodes::Code opcode;
328 while (!bcs.is_last_bytecode()) { 337 while (!bcs.is_last_bytecode()) {
338 // Check for recursive re-verification before each bytecode.
339 if (was_recursively_verified()) return;
340
329 opcode = bcs.raw_next(); 341 opcode = bcs.raw_next();
330 u2 bci = bcs.bci(); 342 u2 bci = bcs.bci();
331 343
332 // Set current frame's offset to bci 344 // Set current frame's offset to bci
333 current_frame.set_offset(bci); 345 current_frame.set_offset(bci);
1468 void ClassVerifier::verify_cp_type( 1480 void ClassVerifier::verify_cp_type(
1469 int index, constantPoolHandle cp, unsigned int types, TRAPS) { 1481 int index, constantPoolHandle cp, unsigned int types, TRAPS) {
1470 1482
1471 // In some situations, bytecode rewriting may occur while we're verifying. 1483 // In some situations, bytecode rewriting may occur while we're verifying.
1472 // In this case, a constant pool cache exists and some indices refer to that 1484 // In this case, a constant pool cache exists and some indices refer to that
1473 // instead. Get the original index for the tag check 1485 // instead. Be sure we don't pick up such indices by accident.
1474 constantPoolCacheOop cache = cp->cache(); 1486 // We must check was_recursively_verified() before we get here.
1475 if (cache != NULL && 1487 guarantee(cp->cache() == NULL, "not rewritten yet");
1476 ((types == (1 << JVM_CONSTANT_InterfaceMethodref)) ||
1477 (types == (1 << JVM_CONSTANT_Methodref)) ||
1478 (types == (1 << JVM_CONSTANT_Fieldref)))) {
1479 int native_index = index;
1480 if (Bytes::is_Java_byte_ordering_different()) {
1481 native_index = Bytes::swap_u2(index);
1482 }
1483 assert((native_index >= 0) && (native_index < cache->length()),
1484 "Must be a legal index into the cp cache");
1485 index = cache->entry_at(native_index)->constant_pool_index();
1486 }
1487 1488
1488 verify_cp_index(cp, index, CHECK_VERIFY(this)); 1489 verify_cp_index(cp, index, CHECK_VERIFY(this));
1489 unsigned int tag = cp->tag_at(index).value(); 1490 unsigned int tag = cp->tag_at(index).value();
1490 if ((types & (1 << tag)) == 0) { 1491 if ((types & (1 << tag)) == 0) {
1491 verify_error( 1492 verify_error(