File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes final static object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "final static object" Watch "final static object" New topic
Author

final static object

Rajeev Ravindran
Ranch Hand

Joined: Aug 27, 2002
Posts: 455
hi,

i have a static variable defined in my util class

public static final Object IN_QUEUE = "In Queue";

i see that FAUtil.IN_QUEUE.toString() threw null pointer exception and after bouncing the container ( the code is part of a web application deployed on OC4J) it started working again. I did see this issue once or twice during the development time but wasnt able to reproduce , it happened randomly.

I cant find any valid explanation for static final object throwing nullpointer exception. any comments ?

thanks,
Raj


SCJP, SCWCD, SCBCD, Oracle Certified Professional (SQL n PL/SQL)
Ireneusz Kordal
Ranch Hand

Joined: Jun 21, 2008
Posts: 423
Rajeev Ravindran wrote:hi,
i see that FAUtil.IN_QUEUE.toString() threw null pointer exception


Maybe FAUtil is null.
Rajeev Ravindran
Ranch Hand

Joined: Aug 27, 2002
Posts: 455
FAUtil is my util class and IN_QUEUE is the static variable defined inside the class.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24184
    
  34

Sounds like a JVM bug, pure and simple. What JVM are you running on?


[Jess in Action][AskingGoodQuestions]
Rajeev Ravindran
Ranch Hand

Joined: Aug 27, 2002
Posts: 455
1.6 in my local environment and 1.5 in unix boxes

barbary{39}$ java -version
java version "1.5.0_11"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_11-b03)
Java HotSpot(TM) Server VM (build 1.5.0_11-b03, mixed mode)

I usually declare the variable as String instead of Object but for some reason i had to define it as an object for this application.. An easy fix will be to use String literal instead of defining variable in util class but i would hate to do that.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: final static object