« Back to Log

Too many parameters?

Posted by myself on October 06, 2006

Today I came across an interesting fact about java (referring to the programming language, not the island). But first things first. You may not be interesting in the previous history but I'll tell it anyway.
During my diploma work (that will be finished in one week by the way) I had to generate some classes invoking the wsdl2java parser. I won't explain what that parser is about. Anyway, I invoked the parser on the amazon web service which got me an interesting error. ItemAttributes.java:538: too many parameters So I counted them and I got 261 arguments. That made me wonder how many arguments were actually allowed for a method in java. I searched the java forums and mailinglist and found the answer in the Java Virtual Machine Specification. The following summarizes the facts I was interested in.
"Java limits the number of method parameters to 255 or 254 or less if parmeters are of type long or double. The 255 method parameter limit is for static methods and 254 for non static methods." And some more limitation facts for that matter.

  • method bytecode: 65,535 bytes
  • local variables: 65,535 (each long or double counts as two variables)
  • fields: 65,535 (does not include inherited fields)
  • methods: 65,535 (does not include inherited methods)
  • method parameters: 255 (each long or double counts as two parameters)

I hope that no programmer will ever get even close to those limits. Otherwise the class design should definitely be reconsidered. Anyway, I'm positive that I'm not going to ever see a method that has more parameters than this one...

Posted by on May 14, 2009

<h1>waiving?intuitively!aught arose German.Jonathan legislates. </h1>

Random Quote

The one function TV news performs very well is that when there is no news we give it to you with the same emphasis as if there were.

David Brinkley

» ...

koffeinfrei on identi.ca

icon
2010-07-26 11:46:49
Everybody needs a fishbowl: “YouTube - Barry Schwartz: The paradox of choice” — http://www.youtube.com/watch?v=VO6XEQIsCoM
icon
2010-06-18 09:07:19
@kentbrew: what i'm i missing? the #identica-badge doesn't show my entries on http://koffeinfrei.org/
icon
2010-06-16 08:00:30
“YouTube - BP Spills Coffee” — http://www.youtube.com/watch?v=2AAa0gd7ClM
icon
2010-06-01 20:03:29
"The surprising truth about what motivates us”: http://www.youtube.com/watch?v=u6XAPnuFjJc&feature=player_embedded
icon
2010-05-20 21:11:48
“Sumatra PDF is a slim, free, open-source PDF viewer for Windows” — http://blog.kowalczyk.info/software/sumatrapdf/index.html

Ying and Yang

where I am
where I should be