commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Turner <>
Subject byte b = 'a'; not allowed
Date Sat, 05 Jan 2002 03:41:16 GMT
There seems to be a bug in 'javac', which lets you implicitly typecast a char
to a byte. Eg:

public class Test {
  public static void main(String args[]) {
    byte b = 'a';

'javac' compiles fine. That's from the Blackdown 1.3.0 JDK.

'jikes' reports:

Found 1 semantic error compiling "":

     3.                 byte b = 'a';
*** Error: A byte value must be an integer value (note that a character literal is not an
integer value) in the range -128..127.

Which makes perfect sense, since a char is 16 bits, and a byte is 8 bits. This
is relevant to httpclient, which would not compile with jikes:

    [javac] Found 22 semantic errors compiling "/home/jeff/apache/jakarta/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/":
    [javac]    703.             case '0':
    [javac]                          <->

I fixed httpclient with a typecast (email waiting in a moderator's queue
presumably), but I thought I'd raise awareness of the issue here, and take the
opportunity to do a bit of jikes advocacy ;)


To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message