< prev index next >

src/hotspot/share/interpreter/bytecodeUtils.cpp

Print this page
@@ -978,10 +978,11 @@
        stack->pop(1 - Bytecodes::depth(code));
        stack->push(bci, Signature::basic_type(signature));
        break;
      }
  
+     case Bytecodes::_withfield:
      case Bytecodes::_putstatic:
      case Bytecodes::_putfield: {
        int cp_index = Bytes::get_native_u2(code_base + pos) DEBUG_ONLY(+ ConstantPool::CPCACHE_INDEX_TAG);
        ConstantPool* cp = _method->constants();
        int name_and_type_index = cp->name_and_type_ref_index_at(cp_index);

@@ -1110,10 +1111,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:

@@ -1130,10 +1132,11 @@
      case Bytecodes::_sastore:
        return 2;
      case Bytecodes::_lastore:
      case Bytecodes::_dastore:
        return 3;
+     case Bytecodes::_withfield:
      case Bytecodes::_putfield: {
          int cp_index = Bytes::get_native_u2(code_base + pos) DEBUG_ONLY(+ ConstantPool::CPCACHE_INDEX_TAG);
          ConstantPool* cp = _method->constants();
          int name_and_type_index = cp->name_and_type_ref_index_at(cp_index);
          int type_index = cp->signature_ref_index_at(name_and_type_index);

@@ -1170,11 +1173,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 \"")) {
-     os->print("\" is null");
+     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;
  }
  

@@ -1420,10 +1429,11 @@
          int name_and_type_index = cp->name_and_type_ref_index_at(cp_index);
          int name_index = cp->name_ref_index_at(name_and_type_index);
          Symbol* name = cp->symbol_at(name_index);
          os->print("Cannot read field \"%s\"", name->as_C_string());
        } break;
+     case Bytecodes::_withfield:
      case Bytecodes::_putfield: {
          int cp_index = Bytes::get_native_u2(code_base + pos) DEBUG_ONLY(+ ConstantPool::CPCACHE_INDEX_TAG);
          os->print("Cannot assign field \"%s\"", get_field_name(_method, cp_index));
        } break;
      case Bytecodes::_invokevirtual:

@@ -1432,10 +1442,15 @@
          int cp_index = Bytes::get_native_u2(code_base+ pos) DEBUG_ONLY(+ ConstantPool::CPCACHE_INDEX_TAG);
          os->print("Cannot invoke \"");
          print_method_name(os, _method, cp_index);
          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 >