-
Bug
-
Resolution: Fixed
-
P4
-
5.0
-
b40
-
generic
-
solaris_8
Date: Tue, 25 Nov 2003 09:49:32 -0800
From: <###@###.###>
Subject: Suggestion: better error message for "new T()"
To: <###@###.###>
I can understand why type erasure does not allow
new T()
but users might be scratching their heads.
private static class Type<T> {
Type() { T t = new T(); }
}
gives
NewT.java:4: unexpected type
found : T
required: class
Type() { T t = new T(); }
^
It would be nice if we could give an error message like we do with
arrays,
arrays of generic types are not allowed
making it clear(er) why "new T()" is not allowed.
From: <###@###.###>
Subject: Suggestion: better error message for "new T()"
To: <###@###.###>
I can understand why type erasure does not allow
new T()
but users might be scratching their heads.
private static class Type<T> {
Type() { T t = new T(); }
}
gives
NewT.java:4: unexpected type
found : T
required: class
Type() { T t = new T(); }
^
It would be nice if we could give an error message like we do with
arrays,
arrays of generic types are not allowed
making it clear(er) why "new T()" is not allowed.