diff options
Diffstat (limited to 'java')
29 files changed, 3310 insertions, 198 deletions
diff --git a/java/build.xml b/java/build.xml index abb6569e399..4164c47b28d 100644 --- a/java/build.xml +++ b/java/build.xml @@ -577,6 +577,7 @@ </fileset> <fileset dir="test/Ice/optional"> <include name="Test.ice" /> + <include name="TestAMD.ice" /> </fileset> <fileset dir="test/Ice/stream"> <include name="Test.ice" /> diff --git a/java/src/Ice/BooleanOptional.java b/java/src/Ice/BooleanOptional.java new file mode 100644 index 00000000000..724f89e7460 --- /dev/null +++ b/java/src/Ice/BooleanOptional.java @@ -0,0 +1,106 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +package Ice; + +/** + * Manages an optional boolean parameter. + **/ +public class BooleanOptional +{ + /** + * The value defaults to unset. + **/ + public BooleanOptional() + { + _isSet = false; + } + + /** + * Sets the value to the given argument. + * + * @param v The initial value. + **/ + public BooleanOptional(boolean v) + { + _value = v; + _isSet = true; + } + + /** + * Sets the value to a shallow copy of the given optional. + * + * @param opt The source value. + **/ + public BooleanOptional(BooleanOptional opt) + { + _value = opt._value; + _isSet = opt._isSet; + } + + /** + * Obtains the current value. + * + * @return The current value. + * @throws IllegalStateException If the value is not set. + **/ + public boolean get() + { + if(!_isSet) + { + throw new IllegalStateException("no value is set"); + } + return _value; + } + + /** + * Sets the value to the given argument. + * + * @param v The new value. + **/ + public void set(boolean v) + { + _value = v; + _isSet = true; + } + + /** + * If the given argument is set, this optional is set to a shallow copy of the argument, + * otherwise this optional is unset. + * + * @param opt The source value. + **/ + public void set(BooleanOptional opt) + { + _value = opt._value; + _isSet = opt._isSet; + } + + /** + * Determines whether the value is set. + * + * @return True if the value is set, false otherwise. + **/ + public boolean isSet() + { + return _isSet; + } + + /** + * Unsets this value. + **/ + public void clear() + { + _isSet = false; + _value = false; + } + + private boolean _value; + private boolean _isSet; +} diff --git a/java/src/Ice/ByteOptional.java b/java/src/Ice/ByteOptional.java new file mode 100644 index 00000000000..4430f634ffc --- /dev/null +++ b/java/src/Ice/ByteOptional.java @@ -0,0 +1,106 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +package Ice; + +/** + * Manages an optional byte parameter. + **/ +public class ByteOptional +{ + /** + * The value defaults to unset. + **/ + public ByteOptional() + { + _isSet = false; + } + + /** + * Sets the value to the given argument. + * + * @param v The initial value. + **/ + public ByteOptional(byte v) + { + _value = v; + _isSet = true; + } + + /** + * Sets the value to a shallow copy of the given optional. + * + * @param opt The source value. + **/ + public ByteOptional(ByteOptional opt) + { + _value = opt._value; + _isSet = opt._isSet; + } + + /** + * Obtains the current value. + * + * @return The current value. + * @throws IllegalStateException If the value is not set. + **/ + public byte get() + { + if(!_isSet) + { + throw new IllegalStateException("no value is set"); + } + return _value; + } + + /** + * Sets the value to the given argument. + * + * @param v The new value. + **/ + public void set(byte v) + { + _value = v; + _isSet = true; + } + + /** + * If the given argument is set, this optional is set to a shallow copy of the argument, + * otherwise this optional is unset. + * + * @param opt The source value. + **/ + public void set(ByteOptional opt) + { + _value = opt._value; + _isSet = opt._isSet; + } + + /** + * Determines whether the value is set. + * + * @return True if the value is set, false otherwise. + **/ + public boolean isSet() + { + return _isSet; + } + + /** + * Unsets this value. + **/ + public void clear() + { + _isSet = false; + _value = 0; + } + + private byte _value; + private boolean _isSet; +} diff --git a/java/src/Ice/DoubleOptional.java b/java/src/Ice/DoubleOptional.java new file mode 100644 index 00000000000..d9b78066616 --- /dev/null +++ b/java/src/Ice/DoubleOptional.java @@ -0,0 +1,106 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +package Ice; + +/** + * Manages an optional double parameter. + **/ +public class DoubleOptional +{ + /** + * The value defaults to unset. + **/ + public DoubleOptional() + { + _isSet = false; + } + + /** + * Sets the value to the given argument. + * + * @param v The initial value. + **/ + public DoubleOptional(double v) + { + _value = v; + _isSet = true; + } + + /** + * Sets the value to a shallow copy of the given optional. + * + * @param opt The source value. + **/ + public DoubleOptional(DoubleOptional opt) + { + _value = opt._value; + _isSet = opt._isSet; + } + + /** + * Obtains the current value. + * + * @return The current value. + * @throws IllegalStateException If the value is not set. + **/ + public double get() + { + if(!_isSet) + { + throw new IllegalStateException("no value is set"); + } + return _value; + } + + /** + * Sets the value to the given argument. + * + * @param v The new value. + **/ + public void set(double v) + { + _value = v; + _isSet = true; + } + + /** + * If the given argument is set, this optional is set to a shallow copy of the argument, + * otherwise this optional is unset. + * + * @param opt The source value. + **/ + public void set(DoubleOptional opt) + { + _value = opt._value; + _isSet = opt._isSet; + } + + /** + * Determines whether the value is set. + * + * @return True if the value is set, false otherwise. + **/ + public boolean isSet() + { + return _isSet; + } + + /** + * Unsets this value. + **/ + public void clear() + { + _isSet = false; + _value = 0; + } + + private double _value; + private boolean _isSet; +} diff --git a/java/src/Ice/FloatOptional.java b/java/src/Ice/FloatOptional.java new file mode 100644 index 00000000000..d8f11cb6e5e --- /dev/null +++ b/java/src/Ice/FloatOptional.java @@ -0,0 +1,106 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +package Ice; + +/** + * Manages an optional float parameter. + **/ +public class FloatOptional +{ + /** + * The value defaults to unset. + **/ + public FloatOptional() + { + _isSet = false; + } + + /** + * Sets the value to the given argument. + * + * @param v The initial value. + **/ + public FloatOptional(float v) + { + _value = v; + _isSet = true; + } + + /** + * Sets the value to a shallow copy of the given optional. + * + * @param opt The source value. + **/ + public FloatOptional(FloatOptional opt) + { + _value = opt._value; + _isSet = opt._isSet; + } + + /** + * Obtains the current value. + * + * @return The current value. + * @throws IllegalStateException If the value is not set. + **/ + public float get() + { + if(!_isSet) + { + throw new IllegalStateException("no value is set"); + } + return _value; + } + + /** + * Sets the value to the given argument. + * + * @param v The new value. + **/ + public void set(float v) + { + _value = v; + _isSet = true; + } + + /** + * If the given argument is set, this optional is set to a shallow copy of the argument, + * otherwise this optional is unset. + * + * @param opt The source value. + **/ + public void set(FloatOptional opt) + { + _value = opt._value; + _isSet = opt._isSet; + } + + /** + * Determines whether the value is set. + * + * @return True if the value is set, false otherwise. + **/ + public boolean isSet() + { + return _isSet; + } + + /** + * Unsets this value. + **/ + public void clear() + { + _isSet = false; + _value = (float)0; + } + + private float _value; + private boolean _isSet; +} diff --git a/java/src/Ice/IntOptional.java b/java/src/Ice/IntOptional.java new file mode 100644 index 00000000000..d80f963b11a --- /dev/null +++ b/java/src/Ice/IntOptional.java @@ -0,0 +1,106 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +package Ice; + +/** + * Manages an optional int parameter. + **/ +public class IntOptional +{ + /** + * The value defaults to unset. + **/ + public IntOptional() + { + _isSet = false; + } + + /** + * Sets the value to the given argument. + * + * @param v The initial value. + **/ + public IntOptional(int v) + { + _value = v; + _isSet = true; + } + + /** + * Sets the value to a shallow copy of the given optional. + * + * @param opt The source value. + **/ + public IntOptional(IntOptional opt) + { + _value = opt._value; + _isSet = opt._isSet; + } + + /** + * Obtains the current value. + * + * @return The current value. + * @throws IllegalStateException If the value is not set. + **/ + public int get() + { + if(!_isSet) + { + throw new IllegalStateException("no value is set"); + } + return _value; + } + + /** + * Sets the value to the given argument. + * + * @param v The new value. + **/ + public void set(int v) + { + _value = v; + _isSet = true; + } + + /** + * If the given argument is set, this optional is set to a shallow copy of the argument, + * otherwise this optional is unset. + * + * @param opt The source value. + **/ + public void set(IntOptional opt) + { + _value = opt._value; + _isSet = opt._isSet; + } + + /** + * Determines whether the value is set. + * + * @return True if the value is set, false otherwise. + **/ + public boolean isSet() + { + return _isSet; + } + + /** + * Unsets this value. + **/ + public void clear() + { + _isSet = false; + _value = 0; + } + + private int _value; + private boolean _isSet; +} diff --git a/java/src/Ice/LongOptional.java b/java/src/Ice/LongOptional.java new file mode 100644 index 00000000000..a40c362736f --- /dev/null +++ b/java/src/Ice/LongOptional.java @@ -0,0 +1,106 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +package Ice; + +/** + * Manages an optional long parameter. + **/ +public class LongOptional +{ + /** + * The value defaults to unset. + **/ + public LongOptional() + { + _isSet = false; + } + + /** + * Sets the value to the given argument. + * + * @param v The initial value. + **/ + public LongOptional(long v) + { + _value = v; + _isSet = true; + } + + /** + * Sets the value to a shallow copy of the given optional. + * + * @param opt The source value. + **/ + public LongOptional(LongOptional opt) + { + _value = opt._value; + _isSet = opt._isSet; + } + + /** + * Obtains the current value. + * + * @return The current value. + * @throws IllegalStateException If the value is not set. + **/ + public long get() + { + if(!_isSet) + { + throw new IllegalStateException("no value is set"); + } + return _value; + } + + /** + * Sets the value to the given argument. + * + * @param v The new value. + **/ + public void set(long v) + { + _value = v; + _isSet = true; + } + + /** + * If the given argument is set, this optional is set to a shallow copy of the argument, + * otherwise this optional is unset. + * + * @param opt The source value. + **/ + public void set(LongOptional opt) + { + _value = opt._value; + _isSet = opt._isSet; + } + + /** + * Determines whether the value is set. + * + * @return True if the value is set, false otherwise. + **/ + public boolean isSet() + { + return _isSet; + } + + /** + * Unsets this value. + **/ + public void clear() + { + _isSet = false; + _value = 0; + } + + private long _value; + private boolean _isSet; +} diff --git a/java/src/Ice/ObjectImpl.java b/java/src/Ice/ObjectImpl.java index 6d2352d6075..7ff5636cc0f 100644 --- a/java/src/Ice/ObjectImpl.java +++ b/java/src/Ice/ObjectImpl.java @@ -91,7 +91,7 @@ public abstract class ObjectImpl implements Object, java.lang.Cloneable, java.io String __id = __is.readString(); __inS.endReadParams(); boolean __ret = __obj.ice_isA(__id, __current); - IceInternal.BasicStream __os = __inS.__startWriteParams(); + IceInternal.BasicStream __os = __inS.__startWriteParams(Ice.FormatType.DefaultFormat); __os.writeBool(__ret); __inS.__endWriteParams(true); return DispatchStatus.DispatchOK; @@ -154,7 +154,7 @@ public abstract class ObjectImpl implements Object, java.lang.Cloneable, java.io { __inS.readEmptyParams(); String[] __ret = __obj.ice_ids(__current); - IceInternal.BasicStream __os = __inS.__startWriteParams(); + IceInternal.BasicStream __os = __inS.__startWriteParams(Ice.FormatType.DefaultFormat); __os.writeStringSeq(__ret); __inS.__endWriteParams(true); return DispatchStatus.DispatchOK; @@ -188,7 +188,7 @@ public abstract class ObjectImpl implements Object, java.lang.Cloneable, java.io { __inS.readEmptyParams(); String __ret = __obj.ice_id(__current); - IceInternal.BasicStream __os = __inS.__startWriteParams(); + IceInternal.BasicStream __os = __inS.__startWriteParams(Ice.FormatType.DefaultFormat); __os.writeString(__ret); __inS.__endWriteParams(true); return DispatchStatus.DispatchOK; diff --git a/java/src/Ice/ObjectPrxHelperBase.java b/java/src/Ice/ObjectPrxHelperBase.java index 916ada0220d..9a1de69d685 100644 --- a/java/src/Ice/ObjectPrxHelperBase.java +++ b/java/src/Ice/ObjectPrxHelperBase.java @@ -209,7 +209,7 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable try { __result.__prepare(__ice_isA_name, OperationMode.Nonmutating, __context, __explicitCtx); - IceInternal.BasicStream __os = __result.__startWriteParams(); + IceInternal.BasicStream __os = __result.__startWriteParams(Ice.FormatType.DefaultFormat); __os.writeString(__id); __result.__endWriteParams(); __result.__send(true); diff --git a/java/src/Ice/OutputStream.java b/java/src/Ice/OutputStream.java index d921241b2f4..7c92d240ff3 100644 --- a/java/src/Ice/OutputStream.java +++ b/java/src/Ice/OutputStream.java @@ -190,13 +190,6 @@ public interface OutputStream void writeException(UserException ex); /** - * Select the format to be used for classes and exceptions. - * - * @param format Specify the compact or sliced format. - **/ - void format(FormatType format); - - /** * Marks the start of an Ice object. * * @param slicedData Preserved slices for this object, or null. @@ -237,8 +230,11 @@ public interface OutputStream * Writes the start of an encapsulation to the stream. * * @param encoding The encoding version of the encapsulation. + * + * @param format Specify the compact or sliced format. + * **/ - void startEncapsulation(Ice.EncodingVersion encoding); + void startEncapsulation(Ice.EncodingVersion encoding, Ice.FormatType format); /** * Writes the start of an encapsulation to the stream. diff --git a/java/src/Ice/OutputStreamI.java b/java/src/Ice/OutputStreamI.java index 0a28528037f..67a51d4cbe5 100644 --- a/java/src/Ice/OutputStreamI.java +++ b/java/src/Ice/OutputStreamI.java @@ -172,12 +172,6 @@ public class OutputStreamI implements OutputStream } public void - format(FormatType format) - { - _os.format(format); - } - - public void startObject(SlicedData slicedData) { _os.startWriteObject(slicedData); @@ -214,9 +208,9 @@ public class OutputStreamI implements OutputStream } public void - startEncapsulation(Ice.EncodingVersion encoding) + startEncapsulation(Ice.EncodingVersion encoding, Ice.FormatType format) { - _os.startWriteEncaps(encoding); + _os.startWriteEncaps(encoding, format); } public void diff --git a/java/src/Ice/PropertiesI.java b/java/src/Ice/PropertiesI.java index ff76acfb62e..9af0d68033a 100644 --- a/java/src/Ice/PropertiesI.java +++ b/java/src/Ice/PropertiesI.java @@ -176,7 +176,9 @@ public final class PropertiesI implements Properties // assert(dotPos != -1); String propPrefix = pattern.substring(0, dotPos - 1); - if(!propPrefix.equals(prefix)) + boolean mismatchCase = false; + String otherKey = ""; + if(!propPrefix.toUpperCase().equals(prefix.toUpperCase())) { continue; } @@ -197,11 +199,28 @@ public final class PropertiesI implements Properties key = IceInternal.PropertyNames.validProps[i][j].deprecatedBy(); } } + + if(!found) + { + pComp = java.util.regex.Pattern.compile(pattern.toUpperCase()); + m = pComp.matcher(key.toUpperCase()); + if(m.matches()) + { + found = true; + mismatchCase = true; + otherKey = pattern.replaceAll("\\\\", ""); + break; + } + } } if(!found) { logger.warning("unknown property: " + key); } + else if(mismatchCase) + { + logger.warning("unknown property: `" + key + "'; did you mean `" + otherKey + "'"); + } } } diff --git a/java/src/Ice/ShortOptional.java b/java/src/Ice/ShortOptional.java new file mode 100644 index 00000000000..b3d3742f8ad --- /dev/null +++ b/java/src/Ice/ShortOptional.java @@ -0,0 +1,106 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +package Ice; + +/** + * Manages an optional short parameter. + **/ +public class ShortOptional +{ + /** + * The value defaults to unset. + **/ + public ShortOptional() + { + _isSet = false; + } + + /** + * Sets the value to the given argument. + * + * @param v The initial value. + **/ + public ShortOptional(short v) + { + _value = v; + _isSet = true; + } + + /** + * Sets the value to a shallow copy of the given optional. + * + * @param opt The source value. + **/ + public ShortOptional(ShortOptional opt) + { + _value = opt._value; + _isSet = opt._isSet; + } + + /** + * Obtains the current value. + * + * @return The current value. + * @throws IllegalStateException If the value is not set. + **/ + public short get() + { + if(!_isSet) + { + throw new IllegalStateException("no value is set"); + } + return _value; + } + + /** + * Sets the value to the given argument. + * + * @param v The new value. + **/ + public void set(short v) + { + _value = v; + _isSet = true; + } + + /** + * If the given argument is set, this optional is set to a shallow copy of the argument, + * otherwise this optional is unset. + * + * @param opt The source value. + **/ + public void set(ShortOptional opt) + { + _value = opt._value; + _isSet = opt._isSet; + } + + /** + * Determines whether the value is set. + * + * @return True if the value is set, false otherwise. + **/ + public boolean isSet() + { + return _isSet; + } + + /** + * Unsets this value. + **/ + public void clear() + { + _isSet = false; + _value = 0; + } + + private short _value; + private boolean _isSet; +} diff --git a/java/src/Ice/_ObjectDelM.java b/java/src/Ice/_ObjectDelM.java index 05e217f45a6..398eed35a11 100644 --- a/java/src/Ice/_ObjectDelM.java +++ b/java/src/Ice/_ObjectDelM.java @@ -20,7 +20,7 @@ public class _ObjectDelM implements _ObjectDel { try { - IceInternal.BasicStream __os = __og.startWriteParams(); + IceInternal.BasicStream __os = __og.startWriteParams(Ice.FormatType.DefaultFormat); __os.writeString(__id); __og.endWriteParams(); } diff --git a/java/src/IceInternal/BasicStream.java b/java/src/IceInternal/BasicStream.java index 3ed20b61b90..e8d0483e8fa 100644 --- a/java/src/IceInternal/BasicStream.java +++ b/java/src/IceInternal/BasicStream.java @@ -48,7 +48,6 @@ public class BasicStream _unlimited = unlimited; _startSeq = -1; - _format = _instance.defaultsAndOverrides().defaultFormat; _sizePos = -1; } @@ -142,10 +141,6 @@ public class BasicStream other._minSeqSize = _minSeqSize; _minSeqSize = tmpMinSeqSize; - Ice.FormatType tmpFormat = other._format; - other._format = _format; - _format = tmpFormat; - int tmpSizePos = other._sizePos; other._sizePos = _sizePos; _sizePos = tmpSizePos; @@ -188,15 +183,6 @@ public class BasicStream } public void - format(Ice.FormatType format) - { - if(format != Ice.FormatType.DefaultFormat) - { - _format = format; - } - } - - public void startWriteObject(Ice.SlicedData data) { assert(_writeEncapsStack != null && _writeEncapsStack.encoder != null); @@ -263,16 +249,16 @@ public class BasicStream if(_writeEncapsStack != null) { - startWriteEncaps(_writeEncapsStack.encoding); + startWriteEncaps(_writeEncapsStack.encoding, _writeEncapsStack.format); } else { - startWriteEncaps(_encoding); + startWriteEncaps(_encoding, Ice.FormatType.DefaultFormat); } } public void - startWriteEncaps(Ice.EncodingVersion encoding) + startWriteEncaps(Ice.EncodingVersion encoding, Ice.FormatType format) { Protocol.checkSupportedEncoding(encoding); @@ -289,6 +275,7 @@ public class BasicStream curr.next = _writeEncapsStack; _writeEncapsStack = curr; + _writeEncapsStack.format = format; _writeEncapsStack.setEncoding(encoding); _writeEncapsStack.start = _buf.size(); @@ -822,11 +809,20 @@ public class BasicStream } public void - writeByte(int tag, Ice.Optional<Byte> v) + writeByte(int tag, Ice.ByteOptional v) { - if(v != null && v.isSet() && writeOpt(tag, Ice.OptionalType.F1)) + if(v != null && v.isSet()) { - writeByte(v.get()); + writeByte(tag, v.get()); + } + } + + public void + writeByte(int tag, byte v) + { + if(writeOpt(tag, Ice.OptionalType.F1)) + { + writeByte(v); } } @@ -854,9 +850,18 @@ public class BasicStream public void writeByteSeq(int tag, Ice.Optional<byte[]> v) { - if(v != null && v.isSet() && writeOpt(tag, Ice.OptionalType.VSize)) + if(v != null && v.isSet()) + { + writeByteSeq(tag, v.get()); + } + } + + public void + writeByteSeq(int tag, byte[] v) + { + if(writeOpt(tag, Ice.OptionalType.VSize)) { - writeByteSeq(v.get()); + writeByteSeq(v); } } @@ -896,7 +901,7 @@ public class BasicStream } public void - readByte(int tag, Ice.Optional<Byte> v) + readByte(int tag, Ice.ByteOptional v) { if(readOpt(tag, Ice.OptionalType.F1)) { @@ -965,11 +970,20 @@ public class BasicStream } public void - writeBool(int tag, Ice.Optional<Boolean> v) + writeBool(int tag, Ice.BooleanOptional v) { - if(v != null && v.isSet() && writeOpt(tag, Ice.OptionalType.F1)) + if(v != null && v.isSet()) { - writeBool(v.get()); + writeBool(tag, v.get()); + } + } + + public void + writeBool(int tag, boolean v) + { + if(writeOpt(tag, Ice.OptionalType.F1)) + { + writeBool(v); } } @@ -1000,9 +1014,18 @@ public class BasicStream public void writeBoolSeq(int tag, Ice.Optional<boolean[]> v) { - if(v != null && v.isSet() && writeOpt(tag, Ice.OptionalType.VSize)) + if(v != null && v.isSet()) + { + writeBoolSeq(tag, v.get()); + } + } + + public void + writeBoolSeq(int tag, boolean[] v) + { + if(writeOpt(tag, Ice.OptionalType.VSize)) { - writeBoolSeq(v.get()); + writeBoolSeq(v); } } @@ -1020,7 +1043,7 @@ public class BasicStream } public void - readBool(int tag, Ice.Optional<Boolean> v) + readBool(int tag, Ice.BooleanOptional v) { if(readOpt(tag, Ice.OptionalType.F1)) { @@ -1072,11 +1095,20 @@ public class BasicStream } public void - writeShort(int tag, Ice.Optional<Short> v) + writeShort(int tag, Ice.ShortOptional v) + { + if(v != null && v.isSet()) + { + writeShort(tag, v.get()); + } + } + + public void + writeShort(int tag, short v) { - if(v != null && v.isSet() && writeOpt(tag, Ice.OptionalType.F2)) + if(writeOpt(tag, Ice.OptionalType.F2)) { - writeShort(v.get()); + writeShort(v); } } @@ -1100,11 +1132,19 @@ public class BasicStream public void writeShortSeq(int tag, Ice.Optional<short[]> v) { - if(v != null && v.isSet() && writeOpt(tag, Ice.OptionalType.VSize)) + if(v != null && v.isSet()) { - final short[] arr = v.get(); - writeSize(arr == null || arr.length == 0 ? 1 : arr.length * 2 + (arr.length > 254 ? 5 : 1)); - writeShortSeq(arr); + writeShortSeq(tag, v.get()); + } + } + + public void + writeShortSeq(int tag, short[] v) + { + if(writeOpt(tag, Ice.OptionalType.VSize)) + { + writeSize(v == null || v.length == 0 ? 1 : v.length * 2 + (v.length > 254 ? 5 : 1)); + writeShortSeq(v); } } @@ -1122,7 +1162,7 @@ public class BasicStream } public void - readShort(int tag, Ice.Optional<Short> v) + readShort(int tag, Ice.ShortOptional v) { if(readOpt(tag, Ice.OptionalType.F2)) { @@ -1174,11 +1214,20 @@ public class BasicStream } public void - writeInt(int tag, Ice.Optional<Integer> v) + writeInt(int tag, Ice.IntOptional v) + { + if(v != null && v.isSet()) + { + writeInt(tag, v.get()); + } + } + + public void + writeInt(int tag, int v) { - if(v != null && v.isSet() && writeOpt(tag, Ice.OptionalType.F4)) + if(writeOpt(tag, Ice.OptionalType.F4)) { - writeInt(v.get()); + writeInt(v); } } @@ -1208,11 +1257,19 @@ public class BasicStream public void writeIntSeq(int tag, Ice.Optional<int[]> v) { - if(v != null && v.isSet() && writeOpt(tag, Ice.OptionalType.VSize)) + if(v != null && v.isSet()) { - final int[] arr = v.get(); - writeSize(arr == null || arr.length == 0 ? 1 : arr.length * 4 + (arr.length > 254 ? 5 : 1)); - writeIntSeq(arr); + writeIntSeq(tag, v.get()); + } + } + + public void + writeIntSeq(int tag, int[] v) + { + if(writeOpt(tag, Ice.OptionalType.VSize)) + { + writeSize(v == null || v.length == 0 ? 1 : v.length * 4 + (v.length > 254 ? 5 : 1)); + writeIntSeq(v); } } @@ -1230,7 +1287,7 @@ public class BasicStream } public void - readInt(int tag, Ice.Optional<Integer> v) + readInt(int tag, Ice.IntOptional v) { if(readOpt(tag, Ice.OptionalType.F4)) { @@ -1282,11 +1339,20 @@ public class BasicStream } public void - writeLong(int tag, Ice.Optional<Long> v) + writeLong(int tag, Ice.LongOptional v) { - if(v != null && v.isSet() && writeOpt(tag, Ice.OptionalType.F8)) + if(v != null && v.isSet()) { - writeLong(v.get()); + writeLong(tag, v.get()); + } + } + + public void + writeLong(int tag, long v) + { + if(writeOpt(tag, Ice.OptionalType.F8)) + { + writeLong(v); } } @@ -1310,11 +1376,19 @@ public class BasicStream public void writeLongSeq(int tag, Ice.Optional<long[]> v) { - if(v != null && v.isSet() && writeOpt(tag, Ice.OptionalType.VSize)) + if(v != null && v.isSet()) + { + writeLongSeq(tag, v.get()); + } + } + + public void + writeLongSeq(int tag, long[] v) + { + if(writeOpt(tag, Ice.OptionalType.VSize)) { - final long[] arr = v.get(); - writeSize(arr == null || arr.length == 0 ? 1 : arr.length * 8 + (arr.length > 254 ? 5 : 1)); - writeLongSeq(arr); + writeSize(v == null || v.length == 0 ? 1 : v.length * 8 + (v.length > 254 ? 5 : 1)); + writeLongSeq(v); } } @@ -1332,7 +1406,7 @@ public class BasicStream } public void - readLong(int tag, Ice.Optional<Long> v) + readLong(int tag, Ice.LongOptional v) { if(readOpt(tag, Ice.OptionalType.F8)) { @@ -1384,11 +1458,20 @@ public class BasicStream } public void - writeFloat(int tag, Ice.Optional<Float> v) + writeFloat(int tag, Ice.FloatOptional v) { - if(v != null && v.isSet() && writeOpt(tag, Ice.OptionalType.F4)) + if(v != null && v.isSet()) { - writeFloat(v.get()); + writeFloat(tag, v.get()); + } + } + + public void + writeFloat(int tag, float v) + { + if(writeOpt(tag, Ice.OptionalType.F4)) + { + writeFloat(v); } } @@ -1412,11 +1495,19 @@ public class BasicStream public void writeFloatSeq(int tag, Ice.Optional<float[]> v) { - if(v != null && v.isSet() && writeOpt(tag, Ice.OptionalType.VSize)) + if(v != null && v.isSet()) + { + writeFloatSeq(tag, v.get()); + } + } + + public void + writeFloatSeq(int tag, float[] v) + { + if(writeOpt(tag, Ice.OptionalType.VSize)) { - final float[] arr = v.get(); - writeSize(arr == null || arr.length == 0 ? 1 : arr.length * 4 + (arr.length > 254 ? 5 : 1)); - writeFloatSeq(arr); + writeSize(v == null || v.length == 0 ? 1 : v.length * 4 + (v.length > 254 ? 5 : 1)); + writeFloatSeq(v); } } @@ -1434,7 +1525,7 @@ public class BasicStream } public void - readFloat(int tag, Ice.Optional<Float> v) + readFloat(int tag, Ice.FloatOptional v) { if(readOpt(tag, Ice.OptionalType.F4)) { @@ -1486,11 +1577,20 @@ public class BasicStream } public void - writeDouble(int tag, Ice.Optional<Double> v) + writeDouble(int tag, Ice.DoubleOptional v) { - if(v != null && v.isSet() && writeOpt(tag, Ice.OptionalType.F8)) + if(v != null && v.isSet()) { - writeDouble(v.get()); + writeDouble(tag, v.get()); + } + } + + public void + writeDouble(int tag, double v) + { + if(writeOpt(tag, Ice.OptionalType.F8)) + { + writeDouble(v); } } @@ -1514,11 +1614,19 @@ public class BasicStream public void writeDoubleSeq(int tag, Ice.Optional<double[]> v) { - if(v != null && v.isSet() && writeOpt(tag, Ice.OptionalType.VSize)) + if(v != null && v.isSet()) { - final double[] arr = v.get(); - writeSize(arr == null || arr.length == 0 ? 1 : arr.length * 8 + (arr.length > 254 ? 5 : 1)); - writeDoubleSeq(arr); + writeDoubleSeq(tag, v.get()); + } + } + + public void + writeDoubleSeq(int tag, double[] v) + { + if(writeOpt(tag, Ice.OptionalType.VSize)) + { + writeSize(v == null || v.length == 0 ? 1 : v.length * 8 + (v.length > 254 ? 5 : 1)); + writeDoubleSeq(v); } } @@ -1536,7 +1644,7 @@ public class BasicStream } public void - readDouble(int tag, Ice.Optional<Double> v) + readDouble(int tag, Ice.DoubleOptional v) { if(readOpt(tag, Ice.OptionalType.F8)) { @@ -1649,9 +1757,18 @@ public class BasicStream public void writeString(int tag, Ice.Optional<String> v) { - if(v != null && v.isSet() && writeOpt(tag, Ice.OptionalType.VSize)) + if(v != null && v.isSet()) + { + writeString(tag, v.get()); + } + } + + public void + writeString(int tag, String v) + { + if(writeOpt(tag, Ice.OptionalType.VSize)) { - writeString(v.get()); + writeString(v); } } @@ -1675,10 +1792,19 @@ public class BasicStream public void writeStringSeq(int tag, Ice.Optional<String[]> v) { - if(v != null && v.isSet() && writeOpt(tag, Ice.OptionalType.FSize)) + if(v != null && v.isSet()) + { + writeStringSeq(tag, v.get()); + } + } + + public void + writeStringSeq(int tag, String[] v) + { + if(writeOpt(tag, Ice.OptionalType.FSize)) { startSize(); - writeStringSeq(v.get()); + writeStringSeq(v); endSize(); } } @@ -1809,10 +1935,19 @@ public class BasicStream public void writeProxy(int tag, Ice.Optional<Ice.ObjectPrx> v) { - if(v != null && v.isSet() && writeOpt(tag, Ice.OptionalType.FSize)) + if(v != null && v.isSet()) + { + writeProxy(tag, v.get()); + } + } + + public void + writeProxy(int tag, Ice.ObjectPrx v) + { + if(writeOpt(tag, Ice.OptionalType.FSize)) { startSize(); - writeProxy(v.get()); + writeProxy(v); endSize(); } } @@ -1895,9 +2030,18 @@ public class BasicStream public <T extends Ice.Object> void writeObject(int tag, Ice.Optional<T> v) { - if(v != null && v.isSet() && writeOpt(tag, Ice.OptionalType.Size)) + if(v != null && v.isSet()) + { + writeObject(tag, v.get()); + } + } + + public void + writeObject(int tag, Ice.Object v) + { + if(writeOpt(tag, Ice.OptionalType.Size)) { - writeObject(v.get()); + writeObject(v); } } @@ -3529,11 +3673,10 @@ public class BasicStream private static final class EncapsEncoder { - EncapsEncoder(BasicStream stream, WriteEncaps encaps, Ice.FormatType format) + EncapsEncoder(BasicStream stream, WriteEncaps encaps) { _stream = stream; _encaps = encaps; - _format = format; _sliceType = SliceType.NoSlice; _usesClasses = false; _objectIdIndex = 0; @@ -3562,7 +3705,7 @@ public class BasicStream _stream.writeInt(-index); _usesClasses = true; } - else if(_sliceType != SliceType.NoSlice && _format == Ice.FormatType.SlicedFormat) + else if(_sliceType != SliceType.NoSlice && _encaps.format == Ice.FormatType.SlicedFormat) { // // An object reference that appears inside a slice of an @@ -3674,7 +3817,7 @@ public class BasicStream // Encode the slice size for the old encoding and if using the // sliced format. // - if(_encaps.encoding_1_0 || _format == Ice.FormatType.SlicedFormat) + if(_encaps.encoding_1_0 || _encaps.format == Ice.FormatType.SlicedFormat) { _sliceFlags |= FLAG_HAS_SLICE_SIZE; } @@ -3700,7 +3843,7 @@ public class BasicStream // Encode the type ID (only in the first slice for the compact // encoding). // - if(_format == Ice.FormatType.SlicedFormat || _encaps.encoding_1_0 || _firstSlice) + if(_encaps.format == Ice.FormatType.SlicedFormat || _encaps.encoding_1_0 || _firstSlice) { // // If the type ID has already been seen, write the index @@ -3767,7 +3910,7 @@ public class BasicStream if(!_indirectionTable.isEmpty()) { assert(!_encaps.encoding_1_0); - assert(_format == Ice.FormatType.SlicedFormat); + assert(_encaps.format == Ice.FormatType.SlicedFormat); _sliceFlags |= FLAG_HAS_INDIRECTION_TABLE; // @@ -3899,7 +4042,7 @@ public class BasicStream // using the sliced format. Otherwise, we ignore the preserved slices, which // essentially "slices" the object into the most-derived type known by the sender. // - if(_encaps.encoding_1_0 || _format != Ice.FormatType.SlicedFormat) + if(_encaps.encoding_1_0 || _encaps.format != Ice.FormatType.SlicedFormat) { return; } @@ -3962,7 +4105,6 @@ public class BasicStream private final BasicStream _stream; private final WriteEncaps _encaps; - private final Ice.FormatType _format; // Object/exception attributes private SliceType _sliceType; @@ -4022,6 +4164,7 @@ public class BasicStream } int start; + Ice.FormatType format; Ice.EncodingVersion encoding; boolean encoding_1_0; @@ -4092,9 +4235,14 @@ public class BasicStream _writeEncapsStack.setEncoding(_encoding); } + if(_writeEncapsStack.format == Ice.FormatType.DefaultFormat) + { + _writeEncapsStack.format = _instance.defaultsAndOverrides().defaultFormat; + } + if(_writeEncapsStack.encoder == null) // Lazy initialization. { - _writeEncapsStack.encoder = new EncapsEncoder(this, _writeEncapsStack, _format); + _writeEncapsStack.encoder = new EncapsEncoder(this, _writeEncapsStack); } } @@ -4106,8 +4254,6 @@ public class BasicStream private int _startSeq; private int _minSeqSize; - private Ice.FormatType _format; - private int _sizePos; private static final byte FLAG_HAS_TYPE_ID_STRING = (byte)(1<<0); diff --git a/java/src/IceInternal/EndpointFactoryManager.java b/java/src/IceInternal/EndpointFactoryManager.java index 9c7c075851e..b3c666c4c6a 100644 --- a/java/src/IceInternal/EndpointFactoryManager.java +++ b/java/src/IceInternal/EndpointFactoryManager.java @@ -108,7 +108,7 @@ public final class EndpointFactoryManager // and ask the factory to read the endpoint data from that stream to create // the actual endpoint. // - BasicStream bs = new BasicStream(_instance, Protocol.currentEncoding, true, false); + BasicStream bs = new BasicStream(_instance, Protocol.currentProtocolEncoding, true, false); ue.streamWrite(bs); Buffer buf = bs.getBuffer(); buf.b.position(0); diff --git a/java/src/IceInternal/Incoming.java b/java/src/IceInternal/Incoming.java index 25eeab25bf5..819a6dda886 100644 --- a/java/src/IceInternal/Incoming.java +++ b/java/src/IceInternal/Incoming.java @@ -149,7 +149,7 @@ final public class Incoming extends IncomingBase implements Ice.Request if(_response) { _os.writeByte(ReplyStatus.replyUserException); - _os.startWriteEncaps(encoding); + _os.startWriteEncaps(encoding, Ice.FormatType.DefaultFormat); _os.writeUserException(ex); _os.endWriteEncaps(); _connection.sendResponse(_os, _compress); diff --git a/java/src/IceInternal/IncomingBase.java b/java/src/IceInternal/IncomingBase.java index 0f4000efbad..f3d89f3b71d 100644 --- a/java/src/IceInternal/IncomingBase.java +++ b/java/src/IceInternal/IncomingBase.java @@ -88,14 +88,14 @@ public class IncomingBase } public BasicStream - __startWriteParams() + __startWriteParams(Ice.FormatType format) { if(_response) { assert(_os.size() == Protocol.headerSize + 4); // Reply status position. assert(_current.encoding != null); // Encoding for reply is known. _os.writeByte((byte)0); - _os.startWriteEncaps(_current.encoding); + _os.startWriteEncaps(_current.encoding, format); } // @@ -152,6 +152,14 @@ public class IncomingBase } } + public void + __writeUserException(Ice.UserException ex, Ice.FormatType format) + { + BasicStream __os = __startWriteParams(format); + __os.writeUserException(ex); + __endWriteParams(false); + } + // // These functions allow this object to be reused, rather than reallocated. // diff --git a/java/src/IceInternal/OpaqueEndpointI.java b/java/src/IceInternal/OpaqueEndpointI.java index 91c34ad00bf..3982b095415 100644 --- a/java/src/IceInternal/OpaqueEndpointI.java +++ b/java/src/IceInternal/OpaqueEndpointI.java @@ -164,7 +164,7 @@ final class OpaqueEndpointI extends EndpointI streamWrite(BasicStream s) { s.writeShort(_type); - s.startWriteEncaps(_rawEncoding); + s.startWriteEncaps(_rawEncoding, Ice.FormatType.DefaultFormat); s.writeBlob(_rawBytes); s.endWriteEncaps(); } diff --git a/java/src/IceInternal/Outgoing.java b/java/src/IceInternal/Outgoing.java index c7ace46eb31..aa07f8aa052 100644 --- a/java/src/IceInternal/Outgoing.java +++ b/java/src/IceInternal/Outgoing.java @@ -457,9 +457,9 @@ public final class Outgoing implements OutgoingMessageCallback } public BasicStream - startWriteParams() + startWriteParams(Ice.FormatType format) { - _os.startWriteEncaps(_encoding); + _os.startWriteEncaps(_encoding, format); return _os; } diff --git a/java/src/IceInternal/OutgoingAsync.java b/java/src/IceInternal/OutgoingAsync.java index ca55efc67b1..2333c148c47 100644 --- a/java/src/IceInternal/OutgoingAsync.java +++ b/java/src/IceInternal/OutgoingAsync.java @@ -397,9 +397,9 @@ public class OutgoingAsync extends Ice.AsyncResult implements OutgoingAsyncMessa } public BasicStream - __startWriteParams() + __startWriteParams(Ice.FormatType format) { - _os.startWriteEncaps(_encoding); + _os.startWriteEncaps(_encoding, format); return _os; } diff --git a/java/test/Ice/optional/AMDInitialI.java b/java/test/Ice/optional/AMDInitialI.java new file mode 100644 index 00000000000..732b0152b46 --- /dev/null +++ b/java/test/Ice/optional/AMDInitialI.java @@ -0,0 +1,428 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +package test.Ice.optional; + +import test.Ice.optional.AMD.Test.*; + +public final class AMDInitialI extends Initial +{ + public void + shutdown_async(AMD_Initial_shutdown cb, Ice.Current current) + { + current.adapter.getCommunicator().shutdown(); + cb.ice_response(); + } + + public void + pingPong_async(AMD_Initial_pingPong cb, Ice.Object obj, Ice.Current current) + { + cb.ice_response(obj); + } + + public void + opOptionalException_async(AMD_Initial_opOptionalException cb, Ice.IntOptional a, Ice.Optional<String> b, + Ice.Optional<OneOptional> o, Ice.Current current) + throws OptionalException + { + OptionalException ex = new OptionalException(); + if(a.isSet()) + { + ex.setA(a.get()); + } + else + { + ex.clearA(); // The member "a" has a default value. + } + if(b.isSet()) + { + ex.setB(b.get()); + } + if(o.isSet()) + { + ex.setO(o.get()); + } + cb.ice_exception(ex); + } + + public void + opByte_async(AMD_Initial_opByte cb, Ice.ByteOptional p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opByteOpt_async(AMD_Initial_opByteOpt cb, Ice.ByteOptional p1, Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opBool_async(AMD_Initial_opBool cb, Ice.BooleanOptional p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opBoolOpt_async(AMD_Initial_opBoolOpt cb, Ice.BooleanOptional p1, Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opShort_async(AMD_Initial_opShort cb, Ice.ShortOptional p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opShortOpt_async(AMD_Initial_opShortOpt cb, Ice.ShortOptional p1, Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opInt_async(AMD_Initial_opInt cb, Ice.IntOptional p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opIntOpt_async(AMD_Initial_opIntOpt cb, Ice.IntOptional p1, Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opLong_async(AMD_Initial_opLong cb, Ice.LongOptional p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opLongOpt_async(AMD_Initial_opLongOpt cb, Ice.LongOptional p1, Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opFloat_async(AMD_Initial_opFloat cb, Ice.FloatOptional p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opFloatOpt_async(AMD_Initial_opFloatOpt cb, Ice.FloatOptional p1, Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opDouble_async(AMD_Initial_opDouble cb, Ice.DoubleOptional p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opDoubleOpt_async(AMD_Initial_opDoubleOpt cb, Ice.DoubleOptional p1, Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opString_async(AMD_Initial_opString cb, Ice.Optional<String> p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opStringOpt_async(AMD_Initial_opStringOpt cb, Ice.Optional<String> p1, Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opMyEnum_async(AMD_Initial_opMyEnum cb, Ice.Optional<MyEnum> p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opMyEnumOpt_async(AMD_Initial_opMyEnumOpt cb, Ice.Optional<MyEnum> p1, Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opSmallStruct_async(AMD_Initial_opSmallStruct cb, Ice.Optional<SmallStruct> p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opSmallStructOpt_async(AMD_Initial_opSmallStructOpt cb, Ice.Optional<SmallStruct> p1, Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opFixedStruct_async(AMD_Initial_opFixedStruct cb, Ice.Optional<FixedStruct> p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opFixedStructOpt_async(AMD_Initial_opFixedStructOpt cb, Ice.Optional<FixedStruct> p1, Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opVarStruct_async(AMD_Initial_opVarStruct cb, Ice.Optional<VarStruct> p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opVarStructOpt_async(AMD_Initial_opVarStructOpt cb, Ice.Optional<VarStruct> p1, Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opOneOptional_async(AMD_Initial_opOneOptional cb, Ice.Optional<OneOptional> p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opOneOptionalOpt_async(AMD_Initial_opOneOptionalOpt cb, Ice.Optional<OneOptional> p1, Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opOneOptionalProxy_async(AMD_Initial_opOneOptionalProxy cb, Ice.Optional<OneOptionalPrx> p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opOneOptionalProxyOpt_async(AMD_Initial_opOneOptionalProxyOpt cb, Ice.Optional<OneOptionalPrx> p1, + Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opByteSeq_async(AMD_Initial_opByteSeq cb, Ice.Optional<byte[]> p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opByteSeqOpt_async(AMD_Initial_opByteSeqOpt cb, Ice.Optional<byte[]> p1, Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opBoolSeq_async(AMD_Initial_opBoolSeq cb, Ice.Optional<boolean[]> p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opBoolSeqOpt_async(AMD_Initial_opBoolSeqOpt cb, Ice.Optional<boolean[]> p1, Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opShortSeq_async(AMD_Initial_opShortSeq cb, Ice.Optional<short[]> p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opShortSeqOpt_async(AMD_Initial_opShortSeqOpt cb, Ice.Optional<short[]> p1, Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opIntSeq_async(AMD_Initial_opIntSeq cb, Ice.Optional<int[]> p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opIntSeqOpt_async(AMD_Initial_opIntSeqOpt cb, Ice.Optional<int[]> p1, Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opLongSeq_async(AMD_Initial_opLongSeq cb, Ice.Optional<long[]> p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opLongSeqOpt_async(AMD_Initial_opLongSeqOpt cb, Ice.Optional<long[]> p1, Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opFloatSeq_async(AMD_Initial_opFloatSeq cb, Ice.Optional<float[]> p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opFloatSeqOpt_async(AMD_Initial_opFloatSeqOpt cb, Ice.Optional<float[]> p1, Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opDoubleSeq_async(AMD_Initial_opDoubleSeq cb, Ice.Optional<double[]> p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opDoubleSeqOpt_async(AMD_Initial_opDoubleSeqOpt cb, Ice.Optional<double[]> p1, Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opStringSeq_async(AMD_Initial_opStringSeq cb, Ice.Optional<String[]> p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opStringSeqOpt_async(AMD_Initial_opStringSeqOpt cb, Ice.Optional<String[]> p1, Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opSmallStructSeq_async(AMD_Initial_opSmallStructSeq cb, Ice.Optional<SmallStruct[]> p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opSmallStructSeqOpt_async(AMD_Initial_opSmallStructSeqOpt cb, Ice.Optional<SmallStruct[]> p1, Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opSmallStructList_async(AMD_Initial_opSmallStructList cb, Ice.Optional<java.util.List<SmallStruct>> p1, + Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opSmallStructListOpt_async(AMD_Initial_opSmallStructListOpt cb, Ice.Optional<java.util.List<SmallStruct>> p1, + Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opFixedStructSeq_async(AMD_Initial_opFixedStructSeq cb, Ice.Optional<FixedStruct[]> p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opFixedStructSeqOpt_async(AMD_Initial_opFixedStructSeqOpt cb, Ice.Optional<FixedStruct[]> p1, Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opFixedStructList_async(AMD_Initial_opFixedStructList cb, Ice.Optional<java.util.List<FixedStruct>> p1, + Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opFixedStructListOpt_async(AMD_Initial_opFixedStructListOpt cb, Ice.Optional<java.util.List<FixedStruct>> p1, + Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opVarStructSeq_async(AMD_Initial_opVarStructSeq cb, Ice.Optional<VarStruct[]> p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opVarStructSeqOpt_async(AMD_Initial_opVarStructSeqOpt cb, Ice.Optional<VarStruct[]> p1, Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opSerializable_async(AMD_Initial_opSerializable cb, Ice.Optional<SerializableClass> p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opSerializableOpt_async(AMD_Initial_opSerializableOpt cb, Ice.Optional<SerializableClass> p1, Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opIntIntDict_async(AMD_Initial_opIntIntDict cb, Ice.Optional<java.util.Map<Integer, Integer>> p1, + Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opIntIntDictOpt_async(AMD_Initial_opIntIntDictOpt cb, Ice.Optional<java.util.Map<Integer, Integer>> p1, + Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opStringIntDict_async(AMD_Initial_opStringIntDict cb, Ice.Optional<java.util.Map<String, Integer>> p1, + Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opStringIntDictOpt_async(AMD_Initial_opStringIntDictOpt cb, Ice.Optional<java.util.Map<String, Integer>> p1, + Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opClassAndUnknownOptional_async(AMD_Initial_opClassAndUnknownOptional cb, A p, Ice.Current current) + { + cb.ice_response(); + } +} diff --git a/java/test/Ice/optional/AMDServer.java b/java/test/Ice/optional/AMDServer.java new file mode 100644 index 00000000000..df5550d0544 --- /dev/null +++ b/java/test/Ice/optional/AMDServer.java @@ -0,0 +1,39 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +package test.Ice.optional; + +public class AMDServer extends test.Util.Application +{ + public int run(String[] args) + { + communicator().getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010:udp"); + Ice.ObjectAdapter adapter = communicator().createObjectAdapter("TestAdapter"); + adapter.add(new AMDInitialI(), communicator().stringToIdentity("initial")); + adapter.activate(); + return WAIT; + } + + protected Ice.InitializationData getInitData(Ice.StringSeqHolder argsH) + { + Ice.InitializationData initData = new Ice.InitializationData(); + initData.properties = Ice.Util.createProperties(argsH); + initData.properties.setProperty("Ice.Package.Test", "test.Ice.optional.AMD"); + return initData; + } + + public static void main(String[] args) + { + AMDServer c = new AMDServer(); + int status = c.main("Server", args); + + System.gc(); + System.exit(status); + } +} diff --git a/java/test/Ice/optional/AllTests.java b/java/test/Ice/optional/AllTests.java index 3f8f2ca8722..98538ba7311 100644 --- a/java/test/Ice/optional/AllTests.java +++ b/java/test/Ice/optional/AllTests.java @@ -317,6 +317,21 @@ public class AllTests test(!mo9.hasBos()); + { + OptionalWithCustom owc1 = new OptionalWithCustom(); + java.util.ArrayList<Byte> l = new java.util.ArrayList<Byte>(); + l.add((byte)5); + l.add((byte)6); + l.add((byte)7); + owc1.setBs(l); + owc1.setS(new ClassVarStruct(5)); + OptionalWithCustom owc2 = (OptionalWithCustom)initial.pingPong(owc1); + test(owc2.hasBs()); + test(owc2.getBs().equals(l)); + test(owc2.hasS()); + test(owc2.getS().a == 5); + } + // // Send a request using blobjects. Upon receival, we don't read // any of the optional members. This ensures the optional members @@ -509,16 +524,24 @@ public class AllTests out.print("testing optional parameters... "); out.flush(); { - Ice.Optional<Byte> p1 = new Ice.Optional<Byte>(); - Ice.Optional<Byte> p3 = new Ice.Optional<Byte>(); - Ice.Optional<Byte> p2 = initial.opByte(p1, p3); + Ice.ByteOptional p1 = new Ice.ByteOptional(); + Ice.ByteOptional p3 = new Ice.ByteOptional(); + Ice.ByteOptional p2 = initial.opByteOpt(p1, p3); test(!p2.isSet() && !p3.isSet()); p1.set((byte)56); - p2 = initial.opByte(p1, p3); + p2 = initial.opByteOpt(p1, p3); + test(p2.get() == (byte)56 && p3.get() == (byte)56); + Ice.AsyncResult r = initial.begin_opByteOpt(p1); + p2 = initial.end_opByteOpt(p3, r); + test(p2.get() == (byte)56 && p3.get() == (byte)56); + p2 = initial.opByte(p1.get(), p3); + test(p2.get() == (byte)56 && p3.get() == (byte)56); + r = initial.begin_opByte(p1.get()); + p2 = initial.end_opByte(p3, r); test(p2.get() == (byte)56 && p3.get() == (byte)56); - p2 = initial.opByte(new Ice.Optional<Byte>(), p3); + p2 = initial.opByteOpt(new Ice.ByteOptional(), p3); test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. os = Ice.Util.createOutputStream(communicator); @@ -542,16 +565,147 @@ public class AllTests } { - Ice.Optional<Long> p1 = new Ice.Optional<Long>(); - Ice.Optional<Long> p3 = new Ice.Optional<Long>(); - Ice.Optional<Long> p2 = initial.opLong(p1, p3); + Ice.BooleanOptional p1 = new Ice.BooleanOptional(); + Ice.BooleanOptional p3 = new Ice.BooleanOptional(); + Ice.BooleanOptional p2 = initial.opBoolOpt(p1, p3); + test(!p2.isSet() && !p3.isSet()); + + p1.set(true); + p2 = initial.opBoolOpt(p1, p3); + test(p2.get() == true && p3.get() == true); + Ice.AsyncResult r = initial.begin_opBoolOpt(p1); + p2 = initial.end_opBoolOpt(p3, r); + test(p2.get() == true && p3.get() == true); + p2 = initial.opBool(true, p3); + test(p2.get() == true && p3.get() == true); + r = initial.begin_opBool(true); + p2 = initial.end_opBool(p3, r); + test(p2.get() == true && p3.get() == true); + + p2 = initial.opBoolOpt(new Ice.BooleanOptional(), p3); + test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. + + os = Ice.Util.createOutputStream(communicator); + os.startEncapsulation(); + os.writeOptional(2, Ice.OptionalType.F1); + os.writeBool(p1.get()); + os.endEncapsulation(); + inEncaps = os.finished(); + initial.ice_invoke("opBool", Ice.OperationMode.Normal, inEncaps, outEncaps); + in = Ice.Util.createInputStream(communicator, outEncaps.value); + in.startEncapsulation(); + test(in.readOptional(1, Ice.OptionalType.F1)); + test(in.readBool() == true); + test(in.readOptional(3, Ice.OptionalType.F1)); + test(in.readBool() == true); + in.endEncapsulation(); + + in = Ice.Util.createInputStream(communicator, outEncaps.value); + in.startEncapsulation(); + in.endEncapsulation(); + } + + { + Ice.ShortOptional p1 = new Ice.ShortOptional(); + Ice.ShortOptional p3 = new Ice.ShortOptional(); + Ice.ShortOptional p2 = initial.opShortOpt(p1, p3); + test(!p2.isSet() && !p3.isSet()); + + p1.set((short)56); + p2 = initial.opShortOpt(p1, p3); + test(p2.get() == 56 && p3.get() == 56); + Ice.AsyncResult r = initial.begin_opShortOpt(p1); + p2 = initial.end_opShortOpt(p3, r); + test(p2.get() == 56 && p3.get() == 56); + p2 = initial.opShort(p1.get(), p3); + test(p2.get() == 56 && p3.get() == 56); + r = initial.begin_opShort(p1.get()); + p2 = initial.end_opShort(p3, r); + test(p2.get() == 56 && p3.get() == 56); + + p2 = initial.opShortOpt(new Ice.ShortOptional(), p3); + test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. + + os = Ice.Util.createOutputStream(communicator); + os.startEncapsulation(); + os.writeOptional(2, Ice.OptionalType.F2); + os.writeShort(p1.get()); + os.endEncapsulation(); + inEncaps = os.finished(); + initial.ice_invoke("opShort", Ice.OperationMode.Normal, inEncaps, outEncaps); + in = Ice.Util.createInputStream(communicator, outEncaps.value); + in.startEncapsulation(); + test(in.readOptional(1, Ice.OptionalType.F2)); + test(in.readShort() == 56); + test(in.readOptional(3, Ice.OptionalType.F2)); + test(in.readShort() == 56); + in.endEncapsulation(); + + in = Ice.Util.createInputStream(communicator, outEncaps.value); + in.startEncapsulation(); + in.endEncapsulation(); + } + + { + Ice.IntOptional p1 = new Ice.IntOptional(); + Ice.IntOptional p3 = new Ice.IntOptional(); + Ice.IntOptional p2 = initial.opIntOpt(p1, p3); + test(!p2.isSet() && !p3.isSet()); + + p1.set(56); + p2 = initial.opIntOpt(p1, p3); + test(p2.get() == 56 && p3.get() == 56); + Ice.AsyncResult r = initial.begin_opIntOpt(p1); + p2 = initial.end_opIntOpt(p3, r); + test(p2.get() == 56 && p3.get() == 56); + p2 = initial.opInt(p1.get(), p3); + test(p2.get() == 56 && p3.get() == 56); + r = initial.begin_opInt(p1.get()); + p2 = initial.end_opInt(p3, r); + test(p2.get() == 56 && p3.get() == 56); + + p2 = initial.opIntOpt(new Ice.IntOptional(), p3); + test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. + + os = Ice.Util.createOutputStream(communicator); + os.startEncapsulation(); + os.writeOptional(2, Ice.OptionalType.F4); + os.writeInt(p1.get()); + os.endEncapsulation(); + inEncaps = os.finished(); + initial.ice_invoke("opInt", Ice.OperationMode.Normal, inEncaps, outEncaps); + in = Ice.Util.createInputStream(communicator, outEncaps.value); + in.startEncapsulation(); + test(in.readOptional(1, Ice.OptionalType.F4)); + test(in.readInt() == 56); + test(in.readOptional(3, Ice.OptionalType.F4)); + test(in.readInt() == 56); + in.endEncapsulation(); + + in = Ice.Util.createInputStream(communicator, outEncaps.value); + in.startEncapsulation(); + in.endEncapsulation(); + } + + { + Ice.LongOptional p1 = new Ice.LongOptional(); + Ice.LongOptional p3 = new Ice.LongOptional(); + Ice.LongOptional p2 = initial.opLongOpt(p1, p3); test(!p2.isSet() && !p3.isSet()); - p1.set((long)56); - p2 = initial.opLong(p1, p3); + p1.set(56); + p2 = initial.opLongOpt(p1, p3); + test(p2.get() == 56 && p3.get() == 56); + Ice.AsyncResult r = initial.begin_opLongOpt(p1); + p2 = initial.end_opLongOpt(p3, r); + test(p2.get() == 56 && p3.get() == 56); + p2 = initial.opLong(p1.get(), p3); + test(p2.get() == 56 && p3.get() == 56); + r = initial.begin_opLong(p1.get()); + p2 = initial.end_opLong(p3, r); test(p2.get() == 56 && p3.get() == 56); - p2 = initial.opLong(new Ice.Optional<Long>(), p3); + p2 = initial.opLongOpt(new Ice.LongOptional(), p3); test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. os = Ice.Util.createOutputStream(communicator); @@ -575,16 +729,106 @@ public class AllTests } { + Ice.FloatOptional p1 = new Ice.FloatOptional(); + Ice.FloatOptional p3 = new Ice.FloatOptional(); + Ice.FloatOptional p2 = initial.opFloatOpt(p1, p3); + test(!p2.isSet() && !p3.isSet()); + + p1.set((float)1.0); + p2 = initial.opFloatOpt(p1, p3); + test(p2.get() == 1.0 && p3.get() == 1.0); + Ice.AsyncResult r = initial.begin_opFloatOpt(p1); + p2 = initial.end_opFloatOpt(p3, r); + test(p2.get() == 1.0 && p3.get() == 1.0); + p2 = initial.opFloat(p1.get(), p3); + test(p2.get() == 1.0 && p3.get() == 1.0); + r = initial.begin_opFloat(p1.get()); + p2 = initial.end_opFloat(p3, r); + test(p2.get() == 1.0 && p3.get() == 1.0); + + p2 = initial.opFloatOpt(new Ice.FloatOptional(), p3); + test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. + + os = Ice.Util.createOutputStream(communicator); + os.startEncapsulation(); + os.writeOptional(2, Ice.OptionalType.F4); + os.writeFloat(p1.get()); + os.endEncapsulation(); + inEncaps = os.finished(); + initial.ice_invoke("opFloat", Ice.OperationMode.Normal, inEncaps, outEncaps); + in = Ice.Util.createInputStream(communicator, outEncaps.value); + in.startEncapsulation(); + test(in.readOptional(1, Ice.OptionalType.F4)); + test(in.readFloat() == 1.0); + test(in.readOptional(3, Ice.OptionalType.F4)); + test(in.readFloat() == 1.0); + in.endEncapsulation(); + + in = Ice.Util.createInputStream(communicator, outEncaps.value); + in.startEncapsulation(); + in.endEncapsulation(); + } + + { + Ice.DoubleOptional p1 = new Ice.DoubleOptional(); + Ice.DoubleOptional p3 = new Ice.DoubleOptional(); + Ice.DoubleOptional p2 = initial.opDoubleOpt(p1, p3); + test(!p2.isSet() && !p3.isSet()); + + p1.set(1.0); + p2 = initial.opDoubleOpt(p1, p3); + test(p2.get() == 1.0 && p3.get() == 1.0); + Ice.AsyncResult r = initial.begin_opDoubleOpt(p1); + p2 = initial.end_opDoubleOpt(p3, r); + test(p2.get() == 1.0 && p3.get() == 1.0); + p2 = initial.opDouble(p1.get(), p3); + test(p2.get() == 1.0 && p3.get() == 1.0); + r = initial.begin_opDouble(p1.get()); + p2 = initial.end_opDouble(p3, r); + test(p2.get() == 1.0 && p3.get() == 1.0); + + p2 = initial.opDoubleOpt(new Ice.DoubleOptional(), p3); + test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. + + os = Ice.Util.createOutputStream(communicator); + os.startEncapsulation(); + os.writeOptional(2, Ice.OptionalType.F8); + os.writeDouble(p1.get()); + os.endEncapsulation(); + inEncaps = os.finished(); + initial.ice_invoke("opDouble", Ice.OperationMode.Normal, inEncaps, outEncaps); + in = Ice.Util.createInputStream(communicator, outEncaps.value); + in.startEncapsulation(); + test(in.readOptional(1, Ice.OptionalType.F8)); + test(in.readDouble() == 1.0); + test(in.readOptional(3, Ice.OptionalType.F8)); + test(in.readDouble() == 1.0); + in.endEncapsulation(); + + in = Ice.Util.createInputStream(communicator, outEncaps.value); + in.startEncapsulation(); + in.endEncapsulation(); + } + + { Ice.Optional<String> p1 = new Ice.Optional<String>(); Ice.Optional<String> p3 = new Ice.Optional<String>(); - Ice.Optional<String> p2 = initial.opString(p1, p3); + Ice.Optional<String> p2 = initial.opStringOpt(p1, p3); test(!p2.isSet() && !p3.isSet()); p1.set("test"); - p2 = initial.opString(p1, p3); + p2 = initial.opStringOpt(p1, p3); + test(p2.get().equals("test") && p3.get().equals("test")); + Ice.AsyncResult r = initial.begin_opStringOpt(p1); + p2 = initial.end_opStringOpt(p3, r); + test(p2.get().equals("test") && p3.get().equals("test")); + p2 = initial.opString(p1.get(), p3); + test(p2.get().equals("test") && p3.get().equals("test")); + r = initial.begin_opString(p1.get()); + p2 = initial.end_opString(p3, r); test(p2.get().equals("test") && p3.get().equals("test")); - p2 = initial.opString(new Ice.Optional<String>(), p3); + p2 = initial.opStringOpt(new Ice.Optional<String>(), p3); test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. os = Ice.Util.createOutputStream(communicator); @@ -608,16 +852,207 @@ public class AllTests } { + Ice.Optional<MyEnum> p1 = new Ice.Optional<MyEnum>(); + Ice.Optional<MyEnum> p3 = new Ice.Optional<MyEnum>(); + Ice.Optional<MyEnum> p2 = initial.opMyEnumOpt(p1, p3); + test(!p2.isSet() && !p3.isSet()); + + p1.set(MyEnum.MyEnumMember); + p2 = initial.opMyEnumOpt(p1, p3); + test(p2.get() == MyEnum.MyEnumMember && p3.get() == MyEnum.MyEnumMember); + Ice.AsyncResult r = initial.begin_opMyEnumOpt(p1); + p2 = initial.end_opMyEnumOpt(p3, r); + test(p2.get() == MyEnum.MyEnumMember && p3.get() == MyEnum.MyEnumMember); + p2 = initial.opMyEnum(p1.get(), p3); + test(p2.get() == MyEnum.MyEnumMember && p3.get() == MyEnum.MyEnumMember); + r = initial.begin_opMyEnum(p1.get()); + p2 = initial.end_opMyEnum(p3, r); + test(p2.get() == MyEnum.MyEnumMember && p3.get() == MyEnum.MyEnumMember); + + p2 = initial.opMyEnumOpt(new Ice.Optional<MyEnum>(), p3); + test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. + + os = Ice.Util.createOutputStream(communicator); + os.startEncapsulation(); + os.writeOptional(2, Ice.OptionalType.Size); + p1.get().ice_write(os); + os.endEncapsulation(); + inEncaps = os.finished(); + initial.ice_invoke("opMyEnum", Ice.OperationMode.Normal, inEncaps, outEncaps); + in = Ice.Util.createInputStream(communicator, outEncaps.value); + in.startEncapsulation(); + test(in.readOptional(1, Ice.OptionalType.Size)); + test(MyEnum.ice_read(in) == MyEnum.MyEnumMember); + test(in.readOptional(3, Ice.OptionalType.Size)); + test(MyEnum.ice_read(in) == MyEnum.MyEnumMember); + in.endEncapsulation(); + + in = Ice.Util.createInputStream(communicator, outEncaps.value); + in.startEncapsulation(); + in.endEncapsulation(); + } + + { + Ice.Optional<SmallStruct> p1 = new Ice.Optional<SmallStruct>(); + Ice.Optional<SmallStruct> p3 = new Ice.Optional<SmallStruct>(); + Ice.Optional<SmallStruct> p2 = initial.opSmallStructOpt(p1, p3); + test(!p2.isSet() && !p3.isSet()); + + p1.set(new SmallStruct((byte)56)); + p2 = initial.opSmallStructOpt(p1, p3); + test(p2.get().m == (byte)56 && p3.get().m == (byte)56); + Ice.AsyncResult r = initial.begin_opSmallStructOpt(p1); + p2 = initial.end_opSmallStructOpt(p3, r); + test(p2.get().m == (byte)56 && p3.get().m == (byte)56); + p2 = initial.opSmallStruct(p1.get(), p3); + test(p2.get().m == (byte)56 && p3.get().m == (byte)56); + r = initial.begin_opSmallStruct(p1.get()); + p2 = initial.end_opSmallStruct(p3, r); + test(p2.get().m == (byte)56 && p3.get().m == (byte)56); + + p2 = initial.opSmallStructOpt(new Ice.Optional<SmallStruct>(), p3); + test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. + + os = Ice.Util.createOutputStream(communicator); + os.startEncapsulation(); + os.writeOptional(2, Ice.OptionalType.VSize); + os.writeSize(1); + p1.get().ice_write(os); + os.endEncapsulation(); + inEncaps = os.finished(); + initial.ice_invoke("opSmallStruct", Ice.OperationMode.Normal, inEncaps, outEncaps); + in = Ice.Util.createInputStream(communicator, outEncaps.value); + in.startEncapsulation(); + test(in.readOptional(1, Ice.OptionalType.VSize)); + in.skipSize(); + SmallStruct f = new SmallStruct(); + f.ice_read(in); + test(f.m == (byte)56); + test(in.readOptional(3, Ice.OptionalType.VSize)); + in.skipSize(); + f.ice_read(in); + test(f.m == (byte)56); + in.endEncapsulation(); + + in = Ice.Util.createInputStream(communicator, outEncaps.value); + in.startEncapsulation(); + in.endEncapsulation(); + } + + { + Ice.Optional<FixedStruct> p1 = new Ice.Optional<FixedStruct>(); + Ice.Optional<FixedStruct> p3 = new Ice.Optional<FixedStruct>(); + Ice.Optional<FixedStruct> p2 = initial.opFixedStructOpt(p1, p3); + test(!p2.isSet() && !p3.isSet()); + + p1.set(new FixedStruct(56)); + p2 = initial.opFixedStructOpt(p1, p3); + test(p2.get().m == 56 && p3.get().m == 56); + Ice.AsyncResult r = initial.begin_opFixedStructOpt(p1); + p2 = initial.end_opFixedStructOpt(p3, r); + test(p2.get().m == 56 && p3.get().m == 56); + p2 = initial.opFixedStruct(p1.get(), p3); + test(p2.get().m == 56 && p3.get().m == 56); + r = initial.begin_opFixedStruct(p1.get()); + p2 = initial.end_opFixedStruct(p3, r); + test(p2.get().m == 56 && p3.get().m == 56); + + p2 = initial.opFixedStructOpt(new Ice.Optional<FixedStruct>(), p3); + test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. + + os = Ice.Util.createOutputStream(communicator); + os.startEncapsulation(); + os.writeOptional(2, Ice.OptionalType.VSize); + os.writeSize(4); + p1.get().ice_write(os); + os.endEncapsulation(); + inEncaps = os.finished(); + initial.ice_invoke("opFixedStruct", Ice.OperationMode.Normal, inEncaps, outEncaps); + in = Ice.Util.createInputStream(communicator, outEncaps.value); + in.startEncapsulation(); + test(in.readOptional(1, Ice.OptionalType.VSize)); + in.skipSize(); + FixedStruct f = new FixedStruct(); + f.ice_read(in); + test(f.m == 56); + test(in.readOptional(3, Ice.OptionalType.VSize)); + in.skipSize(); + f.ice_read(in); + test(f.m == 56); + in.endEncapsulation(); + + in = Ice.Util.createInputStream(communicator, outEncaps.value); + in.startEncapsulation(); + in.endEncapsulation(); + } + + { + Ice.Optional<VarStruct> p1 = new Ice.Optional<VarStruct>(); + Ice.Optional<VarStruct> p3 = new Ice.Optional<VarStruct>(); + Ice.Optional<VarStruct> p2 = initial.opVarStructOpt(p1, p3); + test(!p2.isSet() && !p3.isSet()); + + p1.set(new VarStruct("test")); + p2 = initial.opVarStructOpt(p1, p3); + test(p2.get().m.equals("test") && p3.get().m.equals("test")); + Ice.AsyncResult r = initial.begin_opVarStructOpt(p1); + p2 = initial.end_opVarStructOpt(p3, r); + test(p2.get().m.equals("test") && p3.get().m.equals("test")); + p2 = initial.opVarStruct(p1.get(), p3); + test(p2.get().m.equals("test") && p3.get().m.equals("test")); + r = initial.begin_opVarStruct(p1.get()); + p2 = initial.end_opVarStruct(p3, r); + test(p2.get().m.equals("test") && p3.get().m.equals("test")); + + p2 = initial.opVarStructOpt(new Ice.Optional<VarStruct>(), p3); + test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. + + os = Ice.Util.createOutputStream(communicator); + os.startEncapsulation(); + os.writeOptional(2, Ice.OptionalType.FSize); + os.startSize(); + p1.get().ice_write(os); + os.endSize(); + os.endEncapsulation(); + inEncaps = os.finished(); + initial.ice_invoke("opVarStruct", Ice.OperationMode.Normal, inEncaps, outEncaps); + in = Ice.Util.createInputStream(communicator, outEncaps.value); + in.startEncapsulation(); + test(in.readOptional(1, Ice.OptionalType.FSize)); + in.skip(4); + VarStruct v = new VarStruct(); + v.ice_read(in); + test(v.m.equals("test")); + test(in.readOptional(3, Ice.OptionalType.FSize)); + in.skip(4); + v.ice_read(in); + test(v.m.equals("test")); + in.endEncapsulation(); + + in = Ice.Util.createInputStream(communicator, outEncaps.value); + in.startEncapsulation(); + in.endEncapsulation(); + } + + { Ice.Optional<OneOptional> p1 = new Ice.Optional<OneOptional>(); Ice.Optional<OneOptional> p3 = new Ice.Optional<OneOptional>(); - Ice.Optional<OneOptional> p2 = initial.opOneOptional(p1, p3); + Ice.Optional<OneOptional> p2 = initial.opOneOptionalOpt(p1, p3); test(!p2.isSet() && !p3.isSet()); p1.set(new OneOptional(58)); - p2 = initial.opOneOptional(p1, p3); + p2 = initial.opOneOptionalOpt(p1, p3); + test(p2.get().getA() == 58 && p3.get().getA() == 58); + Ice.AsyncResult r = initial.begin_opOneOptionalOpt(p1); + p2 = initial.end_opOneOptionalOpt(p3, r); + test(p2.get().getA() == 58 && p3.get().getA() == 58); + p2 = initial.opOneOptional(p1.get(), p3); + test(p2.get().getA() == 58 && p3.get().getA() == 58); + r = initial.begin_opOneOptional(p1.get()); + p2 = initial.end_opOneOptional(p3, r); test(p2.get().getA() == 58 && p3.get().getA() == 58); - p2 = initial.opOneOptional(new Ice.Optional<OneOptional>(), p3); + p2 = initial.opOneOptionalOpt(new Ice.Optional<OneOptional>(), p3); test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. os = Ice.Util.createOutputStream(communicator); @@ -646,14 +1081,22 @@ public class AllTests { Ice.Optional<OneOptionalPrx> p1 = new Ice.Optional<OneOptionalPrx>(); Ice.Optional<OneOptionalPrx> p3 = new Ice.Optional<OneOptionalPrx>(); - Ice.Optional<OneOptionalPrx> p2 = initial.opOneOptionalProxy(p1, p3); + Ice.Optional<OneOptionalPrx> p2 = initial.opOneOptionalProxyOpt(p1, p3); test(!p2.isSet() && !p3.isSet()); p1.set(OneOptionalPrxHelper.uncheckedCast(communicator.stringToProxy("test"))); - p2 = initial.opOneOptionalProxy(p1, p3); + p2 = initial.opOneOptionalProxyOpt(p1, p3); + test(p2.get().equals(p1.get()) && p3.get().equals(p1.get())); + Ice.AsyncResult r = initial.begin_opOneOptionalProxyOpt(p1); + p2 = initial.end_opOneOptionalProxyOpt(p3, r); + test(p2.get().equals(p1.get()) && p3.get().equals(p1.get())); + p2 = initial.opOneOptionalProxy(p1.get(), p3); + test(p2.get().equals(p1.get()) && p3.get().equals(p1.get())); + r = initial.begin_opOneOptionalProxy(p1.get()); + p2 = initial.end_opOneOptionalProxy(p3, r); test(p2.get().equals(p1.get()) && p3.get().equals(p1.get())); - p2 = initial.opOneOptionalProxy(new Ice.Optional<OneOptionalPrx>(), p3); + p2 = initial.opOneOptionalProxyOpt(new Ice.Optional<OneOptionalPrx>(), p3); test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. os = Ice.Util.createOutputStream(communicator); @@ -683,15 +1126,23 @@ public class AllTests { Ice.Optional<byte[]> p1 = new Ice.Optional<byte[]>(); Ice.Optional<byte[]> p3 = new Ice.Optional<byte[]>(); - Ice.Optional<byte[]> p2 = initial.opByteSeq(p1, p3); + Ice.Optional<byte[]> p2 = initial.opByteSeqOpt(p1, p3); test(!p2.isSet() && !p3.isSet()); p1.set(new byte[100]); java.util.Arrays.fill(p1.get(), (byte)56); - p2 = initial.opByteSeq(p1, p3); + p2 = initial.opByteSeqOpt(p1, p3); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + Ice.AsyncResult r = initial.begin_opByteSeqOpt(p1); + p2 = initial.end_opByteSeqOpt(p3, r); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + p2 = initial.opByteSeq(p1.get(), p3); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + r = initial.begin_opByteSeq(p1.get()); + p2 = initial.end_opByteSeq(p3, r); test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); - p2 = initial.opByteSeq(new Ice.Optional<byte[]>(), p3); + p2 = initial.opByteSeqOpt(new Ice.Optional<byte[]>(), p3); test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. os = Ice.Util.createOutputStream(communicator); @@ -715,17 +1166,66 @@ public class AllTests } { + Ice.Optional<boolean[]> p1 = new Ice.Optional<boolean[]>(); + Ice.Optional<boolean[]> p3 = new Ice.Optional<boolean[]>(); + Ice.Optional<boolean[]> p2 = initial.opBoolSeqOpt(p1, p3); + test(!p2.isSet() && !p3.isSet()); + + p1.set(new boolean[100]); + p2 = initial.opBoolSeqOpt(p1, p3); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + Ice.AsyncResult r = initial.begin_opBoolSeqOpt(p1); + p2 = initial.end_opBoolSeqOpt(p3, r); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + p2 = initial.opBoolSeq(p1.get(), p3); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + r = initial.begin_opBoolSeq(p1.get()); + p2 = initial.end_opBoolSeq(p3, r); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + + p2 = initial.opBoolSeqOpt(new Ice.Optional<boolean[]>(), p3); + test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. + + os = Ice.Util.createOutputStream(communicator); + os.startEncapsulation(); + os.writeOptional(2, Ice.OptionalType.VSize); + os.writeBoolSeq(p1.get()); + os.endEncapsulation(); + inEncaps = os.finished(); + initial.ice_invoke("opBoolSeq", Ice.OperationMode.Normal, inEncaps, outEncaps); + in = Ice.Util.createInputStream(communicator, outEncaps.value); + in.startEncapsulation(); + test(in.readOptional(1, Ice.OptionalType.VSize)); + test(java.util.Arrays.equals(in.readBoolSeq(), p1.get())); + test(in.readOptional(3, Ice.OptionalType.VSize)); + test(java.util.Arrays.equals(in.readBoolSeq(), p1.get())); + in.endEncapsulation(); + + in = Ice.Util.createInputStream(communicator, outEncaps.value); + in.startEncapsulation(); + in.endEncapsulation(); + } + + { Ice.Optional<short[]> p1 = new Ice.Optional<short[]>(); Ice.Optional<short[]> p3 = new Ice.Optional<short[]>(); - Ice.Optional<short[]> p2 = initial.opShortSeq(p1, p3); + Ice.Optional<short[]> p2 = initial.opShortSeqOpt(p1, p3); test(!p2.isSet() && !p3.isSet()); p1.set(new short[100]); java.util.Arrays.fill(p1.get(), (short)56); - p2 = initial.opShortSeq(p1, p3); + p2 = initial.opShortSeqOpt(p1, p3); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + Ice.AsyncResult r = initial.begin_opShortSeqOpt(p1); + p2 = initial.end_opShortSeqOpt(p3, r); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + p2 = initial.opShortSeq(p1.get(), p3); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + r = initial.begin_opShortSeq(p1.get()); + p2 = initial.end_opShortSeq(p3, r); test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); - p2 = initial.opShortSeq(new Ice.Optional<short[]>(), p3); + p2 = initial.opShortSeqOpt(new Ice.Optional<short[]>(), p3); test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. os = Ice.Util.createOutputStream(communicator); @@ -752,31 +1252,178 @@ public class AllTests } { - Ice.Optional<boolean[]> p1 = new Ice.Optional<boolean[]>(); - Ice.Optional<boolean[]> p3 = new Ice.Optional<boolean[]>(); - Ice.Optional<boolean[]> p2 = initial.opBoolSeq(p1, p3); + Ice.Optional<int[]> p1 = new Ice.Optional<int[]>(); + Ice.Optional<int[]> p3 = new Ice.Optional<int[]>(); + Ice.Optional<int[]> p2 = initial.opIntSeqOpt(p1, p3); test(!p2.isSet() && !p3.isSet()); - p1.set(new boolean[100]); - p2 = initial.opBoolSeq(p1, p3); + p1.set(new int[100]); + java.util.Arrays.fill(p1.get(), 56); + p2 = initial.opIntSeqOpt(p1, p3); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + Ice.AsyncResult r = initial.begin_opIntSeqOpt(p1); + p2 = initial.end_opIntSeqOpt(p3, r); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + p2 = initial.opIntSeq(p1.get(), p3); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + r = initial.begin_opIntSeq(p1.get()); + p2 = initial.end_opIntSeq(p3, r); test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); - p2 = initial.opBoolSeq(new Ice.Optional<boolean[]>(), p3); + p2 = initial.opIntSeqOpt(new Ice.Optional<int[]>(), p3); test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. os = Ice.Util.createOutputStream(communicator); os.startEncapsulation(); os.writeOptional(2, Ice.OptionalType.VSize); - os.writeBoolSeq(p1.get()); + os.writeSize(p1.get().length * 4 + (p1.get().length > 254 ? 5 : 1)); + os.writeIntSeq(p1.get()); os.endEncapsulation(); inEncaps = os.finished(); - initial.ice_invoke("opBoolSeq", Ice.OperationMode.Normal, inEncaps, outEncaps); + initial.ice_invoke("opIntSeq", Ice.OperationMode.Normal, inEncaps, outEncaps); in = Ice.Util.createInputStream(communicator, outEncaps.value); in.startEncapsulation(); test(in.readOptional(1, Ice.OptionalType.VSize)); - test(java.util.Arrays.equals(in.readBoolSeq(), p1.get())); + in.skipSize(); + test(java.util.Arrays.equals(in.readIntSeq(), p1.get())); test(in.readOptional(3, Ice.OptionalType.VSize)); - test(java.util.Arrays.equals(in.readBoolSeq(), p1.get())); + in.skipSize(); + test(java.util.Arrays.equals(in.readIntSeq(), p1.get())); + in.endEncapsulation(); + + in = Ice.Util.createInputStream(communicator, outEncaps.value); + in.startEncapsulation(); + in.endEncapsulation(); + } + + { + Ice.Optional<long[]> p1 = new Ice.Optional<long[]>(); + Ice.Optional<long[]> p3 = new Ice.Optional<long[]>(); + Ice.Optional<long[]> p2 = initial.opLongSeqOpt(p1, p3); + test(!p2.isSet() && !p3.isSet()); + + p1.set(new long[100]); + java.util.Arrays.fill(p1.get(), 56); + p2 = initial.opLongSeqOpt(p1, p3); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + Ice.AsyncResult r = initial.begin_opLongSeqOpt(p1); + p2 = initial.end_opLongSeqOpt(p3, r); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + p2 = initial.opLongSeq(p1.get(), p3); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + r = initial.begin_opLongSeq(p1.get()); + p2 = initial.end_opLongSeq(p3, r); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + + p2 = initial.opLongSeqOpt(new Ice.Optional<long[]>(), p3); + test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. + + os = Ice.Util.createOutputStream(communicator); + os.startEncapsulation(); + os.writeOptional(2, Ice.OptionalType.VSize); + os.writeSize(p1.get().length * 8 + (p1.get().length > 254 ? 5 : 1)); + os.writeLongSeq(p1.get()); + os.endEncapsulation(); + inEncaps = os.finished(); + initial.ice_invoke("opLongSeq", Ice.OperationMode.Normal, inEncaps, outEncaps); + in = Ice.Util.createInputStream(communicator, outEncaps.value); + in.startEncapsulation(); + test(in.readOptional(1, Ice.OptionalType.VSize)); + in.skipSize(); + test(java.util.Arrays.equals(in.readLongSeq(), p1.get())); + test(in.readOptional(3, Ice.OptionalType.VSize)); + in.skipSize(); + test(java.util.Arrays.equals(in.readLongSeq(), p1.get())); + in.endEncapsulation(); + + in = Ice.Util.createInputStream(communicator, outEncaps.value); + in.startEncapsulation(); + in.endEncapsulation(); + } + + { + Ice.Optional<float[]> p1 = new Ice.Optional<float[]>(); + Ice.Optional<float[]> p3 = new Ice.Optional<float[]>(); + Ice.Optional<float[]> p2 = initial.opFloatSeqOpt(p1, p3); + test(!p2.isSet() && !p3.isSet()); + + p1.set(new float[100]); + java.util.Arrays.fill(p1.get(), (float)1.0); + p2 = initial.opFloatSeqOpt(p1, p3); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + Ice.AsyncResult r = initial.begin_opFloatSeqOpt(p1); + p2 = initial.end_opFloatSeqOpt(p3, r); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + p2 = initial.opFloatSeq(p1.get(), p3); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + r = initial.begin_opFloatSeq(p1.get()); + p2 = initial.end_opFloatSeq(p3, r); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + + p2 = initial.opFloatSeqOpt(new Ice.Optional<float[]>(), p3); + test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. + + os = Ice.Util.createOutputStream(communicator); + os.startEncapsulation(); + os.writeOptional(2, Ice.OptionalType.VSize); + os.writeSize(p1.get().length * 4 + (p1.get().length > 254 ? 5 : 1)); + os.writeFloatSeq(p1.get()); + os.endEncapsulation(); + inEncaps = os.finished(); + initial.ice_invoke("opFloatSeq", Ice.OperationMode.Normal, inEncaps, outEncaps); + in = Ice.Util.createInputStream(communicator, outEncaps.value); + in.startEncapsulation(); + test(in.readOptional(1, Ice.OptionalType.VSize)); + in.skipSize(); + test(java.util.Arrays.equals(in.readFloatSeq(), p1.get())); + test(in.readOptional(3, Ice.OptionalType.VSize)); + in.skipSize(); + test(java.util.Arrays.equals(in.readFloatSeq(), p1.get())); + in.endEncapsulation(); + + in = Ice.Util.createInputStream(communicator, outEncaps.value); + in.startEncapsulation(); + in.endEncapsulation(); + } + + { + Ice.Optional<double[]> p1 = new Ice.Optional<double[]>(); + Ice.Optional<double[]> p3 = new Ice.Optional<double[]>(); + Ice.Optional<double[]> p2 = initial.opDoubleSeqOpt(p1, p3); + test(!p2.isSet() && !p3.isSet()); + + p1.set(new double[100]); + java.util.Arrays.fill(p1.get(), 1.0); + p2 = initial.opDoubleSeqOpt(p1, p3); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + Ice.AsyncResult r = initial.begin_opDoubleSeqOpt(p1); + p2 = initial.end_opDoubleSeqOpt(p3, r); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + p2 = initial.opDoubleSeq(p1.get(), p3); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + r = initial.begin_opDoubleSeq(p1.get()); + p2 = initial.end_opDoubleSeq(p3, r); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + + p2 = initial.opDoubleSeqOpt(new Ice.Optional<double[]>(), p3); + test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. + + os = Ice.Util.createOutputStream(communicator); + os.startEncapsulation(); + os.writeOptional(2, Ice.OptionalType.VSize); + os.writeSize(p1.get().length * 8 + (p1.get().length > 254 ? 5 : 1)); + os.writeDoubleSeq(p1.get()); + os.endEncapsulation(); + inEncaps = os.finished(); + initial.ice_invoke("opDoubleSeq", Ice.OperationMode.Normal, inEncaps, outEncaps); + in = Ice.Util.createInputStream(communicator, outEncaps.value); + in.startEncapsulation(); + test(in.readOptional(1, Ice.OptionalType.VSize)); + in.skipSize(); + test(java.util.Arrays.equals(in.readDoubleSeq(), p1.get())); + test(in.readOptional(3, Ice.OptionalType.VSize)); + in.skipSize(); + test(java.util.Arrays.equals(in.readDoubleSeq(), p1.get())); in.endEncapsulation(); in = Ice.Util.createInputStream(communicator, outEncaps.value); @@ -787,15 +1434,23 @@ public class AllTests { Ice.Optional<String[]> p1 = new Ice.Optional<String[]>(); Ice.Optional<String[]> p3 = new Ice.Optional<String[]>(); - Ice.Optional<String[]> p2 = initial.opStringSeq(p1, p3); + Ice.Optional<String[]> p2 = initial.opStringSeqOpt(p1, p3); test(!p2.isSet() && !p3.isSet()); p1.set(new String[10]); java.util.Arrays.fill(p1.get(), "test1"); - p2 = initial.opStringSeq(p1, p3); + p2 = initial.opStringSeqOpt(p1, p3); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + Ice.AsyncResult r = initial.begin_opStringSeqOpt(p1); + p2 = initial.end_opStringSeqOpt(p3, r); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + p2 = initial.opStringSeq(p1.get(), p3); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + r = initial.begin_opStringSeq(p1.get()); + p2 = initial.end_opStringSeq(p3, r); test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); - p2 = initial.opStringSeq(new Ice.Optional<String[]>(), p3); + p2 = initial.opStringSeqOpt(new Ice.Optional<String[]>(), p3); test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. os = Ice.Util.createOutputStream(communicator); @@ -823,9 +1478,127 @@ public class AllTests } { + Ice.Optional<SmallStruct[]> p1 = new Ice.Optional<SmallStruct[]>(); + Ice.Optional<SmallStruct[]> p3 = new Ice.Optional<SmallStruct[]>(); + Ice.Optional<SmallStruct[]> p2 = initial.opSmallStructSeqOpt(p1, p3); + test(!p2.isSet() && !p3.isSet()); + + p1.set(new SmallStruct[10]); + for(int i = 0; i < p1.get().length; ++i) + { + p1.get()[i] = new SmallStruct(); + } + p2 = initial.opSmallStructSeqOpt(p1, p3); + for(int i = 0; i < p1.get().length; ++i) + { + test(p2.get()[i].equals(p1.get()[i])); + } + Ice.AsyncResult r = initial.begin_opSmallStructSeqOpt(p1); + p2 = initial.end_opSmallStructSeqOpt(p3, r); + for(int i = 0; i < p1.get().length; ++i) + { + test(p2.get()[i].equals(p1.get()[i])); + } + p2 = initial.opSmallStructSeq(p1.get(), p3); + for(int i = 0; i < p1.get().length; ++i) + { + test(p2.get()[i].equals(p1.get()[i])); + } + r = initial.begin_opSmallStructSeq(p1.get()); + p2 = initial.end_opSmallStructSeq(p3, r); + for(int i = 0; i < p1.get().length; ++i) + { + test(p2.get()[i].equals(p1.get()[i])); + } + + p2 = initial.opSmallStructSeqOpt(new Ice.Optional<SmallStruct[]>(), p3); + test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. + + os = Ice.Util.createOutputStream(communicator); + os.startEncapsulation(); + os.writeOptional(2, Ice.OptionalType.VSize); + os.writeSize(p1.get().length + (p1.get().length > 254 ? 5 : 1)); + SmallStructSeqHelper.write(os, p1.get()); + os.endEncapsulation(); + inEncaps = os.finished(); + initial.ice_invoke("opSmallStructSeq", Ice.OperationMode.Normal, inEncaps, outEncaps); + in = Ice.Util.createInputStream(communicator, outEncaps.value); + in.startEncapsulation(); + test(in.readOptional(1, Ice.OptionalType.VSize)); + in.skipSize(); + SmallStruct[] arr = SmallStructSeqHelper.read(in); + for(int i = 0; i < p1.get().length; ++i) + { + test(arr[i].equals(p1.get()[i])); + } + test(in.readOptional(3, Ice.OptionalType.VSize)); + in.skipSize(); + arr = SmallStructSeqHelper.read(in); + for(int i = 0; i < p1.get().length; ++i) + { + test(arr[i].equals(p1.get()[i])); + } + in.endEncapsulation(); + + in = Ice.Util.createInputStream(communicator, outEncaps.value); + in.startEncapsulation(); + in.endEncapsulation(); + } + + { + Ice.Optional<java.util.List<SmallStruct>> p1 = new Ice.Optional<java.util.List<SmallStruct>>(); + Ice.Optional<java.util.List<SmallStruct>> p3 = new Ice.Optional<java.util.List<SmallStruct>>(); + Ice.Optional<java.util.List<SmallStruct>> p2 = initial.opSmallStructListOpt(p1, p3); + test(!p2.isSet() && !p3.isSet()); + + p1.set(new java.util.ArrayList<SmallStruct>()); + for(int i = 0; i < 10; ++i) + { + p1.get().add(new SmallStruct()); + } + p2 = initial.opSmallStructListOpt(p1, p3); + test(p2.get().equals(p1.get())); + Ice.AsyncResult r = initial.begin_opSmallStructListOpt(p1); + p2 = initial.end_opSmallStructListOpt(p3, r); + test(p2.get().equals(p1.get())); + p2 = initial.opSmallStructList(p1.get(), p3); + test(p2.get().equals(p1.get())); + r = initial.begin_opSmallStructList(p1.get()); + p2 = initial.end_opSmallStructList(p3, r); + test(p2.get().equals(p1.get())); + + p2 = initial.opSmallStructListOpt(new Ice.Optional<java.util.List<SmallStruct>>(), p3); + test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. + + os = Ice.Util.createOutputStream(communicator); + os.startEncapsulation(); + os.writeOptional(2, Ice.OptionalType.VSize); + os.writeSize(p1.get().size() + (p1.get().size() > 254 ? 5 : 1)); + SmallStructListHelper.write(os, p1.get()); + os.endEncapsulation(); + inEncaps = os.finished(); + initial.ice_invoke("opSmallStructList", Ice.OperationMode.Normal, inEncaps, outEncaps); + in = Ice.Util.createInputStream(communicator, outEncaps.value); + in.startEncapsulation(); + test(in.readOptional(1, Ice.OptionalType.VSize)); + in.skipSize(); + java.util.List<SmallStruct> arr = SmallStructListHelper.read(in); + test(arr.equals(p1.get())); + test(in.readOptional(3, Ice.OptionalType.VSize)); + in.skipSize(); + arr = SmallStructListHelper.read(in); + test(arr.equals(p1.get())); + in.endEncapsulation(); + + in = Ice.Util.createInputStream(communicator, outEncaps.value); + in.startEncapsulation(); + in.endEncapsulation(); + } + + { Ice.Optional<FixedStruct[]> p1 = new Ice.Optional<FixedStruct[]>(); Ice.Optional<FixedStruct[]> p3 = new Ice.Optional<FixedStruct[]>(); - Ice.Optional<FixedStruct[]> p2 = initial.opFixedStructSeq(p1, p3); + Ice.Optional<FixedStruct[]> p2 = initial.opFixedStructSeqOpt(p1, p3); test(!p2.isSet() && !p3.isSet()); p1.set(new FixedStruct[10]); @@ -833,13 +1606,30 @@ public class AllTests { p1.get()[i] = new FixedStruct(); } - p2 = initial.opFixedStructSeq(p1, p3); + p2 = initial.opFixedStructSeqOpt(p1, p3); + for(int i = 0; i < p1.get().length; ++i) + { + test(p2.get()[i].equals(p1.get()[i])); + } + Ice.AsyncResult r = initial.begin_opFixedStructSeqOpt(p1); + p2 = initial.end_opFixedStructSeqOpt(p3, r); + for(int i = 0; i < p1.get().length; ++i) + { + test(p2.get()[i].equals(p1.get()[i])); + } + p2 = initial.opFixedStructSeq(p1.get(), p3); + for(int i = 0; i < p1.get().length; ++i) + { + test(p2.get()[i].equals(p1.get()[i])); + } + r = initial.begin_opFixedStructSeq(p1.get()); + p2 = initial.end_opFixedStructSeq(p3, r); for(int i = 0; i < p1.get().length; ++i) { test(p2.get()[i].equals(p1.get()[i])); } - p2 = initial.opFixedStructSeq(new Ice.Optional<FixedStruct[]>(), p3); + p2 = initial.opFixedStructSeqOpt(new Ice.Optional<FixedStruct[]>(), p3); test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. os = Ice.Util.createOutputStream(communicator); @@ -874,9 +1664,59 @@ public class AllTests } { + Ice.Optional<java.util.List<FixedStruct>> p1 = new Ice.Optional<java.util.List<FixedStruct>>(); + Ice.Optional<java.util.List<FixedStruct>> p3 = new Ice.Optional<java.util.List<FixedStruct>>(); + Ice.Optional<java.util.List<FixedStruct>> p2 = initial.opFixedStructListOpt(p1, p3); + test(!p2.isSet() && !p3.isSet()); + + p1.set(new java.util.ArrayList<FixedStruct>()); + for(int i = 0; i < 10; ++i) + { + p1.get().add(new FixedStruct()); + } + p2 = initial.opFixedStructListOpt(p1, p3); + test(p2.get().equals(p1.get())); + Ice.AsyncResult r = initial.begin_opFixedStructListOpt(p1); + p2 = initial.end_opFixedStructListOpt(p3, r); + test(p2.get().equals(p1.get())); + p2 = initial.opFixedStructList(p1.get(), p3); + test(p2.get().equals(p1.get())); + r = initial.begin_opFixedStructList(p1.get()); + p2 = initial.end_opFixedStructList(p3, r); + test(p2.get().equals(p1.get())); + + p2 = initial.opFixedStructListOpt(new Ice.Optional<java.util.List<FixedStruct>>(), p3); + test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. + + os = Ice.Util.createOutputStream(communicator); + os.startEncapsulation(); + os.writeOptional(2, Ice.OptionalType.VSize); + os.writeSize(p1.get().size() * 4 + (p1.get().size() > 254 ? 5 : 1)); + FixedStructListHelper.write(os, p1.get()); + os.endEncapsulation(); + inEncaps = os.finished(); + initial.ice_invoke("opFixedStructList", Ice.OperationMode.Normal, inEncaps, outEncaps); + in = Ice.Util.createInputStream(communicator, outEncaps.value); + in.startEncapsulation(); + test(in.readOptional(1, Ice.OptionalType.VSize)); + in.skipSize(); + java.util.List<FixedStruct> arr = FixedStructListHelper.read(in); + test(arr.equals(p1.get())); + test(in.readOptional(3, Ice.OptionalType.VSize)); + in.skipSize(); + arr = FixedStructListHelper.read(in); + test(arr.equals(p1.get())); + in.endEncapsulation(); + + in = Ice.Util.createInputStream(communicator, outEncaps.value); + in.startEncapsulation(); + in.endEncapsulation(); + } + + { Ice.Optional<VarStruct[]> p1 = new Ice.Optional<VarStruct[]>(); Ice.Optional<VarStruct[]> p3 = new Ice.Optional<VarStruct[]>(); - Ice.Optional<VarStruct[]> p2 = initial.opVarStructSeq(p1, p3); + Ice.Optional<VarStruct[]> p2 = initial.opVarStructSeqOpt(p1, p3); test(!p2.isSet() && !p3.isSet()); p1.set(new VarStruct[10]); @@ -884,13 +1724,30 @@ public class AllTests { p1.get()[i] = new VarStruct(""); } - p2 = initial.opVarStructSeq(p1, p3); + p2 = initial.opVarStructSeqOpt(p1, p3); + for(int i = 0; i < p1.get().length; ++i) + { + test(p2.get()[i].equals(p1.get()[i])); + } + Ice.AsyncResult r = initial.begin_opVarStructSeqOpt(p1); + p2 = initial.end_opVarStructSeqOpt(p3, r); + for(int i = 0; i < p1.get().length; ++i) + { + test(p2.get()[i].equals(p1.get()[i])); + } + p2 = initial.opVarStructSeq(p1.get(), p3); + for(int i = 0; i < p1.get().length; ++i) + { + test(p2.get()[i].equals(p1.get()[i])); + } + r = initial.begin_opVarStructSeq(p1.get()); + p2 = initial.end_opVarStructSeq(p3, r); for(int i = 0; i < p1.get().length; ++i) { test(p2.get()[i].equals(p1.get()[i])); } - p2 = initial.opVarStructSeq(new Ice.Optional<VarStruct[]>(), p3); + p2 = initial.opVarStructSeqOpt(new Ice.Optional<VarStruct[]>(), p3); test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. os = Ice.Util.createOutputStream(communicator); @@ -924,6 +1781,146 @@ public class AllTests in.startEncapsulation(); in.endEncapsulation(); } + + { + Ice.Optional<SerializableClass> p1 = new Ice.Optional<SerializableClass>(); + Ice.Optional<SerializableClass> p3 = new Ice.Optional<SerializableClass>(); + Ice.Optional<SerializableClass> p2 = initial.opSerializableOpt(p1, p3); + test(!p2.isSet() && !p3.isSet()); + + p1.set(new SerializableClass(58)); + p2 = initial.opSerializableOpt(p1, p3); + test(p2.get().equals(p1.get()) && p3.get().equals(p1.get())); + Ice.AsyncResult r = initial.begin_opSerializableOpt(p1); + p2 = initial.end_opSerializableOpt(p3, r); + test(p2.get().equals(p1.get()) && p3.get().equals(p1.get())); + p2 = initial.opSerializable(p1.get(), p3); + test(p2.get().equals(p1.get()) && p3.get().equals(p1.get())); + r = initial.begin_opSerializable(p1.get()); + p2 = initial.end_opSerializable(p3, r); + test(p2.get().equals(p1.get()) && p3.get().equals(p1.get())); + + p2 = initial.opSerializableOpt(new Ice.Optional<SerializableClass>(), p3); + test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. + + os = Ice.Util.createOutputStream(communicator); + os.startEncapsulation(); + os.writeOptional(2, Ice.OptionalType.VSize); + os.writeSerializable(p1.get()); + os.endEncapsulation(); + inEncaps = os.finished(); + initial.ice_invoke("opSerializable", Ice.OperationMode.Normal, inEncaps, outEncaps); + in = Ice.Util.createInputStream(communicator, outEncaps.value); + in.startEncapsulation(); + test(in.readOptional(1, Ice.OptionalType.VSize)); + SerializableClass sc = SerializableHelper.read(in); + test(sc.equals(p1.get())); + test(in.readOptional(3, Ice.OptionalType.VSize)); + sc = SerializableHelper.read(in); + test(sc.equals(p1.get())); + in.endEncapsulation(); + + in = Ice.Util.createInputStream(communicator, outEncaps.value); + in.startEncapsulation(); + in.endEncapsulation(); + } + + { + Ice.Optional<java.util.Map<Integer, Integer>> p1 = new Ice.Optional<java.util.Map<Integer, Integer>>(); + Ice.Optional<java.util.Map<Integer, Integer>> p3 = new Ice.Optional<java.util.Map<Integer, Integer>>(); + Ice.Optional<java.util.Map<Integer, Integer>> p2 = initial.opIntIntDictOpt(p1, p3); + test(!p2.isSet() && !p3.isSet()); + + p1.set(new java.util.HashMap<Integer, Integer>()); + p1.get().put(1, 2); + p1.get().put(2, 3); + p2 = initial.opIntIntDictOpt(p1, p3); + test(p2.get().equals(p1.get()) && p3.get().equals(p1.get())); + Ice.AsyncResult r = initial.begin_opIntIntDictOpt(p1); + p2 = initial.end_opIntIntDictOpt(p3, r); + test(p2.get().equals(p1.get()) && p3.get().equals(p1.get())); + p2 = initial.opIntIntDict(p1.get(), p3); + test(p2.get().equals(p1.get()) && p3.get().equals(p1.get())); + r = initial.begin_opIntIntDict(p1.get()); + p2 = initial.end_opIntIntDict(p3, r); + test(p2.get().equals(p1.get()) && p3.get().equals(p1.get())); + + p2 = initial.opIntIntDictOpt(new Ice.Optional<java.util.Map<Integer, Integer>>(), p3); + test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. + + os = Ice.Util.createOutputStream(communicator); + os.startEncapsulation(); + os.writeOptional(2, Ice.OptionalType.VSize); + os.writeSize(p1.get().size() * 8 + (p1.get().size() > 254 ? 5 : 1)); + IntIntDictHelper.write(os, p1.get()); + os.endEncapsulation(); + inEncaps = os.finished(); + initial.ice_invoke("opIntIntDict", Ice.OperationMode.Normal, inEncaps, outEncaps); + in = Ice.Util.createInputStream(communicator, outEncaps.value); + in.startEncapsulation(); + test(in.readOptional(1, Ice.OptionalType.VSize)); + in.skipSize(); + java.util.Map<Integer, Integer> m = IntIntDictHelper.read(in); + test(m.equals(p1.get())); + test(in.readOptional(3, Ice.OptionalType.VSize)); + in.skipSize(); + m = IntIntDictHelper.read(in); + test(m.equals(p1.get())); + in.endEncapsulation(); + + in = Ice.Util.createInputStream(communicator, outEncaps.value); + in.startEncapsulation(); + in.endEncapsulation(); + } + + { + Ice.Optional<java.util.Map<String, Integer>> p1 = new Ice.Optional<java.util.Map<String, Integer>>(); + Ice.Optional<java.util.Map<String, Integer>> p3 = new Ice.Optional<java.util.Map<String, Integer>>(); + Ice.Optional<java.util.Map<String, Integer>> p2 = initial.opStringIntDictOpt(p1, p3); + test(!p2.isSet() && !p3.isSet()); + + p1.set(new java.util.HashMap<String, Integer>()); + p1.get().put("1", 1); + p1.get().put("2", 2); + p2 = initial.opStringIntDictOpt(p1, p3); + test(p2.get().equals(p1.get()) && p3.get().equals(p1.get())); + Ice.AsyncResult r = initial.begin_opStringIntDictOpt(p1); + p2 = initial.end_opStringIntDictOpt(p3, r); + test(p2.get().equals(p1.get()) && p3.get().equals(p1.get())); + p2 = initial.opStringIntDict(p1.get(), p3); + test(p2.get().equals(p1.get()) && p3.get().equals(p1.get())); + r = initial.begin_opStringIntDict(p1.get()); + p2 = initial.end_opStringIntDict(p3, r); + test(p2.get().equals(p1.get()) && p3.get().equals(p1.get())); + + p2 = initial.opStringIntDictOpt(new Ice.Optional<java.util.Map<String, Integer>>(), p3); + test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. + + os = Ice.Util.createOutputStream(communicator); + os.startEncapsulation(); + os.writeOptional(2, Ice.OptionalType.FSize); + os.startSize(); + StringIntDictHelper.write(os, p1.get()); + os.endSize(); + os.endEncapsulation(); + inEncaps = os.finished(); + initial.ice_invoke("opStringIntDict", Ice.OperationMode.Normal, inEncaps, outEncaps); + in = Ice.Util.createInputStream(communicator, outEncaps.value); + in.startEncapsulation(); + test(in.readOptional(1, Ice.OptionalType.FSize)); + in.skip(4); + java.util.Map<String, Integer> m = StringIntDictHelper.read(in); + test(m.equals(p1.get())); + test(in.readOptional(3, Ice.OptionalType.FSize)); + in.skip(4); + m = StringIntDictHelper.read(in); + test(m.equals(p1.get())); + in.endEncapsulation(); + + in = Ice.Util.createInputStream(communicator, outEncaps.value); + in.startEncapsulation(); + in.endEncapsulation(); + } out.println("ok"); out.print("testing exception optionals... "); @@ -931,7 +1928,7 @@ public class AllTests { try { - Ice.Optional<Integer> a = new Ice.Optional<Integer>(); + Ice.IntOptional a = new Ice.IntOptional(); Ice.Optional<String> b = new Ice.Optional<String>(); Ice.Optional<OneOptional> o = new Ice.Optional<OneOptional>(); initial.opOptionalException(a, b, o); @@ -945,7 +1942,7 @@ public class AllTests try { - Ice.Optional<Integer> a = new Ice.Optional<Integer>(30); + Ice.IntOptional a = new Ice.IntOptional(30); Ice.Optional<String> b = new Ice.Optional<String>("test"); Ice.Optional<OneOptional> o = new Ice.Optional<OneOptional>(new OneOptional(53)); initial.opOptionalException(a, b, o); diff --git a/java/test/Ice/optional/InitialI.java b/java/test/Ice/optional/InitialI.java index a4faf01c47c..2acba8b6158 100644 --- a/java/test/Ice/optional/InitialI.java +++ b/java/test/Ice/optional/InitialI.java @@ -26,7 +26,7 @@ public final class InitialI extends Initial } public void - opOptionalException(Ice.Optional<Integer> a, Ice.Optional<String> b, Ice.Optional<OneOptional> o, + opOptionalException(Ice.IntOptional a, Ice.Optional<String> b, Ice.Optional<OneOptional> o, Ice.Current current) throws OptionalException { @@ -50,78 +50,425 @@ public final class InitialI extends Initial throw ex; } - public Ice.Optional<Byte> - opByte(Ice.Optional<Byte> p1, Ice.Optional<Byte> p3, Ice.Current current) + public byte + opByte(Ice.ByteOptional p1, Ice.ByteHolder p3, Ice.Current current) + { + p3.value = p1.get(); + return p1.get(); + } + + public Ice.ByteOptional + opByteOpt(Ice.ByteOptional p1, Ice.ByteOptional p3, Ice.Current current) + { + p3.set(p1); + return p1; + } + + public boolean + opBool(Ice.BooleanOptional p1, Ice.BooleanHolder p3, Ice.Current current) + { + p3.value = p1.get(); + return p1.get(); + } + + public Ice.BooleanOptional + opBoolOpt(Ice.BooleanOptional p1, Ice.BooleanOptional p3, Ice.Current current) + { + p3.set(p1); + return p1; + } + + public short + opShort(Ice.ShortOptional p1, Ice.ShortHolder p3, Ice.Current current) + { + p3.value = p1.get(); + return p1.get(); + } + + public Ice.ShortOptional + opShortOpt(Ice.ShortOptional p1, Ice.ShortOptional p3, Ice.Current current) { p3.set(p1); return p1; } - public Ice.Optional<Long> - opLong(Ice.Optional<Long> p1, Ice.Optional<Long> p3, Ice.Current current) + public int + opInt(Ice.IntOptional p1, Ice.IntHolder p3, Ice.Current current) + { + p3.value = p1.get(); + return p1.get(); + } + + public Ice.IntOptional + opIntOpt(Ice.IntOptional p1, Ice.IntOptional p3, Ice.Current current) { p3.set(p1); return p1; } + public long + opLong(Ice.LongOptional p1, Ice.LongHolder p3, Ice.Current current) + { + p3.value = p1.get(); + return p1.get(); + } + + public Ice.LongOptional + opLongOpt(Ice.LongOptional p1, Ice.LongOptional p3, Ice.Current current) + { + p3.set(p1); + return p1; + } + + public float + opFloat(Ice.FloatOptional p1, Ice.FloatHolder p3, Ice.Current current) + { + p3.value = p1.get(); + return p1.get(); + } + + public Ice.FloatOptional + opFloatOpt(Ice.FloatOptional p1, Ice.FloatOptional p3, Ice.Current current) + { + p3.set(p1); + return p1; + } + + public double + opDouble(Ice.DoubleOptional p1, Ice.DoubleHolder p3, Ice.Current current) + { + p3.value = p1.get(); + return p1.get(); + } + + public Ice.DoubleOptional + opDoubleOpt(Ice.DoubleOptional p1, Ice.DoubleOptional p3, Ice.Current current) + { + p3.set(p1); + return p1; + } + + public String + opString(Ice.Optional<String> p1, Ice.StringHolder p3, Ice.Current current) + { + p3.value = p1.get(); + return p1.get(); + } + public Ice.Optional<String> - opString(Ice.Optional<String> p1, Ice.Optional<String> p3, Ice.Current current) + opStringOpt(Ice.Optional<String> p1, Ice.Optional<String> p3, Ice.Current current) + { + p3.set(p1); + return p1; + } + + public MyEnum + opMyEnum(Ice.Optional<MyEnum> p1, MyEnumHolder p3, Ice.Current current) + { + p3.value = p1.get(); + return p1.get(); + } + + public Ice.Optional<MyEnum> + opMyEnumOpt(Ice.Optional<MyEnum> p1, Ice.Optional<MyEnum> p3, Ice.Current current) + { + p3.set(p1); + return p1; + } + + public SmallStruct + opSmallStruct(Ice.Optional<SmallStruct> p1, SmallStructHolder p3, Ice.Current current) + { + p3.value = p1.get(); + return p1.get(); + } + + public Ice.Optional<SmallStruct> + opSmallStructOpt(Ice.Optional<SmallStruct> p1, Ice.Optional<SmallStruct> p3, Ice.Current current) { p3.set(p1); return p1; } + public FixedStruct + opFixedStruct(Ice.Optional<FixedStruct> p1, FixedStructHolder p3, Ice.Current current) + { + p3.value = p1.get(); + return p1.get(); + } + + public Ice.Optional<FixedStruct> + opFixedStructOpt(Ice.Optional<FixedStruct> p1, Ice.Optional<FixedStruct> p3, Ice.Current current) + { + p3.set(p1); + return p1; + } + + public VarStruct + opVarStruct(Ice.Optional<VarStruct> p1, VarStructHolder p3, Ice.Current current) + { + p3.value = p1.get(); + return p1.get(); + } + + public Ice.Optional<VarStruct> + opVarStructOpt(Ice.Optional<VarStruct> p1, Ice.Optional<VarStruct> p3, Ice.Current current) + { + p3.set(p1); + return p1; + } + + public OneOptional + opOneOptional(Ice.Optional<OneOptional> p1, OneOptionalHolder p3, Ice.Current current) + { + p3.value = p1.get(); + return p1.get(); + } + public Ice.Optional<OneOptional> - opOneOptional(Ice.Optional<OneOptional> p1, Ice.Optional<OneOptional> p3, Ice.Current current) + opOneOptionalOpt(Ice.Optional<OneOptional> p1, Ice.Optional<OneOptional> p3, Ice.Current current) { p3.set(p1); return p1; } + public OneOptionalPrx + opOneOptionalProxy(Ice.Optional<OneOptionalPrx> p1, OneOptionalPrxHolder p3, Ice.Current current) + { + p3.value = p1.get(); + return p1.get(); + } + public Ice.Optional<OneOptionalPrx> - opOneOptionalProxy(Ice.Optional<OneOptionalPrx> p1, Ice.Optional<OneOptionalPrx> p3, Ice.Current current) + opOneOptionalProxyOpt(Ice.Optional<OneOptionalPrx> p1, Ice.Optional<OneOptionalPrx> p3, Ice.Current current) { p3.set(p1); return p1; } + public byte[] + opByteSeq(Ice.Optional<byte[]> p1, ByteSeqHolder p3, Ice.Current current) + { + p3.value = p1.get(); + return p1.get(); + } + public Ice.Optional<byte[]> - opByteSeq(Ice.Optional<byte[]> p1, Ice.Optional<byte[]> p3, Ice.Current current) + opByteSeqOpt(Ice.Optional<byte[]> p1, Ice.Optional<byte[]> p3, Ice.Current current) { p3.set(p1); return p1; } + public boolean[] + opBoolSeq(Ice.Optional<boolean[]> p1, BoolSeqHolder p3, Ice.Current current) + { + p3.value = p1.get(); + return p1.get(); + } + + public Ice.Optional<boolean[]> + opBoolSeqOpt(Ice.Optional<boolean[]> p1, Ice.Optional<boolean[]> p3, Ice.Current current) + { + p3.set(p1); + return p1; + } + + public short[] + opShortSeq(Ice.Optional<short[]> p1, ShortSeqHolder p3, Ice.Current current) + { + p3.value = p1.get(); + return p1.get(); + } + public Ice.Optional<short[]> - opShortSeq(Ice.Optional<short[]> p1, Ice.Optional<short[]> p3, Ice.Current current) + opShortSeqOpt(Ice.Optional<short[]> p1, Ice.Optional<short[]> p3, Ice.Current current) { p3.set(p1); return p1; } - public Ice.Optional<boolean[]> - opBoolSeq(Ice.Optional<boolean[]> p1, Ice.Optional<boolean[]> p3, Ice.Current current) + public int[] + opIntSeq(Ice.Optional<int[]> p1, IntSeqHolder p3, Ice.Current current) + { + p3.value = p1.get(); + return p1.get(); + } + + public Ice.Optional<int[]> + opIntSeqOpt(Ice.Optional<int[]> p1, Ice.Optional<int[]> p3, Ice.Current current) { p3.set(p1); return p1; } + public long[] + opLongSeq(Ice.Optional<long[]> p1, LongSeqHolder p3, Ice.Current current) + { + p3.value = p1.get(); + return p1.get(); + } + + public Ice.Optional<long[]> + opLongSeqOpt(Ice.Optional<long[]> p1, Ice.Optional<long[]> p3, Ice.Current current) + { + p3.set(p1); + return p1; + } + + public float[] + opFloatSeq(Ice.Optional<float[]> p1, FloatSeqHolder p3, Ice.Current current) + { + p3.value = p1.get(); + return p1.get(); + } + + public Ice.Optional<float[]> + opFloatSeqOpt(Ice.Optional<float[]> p1, Ice.Optional<float[]> p3, Ice.Current current) + { + p3.set(p1); + return p1; + } + + public double[] + opDoubleSeq(Ice.Optional<double[]> p1, DoubleSeqHolder p3, Ice.Current current) + { + p3.value = p1.get(); + return p1.get(); + } + + public Ice.Optional<double[]> + opDoubleSeqOpt(Ice.Optional<double[]> p1, Ice.Optional<double[]> p3, Ice.Current current) + { + p3.set(p1); + return p1; + } + + public String[] + opStringSeq(Ice.Optional<String[]> p1, StringSeqHolder p3, Ice.Current current) + { + p3.value = p1.get(); + return p1.get(); + } + public Ice.Optional<String[]> - opStringSeq(Ice.Optional<String[]> p1, Ice.Optional<String[]> p3, Ice.Current current) + opStringSeqOpt(Ice.Optional<String[]> p1, Ice.Optional<String[]> p3, Ice.Current current) + { + p3.set(p1); + return p1; + } + + public SmallStruct[] + opSmallStructSeq(Ice.Optional<SmallStruct[]> p1, SmallStructSeqHolder p3, Ice.Current current) + { + p3.value = p1.get(); + return p1.get(); + } + + public Ice.Optional<SmallStruct[]> + opSmallStructSeqOpt(Ice.Optional<SmallStruct[]> p1, Ice.Optional<SmallStruct[]> p3, Ice.Current current) { p3.set(p1); return p1; } + public java.util.List<SmallStruct> + opSmallStructList(Ice.Optional<java.util.List<SmallStruct>> p1, SmallStructListHolder p3, Ice.Current current) + { + p3.value = p1.get(); + return p1.get(); + } + + public Ice.Optional<java.util.List<SmallStruct>> + opSmallStructListOpt(Ice.Optional<java.util.List<SmallStruct>> p1, + Ice.Optional<java.util.List<SmallStruct>> p3, Ice.Current current) + { + p3.set(p1); + return p1; + } + + public FixedStruct[] + opFixedStructSeq(Ice.Optional<FixedStruct[]> p1, FixedStructSeqHolder p3, Ice.Current current) + { + p3.value = p1.get(); + return p1.get(); + } + public Ice.Optional<FixedStruct[]> - opFixedStructSeq(Ice.Optional<FixedStruct[]> p1, Ice.Optional<FixedStruct[]> p3, Ice.Current current) + opFixedStructSeqOpt(Ice.Optional<FixedStruct[]> p1, Ice.Optional<FixedStruct[]> p3, Ice.Current current) { p3.set(p1); return p1; } + public java.util.List<FixedStruct> + opFixedStructList(Ice.Optional<java.util.List<FixedStruct>> p1, FixedStructListHolder p3, Ice.Current current) + { + p3.value = p1.get(); + return p1.get(); + } + + public Ice.Optional<java.util.List<FixedStruct>> + opFixedStructListOpt(Ice.Optional<java.util.List<FixedStruct>> p1, + Ice.Optional<java.util.List<FixedStruct>> p3, Ice.Current current) + { + p3.set(p1); + return p1; + } + + public VarStruct[] + opVarStructSeq(Ice.Optional<VarStruct[]> p1, VarStructSeqHolder p3, Ice.Current current) + { + p3.value = p1.get(); + return p1.get(); + } + public Ice.Optional<VarStruct[]> - opVarStructSeq(Ice.Optional<VarStruct[]> p1, Ice.Optional<VarStruct[]> p3, Ice.Current current) + opVarStructSeqOpt(Ice.Optional<VarStruct[]> p1, Ice.Optional<VarStruct[]> p3, Ice.Current current) + { + p3.set(p1); + return p1; + } + + public SerializableClass + opSerializable(Ice.Optional<SerializableClass> p1, Ice.Holder<SerializableClass> p3, Ice.Current current) + { + p3.value = p1.get(); + return p1.get(); + } + + public Ice.Optional<SerializableClass> + opSerializableOpt(Ice.Optional<SerializableClass> p1, Ice.Optional<SerializableClass> p3, Ice.Current current) + { + p3.set(p1); + return p1; + } + + public java.util.Map<Integer, Integer> + opIntIntDict(Ice.Optional<java.util.Map<Integer, Integer>> p1, IntIntDictHolder p3, Ice.Current current) + { + p3.value = p1.get(); + return p1.get(); + } + + public Ice.Optional<java.util.Map<Integer, Integer>> + opIntIntDictOpt(Ice.Optional<java.util.Map<Integer, Integer>> p1, + Ice.Optional<java.util.Map<Integer, Integer>> p3, Ice.Current current) + { + p3.set(p1); + return p1; + } + + public java.util.Map<String, Integer> + opStringIntDict(Ice.Optional<java.util.Map<String, Integer>> p1, StringIntDictHolder p3, Ice.Current current) + { + p3.value = p1.get(); + return p1.get(); + } + + public Ice.Optional<java.util.Map<String, Integer>> + opStringIntDictOpt(Ice.Optional<java.util.Map<String, Integer>> p1, + Ice.Optional<java.util.Map<String, Integer>> p3, Ice.Current current) { p3.set(p1); return p1; diff --git a/java/test/Ice/optional/SerializableClass.java b/java/test/Ice/optional/SerializableClass.java new file mode 100644 index 00000000000..51edc4f328d --- /dev/null +++ b/java/test/Ice/optional/SerializableClass.java @@ -0,0 +1,31 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +package test.Ice.optional; + +public class SerializableClass implements java.io.Serializable +{ + public SerializableClass(int v) + { + _v = v; + } + + public boolean equals(Object obj) + { + if(obj instanceof SerializableClass) + { + return _v == ((SerializableClass)obj)._v; + } + + return false; + } + + private int _v; + public static final long serialVersionUID = 1; +} diff --git a/java/test/Ice/optional/Test.ice b/java/test/Ice/optional/Test.ice index 0579a6bb8f2..ce4c442d93b 100644 --- a/java/test/Ice/optional/Test.ice +++ b/java/test/Ice/optional/Test.ice @@ -9,8 +9,6 @@ #pragma once -[["cpp:include:list"]] - [["java:package:test.Ice.optional"]] module Test { @@ -25,6 +23,11 @@ enum MyEnum MyEnumMember }; +struct SmallStruct +{ + byte m; +}; + struct FixedStruct { int m; @@ -35,7 +38,7 @@ struct VarStruct string m; }; -["cpp:class"] struct ClassVarStruct +struct ClassVarStruct { int a; }; @@ -43,13 +46,22 @@ struct VarStruct sequence<byte> ByteSeq; sequence<bool> BoolSeq; sequence<short> ShortSeq; +sequence<int> IntSeq; +sequence<long> LongSeq; +sequence<float> FloatSeq; +sequence<double> DoubleSeq; sequence<string> StringSeq; sequence<MyEnum> MyEnumSeq; +sequence<SmallStruct> SmallStructSeq; +["java:type:java.util.ArrayList<SmallStruct>"] sequence<SmallStruct> SmallStructList; sequence<FixedStruct> FixedStructSeq; +["java:type:java.util.ArrayList<FixedStruct>"] sequence<FixedStruct> FixedStructList; sequence<VarStruct> VarStructSeq; sequence<OneOptional> OneOptionalSeq; sequence<OneOptional*> OneOptionalPrxSeq; +["java:serializable:test.Ice.optional.SerializableClass"] sequence<byte> Serializable; + dictionary<int, int> IntIntDict; dictionary<string, int> StringIntDict; dictionary<int, MyEnum> IntEnumDict; @@ -142,47 +154,121 @@ exception RequiredException extends OptionalException class OptionalWithCustom { - ["cpp:type:std::list< ::Ice::Byte>"] optional(1) ByteSeq bs; + ["java:type:java.util.ArrayList<Byte>"] optional(1) ByteSeq bs; optional(2) ClassVarStruct s; }; +["ami"] class Initial { void shutdown(); Object pingPong(Object o); + ["java:optional"] void opOptionalException(optional(1) int a, optional(2) string b, optional(3) OneOptional o) throws OptionalException; optional(1) byte opByte(optional(2) byte p1, out optional(3) byte p3); + ["java:optional"] optional(1) byte opByteOpt(optional(2) byte p1, out optional(3) byte p3); + + optional(1) bool opBool(optional(2) bool p1, out optional(3) bool p3); + ["java:optional"] optional(1) bool opBoolOpt(optional(2) bool p1, out optional(3) bool p3); + + optional(1) short opShort(optional(2) short p1, out optional(3) short p3); + ["java:optional"] optional(1) short opShortOpt(optional(2) short p1, out optional(3) short p3); + + optional(1) int opInt(optional(2) int p1, out optional(3) int p3); + ["java:optional"] optional(1) int opIntOpt(optional(2) int p1, out optional(3) int p3); optional(1) long opLong(optional(2) long p1, out optional(3) long p3); + ["java:optional"] optional(1) long opLongOpt(optional(2) long p1, out optional(3) long p3); + + optional(1) float opFloat(optional(2) float p1, out optional(3) float p3); + ["java:optional"] optional(1) float opFloatOpt(optional(2) float p1, out optional(3) float p3); + + optional(1) double opDouble(optional(2) double p1, out optional(3) double p3); + ["java:optional"] optional(1) double opDoubleOpt(optional(2) double p1, out optional(3) double p3); optional(1) string opString(optional(2) string p1, out optional(3) string p3); + ["java:optional"] optional(1) string opStringOpt(optional(2) string p1, out optional(3) string p3); + + optional(1) MyEnum opMyEnum(optional(2) MyEnum p1, out optional(3) MyEnum p3); + ["java:optional"] optional(1) MyEnum opMyEnumOpt(optional(2) MyEnum p1, out optional(3) MyEnum p3); + + optional(1) SmallStruct opSmallStruct(optional(2) SmallStruct p1, out optional(3) SmallStruct p3); + ["java:optional"] optional(1) SmallStruct opSmallStructOpt(optional(2) SmallStruct p1, + out optional(3) SmallStruct p3); + + optional(1) FixedStruct opFixedStruct(optional(2) FixedStruct p1, out optional(3) FixedStruct p3); + ["java:optional"] optional(1) FixedStruct opFixedStructOpt(optional(2) FixedStruct p1, + out optional(3) FixedStruct p3); + + optional(1) VarStruct opVarStruct(optional(2) VarStruct p1, out optional(3) VarStruct p3); + ["java:optional"] optional(1) VarStruct opVarStructOpt(optional(2) VarStruct p1, out optional(3) VarStruct p3); optional(1) OneOptional opOneOptional(optional(2) OneOptional p1, out optional(3) OneOptional p3); + ["java:optional"] optional(1) OneOptional opOneOptionalOpt(optional(2) OneOptional p1, + out optional(3) OneOptional p3); optional(1) OneOptional* opOneOptionalProxy(optional(2) OneOptional* p1, out optional(3) OneOptional* p3); + ["java:optional"] optional(1) OneOptional* opOneOptionalProxyOpt(optional(2) OneOptional* p1, + out optional(3) OneOptional* p3); + + optional(1) ByteSeq opByteSeq(optional(2) ByteSeq p1, out optional(3) ByteSeq p3); + ["java:optional"] optional(1) ByteSeq opByteSeqOpt(optional(2) ByteSeq p1, out optional(3) ByteSeq p3); + + optional(1) BoolSeq opBoolSeq(optional(2) BoolSeq p1, out optional(3) BoolSeq p3); + ["java:optional"] optional(1) BoolSeq opBoolSeqOpt(optional(2) BoolSeq p1, out optional(3) BoolSeq p3); + + optional(1) ShortSeq opShortSeq(optional(2) ShortSeq p1, out optional(3) ShortSeq p3); + ["java:optional"] optional(1) ShortSeq opShortSeqOpt(optional(2) ShortSeq p1, out optional(3) ShortSeq p3); + + optional(1) IntSeq opIntSeq(optional(2) IntSeq p1, out optional(3) IntSeq p3); + ["java:optional"] optional(1) IntSeq opIntSeqOpt(optional(2) IntSeq p1, out optional(3) IntSeq p3); + + optional(1) LongSeq opLongSeq(optional(2) LongSeq p1, out optional(3) LongSeq p3); + ["java:optional"] optional(1) LongSeq opLongSeqOpt(optional(2) LongSeq p1, out optional(3) LongSeq p3); + + optional(1) FloatSeq opFloatSeq(optional(2) FloatSeq p1, out optional(3) FloatSeq p3); + ["java:optional"] optional(1) FloatSeq opFloatSeqOpt(optional(2) FloatSeq p1, out optional(3) FloatSeq p3); + + optional(1) DoubleSeq opDoubleSeq(optional(2) DoubleSeq p1, out optional(3) DoubleSeq p3); + ["java:optional"] optional(1) DoubleSeq opDoubleSeqOpt(optional(2) DoubleSeq p1, out optional(3) DoubleSeq p3); + + optional(1) StringSeq opStringSeq(optional(2) StringSeq p1, out optional(3) StringSeq p3); + ["java:optional"] optional(1) StringSeq opStringSeqOpt(optional(2) StringSeq p1, out optional(3) StringSeq p3); + + optional(1) SmallStructSeq opSmallStructSeq(optional(2) SmallStructSeq p1, out optional(3) SmallStructSeq p3); + ["java:optional"] optional(1) SmallStructSeq opSmallStructSeqOpt(optional(2) SmallStructSeq p1, + out optional(3) SmallStructSeq p3); + + optional(1) SmallStructList opSmallStructList(optional(2) SmallStructList p1, out optional(3) SmallStructList p3); + ["java:optional"] optional(1) SmallStructList opSmallStructListOpt(optional(2) SmallStructList p1, + out optional(3) SmallStructList p3); - // Custom mapping operations - ["cpp:array"] optional(1) ByteSeq opByteSeq(["cpp:array"] optional(2) ByteSeq p1, - out ["cpp:array"] optional(3) ByteSeq p3); + optional(1) FixedStructSeq opFixedStructSeq(optional(2) FixedStructSeq p1, out optional(3) FixedStructSeq p3); + ["java:optional"] optional(1) FixedStructSeq opFixedStructSeqOpt(optional(2) FixedStructSeq p1, + out optional(3) FixedStructSeq p3); - ["cpp:array"] optional(1) ShortSeq opShortSeq(["cpp:array"] optional(2) ShortSeq p1, - out ["cpp:array"] optional(3) ShortSeq p3); + optional(1) FixedStructList opFixedStructList(optional(2) FixedStructList p1, out optional(3) FixedStructList p3); + ["java:optional"] optional(1) FixedStructList opFixedStructListOpt(optional(2) FixedStructList p1, + out optional(3) FixedStructList p3); - ["cpp:range:array"] optional(1) BoolSeq opBoolSeq(["cpp:range:array"] optional(2) BoolSeq p1, - out ["cpp:range:array"] optional(3) BoolSeq p3); + optional(1) VarStructSeq opVarStructSeq(optional(2) VarStructSeq p1, out optional(3) VarStructSeq p3); + ["java:optional"] optional(1) VarStructSeq opVarStructSeqOpt(optional(2) VarStructSeq p1, + out optional(3) VarStructSeq p3); - ["cpp:range"] optional(1) StringSeq opStringSeq(["cpp:range"] optional(2) StringSeq p1, - out ["cpp:range"] optional(3) StringSeq p3); + optional(1) Serializable opSerializable(optional(2) Serializable p1, out optional(3) Serializable p3); + ["java:optional"] optional(1) Serializable opSerializableOpt(optional(2) Serializable p1, + out optional(3) Serializable p3); - ["cpp:array"] optional(1) FixedStructSeq opFixedStructSeq(["cpp:array"] optional(2) FixedStructSeq p1, - out ["cpp:array"] optional(3) FixedStructSeq p3); + optional(1) IntIntDict opIntIntDict(optional(2) IntIntDict p1, out optional(3) IntIntDict p3); + ["java:optional"] optional(1) IntIntDict opIntIntDictOpt(optional(2) IntIntDict p1, out optional(3) IntIntDict p3); - ["cpp:range"] optional(1) VarStructSeq opVarStructSeq(["cpp:range"] optional(2) VarStructSeq p1, - out ["cpp:range"] optional(3) VarStructSeq p3); + optional(1) StringIntDict opStringIntDict(optional(2) StringIntDict p1, out optional(3) StringIntDict p3); + ["java:optional"] optional(1) StringIntDict opStringIntDictOpt(optional(2) StringIntDict p1, + out optional(3) StringIntDict p3); void opClassAndUnknownOptional(A p); }; diff --git a/java/test/Ice/optional/TestAMD.ice b/java/test/Ice/optional/TestAMD.ice new file mode 100644 index 00000000000..42209e9ee1e --- /dev/null +++ b/java/test/Ice/optional/TestAMD.ice @@ -0,0 +1,276 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#pragma once + +[["java:package:test.Ice.optional.AMD"]] +module Test +{ + +class OneOptional +{ + optional(1) int a; +}; + +enum MyEnum +{ + MyEnumMember +}; + +struct SmallStruct +{ + byte m; +}; + +struct FixedStruct +{ + int m; +}; + +struct VarStruct +{ + string m; +}; + +struct ClassVarStruct +{ + int a; +}; + +sequence<byte> ByteSeq; +sequence<bool> BoolSeq; +sequence<short> ShortSeq; +sequence<int> IntSeq; +sequence<long> LongSeq; +sequence<float> FloatSeq; +sequence<double> DoubleSeq; +sequence<string> StringSeq; +sequence<MyEnum> MyEnumSeq; +sequence<SmallStruct> SmallStructSeq; +["java:type:java.util.ArrayList<SmallStruct>"] sequence<SmallStruct> SmallStructList; +sequence<FixedStruct> FixedStructSeq; +["java:type:java.util.ArrayList<FixedStruct>"] sequence<FixedStruct> FixedStructList; +sequence<VarStruct> VarStructSeq; +sequence<OneOptional> OneOptionalSeq; +sequence<OneOptional*> OneOptionalPrxSeq; + +["java:serializable:test.Ice.optional.SerializableClass"] sequence<byte> Serializable; + +dictionary<int, int> IntIntDict; +dictionary<string, int> StringIntDict; +dictionary<int, MyEnum> IntEnumDict; +dictionary<int, FixedStruct> IntFixedStructDict; +dictionary<int, VarStruct> IntVarStructDict; +dictionary<int, OneOptional> IntOneOptionalDict; +dictionary<int, OneOptional*> IntOneOptionalPrxDict; + +class MultiOptional +{ + optional(1) byte a; + optional(2) bool b; + optional(3) short c; + optional(4) int d; + optional(5) long e; + optional(6) float f; + optional(7) double g; + optional(8) string h; + optional(9) MyEnum i; + optional(10) MultiOptional* j; + optional(11) MultiOptional k; + optional(12) ByteSeq bs; + optional(13) StringSeq ss; + optional(14) IntIntDict iid; + optional(15) StringIntDict sid; + optional(16) FixedStruct fs; + optional(17) VarStruct vs; + + optional(18) ShortSeq shs; + optional(19) MyEnumSeq es; + optional(20) FixedStructSeq fss; + optional(21) VarStructSeq vss; + optional(22) OneOptionalSeq oos; + optional(23) OneOptionalPrxSeq oops; + + optional(24) IntEnumDict ied; + optional(25) IntFixedStructDict ifsd; + optional(26) IntVarStructDict ivsd; + optional(27) IntOneOptionalDict iood; + optional(28) IntOneOptionalPrxDict ioopd; + + optional(29) BoolSeq bos; +}; + +class A +{ + int requiredA; + optional(1) int ma; + optional(50) int mb; + optional(500) int mc; +}; + +["preserve-slice"] +class B extends A +{ + int requiredB; + optional(10) int md; +}; + +class C extends B +{ + string ss; + optional(890) string ms; +}; + +class WD +{ + optional(1) int a = 5; + optional(2) string s = "test"; +}; + +exception OptionalException +{ + optional(1) int a = 5; + optional(2) string b; + optional(50) OneOptional o; +}; + +exception DerivedException extends OptionalException +{ + optional(600) string ss = "test"; + optional(601) OneOptional o2; +}; + +exception RequiredException extends OptionalException +{ + string ss = "test"; + OneOptional o2; +}; + +class OptionalWithCustom +{ + ["java:type:java.util.ArrayList<Byte>"] optional(1) ByteSeq bs; + optional(2) ClassVarStruct s; +}; + +["ami", "amd"] +class Initial +{ + void shutdown(); + + Object pingPong(Object o); + + ["java:optional"] + void opOptionalException(optional(1) int a, optional(2) string b, optional(3) OneOptional o) + throws OptionalException; + + optional(1) byte opByte(optional(2) byte p1, out optional(3) byte p3); + ["java:optional"] optional(1) byte opByteOpt(optional(2) byte p1, out optional(3) byte p3); + + optional(1) bool opBool(optional(2) bool p1, out optional(3) bool p3); + ["java:optional"] optional(1) bool opBoolOpt(optional(2) bool p1, out optional(3) bool p3); + + optional(1) short opShort(optional(2) short p1, out optional(3) short p3); + ["java:optional"] optional(1) short opShortOpt(optional(2) short p1, out optional(3) short p3); + + optional(1) int opInt(optional(2) int p1, out optional(3) int p3); + ["java:optional"] optional(1) int opIntOpt(optional(2) int p1, out optional(3) int p3); + + optional(1) long opLong(optional(2) long p1, out optional(3) long p3); + ["java:optional"] optional(1) long opLongOpt(optional(2) long p1, out optional(3) long p3); + + optional(1) float opFloat(optional(2) float p1, out optional(3) float p3); + ["java:optional"] optional(1) float opFloatOpt(optional(2) float p1, out optional(3) float p3); + + optional(1) double opDouble(optional(2) double p1, out optional(3) double p3); + ["java:optional"] optional(1) double opDoubleOpt(optional(2) double p1, out optional(3) double p3); + + optional(1) string opString(optional(2) string p1, out optional(3) string p3); + ["java:optional"] optional(1) string opStringOpt(optional(2) string p1, out optional(3) string p3); + + optional(1) MyEnum opMyEnum(optional(2) MyEnum p1, out optional(3) MyEnum p3); + ["java:optional"] optional(1) MyEnum opMyEnumOpt(optional(2) MyEnum p1, out optional(3) MyEnum p3); + + optional(1) SmallStruct opSmallStruct(optional(2) SmallStruct p1, out optional(3) SmallStruct p3); + ["java:optional"] optional(1) SmallStruct opSmallStructOpt(optional(2) SmallStruct p1, + out optional(3) SmallStruct p3); + + optional(1) FixedStruct opFixedStruct(optional(2) FixedStruct p1, out optional(3) FixedStruct p3); + ["java:optional"] optional(1) FixedStruct opFixedStructOpt(optional(2) FixedStruct p1, + out optional(3) FixedStruct p3); + + optional(1) VarStruct opVarStruct(optional(2) VarStruct p1, out optional(3) VarStruct p3); + ["java:optional"] optional(1) VarStruct opVarStructOpt(optional(2) VarStruct p1, out optional(3) VarStruct p3); + + optional(1) OneOptional opOneOptional(optional(2) OneOptional p1, out optional(3) OneOptional p3); + ["java:optional"] optional(1) OneOptional opOneOptionalOpt(optional(2) OneOptional p1, + out optional(3) OneOptional p3); + + optional(1) OneOptional* opOneOptionalProxy(optional(2) OneOptional* p1, out optional(3) OneOptional* p3); + ["java:optional"] optional(1) OneOptional* opOneOptionalProxyOpt(optional(2) OneOptional* p1, + out optional(3) OneOptional* p3); + + optional(1) ByteSeq opByteSeq(optional(2) ByteSeq p1, out optional(3) ByteSeq p3); + ["java:optional"] optional(1) ByteSeq opByteSeqOpt(optional(2) ByteSeq p1, out optional(3) ByteSeq p3); + + optional(1) BoolSeq opBoolSeq(optional(2) BoolSeq p1, out optional(3) BoolSeq p3); + ["java:optional"] optional(1) BoolSeq opBoolSeqOpt(optional(2) BoolSeq p1, out optional(3) BoolSeq p3); + + optional(1) ShortSeq opShortSeq(optional(2) ShortSeq p1, out optional(3) ShortSeq p3); + ["java:optional"] optional(1) ShortSeq opShortSeqOpt(optional(2) ShortSeq p1, out optional(3) ShortSeq p3); + + optional(1) IntSeq opIntSeq(optional(2) IntSeq p1, out optional(3) IntSeq p3); + ["java:optional"] optional(1) IntSeq opIntSeqOpt(optional(2) IntSeq p1, out optional(3) IntSeq p3); + + optional(1) LongSeq opLongSeq(optional(2) LongSeq p1, out optional(3) LongSeq p3); + ["java:optional"] optional(1) LongSeq opLongSeqOpt(optional(2) LongSeq p1, out optional(3) LongSeq p3); + + optional(1) FloatSeq opFloatSeq(optional(2) FloatSeq p1, out optional(3) FloatSeq p3); + ["java:optional"] optional(1) FloatSeq opFloatSeqOpt(optional(2) FloatSeq p1, out optional(3) FloatSeq p3); + + optional(1) DoubleSeq opDoubleSeq(optional(2) DoubleSeq p1, out optional(3) DoubleSeq p3); + ["java:optional"] optional(1) DoubleSeq opDoubleSeqOpt(optional(2) DoubleSeq p1, out optional(3) DoubleSeq p3); + + optional(1) StringSeq opStringSeq(optional(2) StringSeq p1, out optional(3) StringSeq p3); + ["java:optional"] optional(1) StringSeq opStringSeqOpt(optional(2) StringSeq p1, out optional(3) StringSeq p3); + + optional(1) SmallStructSeq opSmallStructSeq(optional(2) SmallStructSeq p1, out optional(3) SmallStructSeq p3); + ["java:optional"] optional(1) SmallStructSeq opSmallStructSeqOpt(optional(2) SmallStructSeq p1, + out optional(3) SmallStructSeq p3); + + optional(1) SmallStructList opSmallStructList(optional(2) SmallStructList p1, out optional(3) SmallStructList p3); + ["java:optional"] optional(1) SmallStructList opSmallStructListOpt(optional(2) SmallStructList p1, + out optional(3) SmallStructList p3); + + optional(1) FixedStructSeq opFixedStructSeq(optional(2) FixedStructSeq p1, out optional(3) FixedStructSeq p3); + ["java:optional"] optional(1) FixedStructSeq opFixedStructSeqOpt(optional(2) FixedStructSeq p1, + out optional(3) FixedStructSeq p3); + + optional(1) FixedStructList opFixedStructList(optional(2) FixedStructList p1, out optional(3) FixedStructList p3); + ["java:optional"] optional(1) FixedStructList opFixedStructListOpt(optional(2) FixedStructList p1, + out optional(3) FixedStructList p3); + + optional(1) VarStructSeq opVarStructSeq(optional(2) VarStructSeq p1, out optional(3) VarStructSeq p3); + ["java:optional"] optional(1) VarStructSeq opVarStructSeqOpt(optional(2) VarStructSeq p1, + out optional(3) VarStructSeq p3); + + optional(1) Serializable opSerializable(optional(2) Serializable p1, out optional(3) Serializable p3); + ["java:optional"] optional(1) Serializable opSerializableOpt(optional(2) Serializable p1, + out optional(3) Serializable p3); + + optional(1) IntIntDict opIntIntDict(optional(2) IntIntDict p1, out optional(3) IntIntDict p3); + ["java:optional"] optional(1) IntIntDict opIntIntDictOpt(optional(2) IntIntDict p1, out optional(3) IntIntDict p3); + + optional(1) StringIntDict opStringIntDict(optional(2) StringIntDict p1, out optional(3) StringIntDict p3); + ["java:optional"] optional(1) StringIntDict opStringIntDictOpt(optional(2) StringIntDict p1, + out optional(3) StringIntDict p3); + + void opClassAndUnknownOptional(A p); +}; + +}; diff --git a/java/test/Ice/optional/run.py b/java/test/Ice/optional/run.py index 6ab39a07d80..1faa524d762 100755 --- a/java/test/Ice/optional/run.py +++ b/java/test/Ice/optional/run.py @@ -24,3 +24,5 @@ print("Running test with compact (default) format.") TestUtil.clientServerTest() print("Running test with sliced format.") TestUtil.clientServerTest(additionalClientOptions="--Ice.Default.SlicedFormat", additionalServerOptions="--Ice.Default.SlicedFormat") +print("Running test with AMD server.") +TestUtil.clientServerTest(server="test.Ice.optional.AMDServer") |