<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-size: 12pt; margin: 0px; font-family: Calibri, Arial, Helvetica, sans-serif; color: rgb(0, 0, 0);" class="elementToProof">
Hi Alan,</div>
<div style="font-size: 12pt; margin: 0px; font-family: Calibri, Arial, Helvetica, sans-serif; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-size: 12pt; margin: 0px; font-family: Calibri, Arial, Helvetica, sans-serif; color: rgb(0, 0, 0);" class="elementToProof ContentPasted0">
> You will find places in the JDK code, esp. in performance critical code,
<div class="ContentPasted0">> where assertions are commented out. The reason is that asserts, even if
</div>
<div class="ContentPasted0">> disabled, increase the method size and can impact inlining by the
</div>
<div class="ContentPasted0">> compiler at run-time. So while useful when debugging some issue in such
</div>
<div class="ContentPasted0">> code, they are commended out to avoid increasing the method size.</div>
<div class="ContentPasted0"><br>
</div>
<div class="ContentPasted0">Thanks a bunch! I didn't realize this before!</div>
<div class="ContentPasted0"><br>
</div>
<div class="ContentPasted0 ContentPasted1">> Asserts are very useful during development or when testing, e.g. the JDK
<div class="ContentPasted1">> tests run with -esa and can periodically help catch issues when testing
</div>
> a change.<br>
</div>
<div class="ContentPasted0 ContentPasted1"><br>
</div>
<div class="ContentPasted0 ContentPasted1 ContentPasted2">Indeed. But I am a little bit curious: unlike C/C++, which enables
<code>assert</code></div>
<div class="ContentPasted0 ContentPasted1 ContentPasted2">by default (You could define
<code>NDEBUG</code> to disable it during compilation),</div>
<div class="ContentPasted0 ContentPasted1 ContentPasted2">Java disables <code>assert</code> by default. I wonder why the language designers</div>
<div class="ContentPasted0 ContentPasted1 ContentPasted2">made such a decision. Is it for backward compatibility? IMHO, enabling it by</div>
<div class="ContentPasted0 ContentPasted1 ContentPasted2">default might potentially increase its usage among developers.</div>
<div class="ContentPasted0 ContentPasted1 ContentPasted2"><br>
</div>
<div class="ContentPasted0 ContentPasted1 ContentPasted2">Regards,
<div>Daohan</div>
</div>
</div>
</body>
</html>