On Tue, 26 Jul 2022 21:14:58 GMT, Andy Goryachev <ango...@openjdk.org> wrote:
> - replaced with exact functional equivalent (in the presence of exceptions, > for example) I think the warning serves a good purpose of preventing a bug, it also offloads thinking to the compiler. At the same time, the byte code emitted by two variants is identical, i.e.: source `public int accidental(int x) { boolean rv; if(rv = (x == 0)) { return 1; } return 2; } public int explicit(int x) { boolean rv; if((rv = (x == 0)) == true) { return 1; } return 2; }` byte code: `public int accidental(int); Code: 0: iload_1 1: ifne 8 4: iconst_1 5: goto 9 8: iconst_0 9: dup 10: istore_2 11: ifeq 16 14: iconst_1 15: ireturn 16: iconst_2 17: ireturn` public int explicit(int); Code: 0: iload_1 1: ifne 8 4: iconst_1 5: goto 9 8: iconst_0 9: dup 10: istore_2 11: ifeq 16 14: iconst_1 15: ireturn 16: iconst_2 17: ireturn` I don't know why github can't create a code block normally... sorry. ------------- PR: https://git.openjdk.org/jfx/pull/851