too many parameters

R

Richard Reynolds

Guys, I'm updating some legacy code from Java 1.3.1 to at least 1.4.2_13.

It's a CORBA app (Orbix) and the idl has many modules with many data
members.

The orbix idlj generates two constructors: a no param constructor and one
that takes all data members as params. The later can have hundreds of params
and somewhere between Java 1.3.1 and 1.4.2 a limit seems to have been placed
on the number of params to around 255, or at least that's the limit I've
seen mentioned in a couple of places retrieved from Google searches.

I was wondering if anyone knows if this limit has been lifted in any later
Java version or if there're any compiler options to disable it?

I've also posted on the Orbzone forum to see if there's an Orbix 6.3 idlj
option to stop it adding these constrctors but I'm not hopeful there.

P.S. I'm very limited in messing with the build as it has to be compliant
with a very restrictive compliance system that monitors technology
compatibilities etc.
I am also assuming that there was no param limit in 1.3.1 as the component
must have built before, though thinking about it I should try that tomorrow
as I guess it could've been fudged by messing with the generated Java files,
or possibly the previous Orbix version, 5.1, didn't generate these
constructors by default.

Cheers, Richard.
 
R

Roedy Green

on the number of params to around 255, or at least that's the limit I've
seen mentioned in a couple of places retrieved from Google searches.

One way to find out is download the latest Java, or the one you want
to use, and cook up a method with 255 parms. Then compile.

If it eats it, try 256. If not binary search till you find the limit.

This sounds like a limit that is burned into the class file format
somewhere. 255 would be a 1-byte count. That would be hard to change
now.
 
L

Lew

Roedy said:
One way to find out is download the latest Java, or the one you want
to use, and cook up a method with 255 parms. Then compile.

If it eats it, try 256. If not binary search till you find the limit.

This sounds like a limit that is burned into the class file format
somewhere. 255 would be a 1-byte count. That would be hard to change
now.

If there is such a limit it would violate the JLS.
FormalParameterList:
LastFormalParameter
FormalParameters , LastFormalParameter

FormalParameters:
FormalParameter
FormalParameters , FormalParameter
<http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.4.1>

If there is a limit to method arity it isn't mentioned in the JLS or in any
source I was able to scare up in a quick web search.
 
J

Joshua Cranmer

Richard said:
The orbix idlj generates two constructors: a no param constructor and one
that takes all data members as params. The later can have hundreds of params
and somewhere between Java 1.3.1 and 1.4.2 a limit seems to have been placed
on the number of params to around 255, or at least that's the limit I've
seen mentioned in a couple of places retrieved from Google searches.

I was wondering if anyone knows if this limit has been lifted in any later
Java version or if there're any compiler options to disable it?

Well, the VM spec limits the maximum possible arity to 65533, which is
assuming that all arguments are primitive types and that the return type
is either primitive or void. This limit is based on the fact that the
method descriptor is stored in as a UTF-8 string with an unsigned 2-byte
length. Two characters are '(' and ')'; the last one is for the return type.
 
B

Big Jim

If there is such a limit it would violate the JLS.



<http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.4.1>

If there is a limit to method arity it isn't mentioned in the JLS or in any
source I was able to scare up in a quick web search.

Well, there does seem to be a limit of soms sort, I get this error
message in eclipse:
"Too many parameters, parameter CrvV75 is exceeding the limit of 255
words eligible for method parameters"
This is appearing against param 178 in a constructor using a 1.5
compiler with source compatibility set to 1.4.
 
L

Lew

Big said:
Well, there does seem to be a limit of soms sort, I get this error
message in eclipse:
"Too many parameters, parameter CrvV75 is exceeding the limit of 255
words eligible for method parameters"
This is appearing against param 178 in a constructor using a 1.5
compiler with source compatibility set to 1.4.

Parameter 178, not parameter 255?

Whose JDK?
 
L

Larry A Barowski

Lew said:
Parameter 178, not parameter 255?

From the VM specification, "A method descriptor is valid only if it
represents
method parameters with a total length of 255 or less, where that length
includes
the contribution for 'this' in the case of instance or interface method
invocations.
The total length is calculated by summing the contributions of the
individual
parameters, where a parameter of type long or double contributes two units
to
the length and a parameter of any other type contributes one unit."
 
B

Big Jim

From the VM specification, "A method descriptor is valid only if it
represents
method parameters with a total length of 255 or less, where that length
includes
the contribution for 'this' in the case of instance or interface method
invocations.
The total length is calculated by summing the contributions of the
individual
parameters, where a parameter of type long or double contributes two units
to
the length and a parameter of any other type contributes one unit."

Sounds like my problem alright. Oh well, guess I have to find another
solution. Thanks for that info.
 
M

Mark Thornton

Lew said:
If there is a limit to method arity it isn't mentioned in the JLS or in
any source I was able to scare up in a quick web search.

These limits appear in the JVM specification.
 
O

Owen Jacobson

Guys, I'm updating some legacy code from Java 1.3.1 to at least 1.4.2_13.

It's a CORBA app (Orbix) and the idl has many modules with many data
members.

The orbix idlj generates two constructors: a no param constructor and one
that takes all data members as params. The later can have hundreds of params
and somewhere between Java 1.3.1 and 1.4.2 a limit seems to have been placed
on the number of params to around 255, or at least that's the limit I've
seen mentioned in a couple of places retrieved from Google searches.

I was wondering if anyone knows if this limit has been lifted in any later
Java version or if there're any compiler options to disable it?

I've also posted on the Orbzone forum to see if there's an Orbix 6.3 idlj
option to stop it adding these constrctors but I'm not hopeful there.

P.S. I'm very limited in messing with the build as it has to be compliant
with a very restrictive compliance system that monitors technology
compatibilities etc.
I am also assuming that there was no param limit in 1.3.1 as the component
must have built before, though thinking about it I should try that tomorrow
as I guess it could've been fudged by messing with the generated Java files,
or possibly the previous Orbix version, 5.1, didn't generate these
constructors by default.

Cheers, Richard.

What kind of objects are these, that have hundreds of members?
 
B

Big Jim

What kind of objects are these, that have hundreds of members?- Hide quoted text -

- Show quoted text -

They're business objects, to represent financial entities e.g. bond
trades. They're really just name value pairs or sublists of the same
but are defined in IDL as they are passed over networks to systems
working in defferent languages. The problem isn't with there being
many members but that, as well as all the getters and setters, for
java, Orbix generates a constructor taking every member by default!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,002
Messages
2,570,261
Members
46,858
Latest member
FlorrieTuf

Latest Threads

Top