File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Uninitialized local variables - do they exist in the bytecode?

 
Sigrid Kajdan
Ranch Hand
Posts: 72
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

the "TimeTravel" example in K&B (page 198, assignments chapter)made me curious to look how unitialized method-local variables appear in bytecode (I'm using jclasslib bytecode viewer to view it).

In fact, I see that the int variable day, which is never initialized, does not appear in main's code. Inspecting the local variable table, I see it is not listed either. Yet adding further variables shows that even for such uninitialized variables, slots are reserved (numbering takes them into account), even though, as I said, they are not listed.

Now my question is, are they "still there" somewhere in the bytecode?
Or are they optimized away?

Thanks for your help,
Sigrid
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Although this topic is based on a question in the K&B SCJP book the information you require is beyond the scope of SCJP.

Moving to Java In General (Intermediate).
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic