Module Generics

Provides classes and predicates for working with generic types.

A generic type as declared in the program, for example

  class X<T> { }

is represented by a GenericType.

A parameterized instance of such a type, for example

  X<String>

is represented by a ParameterizedType.

For dealing with legacy code that is unaware of generics, every generic type has a “raw” version, represented by a RawType. In the example, X is the raw version of X<T>.

The erasure of a parameterized or raw type is its generic counterpart.

Type parameters may have bounds as in

  class X<T extends Number> { }

which are represented by a TypeBound.

The terminology for generic methods is analogous.

Import path

semmle.code.java.Generics

Imports

Type

Provides classes and predicates for working with Java types.

Classes

BoundedType

A common super-class for Java types that may have a type bound. This includes type parameters and wildcards.

GenericCall

A call where the callee is a generic callable.

GenericCallable

A generic callable is a callable with a type parameter.

GenericClass

A generic type that is a class.

GenericConstructor

A generic constructor is a constructor with a type parameter.

GenericInterface

A generic type that is an interface.

GenericMethod

A generic method is a method with a type parameter.

GenericSrcMethod

A generic method that is the same as its source declaration.

GenericType

A generic type is a type that has a type parameter.

ParameterizedClass

A parameterized type that is a class.

ParameterizedInterface

A parameterized type that is an interface.

ParameterizedType

A parameterized type is an instantiation of a generic type, where each formal type variable has been replaced with a type argument.

RawClass

A raw type that is a class.

RawInterface

A raw type that is an interface.

RawType

The raw version of a generic type is the type that is formed by using the name of a generic type without specifying its type arguments.

TypeBound

A type bound on a type variable.

TypeVariable

A type parameter used in the declaration of a generic type or method.

Wildcard

A wildcard used as a type argument.