Summary: | static final char NegThree= (char)-3, -3 == NegThree returns true | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Jed Anderson <jed.anderson> |
Component: | Core | Assignee: | Philipe Mulet <philippe_mulet> |
Status: | RESOLVED FIXED | QA Contact: | |
Severity: | normal | ||
Priority: | P3 | CC: | eclipse |
Version: | 2.0 | ||
Target Milestone: | 2.0 M6 | ||
Hardware: | PC | ||
OS: | Windows 2000 | ||
Whiteboard: |
Description
Jed Anderson
2002-04-29 16:47:07 EDT
I think I find the problem. As both operands are constant, the compiler optimizes the code, it computes the result of the operation and just put this value in the byte code. But I think there is a typo in the code which manages that, in EqualExpression.computeConstant(TypeBinding, TypeBinding). With the following modification, the behavior of the generated code is correct. public final void computeConstant(TypeBinding leftTb, TypeBinding rightTb) { if ((left.constant != NotAConstant) && (right.constant != NotAConstant)) { constant = Constant.computeConstantOperationEQUAL_EQUAL( left.constant, leftTb.id, <============= there is the modification EQUAL_EQUAL, right.constant, rightTb.id); if (((bits & OperatorMASK) >> OperatorSHIFT) == NOT_EQUAL) constant = Constant.fromValue(!constant.booleanValue()); } else { constant = NotAConstant; } } Good find. Thanks. Fixed. |