Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4015324
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:36:19+00:00 2026-05-20T09:36:19+00:00

Java generics are implemented using type erasure. That means that if I have a

  • 0

Java generics are implemented using type erasure. That means that if I have a method:

public void setMapParam(Map<String, Integer> p) { ... }

after compilation, it will end up in the .class as:

public void setMapParam(Map p) { ... }

I have a JAR file with generic classes and methods like the above. It is just the binary. No source code no nothing.

But when I use it in code, Eclipse auto completion gives me setMapParam(Map<String, Integer> p) even though in the binary is like setMapParam(Map p).

How does Eclipse now the type (Map<String, Integer>) even if the method signature has been type erased (to Map)? Or am I missing something?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T09:36:20+00:00Added an answer on May 20, 2026 at 9:36 am

    Type erasure does not mean that the compiled code contains no type parameter information. Type parameters that are used in class and member definitions are present in the compiled code and available via reflection (see TypeVariable).

    What type erasure means is that object instances do not have individual type parameters. Given a class definition MapImpl extends HashMap<T extends Comparable, Integer> and an instance of that class, you cannot find out what specific value of T was used in the code that created the instance, because that information does not exist. But you can find out that it extends Comparable and that the value type is Integer, because that information is part of the class definition (and shared by all instances).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Java Generics, I tried to implement a generic console input method. public static
I'm still trying to get my head around using Java's generics. I have no
I have heard that the Java implementation of Generics is not as good as
I mostly use Java and generics are relatively new. I keep reading that Java
What is the concept of erasure in generics in Java?
Take the following generics example import java.util.List; import java.util.ArrayList; public class GenericsTest { private
Is there a Generics Friendly way of using Collection.EMPTY_LIST in my Java Program. I
My understanding is that C# and java differ with respect to generics in some
Because of how generics are implemented in Java (eventually compiling down to objects and
Is it possible to reflectively instantiate a generic type in Java? Using the technique

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.