• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Why does java work this way at Compile-time and Run-time ?

 
Ranch Hand
Posts: 637
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Consider the code below :



While compiling Process, i can specify one version of Input.class. But while running Process, i can specify another version of Input.class . Why doesnt the compiler "bind" the Process class file to the version of Input.class used during compiling ?
As per my reasoning, the advantage is :
->flexibility
->reducing file size by avoiding "binding". But this can be a problem too. What if i forget to add the needed class files before i distribute this class file ?

Can there be any other advantages/disadvantages of this ?

regards
rb

[EDIT] What if someone knows that this class file is needed (possible ???) and then replaces it with his version of Input.class in my folder...that could be bad...my input could be food and his could be poison ?
 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let's consider what would happen if the version binding you suggested would be in place. You've written your Input class, let's call it version 1. You've written your Process class. You find out there is a bug in the Input class. You improve that bug, but Input is now at version 2. That means that you would need to recompile your Process class as well. For your own classes that doesn't matter much, but what if the Input class comes from some external library? If the users of your application upgrade this library your code will stop working. Oops!

Your concerns are valid though. I believe you may be able to (partly) solve this by sealing packages, but I haven't walked that route myself yet so I can't help you out with that one.
 
Rahul Sudip Bose
Ranch Hand
Posts: 637
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Spoor wrote:
Your concerns are valid though. I believe you may be able to (partly) solve this by sealing packages, but I haven't walked that route myself yet so I can't help you out with that one.



Yes, the versions issue is important. Do developers encounter the need for such sealing regularly or does someone else do it for them ?

thanks
rb
 
Ranch Hand
Posts: 58
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Take consolation in the fact that the way in which Java manages libraries, to put it mildly, does not work very well. See: JAR_hell.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic