Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

final static object

 
Rajeev Ravindran
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ireneusz Kordal
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rajeev Ravindran wrote:hi,
i see that FAUtil.IN_QUEUE.toString() threw null pointer exception


Maybe FAUtil is null.
 
Rajeev Ravindran
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
FAUtil is my util class and IN_QUEUE is the static variable defined inside the class.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like a JVM bug, pure and simple. What JVM are you running on?
 
Rajeev Ravindran
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic