• Post Reply Bookmark Topic Watch Topic
  • New Topic

late binding in java  RSS feed

 
Adi Sharma
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
could anyone tell me that if java uses late binding, i.e. that the code to be executed is not known until run-time, how does the compiler know what code to compile.

I was reading "THinking in java" and it said :

"The compiler does ensure that the method
exists and performs type checking on the arguments and return value , but it doesn’t
know the exact code to execute. "

THen what code is compiled by the compiler....

Thanks a zillion.
Aditya Sharma
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
He means that the compiler generally doesn't know which object will be used to call a given instance method; all the compiler knows is that, for example, a method named foo() that returns void and takes one String as an argument will be called. That's enough knowledge for the compiler to generate a call to the method on whatever object will be present. At runtime, the object is finally available, and the JVM can look up the actual method code in a table and invoke it.
 
Campbell Ritchie
Marshal
Posts: 56592
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to JavaRanch
 
Adi Sharma
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot. The concept is crystal clear now. ( I hope so).

Aditya Sharma
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!