FULL PRODUCT VERSION :
jdk1.7.0_05
ADDITIONAL OS VERSION INFORMATION :
3.1.10-1.16-desktop #1 SMP PREEMPT Wed Jun 27 05:21:40 UTC 2012 (d016078) x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
Compiler failed in code line using a conditional assignment with the diamond operator.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile test code below.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Compile without error.
ACTUAL -
Compiler error:
error: incompatible types
List<String> list = true ? new ArrayList<>() : null;
required: List<String>
found: ArrayList<Object>
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
List<String> list = true ? new ArrayList<>() : null;
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Avoid diamond operator or conditional assignment.
jdk1.7.0_05
ADDITIONAL OS VERSION INFORMATION :
3.1.10-1.16-desktop #1 SMP PREEMPT Wed Jun 27 05:21:40 UTC 2012 (d016078) x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
Compiler failed in code line using a conditional assignment with the diamond operator.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile test code below.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Compile without error.
ACTUAL -
Compiler error:
error: incompatible types
List<String> list = true ? new ArrayList<>() : null;
required: List<String>
found: ArrayList<Object>
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
List<String> list = true ? new ArrayList<>() : null;
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Avoid diamond operator or conditional assignment.
- duplicates
-
JDK-7162438 Usage of diamond notation with ?: conditional operator
- Closed