filtering JAVAC.ASSERT
Evgeny Mandrikov edited this page Oct 21, 2017
·
6 revisions
This page discusses a not yet available feature!
In presence of assertions in class compiler generates synthetic field $assertionsDisabled
, static initializer for it and additional condition about value of this field for assertion.
class AssertExample {
void example(boolean x) {
assert x;
}
}
final static synthetic Z $assertionsDisabled
static <clinit>()V
L0
LINENUMBER 1 L0
LDC LAssertExample;.class
INVOKEVIRTUAL java/lang/Class.desiredAssertionStatus ()Z
IFNE L1
ICONST_1
GOTO L2
L1
ICONST_0
L2
PUTSTATIC AssertExample.$assertionsDisabled : Z
RETURN
example(Z)V
GETSTATIC AssertExample.$assertionsDisabled : Z
IFNE L1
ILOAD_1
IFNE L1
NEW class java/lang/AssertionError
DUP
INVOKESPECIAL java/lang/AssertionError.<init> ()V
ATHROW
L1:
...