Files
openide/java/java-tests/testData/inspection/dataFlow/fixture/Boxing128.java
T
Tagir Valeev ec3b05f6a3 ConstantExpressionVisitor fixes
1. Relational operators are promoted according to JLS, not always to double type (IDEA-199775)
2. Casting to boxed type is disabled, as JLS 15.28 suggests
Result of boxed comparison like (Long)128L == (Long)128L is unknown now as size of boxing cache is not specified in JLS
2018-10-02 12:59:27 +07:00

19 lines
843 B
Java

class Foo {
public void foo() {
Integer a = 128;
Integer b = (int) a;// cast is necessary because new object is created
Integer c = 128;
System.out.println(a == b);
System.out.println(a == c); // Not known: integer cache could be enlarged and in general VM is free to cache more integral values
System.out.println(<warning descr="Result of 'a.equals(b)' is always 'true'">a.equals(b)</warning>);
System.out.println(<warning descr="Result of 'a.equals(c)' is always 'true'">a.equals(c)</warning>);
System.out.println((Long)128L == (Long)128L);
System.out.println(<warning descr="Condition '128 == 128' is always 'true'">128 == 128</warning>);
System.out.println((Long)128L != (Long)128L);
System.out.println(<warning descr="Condition '128 != 128' is always 'false'">128 != 128</warning>);
}
}