Files
openide/java/java-tests/testData/inspection/dataFlow/fixture/NewStringWrongEquals.java
T
Tagir Valeevandintellij-monorepo-bot 09c99286e9 [java-dfa] Ignore locality in isSuperType for types compared by equals()
Fixes IDEA-286020 False-positive 'result is always false' when converting string to bytes and backwards

GitOrigin-RevId: 274434e1f80a127645a71cf14d6218fa90aa76ca
2022-01-17 11:13:59 +00:00

26 lines
586 B
Java

import java.nio.charset.*;
class Main {
private static void test() {
Key key = new Key(getBytes());
String s = key.value();
String s1 = new String(getBytes(), StandardCharsets.US_ASCII);
System.out.println("info".equals(s1));
System.out.println("info".equals(s));
}
public static void main(String[] args) {
test();
}
private static byte[] getBytes() {
return "info".getBytes(StandardCharsets.US_ASCII);
}
private record Key(byte[] bytes) {
public String value () {
return new String(bytes, StandardCharsets.US_ASCII);
}
}
}