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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T03:06:45+00:00 2026-05-18T03:06:45+00:00

I have some Java code that needs to compile with current generics aware compilers

  • 0

I have some Java code that needs to compile with current generics aware compilers as well as with older or exotic compilers that don’t know about generics (yet). I managed to get almost all the code compile fine and without warnings except for the rare occasions where Class.isAssignableFrom() is used.

This example compiles with either compiler but generics aware compilers give a warning like:

“Type safety: The method isAssignableFrom(Class) belongs to the raw type Class. References to generic type Class should be parameterized”

public static boolean isType( Class type, Class clazz )
{
    return type.isAssignableFrom( clazz );
}

This gets rid of the warning but of course doesn’t compile without generics:

public static boolean isType( Class<?> type, Class clazz )
{
    return type.isAssignableFrom( clazz );
}

I managed to fix some cases by substituting this against Class.isInstance() and some others using MyClass.class.isAssignableFrom( clazz ) which compiles fine everywhere but a few cases are left where I really need Class.isAssignableFrom() to be invoked on a arbitrary class object. @SuppressWarnings isn’t possible to use either since it’s also only understood by compilers aware of Java 1.5 extensions and newer.

So any ideas how to fix this or do I just have to live with the warnings?

  • 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-18T03:06:46+00:00Added an answer on May 18, 2026 at 3:06 am

    Live with that warning, or use conditional compiling (depends on the build tool you use)… Although I don’t think it is a good practice trying to support two versions of Java which aren’t compatible. And they may be worse things than just warnings on compiling.

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

Sidebar

Related Questions

I have some Java code that is throwing out of memory exceptions after running
I have some Java code that connects to an Oracle database using DriverManager.getConnection(). It
I have a java code that looks like this: //UI thread //Some code Job
We have a system that has some Bash scripts running besides Java code. Since
I have some code which I think should compile, but doesn't: import java.io.InputStream; import
I have some MATLAB code and some Java code that need to talk with
I have some Java code which performs bitwise operations on a BitSet. I have
I have some Java code which looks roughly like this: String urlString = ftp://polar.ncep.noaa.gov/pub/history/waves/multi_1.glo_30m.dp.200601.grb2;
I'm using Zend_Search_Lucene, the PHP port of Java Lucene. I currently have some code
I have java script code to set some of the properties of ajax controls.

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.