All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.checkerframework.framework.type.TypeHierarchy Maven / Gradle / Ivy

Go to download

The Checker Framework enhances Java's type system to make it more powerful and useful. This lets software developers detect and prevent errors in their Java programs. The Checker Framework includes compiler plug-ins ("checkers") that find bugs or verify their absence. It also permits you to write your own compiler plug-ins.

There is a newer version: 3.44.0
Show newest version
package org.checkerframework.framework.type;

import org.checkerframework.framework.util.AnnotatedTypes;

/** Compares AnnotatedTypeMirrors for subtype relationships. See also {@link QualifierHierarchy}. */
public interface TypeHierarchy {

  /**
   * Returns true if {@code subtype} is a subtype of or convertible to {@code supertype} for all
   * hierarchies present. If the underlying Java type of {@code subtype} is not a subtype of or
   * convertible to the underlying Java type of {@code supertype}, then the behavior of this method
   * is undefined.
   *
   * 

Ideally, types that require conversions would be converted before isSubtype is called, but * instead, isSubtype performs some of these conversions. * *

JLS 5.1 specifies 13 categories of conversions. * *

3 categories are converted in isSubtype: * *

    *
  • Boxing conversions: isSubtype calls {@link AnnotatedTypes#asSuper( AnnotatedTypeFactory, * AnnotatedTypeMirror, AnnotatedTypeMirror)} which calls {@link * AnnotatedTypeFactory#getBoxedType} *
  • Unboxing conversions: isSubtype calls {@link AnnotatedTypes#asSuper( * AnnotatedTypeFactory, AnnotatedTypeMirror, AnnotatedTypeMirror)} which calls {@link * AnnotatedTypeFactory#getUnboxedType} *
  • String conversions: Any type to String. isSubtype calls {@link AnnotatedTypes#asSuper} * which calls {@link AnnotatedTypeFactory#getStringType(AnnotatedTypeMirror)} *
* * 2 happen elsewhere: * *
    *
  • Unchecked conversions: Generic type to raw type. Raw types are instantiated with bounds * in AnnotatedTypeFactory#fromTypeTree before is subtype is called *
  • Capture conversions: Wildcards are captured in {@link * AnnotatedTypeFactory#applyCaptureConversion(AnnotatedTypeMirror)} *
* * 7 are not explicitly converted and are treated as though the types are actually subtypes. * *
    *
  • Identity conversions: type to same type *
  • Widening primitive conversions: primitive to primitive (no loss of information, byte to * short for example) *
  • Narrowing primitive conversions: primitive to primitive (possibly loss of information, * short to byte for example) *
  • Widening and Narrowing Primitive Conversion: byte to char *
  • Widening reference conversions: Upcast *
  • Narrowing reference conversions: Downcast *
  • Value set conversions: floating-point value from one value set to another without * changing its type. *
* * @param subtype possible subtype * @param supertype possible supertype * @return true if {@code subtype} is a subtype of {@code supertype} for all hierarchies present. */ boolean isSubtype(AnnotatedTypeMirror subtype, AnnotatedTypeMirror supertype); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy