title: Maximum number of parameters in Java method declaration
body: <p>What is the maximum number of parameters that a method in Java can have and why?</p>
  
  <p>I am using Java 1.8 on a 64-bit Windows system.</p>
  
  <p>All the answers on StackOverflow about this say that the technical limit is 255 parameters without specifying why.</p>
  
  <p>To be precise, 255 for static and 254 for non-static (<code>this</code> will be the 255th in this case) methods.</p>
  
  <p>I thought this could be described in some sort of specification and that there is simply a statically defined maximum number of parameters allowed. </p>
  
  <p>But this was only valid for <strong><code>int</code> and all 4-bytes types</strong>.
  I did some tests with <code>long</code> parameters, and I was only able to declare 127 parameters in that case.</p>
  
  <p>With <code>String</code> parameters, the allowed number I deduced from testing is 255 (it may be because the reference size is 4 bytes in Java?).</p>
  
  <p>But since I am using a 64-bit system, references size should be 8 bytes wide and so with <code>String</code> parameters the maximum allowed number should be 127, similar to <code>long</code> types.</p>
  
  <p>How does this limit is exactly applied? </p>
  
  <p>Does the limit have anything to do with the <strong>stack size</strong> of the method?</p>
  
  <p>Note: I am not really going to use these many parameters in any method, but this question is only to clarify the exact behavior.</p>