diff options
author | Joe George <joe@zeroc.com> | 2023-10-09 13:47:52 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-09 13:47:52 -0400 |
commit | 45cf4a9ccba65d4d2b8129d11c4debcb117cbc68 (patch) | |
tree | adb98c12bd36c24eafc39b00d456cdd03ea051bd /cpp/src/Slice/JavaUtil.cpp | |
parent | Rework Java & Java Compat README files (#1538) (diff) | |
download | ice-45cf4a9ccba65d4d2b8129d11c4debcb117cbc68.tar.bz2 ice-45cf4a9ccba65d4d2b8129d11c4debcb117cbc68.tar.xz ice-45cf4a9ccba65d4d2b8129d11c4debcb117cbc68.zip |
slice2java: fix constructor parameter count check (#1540)
Closes #1539
Diffstat (limited to 'cpp/src/Slice/JavaUtil.cpp')
-rw-r--r-- | cpp/src/Slice/JavaUtil.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/cpp/src/Slice/JavaUtil.cpp b/cpp/src/Slice/JavaUtil.cpp index ad20211a1c7..9ad435fbae7 100644 --- a/cpp/src/Slice/JavaUtil.cpp +++ b/cpp/src/Slice/JavaUtil.cpp @@ -669,6 +669,28 @@ Slice::computeSerialVersionUUID(const ExceptionPtr& p) return hashCode; } +bool +Slice::isValidMethodParameterList(const DataMemberList& members, int additionalUnits) +{ + // The maximum length of a method parameter list is 255 units, including the implicit 'this' parameter. + // Each parameter is 1 unit, except for long and double parameters, which are 2 units. + // Start the length at 1 to account for the implicit 'this' parameter (plus any additional units). + int length = 1 + additionalUnits; + for(DataMemberList::const_iterator p = members.begin(); p != members.end(); ++p) + { + BuiltinPtr builtin = BuiltinPtr::dynamicCast((*p)->type()); + if(builtin && (builtin->kind() == Builtin::KindLong || builtin->kind() == Builtin::KindDouble)) + { + length += 2; + } + else + { + length++; + } + } + return length <= 255; +} + Slice::JavaOutput::JavaOutput() { } |