1 HANDLE_OPCODE(OP_CHECK_CAST /*vAA, class@BBBB*/) 2 { 3 ClassObject* clazz; 4 Object* obj; 5 6 EXPORT_PC(); 7 8 vsrc1 = INST_AA(inst); 9 ref = FETCH(1); /* class to check against */ 10 ILOGV("|check-cast v%d,class@0x%04x", vsrc1, ref); 11 12 obj = (Object*)GET_REGISTER(vsrc1); 13 if (obj != NULL) { 14 #if defined(WITH_EXTRA_OBJECT_VALIDATION) 15 if (!checkForNull(obj)) 16 GOTO_exceptionThrown(); 17 #endif 18 clazz = dvmDexGetResolvedClass(methodClassDex, ref); 19 if (clazz == NULL) { 20 clazz = dvmResolveClass(curMethod->clazz, ref, false); 21 if (clazz == NULL) 22 GOTO_exceptionThrown(); 23 } 24 if (!dvmInstanceof(obj->clazz, clazz)) { 25 dvmThrowClassCastException(obj->clazz, clazz); 26 GOTO_exceptionThrown(); 27 } 28 } 29 } 30 FINISH(2); 31 OP_END 32