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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:26:53+00:00 2026-05-14T00:26:53+00:00

Having these generic interface and class: interface TestIntf<T extends TestIntf<T>> { void test(T param);

  • 0

Having these generic interface and class:

interface TestIntf<T extends TestIntf<T>> 
{
    void test(T param);
}

class TestImpl<T extends TestIntf<T>> implements TestIntf<T> 
{
    @Override
    public void test(T param) { System.out.println(param); }
}

This fails:

Class<? extends TestIntf<?>> clz = TestImpl.class;

(Type mismatch: cannot convert from Class<TestImpl> to Class<? extends TestIntf<?>>)

Why? How to properly provide a reference to TestImpl class to match Class<? extends TestIntf<?>>?

  • 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-14T00:26:53+00:00Added an answer on May 14, 2026 at 12:26 am

    You can’t. Use an unsafe cast.

    Class<? extends TestIntf<?>> clz = (Class<? extends TestIntf<?>>) TestImpl.class;
    

    or don’t use the inner generics:

    Class<? extends TestIntf> clz = TestImpl.class;
    

    Update: When it regards annotations, there is nothing you can do – the annotation has to be changed. You cannot have a class literal represent a generic type.

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

Sidebar

Related Questions

Suppose I have these interfaces: public interface I1 { void foo(); } public interface
I have a generic interface, public interface ICalculator<in T> { void Calculate(T input); }
public interface IProcessor<T> { void Process(T instance); } foreach(AbstractType instance in myClass.SomeCollection) OnProcess(instance); public
These namespaces are added per default when a class is created: using System; using
I have been having these really odd problems with Visual Studio 2010. At this
I need a control having these features: It should be possible use it in
Using jQuery timepickr: http://archive.plugins.jquery.com/project/jquery-timepickr Having included these files: jquery-1.7.1.min.js jquery-ui-1.8.21.custom.min.js ui.timepickr.js And getting this
Keeping these in mind - HttpContext.Current - Foreach I'm having trouble wrapping my head
I'm having the same problem issued in these two links: one , two .
We're having a hard time figuring how these credentials objects work. In fact, they

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.