commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Turner <j...@socialchange.net.au>
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 Test.java' compiles fine. That's from the Blackdown 1.3.0 JDK.

'jikes Test.java' reports:

Found 1 semantic error compiling "Test.java":

     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/URIUtil.java":
    [javac]
    [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 ;)


--Jeff


--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message