Generics Glossary

Inspired by Gilad Bracha's generics tutorial, I put together a glossary for commonly used generics terminology that you might find helpful in conjunction with the tutorial or with your own investigations of generics.

The glossary is below. Comments and corrections are particularly welcome.

This material will probably make its way into a book, so I have to tell you that it is Copyright © 2004 by David Flanagan, and that all rights are reserved.

generic type, generic class, generic interface

A class or interface that declares one or more type variables or formal type parameters and can be parameterized. List<E> is a generic type.

parameterized type

A generic type, with actual type arguments specified for each of its type variables. A parameterized type is sometimes referred to as an invocation of a generic type. List<Integer> is a parameterized type, for example, corresponding to the generic type List<E>.

raw type

A generic type used without actual type arguments. List is the raw type of List<E>, for example. See also erasure. When a raw type is used, the compiler substitutes the upper bound of each type variable (often this is java.lang.Object) as the actual type argument for that variable.

generic method

A method that declares a type variable or uses a wildcard in its signature.

type variable

An identifier that appears in the declaration of a generic type or generic method and represents an actual type argument of a parameterized type. Also known as a formal type parameter. For example, E is the type variable for the generic type List<E>.

formal type parameter

Another name for a type variable.

actual type argument

The type that appears in a parameterized type, or in the invocation of a generic type. For example Integer is the actual type argument of the parameterized type List<Integer>. The term type parameter is sometimes used as a synonym.

invocation

By analogy to method declarations and method invocations, the term invocation is sometimes used to refer to the parameterized type created by supplying actual type arguments for each of the type variables of a generic type. This is a synonym for parameterized type. List<String> is an invocation, of List<E>, for example.

erasure

The process of erasing the generic type information from a signature. The erasure of a generic type is its raw type.

compile-time type

A type known to the Java compiler. Generic types are compile-time types. Contrast with runtime type.

runtime type

The type of an object, as known to the Java VM at runtime, as opposed to the compile-time type known to the Java compiler. Runtime types are always raw types.

wildcard

The character ? used as an actual type argument or in the declaration of a generic method to represent an unknown type.

bounded wildcard

A wildcard with an upper or lower bound specified. For example, ? extends E is a bounded wildcard that specifies an upper bound.

bound

A constraint on a type variable or wildcard that restricts the actual type argument. An upper bound specifies a class and/or interfaces that the argument must be or extend and implement. A lower bound specifies that the actual ancestor must be a type X, or an ancestor of X. A wildcard may have an upper bound or a lower bound of a single type. A type variable can only have an upper bound, but that bound may include one or more interfaces in addition to an optional class.

Books

Comprehensive coverage of Ruby 1.8 and 1.9

"The New Most Important Ruby Book"
Peter Cooper,
rubyinside.com

Completely updated for Ajax and Web 2.0

"A must-have reference"
Brendan Eich,
creator of JavaScript

The classic Java quick-reference