• 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Method Invocation. Generic Methods

 
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi.
Phew, method invocation seems to be a really complex process...

I thought, understanding the basic concepts of the three phases (widening - boxing - vara-args) should be enough for the exam. But then one question arouse: What happens when there are also generic methods involved? So I started to read the language specification regarding this process, but as mentioned above: it's very complex and I feel a bit lost in all the explanations given there.

Maybe there are a few rules, that will help to prognose which method will be called in most cases?

For example:
In this case the generic method is called. But why?
 
Ranch Hand
Posts: 284
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One rule i can share is -: Var-args are always looser... They are more like catch-all-method (As per K&B book).... So this will run your-:
Generic Method
Hope this helps...
[ May 20, 2007: Message edited by: pranav bhatt ]
 
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ranchers,

Sasha wrote:

I thought, understanding the basic concepts of the three phases (widening - boxing - vara-args) should be enough for the exam.
(...)
Maybe there are a few rules, that will help to prognose which method will be called in most cases?



You understand the widening / boxing / var-args thing already. Generics won't introduce new topics here regarding overloading. Maybe get informed about type erasure.

What happens if you add this to your code?

or that:

What does the compiler say about it?


Yours,
Bu.
 
Sasha Ruehmkorf
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you!
"type erasure" was the catchword. For the time being, I'll read every type parameter in method-argument-lists as Object, at least when it comes to decide which method will be invoked.
 
Just the other day, I was thinking ... about this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic