-
Bug
-
Resolution: Fixed
-
P4
-
7
-
b138
-
x86
-
windows_7
-
Verified
FULL PRODUCT VERSION :
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b134)
Java HotSpot(TM) Client VM (build 21.0-b04, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
Documentation on Type Inference for Generic Instance Creation (http://download.java.net/jdk7/docs/technotes/guides/language/type-inference-generic-instance-creation.html) for Java SE 7, the very last example says:
MyClass<Integer> myObject = new <String`> MyClass<>("");
is valid for Java SE 7 but actually failed to compile, the ` is causing compilation error, but removing the ` character would not fix the problem either, when compiling the following line:
MyClass<Integer> myObject = new <String> MyClass<>("");
the compiler gave the following error message:
cannot infer type arguments for MyClass<>;
reason: actual and formal argument lists differ in length
Here is the full code being compiled (Main.java):
public class Main {
static class MyClass<X> {
<T> MyClass(T t) {
}
}
MyClass<Integer> myObject = new <String> MyClass<>("");
}
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class Main {
static class MyClass<X> {
<T> MyClass(T t) {
}
}
MyClass<Integer> myObject = new <String> MyClass<>("");
}
---------- END SOURCE ----------
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b134)
Java HotSpot(TM) Client VM (build 21.0-b04, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
Documentation on Type Inference for Generic Instance Creation (http://download.java.net/jdk7/docs/technotes/guides/language/type-inference-generic-instance-creation.html) for Java SE 7, the very last example says:
MyClass<Integer> myObject = new <String`> MyClass<>("");
is valid for Java SE 7 but actually failed to compile, the ` is causing compilation error, but removing the ` character would not fix the problem either, when compiling the following line:
MyClass<Integer> myObject = new <String> MyClass<>("");
the compiler gave the following error message:
cannot infer type arguments for MyClass<>;
reason: actual and formal argument lists differ in length
Here is the full code being compiled (Main.java):
public class Main {
static class MyClass<X> {
<T> MyClass(T t) {
}
}
MyClass<Integer> myObject = new <String> MyClass<>("");
}
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class Main {
static class MyClass<X> {
<T> MyClass(T t) {
}
}
MyClass<Integer> myObject = new <String> MyClass<>("");
}
---------- END SOURCE ----------
- relates to
-
JDK-7039931 Project Coin: diamond inference fail with generic constructor explicit type-arguments
-
- Closed
-