Skip to content

filtering JAVAC.NOT

Evgeny Mandrikov edited this page Mar 29, 2017 · 5 revisions

This page discusses a not yet available feature!

Description

Source Example

boolean example(boolean x) {
  return !x;
}

boolean pitfall(boolean a, boolean b) {
  return !a && !b;
}

Bytecode Pattern

javac 1.8.0_121

  ...
  IFNE L1
  ICONST_1
  GOTO L2
 L1
  ICONST_0
 L2
  ...

Note that the same bytecode will be generated for !x ? 1 : 0

ecj 4.6.1

  ...
  IFEQ L1
  ICONST_0
  GOTO L2
 L1
  ICONST_1
 L2
  ...

Note that the same bytecode will be generated for x ? 0 : 1