I think, this behaviour is because long and double are treated differently in
java. They are 64bit and two registers will be required to store long/double constants. Since byte ... int constants are all stored in single registers, compiler should be able to compute & compare their value. However, long will require some special treatment to compute its value.
Moreover, if you know the java byte codes, there is no longtobyte conversion instruction, there is only longtoint conversion instruction.
Anyways, Even I am not aware of any exact reason or not satisfied with above explanation.
Are you using 32bit JVM? Could you execute same
test in 64bit enviornment to see if it behaves differently.