Is this a Compiler problem
I have a java file which has the following line of code
String strOne = (strValueToBeRead ==null || strValueToBeRead.equals("")) ?" " : strValueToBeRead;
When I compile the file, a class file gets created. On opening the class file with "jad" (a decompiler) the above line of code is shown as
String strOne = strValueToBeRead !=null && !strValueToBeRead.equals("") ? strValueToBeRead :" ";
Technically speaking both the lines of code will evaluate in exactly the same manner. However it does beg to question, why does the compiler change the code? Isnt this a problem with the compiler
[794 byte] By [
addvermaa] at [2007-10-2 21:56:05]

No.
Brackets don't appear in object code.
The compiler hasn't changed your code; it has compiled your code into object code, and it has chosen the minimal object-code representation because that is part of its function. The decompiler hasn't changed your code either, because it doesn't have your code. It has reconstructed equivalent code from the object code.
The extra brackets you have are redundant. They don't change the meaning of your code, so there is no reason for the compiler to do anything differently because they were there, or for the decompiler to reconstruct them.
Consider if you had had ten sets of redundant brackets instead of one. Would you expect to see them all come back through the compile/decompile cycle?
ejpa at 2007-7-14 1:12:08 >

anyway, it's not the compiler "changing" anything, it's your decompiler interpreting the bytecode in such a way that different sourcecode results from the original you fed the compiler.
Nothing wrong with that, as long as they're functionally equivalent there's no error in the decompiler.