Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Reverted from v. 36

...

The conditions checked by the Java assertions are reasonableare reasonable. However, the validation code is not executed when assertions are disabled.

...

Using assertions to validate method arguments can result in inconsistent computations, runtime exceptions, and control flow vulnerabilities.

Rule

Severity

Likelihood

Remediation Cost

Priority

Level

MET01-J

Medium

Probable

Medium

P8

L2

Related Guidelines

MITRE CWE

CWE-617, Reachable Assertion

Android Implementation Details

The assert statement is supported on the Dalvik VM but is ignored under the default configuration. Assertions may be enabled by setting the system property debug.assert via adb shell setprop debug.assert 1 or by sending the command-line argument --enable-assert to the Dalvik VM.

Bibliography

[Daconta 2003]

Item 7, "My Assertions Are Not gratuitous"

[ESA 2005]

Rule 68, Explicitly check method parameters for validity, and throw an adequate exception in case they are not valid. Do not use the assert statement for this purpose

[JLS 2015]

§14.10, "The assert Statement"

 

...