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 8306349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:18:50+00:00 2026-06-08T18:18:50+00:00

I read all the other questions about this, but i can’t understand why there

  • 0

I read all the other questions about this, but i can’t understand why there is type erasure in my case. I have

public <T extends Aclass&Binterface> boolean test(final T param) {
    ...
}

public boolean test(final Aclass pOtherPPShape) {
    ...
}

Method test(Aclass) has the same erasure test(Aclass) as another method in type ClassName

How should i write two methods that operate on the same class but one with an interface and one not? (i can’t modify the AClass since is from an external library, and have a lot of subtypes with which this code should work)

Is the use of instanceof right in this case?

EDIT:
i use this in a collision test. If the shape passed is instance of an interface, i get a collisionmask(with a method of the interface) and then call the “checker”, if it’s not, i want to instantiate a dummy collisionmask that does some different stuff and pass to the same method of the “checker” (that has as parameters the 2 shapes and 2 collisonmasks)

  • 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-06-08T18:18:51+00:00Added an answer on June 8, 2026 at 6:18 pm

    You’ve recognized that the issue is about type-erasure,
    and that you can’t "overload" on the one parameter with type-erasure in the way
    (type-erasure – you will be assimulated).
    But, you say,

    The generic type signatures are distinct, why did you get a conflict?

    The two types T extends Aclass&Binterface and Aclass are distinct, aren’t they?

    Well, yes and no. While in truth they are distinct, under type-erasure they’re not distinct**1. An excellent resource explains: "In the process of type erasure the compiler replaces type parameters by their leftmost bound". Which in your case was Aclass, which led to the conflict between the two methods.

    The explanation suggests a …

    Solution: formalize the combound**2 generic type declaration to establish a unique leftmost bound

    Replace <T extends Aclass&Binterface> with <T extends AandB>, where AandB is created thus:

    1. Define interface Ainterface with Aclass method signatures

    2. Have Aclass implement Ainterface

    3. Define interface AandB extends Ainterface, Binterface.

    OR

    you can use instanceof.


    **1 "Because the longer wave lengths are refracted by the particles in the atmosphere", per Duncan Jones, another excellent resource.

    **2 That’d be compound, cause I couldn’t resist the fun :-/

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

Sidebar

Related Questions

ok I am well aware there are many other questions about this, but I
First of all, I know there are a few other StackOverflow questions about this
I have read lots of questions and answers about this issue on StackOverflow, but
I have read all threads about this without finding any answer to my problem.
I realize there have been a few other questions on this topic, and the
I've read at least half a dozen other questions about doing this, and I
I already read it so many questions and answers about it but I can't
I have been reading other questions and answers around this but I am not
There are some other SO questions about concurrency but they don't quite address my
I've read a couple of other questions/answers on stack overflow regarding this, but wanted

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.