Top "Type-erasure" questions

In Java, type erasure is the process where the compiler removes all information related to type parameters and type arguments within a class or method when a generic type is instantiated.

What's the reason I can't create generic array types in Java?

What's the reason why Java doesn't allow us to do private T[] elements = new T[initialCapacity]; I could understand .NET …

java generics type-erasure
Java generics type erasure: when and what happens?

I read about Java's type erasure on Oracle's website. When does type erasure occur? At compile time or runtime? When …

java generics type-erasure
How do I get around type erasure on Scala? Or, why can't I get the type parameter of my collections?

It's a sad fact of life on Scala that if you instantiate a List[Int], you can verify that your …

scala type-erasure
Class is a raw type. References to generic type Class<T> should be parameterized

I have the following class (from a simple Spring tutorial) public class CarValidator implements Validator { public boolean supports(Class aClass) { …

java generics warnings suppress-warnings type-erasure
Unchecked assignment warning

I am using Android Studio 1.1.0. This causes no warning: public static class A { public Map<Integer, String> getMap() { …

java generics type-erasure unchecked raw-types
Check if an object is instance of List of given class name

Given an Object o and a String className = "org.foo.Foo", I want to check if o is instance of …

java generics instanceof type-erasure
How to get the class of type variable in Java Generics

I've seen similar questions but they didnt help very much. For instance I've got this Generic Class: public class ContainerTest&…

java generics types type-erasure
Java: cast collection type to subtype

Suppose class B extends class A. I have a List<A> that I happen to know only contains …

java generics collections casting type-erasure
Jackson JsonNode to typed Collection

What is the proper way to convert a Jackson JsonNode to a java collection? If it were a json string …

java json collections jackson type-erasure
Invoking Java Generic Methods

I am studying Java generic feature and I am not sure how to explain the third line in the following …

java generics type-erasure generic-method