A non-transitory, computer-readable storage medium storing program instructions that when executed on a computing device cause the computing device to perform: generating, by a compiler, an annotated class file based on a class declaration, wherein said generating comprises: applying a type erasure operation to a stream of instructions in the class declaration, wherein the stream of instructions is configured for execution by a virtualized execution environment, and wherein the class declaration includes one or more type variables; wherein applying the type erasure operation comprises: creating an encoded form of a program element of the class declaration, wherein the encoded form of the program element is annotated to include metadata specifying specialization information regarding the program element such that the encoded form can be specialized by the virtualized execution environment according to a particular type parameterization; and including the encoded form of the program element in the annotated class file, which is directly usable as a class file by a legacy virtualized execution environment, wherein the legacy virtualized execution environment does not recognize the metadata and therefore ignores the metadata, and so is able to load and use the program element as is without regard to the metadata being present in the encoded form. applying a type erasure operation to a stream of instructions in the class declaration, wherein the stream of instructions is configured for execution by a virtualized execution environment, and wherein the class declaration includes one or more type variables; wherein applying the type erasure operation comprises: creating an encoded form of a program element of the class declaration, wherein the encoded form of the program element is annotated to include metadata specifying specialization information regarding the program element such that the encoded form can be specialized by the virtualized execution environment according to a particular type parameterization; and including the encoded form of the program element in the annotated class file, which is directly usable as a class file by a legacy virtualized execution environment, wherein the legacy virtualized execution environment does not recognize the metadata and therefore ignores the metadata, and so is able to load and use the program element as is without regard to the metadata being present in the encoded form. creating an encoded form of a program element of the class declaration, wherein the encoded form of the program element is annotated to include metadata specifying specialization information regarding the program element such that the encoded form can be specialized by the virtualized execution environment according to a particular type parameterization; and including the encoded form of the program element in the annotated class file, which is directly usable as a class file by a legacy virtualized execution environment, wherein the legacy virtualized execution environment does not recognize the metadata and therefore ignores the metadata, and so is able to load and use the program element as is without regard to the metadata being present in the encoded form.