-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
5.0
-
sparc
-
solaris_10
FULL PRODUCT VERSION :
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) Server VM (build 1.5.0_06-b05, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
SunOS Generic_118822-01 sun4u sparc SUNW,Sun-Fire-880
A DESCRIPTION OF THE PROBLEM :
Comiling the code below produces an error at the statement "value += 1;",
although no error with the equivalent statement "value = value + 1;"
Value.java:8: operator + cannot be applied to java.lang.Object,int
value += 1;
^
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
To compile the source code below with javac.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
It should be compiled without an error.
ACTUAL -
Value.java:8: operator + cannot be applied to java.lang.Object,int
value += 1;
^
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Value.java:8: operator + cannot be applied to java.lang.Object,int
value += 1;
^
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class Value<T> {
public T value;
}
class IntegerValue extends Value<Integer> {
void increment() {
value = value + 1;
value += 1;
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Do not use += operator.
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) Server VM (build 1.5.0_06-b05, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
SunOS Generic_118822-01 sun4u sparc SUNW,Sun-Fire-880
A DESCRIPTION OF THE PROBLEM :
Comiling the code below produces an error at the statement "value += 1;",
although no error with the equivalent statement "value = value + 1;"
Value.java:8: operator + cannot be applied to java.lang.Object,int
value += 1;
^
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
To compile the source code below with javac.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
It should be compiled without an error.
ACTUAL -
Value.java:8: operator + cannot be applied to java.lang.Object,int
value += 1;
^
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Value.java:8: operator + cannot be applied to java.lang.Object,int
value += 1;
^
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class Value<T> {
public T value;
}
class IntegerValue extends Value<Integer> {
void increment() {
value = value + 1;
value += 1;
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Do not use += operator.
- duplicates
-
JDK-6348760 crash: java.lang.AssertionError at com.sun.tools.javac.comp.Lower.abstractLval(Lower.java:1853)
- Closed