static final boolean $assertionsDisabled = !java/util/TaskQueue.desiredAssertionStatus();
which was seen in the source file java.util.TaskQueue.java
static final boolean $assertionsDisabled = !java/util/TaskQueue.desiredAssertionStatus();
which was seen in the source file java.util.TaskQueue.java
Quoting 6.2.1 Assertion Overhead:
It is useful to understand how the assertion mechanism works to see how assertion statements can affect performance. When the compiler finds an assertion in a class, it adds a generated static final field named
$assertionsDisabled
to the class. The field is left unassigned (this is legal bytecode). The assertion itself is compiled into a statement of the form:
if ($assertionsDisabled)
if (!boolean_expression)
throw new AssertionError(String_expression);
Since java identifiers can contain Latin letters, $, _ and digits starting from letter where $ and _ are kind of letters $assertionsDisabled
is a valid java identifiers of type boolean
.
java/util/TaskQueue.desiredAssertionStatus()
does not seem like a valid expression. Probably it should look like java.util.TaskQueue.desiredAssertionStatus()
. In this case it is invocation of static method desiredAssertionStatus()
from class TaskQueue
.
This method returns boolean result. The !
reverses the result.
The only question is what is it really? Since the obvious syntax mistake appears here (/
instead of .
) I assume that this line is a result of decompilation of java code or "bad" coding attempt. Am I right?
I have just checked source code of java.util.TaskQueue.java
. It does not contain such line. So, I am pretty sure now that you got it from de-compilation. Do you probably have IDE plug-in that decompiles all classes if their source code is not found?
It is because this class has an assertion, then the compiler creates this variable for itself.