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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:05:03+00:00 2026-05-15T21:05:03+00:00

I’m looking at some code with this form: 1 package com.stackoverflow.java.questions; 2 import java.util.ArrayList;

  • 0

I’m looking at some code with this form:


     1  package com.stackoverflow.java.questions;

     2  import java.util.ArrayList;
     3  import java.util.List;

     4  public class B extends A<B> {
     5      
     6      private
     7      <C extends A>
     8      List<C> getList(Class<C> cls) {
     9          
    10          List<C> res = new ArrayList<C>();

                 // "snip"... some stuff happening in here, using cls

    11          return res;
    12      }

    13      public
    14      List<A> getList() {
    15          return getList(A.class);
    16      }

    17  }

    18  abstract class A<C extends A<C>> {

    19  }


Yes, I know it’s ugly, but I reduced it as much as I could manage.

My question is how do I properly parameterize the use of A on lines 7, 14, and 15?

Currently, I get warnings (A is a raw type. References to generic type A should be parameterized) from Eclipse for lines 7 and 14. I suspect that I would get one for line 15 as well once I fix the other two, but I’m not certain. Either way, it’s not currently parameterized and probably ought to be, but I have no idea what the syntax is supposed to be.

Any thoughts on how to add the proper parameter semantics and syntax to get rid of these warnings?

Note: I’m not sure if it matters whether or not A is a recursive generic. I still get the same warnings if I simply use “abstract class A {}” in place of its current definition.

Honestly, if it were my own code I’d change it all to be a heck of a lot simpler. Unfortunately, it’s part of an API so I’m trying to change it as little as possible.

Thanks!

UPDATE:

I’m able to address the warnings by parameterizing them as one would expect, but at the cost of an error. It comes down to this, how do I get a Class<A<B>> from an abstract class?

Something like,

Class<A<B>> cls = A.class;

However, this causes a type mismatch error.

UPDATE, part 2:

Turns out, ya just can’t do it due to type erasure. See my other question here.

  • 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-15T21:05:03+00:00Added an answer on May 15, 2026 at 9:05 pm

    Turns out, ya just can’t do it due to type erasure. See my other question here:
    Java: how do I get a class literal from a generic type?

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

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have some data like this: 1 2 3 4 5 9 2 6
I know there's a lot of other questions out there that deal with this
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and

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.