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

how the execution happens?

Ravindranath Chowdary
Ranch Hand

Joined: Nov 08, 2006
Posts: 71
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14352
    
  22

I didn't dig deep into this, but it's probably because of a compiler optimization: the variables S in class V and I in class X are compile-time constants, so in your main() method the compiler replaces "V.S" and "X.I" by the values of the constants - and so classes X and V don't need to be loaded anymore.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
I think that's what Tony was hinting in another post. That bothers me though. What if a third party changes the value of V.S and I plug in a new jar but don't recompile? I'll miss the change?


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Originally posted by Stan James:
I'll miss the change?


Yep. Therefore changing the value of a public static final field is not something to take lightly.


[Jess in Action][AskingGoodQuestions]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: how the execution happens?