java生成255位数据,Java编译错误:参数x超出255个字的限制

I have a constructor (for an auto generated class) that has 255 paremeters. Using ant on linux with javac 1.6.0_02. The class compiles fine and everything is good.

However when I try to compile the same class from within eclipse on windows xp with jdk 1.6, I get the following error

Too many parameters, parameter BLAH is exceeding the limit of 255 words eligible for method parameters

BLAH is the the 256th parameter.

Is there a way to overcome this problem? Changing the auto generated class is not an option as I would need to change it every compile or change the generator. Both options are not acceptable because we can already get this class on linux.

PS: For those who are interested, the java class is generated from an IDL file using JacORB. Unfortunately the number of parameters in the class can not be reduced as it defines an interfaces between our software and other systems.

解决方案

The number of method parameters is

limited to 255 by the definition of a

method descriptor (§4.3.3), where the

limit includes one unit for this in

the case of instance or interface

method invocations. Note that a method

descriptor is defined in terms of a

notion of method parameter length in

which a parameter of type long or

double contributes two units to the

length, so parameters of these types

further reduce the limit.

I suggest you overcome the obstacles in changing the generated code... I'm pretty surprised it works on Linux, to be honest. I wouldn't be entirely surprised if the bytecode it generated was strictly invalid, and it just happens to be working for you at the moment.

While it's always tempting to try to find ways of keeping with the existing code and ignoring the limits, I think in this case you should turn your attention to reducing the number of parameters immediately.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值