Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between DeadObjectException and causing a NullPointerException

Tags:

java

android

What's the difference between the DeadObjectException and a NullPointerException? I think I may understand but I just wanted to make sure.


My Understanding

A DeadObjectException happens when you are trying to make a reference to something (and the memory still exists) but there aren't any pointers holding its address, so there's no way to reach that memory. It's different from a NullPointerException in the fact that the memory still is valid, there's just no way to reach it.


Do I have the right idea? Based on other questions on the site:

  • When android unbind a service I created
  • Memory leaks in Android

I think my assertion is correct, I just wanted to make sure.

like image 321
Jeeter Avatar asked Aug 21 '15 16:08

Jeeter


1 Answers

NullPointerException is when a reference doesn't point to any object within the same Java virtual machine.

DeadObjectException is when a you call a remote object that no longer exists. This happens on 2 different JVM.

like image 170
pmartin8 Avatar answered Sep 28 '22 10:09

pmartin8