Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-5009476

Compound assignments don't work well with Byte, Short

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • 5.0, 6
    • specification
    • 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)
      ======================================================================

            abuckley Alex Buckley
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: