• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

what does method erasure mean?

 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I just read in an article that for a method to compile the method signatures and method erasures should be different.

What exactly does method erasure mean?

Thanks
 
Bartender
Posts: 15743
368
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The erasure is the method signature that you're left with after generic parameters have been erased.

Let's say you have the following two methods:
This is not allowed, because the generic parameter T gets replaced by Object during erasure, leaving the method with the exact same signature as the second method. This however *is* allowed:
The generic parameter gets replaced by String, so this method successfully overloads the one with the Object parameter.
reply
    Bookmark Topic Watch Topic
  • New Topic