On Wed, Jun 23, 2010 at 1:23 AM, Indicator Veritatis <[email protected]>wrote:

> True, this is a Java question, not an Android question. SO it doesn't
> r-e-a-l-l-y belong here.

I am glad we cleared that up.


> 1) no, the NPE does not imply that isMarkAllReadPossibleCache is the
> null variable. Rather, it implies that in the course of trying to
> execute the get method of isMarkAllReadPossibleCache, the DVM
> encountered a null pointer.
>
How so? Where do you see the get() method?


> 2) the NPE occurred during the call to UpdateButtons(), which in turn
> took place during the call to the above get() method.
>
I am really puzzled by that.
You mean that looking at the stacktrace the NPE happens here:
com.newsrob.activities.AbstractNewsRobListActivity.updateButtons(AbstractNewsRobListActivity.java:236)
?
How do you come to this conclusion? In case of a non-wrapped exception isn't
the top stack frame the place where the exception occurs? An exception blows
up and the JVM provides the stacktrace up to this point. You think
otherwise?

3) to tell in any more detail where it came from, I would need the
> rest of your stack trace, which you chose not to show.

The stack trace is complete.


> But now you
> have a better idea how to narrow this down by yourself, without
> exposing the code to us, I hope.

I don't have a better idea and now you got me confused about how to read the
stack trace.

As this is kind of a last straw I would be delighted to learn something new
about exceptions. Maybe that's the cue that's missing.


> On Jun 22, 2:59 am, Mariano Kamp <[email protected]> wrote:
> > Hey guys.
> >
> > This is not an Android issue per-se, but I am puzzled about a Java issue
> and
> > want to pick your brains.
> >
> > I recently got a couple of bug reports with a NPE that I don't understand
> > and can't reproduce myself. Here is an abbreviated representation of the
> > offending class. I tried to stay as close to the actual code as possible.
> >
> > public class EntryManager {
> >
> >   private static EntryManager instance;
> >   private Map<DBQuery, Boolean> isMarkAllReadPossibleCache;
> >
> >   private EntryManager(Context ctx) {
> >     ..
> >     isMarkAllReadPossibleCache = new HashMap<DBQuery, Boolean>();
> >     ..
> >   }
> >
> >   public static synchronized EntryManager getInstance(final Context
> context)
> > {
> >        if (instance == null)
> >            instance = new EntryManager(context.getApplicationContext());
> >        return instance;
> >    }
> >
> >    void fireModelUpdated(final String atomId) {
> >         ..
> >         isMarkAllReadPossibleCache.clear();
> >         ..
> >    }
> >
> >   public boolean isMarkAllReadPossible(final DBQuery dbq) {
> >         if (!isMarkAllReadPossibleCache.containsKey(dbq))
> >             isMarkAllReadPossibleCache.put(dbq,
> > databaseHelper.isMarkAllReadPossible(dbq));
> >
> >        return isMarkAllReadPossibleCache.get(dbq); <!-- NPE is raised
> here
> >     }
> >    ..
> >
> > }
> >
> > In the last line from above a NPE is thrown. So the instance variable
> > isMarkAllReadPossibleCache must be null, right? But I don't see where
> this
> > could happen. It's initialized in the constructor and never set to null
> > afterwards.
> >
> > For completeness here is a stack trace:
> >
> > java.lang.NullPointerException
> > at com.newsrob.EntryManager.isMarkAllReadPossible(EntryManager.java:1529)
> > at
> >
> com.newsrob.activities.AbstractNewsRobListActivity.shouldMarkAllReadButtonBeEnabled(AbstractNewsRobListActivity.java:327)
> > at
> >
> com.newsrob.activities.AbstractNewsRobListActivity.updateButtons(AbstractNewsRobListActivity.java:236)
> > at
> >
> com.newsrob.activities.AbstractNewsRobListActivity.access$2(AbstractNewsRobListActivity.java:215)
> > <-- removed the private access modifier meanwhile
> > at
> >
> com.newsrob.activities.AbstractNewsRobListActivity$13.run(AbstractNewsRobListActivity.java:626)
> > at android.os.Handler.handleCallback(Handler.java:587)
> > at android.os.Handler.dispatchMessage(Handler.java:92)
> > at android.os.Looper.loop(Looper.java:123)
> > at android.app.ActivityThread.main(ActivityThread.java:4203)
> > at java.lang.reflect.Method.invokeNative(Native Method)
> > at java.lang.reflect.Method.invoke(Method.java:521)
> > at
> >
> com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
> > at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
> > at dalvik.system.NativeStart.main(Native Method)
> >
> > Any ideas?
> >
> > Cheers,
> > Mariano
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to