samedi 3 septembre 2016

Creation of TypeVariable instances

The official documentation of TypeVariable is really confusing, firstly it specifies that :

A type variable is created the first time it is needed by a reflective method

and

Repeated creation of a type variable has no effect

So what I understand is that there's only one instance of TypeVariable representing a type variable at run-time, for example :

class A<T> {}

We will have one instance of Type Variable that represent T at run-time.

But the documentation adds :

Multiple objects may be instantiated at run-time to represent a given type variable. Even though a type variable is created only once, this does not imply any requirement to cache instances representing the type variable. However, all instances representing a type variable must be equal() to each other

From the above quotation I understand that there are two kinds of instantiation :

  1. Creation of type variable (Which i don't understand)
  2. Instantiation of multiple instances representing type variable

Can anyone please explain what the difference between them ?





Aucun commentaire:

Enregistrer un commentaire