summaryrefslogtreecommitdiff
path: root/java/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/src')
-rw-r--r--java/src/Ice/Object.java4
-rw-r--r--java/src/IceInternal/BasicStream.java100
-rw-r--r--java/src/IceInternal/Incoming.java2
-rw-r--r--java/src/IceInternal/Outgoing.java4
-rw-r--r--java/src/IceInternal/Reference.java4
-rw-r--r--java/src/IceInternal/ReferenceFactory.java4
-rw-r--r--java/src/IceInternal/TraceUtil.java2
7 files changed, 76 insertions, 44 deletions
diff --git a/java/src/Ice/Object.java b/java/src/Ice/Object.java
index d02442f8fd3..0d7f5ecaef2 100644
--- a/java/src/Ice/Object.java
+++ b/java/src/Ice/Object.java
@@ -188,7 +188,7 @@ public class Object
synchronized(_activeFacetMapMutex)
{
final int sz = _activeFacetMap.size();
- __os.writeInt(sz);
+ __os.writeSize(sz);
java.util.Set set = _activeFacetMap.keySet();
String[] keys = new String[sz];
@@ -206,7 +206,7 @@ public class Object
{
synchronized(_activeFacetMapMutex)
{
- int sz = __is.readInt();
+ int sz = __is.readSize();
_activeFacetMap.clear();
diff --git a/java/src/IceInternal/BasicStream.java b/java/src/IceInternal/BasicStream.java
index 17ef3466c6b..c880b3d7bc1 100644
--- a/java/src/IceInternal/BasicStream.java
+++ b/java/src/IceInternal/BasicStream.java
@@ -138,7 +138,7 @@ public class BasicStream
public void
startWriteEncaps()
{
- writeInt(0); // Encoding
+ writeByte((byte)0); // Encoding
writeInt(0); // Placeholder for the encapsulation length
WriteEncaps curr = _writeEncapsCache;
if (curr != null)
@@ -171,7 +171,7 @@ public class BasicStream
public void
startReadEncaps()
{
- int encoding = readInt();
+ byte encoding = readByte();
if (encoding != 0)
{
throw new Ice.UnsupportedEncodingException();
@@ -186,7 +186,7 @@ public class BasicStream
{
curr = new ReadEncaps();
}
- curr.encoding = (byte)encoding;
+ curr.encoding = encoding;
curr.start = _buf.position();
curr.next = _readEncapsStack;
_readEncapsStack = curr;
@@ -233,7 +233,7 @@ public class BasicStream
public void
skipEncaps()
{
- int encoding = readInt();
+ byte encoding = readByte();
if (encoding != 0)
{
throw new Ice.UnsupportedEncodingException();
@@ -250,6 +250,43 @@ public class BasicStream
}
public void
+ writeSize(int v)
+ {
+ if (v >= 0xff)
+ {
+ expand(5);
+ _buf.put((byte)0xff);
+ _buf.putInt(v);
+ }
+ else
+ {
+ expand(1);
+ _buf.put((byte)v);
+ }
+ }
+
+ public int
+ readSize()
+ {
+ try
+ {
+ byte b = _buf.get();
+ if (b == 0xff)
+ {
+ return _buf.getInt();
+ }
+ else
+ {
+ return (int)b;
+ }
+ }
+ catch (java.nio.BufferUnderflowException ex)
+ {
+ throw new Ice.UnmarshalOutOfBoundsException();
+ }
+ }
+
+ public void
writeBlob(byte[] v)
{
expand(v.length);
@@ -281,8 +318,8 @@ public class BasicStream
public void
writeByteSeq(byte[] v)
{
- expand(4 + v.length);
- _buf.putInt(v.length);
+ writeSize(v.length);
+ expand(v.length);
_buf.put(v);
}
@@ -304,7 +341,7 @@ public class BasicStream
{
try
{
- final int sz = _buf.getInt();
+ final int sz = readSize();
byte[] v = new byte[sz];
_buf.get(v);
return v;
@@ -325,8 +362,8 @@ public class BasicStream
public void
writeBoolSeq(boolean[] v)
{
- expand(4 + v.length);
- _buf.putInt(v.length);
+ writeSize(v.length);
+ expand(v.length);
for (int i = 0; i < v.length; i++)
{
_buf.put(v[i] ? (byte)1 : (byte)0);
@@ -351,7 +388,7 @@ public class BasicStream
{
try
{
- final int sz = _buf.getInt();
+ final int sz = readSize();
boolean[] v = new boolean[sz];
for (int i = 0; i < sz; i++)
{
@@ -375,9 +412,8 @@ public class BasicStream
public void
writeShortSeq(short[] v)
{
- expand(4 + v.length * 2);
- _buf.putInt(v.length);
-
+ writeSize(v.length);
+ expand(v.length * 2);
java.nio.ShortBuffer shortBuf = _buf.asShortBuffer();
shortBuf.put(v);
_buf.position(_buf.position() + v.length * 2);
@@ -401,7 +437,7 @@ public class BasicStream
{
try
{
- final int sz = _buf.getInt();
+ final int sz = readSize();
short[] v = new short[sz];
java.nio.ShortBuffer shortBuf = _buf.asShortBuffer();
shortBuf.get(v);
@@ -424,9 +460,8 @@ public class BasicStream
public void
writeIntSeq(int[] v)
{
- expand(4 + v.length * 4);
- _buf.putInt(v.length);
-
+ writeSize(v.length);
+ expand(v.length * 4);
java.nio.IntBuffer intBuf = _buf.asIntBuffer();
intBuf.put(v);
_buf.position(_buf.position() + v.length * 4);
@@ -450,7 +485,7 @@ public class BasicStream
{
try
{
- final int sz = _buf.getInt();
+ final int sz = readSize();
int[] v = new int[sz];
java.nio.IntBuffer intBuf = _buf.asIntBuffer();
intBuf.get(v);
@@ -473,9 +508,8 @@ public class BasicStream
public void
writeLongSeq(long[] v)
{
- expand(4 + v.length * 8);
- _buf.putInt(v.length);
-
+ writeSize(v.length);
+ expand(v.length * 8);
java.nio.LongBuffer longBuf = _buf.asLongBuffer();
longBuf.put(v);
_buf.position(_buf.position() + v.length * 8);
@@ -499,7 +533,7 @@ public class BasicStream
{
try
{
- final int sz = _buf.getInt();
+ final int sz = readSize();
long[] v = new long[sz];
java.nio.LongBuffer longBuf = _buf.asLongBuffer();
longBuf.get(v);
@@ -522,9 +556,8 @@ public class BasicStream
public void
writeFloatSeq(float[] v)
{
- expand(4 + v.length * 4);
- _buf.putInt(v.length);
-
+ writeSize(v.length);
+ expand(v.length * 4);
java.nio.FloatBuffer floatBuf = _buf.asFloatBuffer();
floatBuf.put(v);
_buf.position(_buf.position() + v.length * 4);
@@ -548,7 +581,7 @@ public class BasicStream
{
try
{
- final int sz = _buf.getInt();
+ final int sz = readSize();
float[] v = new float[sz];
java.nio.FloatBuffer floatBuf = _buf.asFloatBuffer();
floatBuf.get(v);
@@ -571,9 +604,8 @@ public class BasicStream
public void
writeDoubleSeq(double[] v)
{
- expand(4 + v.length * 8);
- _buf.putInt(v.length);
-
+ writeSize(v.length);
+ expand(v.length * 8);
java.nio.DoubleBuffer doubleBuf = _buf.asDoubleBuffer();
doubleBuf.put(v);
_buf.position(_buf.position() + v.length * 8);
@@ -597,7 +629,7 @@ public class BasicStream
{
try
{
- final int sz = _buf.getInt();
+ final int sz = readSize();
double[] v = new double[sz];
java.nio.DoubleBuffer doubleBuf = _buf.asDoubleBuffer();
doubleBuf.get(v);
@@ -614,7 +646,7 @@ public class BasicStream
writeString(String v)
{
final int len = v.length();
- writeInt(len);
+ writeSize(len);
if (len > 0)
{
expand(len);
@@ -628,7 +660,7 @@ public class BasicStream
public void
writeStringSeq(String[] v)
{
- writeInt(v.length);
+ writeSize(v.length);
for (int i = 0; i < v.length; i++)
{
writeString(v[i]);
@@ -638,7 +670,7 @@ public class BasicStream
public String
readString()
{
- final int len = readInt();
+ final int len = readSize();
if (len == 0)
{
@@ -676,7 +708,7 @@ public class BasicStream
public String[]
readStringSeq()
{
- final int sz = readInt();
+ final int sz = readSize();
// Don't use v.resize(sz) or v.reserve(sz) here, as it cannot be
// checked whether sz is a reasonable value
String[] v = new String[sz];
diff --git a/java/src/IceInternal/Incoming.java b/java/src/IceInternal/Incoming.java
index 29e0f597631..ace56c2e838 100644
--- a/java/src/IceInternal/Incoming.java
+++ b/java/src/IceInternal/Incoming.java
@@ -29,7 +29,7 @@ public class Incoming
current.facet = _is.readString();
current.operation = _is.readString();
current.nonmutating = _is.readBool();
- int sz = _is.readInt();
+ int sz = _is.readSize();
while (sz-- > 0)
{
String first = _is.readString();
diff --git a/java/src/IceInternal/Outgoing.java b/java/src/IceInternal/Outgoing.java
index 0cd06592a63..2ed65195eda 100644
--- a/java/src/IceInternal/Outgoing.java
+++ b/java/src/IceInternal/Outgoing.java
@@ -46,12 +46,12 @@ public final class Outgoing
_os.writeBool(nonmutating);
if (context == null)
{
- _os.writeInt(0);
+ _os.writeSize(0);
}
else
{
final int sz = context.size();
- _os.writeInt(sz);
+ _os.writeSize(sz);
if (sz > 0)
{
java.util.Iterator i = context.entrySet().iterator();
diff --git a/java/src/IceInternal/Reference.java b/java/src/IceInternal/Reference.java
index 3f069768f8a..7af1c4653c8 100644
--- a/java/src/IceInternal/Reference.java
+++ b/java/src/IceInternal/Reference.java
@@ -111,7 +111,7 @@ public final class Reference
s.writeBool(secure);
- s.writeInt(origEndpoints.length);
+ s.writeSize(origEndpoints.length);
for (int i = 0; i < origEndpoints.length; i++)
{
origEndpoints[i].streamWrite(s);
@@ -124,7 +124,7 @@ public final class Reference
else
{
s.writeBool(false);
- s.writeInt(endpoints.length);
+ s.writeSize(endpoints.length);
for (int i = 0; i < endpoints.length; i++)
{
endpoints[i].streamWrite(s);
diff --git a/java/src/IceInternal/ReferenceFactory.java b/java/src/IceInternal/ReferenceFactory.java
index 5361da5468b..7522ae752eb 100644
--- a/java/src/IceInternal/ReferenceFactory.java
+++ b/java/src/IceInternal/ReferenceFactory.java
@@ -277,7 +277,7 @@ public final class ReferenceFactory
Endpoint[] origEndpoints;
Endpoint[] endpoints;
- int sz = s.readInt();
+ int sz = s.readSize();
origEndpoints = new Endpoint[sz];
for (int i = 0; i < sz; i++)
{
@@ -291,7 +291,7 @@ public final class ReferenceFactory
}
else
{
- sz = s.readInt();
+ sz = s.readSize();
endpoints = new Endpoint[sz];
for (int i = 0; i < sz; i++)
{
diff --git a/java/src/IceInternal/TraceUtil.java b/java/src/IceInternal/TraceUtil.java
index 49ba175978e..c27e60ff586 100644
--- a/java/src/IceInternal/TraceUtil.java
+++ b/java/src/IceInternal/TraceUtil.java
@@ -251,7 +251,7 @@ final class TraceUtil
out.write("\noperation = " + operation);
boolean nonmutating = stream.readBool();
out.write("\nnonmutating = " + nonmutating);
- int sz = stream.readInt();
+ int sz = stream.readSize();
out.write("\ncontext = ");
while (sz-- > 0)
{