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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:49:00+00:00 2026-05-26T04:49:00+00:00

In the documentation for the utility interface Types , of which an instance must

  • 0

In the documentation for the utility interface Types, of which an instance must be made available to an annotation processor for Java SE 6 or 7 by the compiler, there are two methods which interest me for a code snippet I’m working on. I need to check if a field’s type is a type that inherits from a specific abstract class. The two methods that seem applicable are isAssignable and isSubtype. But I’m not certain which of these to use.

I’ve checked those parts of the Java Language Specification that are referenced in the above documentation. I understand the difference between the concepts of subtypes and assignment conversion (at least I think I do). Unless I’m mistaken, java.lang.Short would not be a subtype of the primitive long (subtyping is defined amongst primitves, but not across classes and primitives), but it can be assigned like so thanks to unboxing and widening conversion:

final Short s = 0;
final long l = s;

However, I’m still not certain what the best method to use would be in my case. Checking for a subtype seems more strict and preferable than assignability, but when it comes to classes it feels as if one automatically implies the other.

Long version short: are isAssignable and isSubtype equivalent when the compared TypeMirrors are both for classes (not interfaces or enums)?

  • 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-26T04:49:00+00:00Added an answer on May 26, 2026 at 4:49 am

    If we take assignment of references, the only conversion which applies in this case is the widening reference conversion (except for the identity conversion, of course). Now we have the following rules for carrying it out:

    A widening reference conversion exists from any type S to any type T, provided S
    is a subtype (§4.10) of T.

    This means that if you consider only classes, it doesn’t matter whether you talk about subtypes or assignability. So yes, the mentioned methods are equivalent in this case.

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

Sidebar

Related Questions

The documentation indicates that the error: option function will make available: XHR instance, a
I have been developing a small Java utility that uses two frameworks: Encog and
Is there documentation/utility that shows the default control template of a given control? I'd
I'm reading the Core Data Utility tutorial from apple documentation and there's a part
Documentation states: Adds a user-defined custom member to an instance of a Windows PowerShell
The documentation available on the boost website is... limited. From what I've been able
Regarding to jQuery utility function jQuery.data() the online documentation says: The jQuery.data() method allows
I'm working through the Core Data Utility at http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/CoreDataUtilityTutorial/Articles/00_introduction.html#//apple_ref/doc/uid/TP40001800-CH202-TP1 I've stumbled on a rather
The documentation page for the YUI Get utility says: Get Utility is ideal for
When you are building a key store with the Java Keytool utility, how are

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.