title: Java JRE fatal error: too many multiplications
body: <p>I was trying to test speed of <code>Math.pow()</code> against multiplication "by hand" and stumbled upon this error:</p>
  
  <blockquote>
    <p>A fatal error has been detected by the Java Runtime Environment:</p>
    
    <p>EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000000005ac46888, pid=1508, tid=6016</p>
    
    <p>JRE version: Java(TM) SE Runtime Environment (8.0_25-b18) (build 1.8.0_25-b18)<br>
    Java VM: Java HotSpot(TM) 64-Bit Server VM (25.25-b02 mixed mode windows-amd64 compressed oops)<br>
    Problematic frame:<br>
    V  [jvm.dll+0x496888]  </p>
    
    <p>Failed to write core dump. Minidumps are not enabled by default on client versions of Windows</p>
  </blockquote>
  
  <p>Code generating it:</p>
  
  <pre><code>long t = System.nanoTime();
  for (int i = 0; i &lt; 10000000; i++) {
      double val = i*i*i*i*i /* 256 times *i */ *i*i*i;
      sum ^= Double.doubleToLongBits(val);
  }
  System.out.println((System.nanoTime() - t) / 10000000);
  </code></pre>
  
  <p>I get that this is really extreme case, but still, this is valid code and the worst thing that could happen should be having Inf in the value, and not JRE crash. Is this really standard behaviour described by oracle or just bug nobody wants to fix just because if you are seeing it, you are really bad person.</p>
  
  <p>For the record run with NetBeans 8.0.2</p>
  
  <p><strong>UPDATE 1</strong></p>
  
  <p>It seems problem is in magnitude of multiplied number.</p>
  
  <pre><code>long t = System.nanoTime();
  for(int j = 0; j &lt; 10000000; j++) {
      int i = j % 50;
      double val = i*i*i*i*i /* 256 times *i */ *i*i*i;
      sum ^= Double.doubleToLongBits(val);
  }
  System.out.println((System.nanoTime() - t) / 10000000);
  </code></pre>
  
  <p>will pass just fine.</p>
  
  <p><strong>UPDATE 2</strong></p>
  
  <p>Tried to run it from console with</p>
  
  <pre><code>java version "1.8.0_45"
  Java(TM) SE Runtime Environment (build 1.8.0_45-b15)
  Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
  </code></pre>
  
  <p>and passed just fine, so I assume it must be either issue with this specific JRE or with NetBeans.</p>