< prev index next >

src/hotspot/share/interpreter/bytecodeUtils.cpp

Print this page
*** 1109,10 ***
--- 1109,11 ---
      case Bytecodes::_getfield:
      case Bytecodes::_arraylength:
      case Bytecodes::_athrow:
      case Bytecodes::_monitorenter:
      case Bytecodes::_monitorexit:
+     case Bytecodes::_checkcast:
        return 0;
      case Bytecodes::_iaload:
      case Bytecodes::_faload:
      case Bytecodes::_aaload:
      case Bytecodes::_baload:

*** 1169,11 ***
    return INVALID_BYTECODE_ENCOUNTERED;
  }
  
  bool ExceptionMessageBuilder::print_NPE_cause(outputStream* os, int bci, int slot) {
    if (print_NPE_cause0(os, bci, slot, _max_cause_detail, false, " because \"")) {
!     os->print("\" is null");
      return true;
    }
    return false;
  }
  
--- 1170,17 ---
    return INVALID_BYTECODE_ENCOUNTERED;
  }
  
  bool ExceptionMessageBuilder::print_NPE_cause(outputStream* os, int bci, int slot) {
    if (print_NPE_cause0(os, bci, slot, _max_cause_detail, false, " because \"")) {
!     address code_base = _method->constMethod()->code_base();
+     Bytecodes::Code code = Bytecodes::java_code_at(_method, code_base + bci);
+     if (code == Bytecodes::_aastore) {
+       os->print("\" is null or is a null-free array and there's an attempt to store null in it");
+     } else {
+       os->print("\" is null");
+     }
      return true;
    }
    return false;
  }
  

*** 1431,10 ***
--- 1438,15 ---
          int cp_index = Bytes::get_native_u2(code_base+ pos);
          os->print("Cannot invoke \"");
          print_method_name(os, _method, cp_index, code);
          os->print("\"");
        } break;
+     case Bytecodes::_checkcast: {
+         int cp_index = Bytes::get_Java_u2(code_base + pos);
+         ConstantPool* cp = _method->constants();
+         os->print("Cannot cast to null-free type \"%s\"", cp->klass_at_noresolve(cp_index)->as_C_string());
+       } break;
  
      default:
        assert(0, "We should have checked this bytecode in get_NPE_null_slot().");
        break;
    }
< prev index next >