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

  • Home
  • SEARCH
  • 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 uses curly braces in two ways // Curly
I have a standalone Java app that has some licensing code that I want
I have to take over and improve/finish some code that transforms Java objects from
I have to ship some groovy code to some users that have only java
Let's say I have some Java code: public class SomeClass { static { private
I have ported some LGPL code from Java to C#, which I plan to
Does anyone have a good solution for integrating some C# code into a java
In my current project, I need to compile java code at runtime (in the
We have a .NET application that needs to pass some data over to a
Some Java mobile devices have distinct heaps for MIDP and VM. What's the distinction

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.