-
Enhancement
-
Resolution: Unresolved
-
P4
-
None
-
5.0, 6
-
Fix Understood
-
generic, x86
-
generic, windows_xp
Name: rmT116609 Date: 03/08/2004
FULL PRODUCT VERSION :
java version "1.5.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b32c)
Java HotSpot(TM) Client VM (build 1.5.0-beta-b32c, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
WindowsXP
A DESCRIPTION OF THE PROBLEM :
The following does not compile, while I belive it should.
Unfortunately the JSR does not say anything about compound assignments
public static void main(String[] args) {
Byte b = (byte)100;
// *= /= %= += -= <<= >>= >>>= &= ^= |=
b+=1; b-=1; b*=1; b/=1; b%=7; b<<=2; b>>=1; b>>>=1; b^=8; b|=2; b&=9;
}
Writing "b++", however works just fine.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile:
public static void main(String[] args) {
Byte b = (byte)100;
// *= /= %= += -= <<= >>= >>>= &= ^= |=
b+=1; b-=1; b*=1; b/=1; b%=7; b<<=2; b>>=1; b>>>=1; b^=8; b|=2; b&=9;
}
ERROR MESSAGES/STACK TRACES THAT OCCUR :
inconvertible types // found : int // required: java.lang.Byte
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
class Test {
public static void main(String[] args) {
Byte b = (byte)100;
// *= /= %= += -= <<= >>= >>>= &= ^= |=
b+=1; b-=1; b*=1; b/=1; b%=7; b<<=2; b>>=1; b>>>=1; b^=8; b|=2; b&=9;
}
}
---------- END SOURCE ----------
(Incident Review ID: 242329)
======================================================================
- duplicates
-
JDK-5025685 Autoboxing spec should specify things for extended assignment Operators too
- Closed
-
JDK-6588248 narrowing primitive conversion after unboxing conversion should work
- Closed
-
JDK-6646584 Compound assignment with Byte, Short and Character
- Closed
- relates to
-
JDK-4995668 Narrowing with autoboxing needs an extra cast
- Closed
-
JDK-4039419 Possibly invisible loss of precision can cause endless loops
- Closed
-
JDK-4655168 Implied narrowing conversion in compound assignments
- Closed
-
JDK-6526446 Fixes to JLS5.5 Casting Conversion
- Closed