Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2007

Tip: Looking for answers? Try searching our database.

polymorphism

Thread view: 
josh - 12 Apr 2007 09:34 GMT
Hi,
can anyone tell me where can I find detailed info (or to explain me)
on how Java implements polymorphism and dynamic binding internally?

Thanks
Mich - 12 Apr 2007 11:43 GMT
> Hi,
> can anyone tell me where can I find detailed info (or to explain me)
> on how Java implements polymorphism and dynamic binding internally?
>
> Thanks

http://www.google.ca/search?client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&
channel=s&hl=en&q=polymorphism+java&meta=&btnG=Google+Search

Chris Uppal - 12 Apr 2007 13:33 GMT
> can anyone tell me where can I find detailed info (or to explain me)
> on how Java implements polymorphism and dynamic binding internally?

That's rather a big topic.  In fact it's a very big topic, and still the
subject of ongoing research.

If you look for "vtable" and "inline cache" (or "polymorphic inline cache")
then you should find some places to /start/ reading.  The following Google
search query looks promising:
   ("vtable" OR "inline cache") java method dispatch
Assume that most of the best information on such subjects will be research
papers and therefore will be in PDF or PostScript format.

Beware of anything which seems to claim or assume that Java implementations
always use vtables unless the either:
   The author is clear about when the implementation the implementation does
   /not/ use vtables for dynamic dispatch.
or:
   The author is part of the group that created the specific JVM
implementation
   s/he is talking about.

   -- chris
josh - 12 Apr 2007 13:44 GMT
On 12 Apr, 14:33, "Chris Uppal" <chris.up...@metagnostic.REMOVE-
THIS.org> wrote:
> > can anyone tell me where can I find detailed info (or to explain me)
> > on how Java implements polymorphism and dynamic binding internally?
[quoted text clipped - 19 lines]
>
>     -- chris

yes I know that it is a big topic and infact I'm seasrching something
to make
a comparative study with C++ where the polymorphism is implemented via
vtables...
Chris Smith - 12 Apr 2007 15:46 GMT
> yes I know that it is a big topic and infact I'm seasrching something
> to make
> a comparative study with C++ where the polymorphism is implemented via
> vtables...

My own suggestion is that you shift the focus of your research a bit.  
The implementation techniques for method dispatch are not properties of
languages; they are properties of implementations of languages.  There
are a few C++ compilers that do not use vtables, and there are plenty of
Java virtual machines that implement method dispatch in different ways
from each other.  In fact, the variations between Java implementations
are probably greater than the variations between early Java
implementations and C++.  Modern Java implementations for widely used
platforms generally don't have one method; instead, they choose between
several means of dispatch depending on the performance footprint of the
code and the potential for optimization.

Signature

Chris Smith

josh - 13 Apr 2007 09:38 GMT
> > yes I know that it is a big topic and infact I'm seasrching something
> > to make
[quoted text clipped - 15 lines]
> --
> Chris Smith

so does SUN write only the language specification and not how the JVM
must
be implmented?

and there is not the SUN's jvm implemetation spec?
Chris Uppal - 13 Apr 2007 10:17 GMT
> so does SUN write only the language specification and not how the JVM
> must be implmented?
>
> and there is not the SUN's jvm implemetation spec?

Not in any relevant sense.  Sun, obviously, decide /how/ any given release of
the JVM is implemented, but there's no public specification of the
implementation techniques used (how could there be -- if nothing else they need
the freedom to introduce new techniques as they are invented, or become
commercially feasible).

If you need /descriptions/ of how any particular version of any particular
vendor's JVM works, then you have several options:

Look at the source -- not always available, but sometimes it is.  Sun make
their source available.

Look for published papers by their JVM development team.  Sun also have
published a few, and some of them are listed somewhere on Sun's website:
   http://research.sun.com/java-topics/pubs/
IBM have published quite a lot too.  I don't have a link handy but searching
for
   "jikes research JVM"
seems to throw up some promising leads (Note that the implementation
technologies in the Jikes JVM are not necessarily used in their commercial
JVMs).

Look for patents applied for by the JVM development teams.

Look for the JVM development teams' blogs (if any).

Look for other material which /claims/ to be about how JVMs are implemented --
but take anything you find with two pinches of salt.  One pinch because stuff
changes over time, but out of date material hangs around on the Web and in
"folk law".  The other because not too many people really know what's going on
inside a high performance JVM except it's designers.

   -- chris
Chris Uppal - 13 Apr 2007 10:14 GMT
> There
> are a few C++ compilers that do not use vtables

Do you have any references/links for that ?   I don't (currently) see how to
implement C++'s turn-off-polymorphism-during-the-ctor semantics without either
massive complexity (worse than "ordinary" PICs), vtables, or nasty run-time
tests.

   -- chris
Chris Smith - 14 Apr 2007 06:37 GMT
> > There
> > are a few C++ compilers that do not use vtables
>
> Do you have any references/links for that ?

Unfortunately, no.  About 15 years ago, I used a C++ compiler for an
embedded processor that did not use vtables -- I know, because part of
the job involved examining the memory layout and writing assembly code
to interact with it.  The processor was the Z80, but I don't recall the
compiler or vendor.

It is simply my assumption that other C++ compilers may not use vtables,
either.  Perhaps my assumption is wrong.

> I don't (currently) see how to
> implement C++'s turn-off-polymorphism-during-the-ctor semantics without either
> massive complexity (worse than "ordinary" PICs), vtables, or nasty run-time
> tests.

The technique involved a single hidden field in each object to identify
its class.  Each virtual method signature foo in some class hierarchy
would cause the compiler to synthesize a _foo_dispatch function, which
did a conditional branch based on the contents of that hidden field.  
Calls to the member function would actually call _foo_dispatch, which
would jump to the appropriate code.

Although I can't guarantee this compiler did it, one could turn off
polymorphism beyond a certain superclass simply by changing the type
field.

Signature

Chris Smith

Tor Iver Wilhelmsen - 13 Apr 2007 19:07 GMT
På Thu, 12 Apr 2007 10:34:08 +0200, skrev josh <xdevel1999@gmail.com>:

> Hi,
> can anyone tell me where can I find detailed info (or to explain me)
> on how Java implements polymorphism and dynamic binding internally?

You want to look for the Java Virtual Machine specification, and possibly  
at least one of the implementations. Sources are available for a few JSE  
implementations. Look in particular on how the invokevirtual instruction  
is implemented.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.