Index: vm/vmcore/include/class_member.h =================================================================== --- vm/vmcore/include/class_member.h (revision 526675) +++ vm/vmcore/include/class_member.h (working copy) @@ -697,7 +697,7 @@ // // private methods for parsing methods // - bool _parse_code(ConstantPool& cp, unsigned code_attr_len, ByteReader &cfs); + bool _parse_code(Global_Env& env, ConstantPool& cp, unsigned code_attr_len, ByteReader &cfs); bool _parse_line_numbers(unsigned attr_len, ByteReader &cfs); Index: vm/vmcore/include/environment.h =================================================================== --- vm/vmcore/include/environment.h (revision 526675) +++ vm/vmcore/include/environment.h (working copy) @@ -72,6 +72,7 @@ bool retain_invisible_annotations; // retain InvisibleAnnotation and InvisibleParameterAnnotation bool verify_all; // Verify all classes including loaded by bootstrap class loader bool verify_strict; // Do strict verification + bool verify; // Verify if -Xverify:none or -noverify flags aren't set size_t system_page_size; // system page size according to use_large_pages value Lock_Manager *p_jit_a_method_lock; Index: vm/vmcore/src/class_support/Environment.cpp =================================================================== --- vm/vmcore/src/class_support/Environment.cpp (revision 526675) +++ vm/vmcore/src/class_support/Environment.cpp (working copy) @@ -140,6 +140,7 @@ verify_all = false; verify_strict = false; + verify = true; pin_interned_strings = false; retain_invisible_annotations = false; Index: vm/vmcore/src/class_support/Verifier_stub.cpp =================================================================== --- vm/vmcore/src/class_support/Verifier_stub.cpp (revision 526675) +++ vm/vmcore/src/class_support/Verifier_stub.cpp (working copy) @@ -53,7 +53,7 @@ Boolean is_forced = env->verify_all; Boolean is_strict = env->verify_strict; Boolean is_bootstrap = m_class_loader->IsBootstrap(); - Boolean is_enabled = get_boolean_property("vm.use_verifier", TRUE, VM_PROPERTIES); + Boolean is_enabled = env->verify; /** * Verify class Index: vm/vmcore/src/class_support/Class_File_Loader.cpp =================================================================== --- vm/vmcore/src/class_support/Class_File_Loader.cpp (revision 526730) +++ vm/vmcore/src/class_support/Class_File_Loader.cpp (working copy) @@ -23,6 +23,7 @@ #include "cxxlog.h" + #include "port_filepath.h" #include @@ -1455,7 +1456,7 @@ } //Method::_parse_local_vars -bool Method::_parse_code(ConstantPool& cp, unsigned code_attr_len, +bool Method::_parse_code(Global_Env& env, ConstantPool& cp, unsigned code_attr_len, ByteReader& cfs) { unsigned real_code_attr_len = 0; @@ -1625,45 +1626,54 @@ } case ATTR_LocalVariableTypeTable: { - uint16 n_local_vars; - if(!cfs.parse_u2_be(&n_local_vars)) { - REPORT_FAILED_METHOD("could not parse local variables number " - "of LocalVariableTypeTable attribute"); - return false; - } - unsigned lnt_attr_len = 2 + n_local_vars * 10; - if(lnt_attr_len != attr_len) { - REPORT_FAILED_METHOD("real LocalVariableTypeTable attribute length differ " - "from declared length (" - << attr_len << " vs. " << lnt_attr_len << ")" ); - return false; - } - if(n_local_vars == 0) break; + if(_class->get_version() < JAVA5_CLASS_FILE_VERSION) { + //skip this attribute for class files of version less than 49 + if (!cfs.skip(attr_len)) + { + REPORT_FAILED_METHOD("error skipping"); + return false; + } + } else { + uint16 n_local_vars; + if(!cfs.parse_u2_be(&n_local_vars)) { + REPORT_FAILED_METHOD("could not parse local variables number " + "of LocalVariableTypeTable attribute"); + return false; + } + unsigned lnt_attr_len = 2 + n_local_vars * 10; + if(lnt_attr_len != attr_len) { + REPORT_FAILED_METHOD("real LocalVariableTypeTable attribute length differ " + "from declared length (" + << attr_len << " vs. " << lnt_attr_len << ")" ); + return false; + } + if(n_local_vars == 0) break; - if(offset_lvtt_array == NULL){ - offset_lvtt_array = lvtt_iter = - (LocalVarOffset*)STD_ALLOCA(sizeof(LocalVarOffset) * n_local_vars); - } - else - { - lvtt_iter->next = (LocalVarOffset*)STD_ALLOCA(sizeof(LocalVarOffset) * n_local_vars); - lvtt_iter = lvtt_iter->next; - } - int off = cfs.get_offset(); - int j = 0; - for(j = 0; j < n_local_vars - 1; j++, lvtt_iter++) - { + if(offset_lvtt_array == NULL){ + offset_lvtt_array = lvtt_iter = + (LocalVarOffset*)STD_ALLOCA(sizeof(LocalVarOffset) * n_local_vars); + } + else + { + lvtt_iter->next = (LocalVarOffset*)STD_ALLOCA(sizeof(LocalVarOffset) * n_local_vars); + lvtt_iter = lvtt_iter->next; + } + int off = cfs.get_offset(); + int j = 0; + for(j = 0; j < n_local_vars - 1; j++, lvtt_iter++) + { + lvtt_iter->value = off + 10*j; + lvtt_iter->next = lvtt_iter + 1; + } lvtt_iter->value = off + 10*j; - lvtt_iter->next = lvtt_iter + 1; - } - lvtt_iter->value = off + 10*j; - lvtt_iter->next = NULL; - num_lvtt_entries += n_local_vars; + lvtt_iter->next = NULL; + num_lvtt_entries += n_local_vars; - if (!cfs.skip(10*n_local_vars)) - { - REPORT_FAILED_METHOD("error skipping"); - return false; + if (!cfs.skip(10*n_local_vars)) + { + REPORT_FAILED_METHOD("error skipping"); + return false; + } } break; } @@ -1695,11 +1705,13 @@ // we should remember this point to return here // after complete LVT and LVTT parsing. int return_point = cfs.get_offset(); - - if(num_lvt_entries == 0 && num_lvtt_entries != 0) { + + if(_class->get_version() >= JAVA5_CLASS_FILE_VERSION) { + if(num_lvt_entries == 0 && num_lvtt_entries != 0) { REPORT_FAILED_METHOD("if LocalVariableTable is empty " - "LocalVariableTypeTable must be empty too"); - return false; + "LocalVariableTypeTable must be empty too"); + return false; + } } if(num_lvt_entries != 0) { @@ -1710,12 +1722,11 @@ if(num_lvtt_entries != 0) { if( num_lvtt_entries < LV_ALLOCATION_THRESHOLD ){ - generic_vars = - (Local_Var_Table *)STD_ALLOCA(sizeof(Local_Var_Table) + - sizeof(Local_Var_Entry) * (num_lvtt_entries - 1)); + generic_vars = (Local_Var_Table *)STD_ALLOCA(sizeof(Local_Var_Table) + + sizeof(Local_Var_Entry) * (num_lvtt_entries - 1)); } else { generic_vars = (Local_Var_Table *)STD_MALLOC(sizeof(Local_Var_Table) + - sizeof(Local_Var_Entry) * (num_lvtt_entries - 1)); + sizeof(Local_Var_Entry) * (num_lvtt_entries - 1)); } generic_vars->length = num_lvtt_entries; } @@ -1751,25 +1762,20 @@ for (j = 0; j < lv_table->length; j++) { if (generic_vars->table[i].name == lv_table->table[j].name && generic_vars->table[i].start_pc == lv_table->table[j].start_pc - /* FIXME This is temporary solution. One broken class file - was found in eclipse plugin. RI loads this class successfully, DRLVM doesn't. - Tests show that this depends on classloader, so further evaluation is needed - to fix it permanently. */ - //&& generic_vars->table[i].length == lv_table->table[j].length + && generic_vars->table[i].length == lv_table->table[j].length && generic_vars->table[i].index == lv_table->table[j].index) { lv_table->table[j].generic_type = generic_vars->table[i].type; break; } } - if(j == lv_table->length) { + if(j == lv_table->length && env.verify) { String* gvi_name = generic_vars->table[i].name; REPORT_FAILED_METHOD("Element "<< gvi_name->bytes << " of LocalVariableTypeTable does not match any of LocalVariableTable entries"); failed = true; break; } - } if( num_lvtt_entries >= LV_ALLOCATION_THRESHOLD ){ STD_FREE(generic_vars); @@ -1996,7 +2002,7 @@ << " method should not have Code attribute present"); return false; } - if(!_parse_code(cp, attr_len, cfs)) + if(!_parse_code(env, cp, attr_len, cfs)) return false; break; Index: vm/vmcore/src/init/vm_init.cpp =================================================================== --- vm/vmcore/src/init/vm_init.cpp (revision 526675) +++ vm/vmcore/src/init/vm_init.cpp (working copy) @@ -653,6 +653,8 @@ parse_vm_arguments(vm_env); + vm_env->verify = get_boolean_property("vm.use_verifier", TRUE, VM_PROPERTIES); + // "Tool Interface" enabling. vm_env->TI->setExecutionMode(vm_env);