summaryrefslogtreecommitdiff
path: root/jurt
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2014-08-15 16:17:25 +0200
committerNoel Grandin <noel@peralex.com>2014-09-25 13:47:25 +0200
commit83636d2c09802aeeb1b30078022d228d04da21eb (patch)
tree8a0c619e16c1f6b5388939d5da2956f7ef758c19 /jurt
parentcf49392511e98851174b353782df9eb6bac46f77 (diff)
java: when rethrowing exceptions, store the original cause
so that we get a nice complete stacktrace when it hits the final handler Change-Id: Iec4fcc15a2a25c55f591b5e069dce3d010197a90
Diffstat (limited to 'jurt')
-rw-r--r--jurt/com/sun/star/comp/connections/PipedConnection.java7
-rw-r--r--jurt/com/sun/star/comp/loader/FactoryHelper.java14
-rw-r--r--jurt/com/sun/star/comp/servicemanager/ServiceManager.java2
-rw-r--r--jurt/com/sun/star/lib/connections/socket/socketAcceptor.java7
-rw-r--r--jurt/com/sun/star/lib/connections/socket/socketConnector.java9
-rw-r--r--jurt/com/sun/star/lib/uno/bridges/java_remote/XConnectionInputStream_Adapter.java4
-rw-r--r--jurt/com/sun/star/lib/uno/bridges/java_remote/XConnectionOutputStream_Adapter.java6
-rw-r--r--jurt/com/sun/star/lib/uno/protocols/urp/Marshal.java352
-rw-r--r--jurt/com/sun/star/lib/uno/protocols/urp/Unmarshal.java279
-rw-r--r--jurt/com/sun/star/lib/uno/protocols/urp/urp.java2
10 files changed, 313 insertions, 369 deletions
diff --git a/jurt/com/sun/star/comp/connections/PipedConnection.java b/jurt/com/sun/star/comp/connections/PipedConnection.java
index d48b2a63df0e..8cae64d3cdfc 100644
--- a/jurt/com/sun/star/comp/connections/PipedConnection.java
+++ b/jurt/com/sun/star/comp/connections/PipedConnection.java
@@ -20,12 +20,9 @@ package com.sun.star.comp.connections;
import com.sun.star.comp.loader.FactoryHelper;
-
import com.sun.star.connection.XConnection;
-
import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.lang.XSingleServiceFactory;
-
import com.sun.star.registry.XRegistryKey;
/**
@@ -121,7 +118,7 @@ public class PipedConnection implements XConnection {
wait(__waitTime);
}
catch(InterruptedException interruptedException) {
- throw new com.sun.star.io.IOException(interruptedException.toString());
+ throw new com.sun.star.io.IOException(interruptedException);
}
}
@@ -175,7 +172,7 @@ public class PipedConnection implements XConnection {
wait(__waitTime); // we wait for data or for the pipe to be closed
}
catch(InterruptedException interruptedException) {
- throw new com.sun.star.io.IOException(interruptedException.toString());
+ throw new com.sun.star.io.IOException(interruptedException);
}
}
diff --git a/jurt/com/sun/star/comp/loader/FactoryHelper.java b/jurt/com/sun/star/comp/loader/FactoryHelper.java
index 92b480174769..3fdbac487180 100644
--- a/jurt/com/sun/star/comp/loader/FactoryHelper.java
+++ b/jurt/com/sun/star/comp/loader/FactoryHelper.java
@@ -29,9 +29,7 @@ import com.sun.star.lang.XServiceInfo;
import com.sun.star.lang.XSingleServiceFactory;
import com.sun.star.lang.XSingleComponentFactory;
import com.sun.star.lang.XTypeProvider;
-
import com.sun.star.registry.XRegistryKey;
-
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.Type;
@@ -207,11 +205,11 @@ public class FactoryHelper {
else if (targetException instanceof com.sun.star.uno.RuntimeException)
throw (com.sun.star.uno.RuntimeException)targetException;
else
- throw new com.sun.star.uno.Exception( targetException.toString() );
+ throw new com.sun.star.uno.Exception( targetException );
} catch (IllegalAccessException illegalAccessException) {
- throw new com.sun.star.uno.Exception( illegalAccessException.toString() );
+ throw new com.sun.star.uno.Exception( illegalAccessException );
} catch (InstantiationException instantiationException) {
- throw new com.sun.star.uno.Exception( instantiationException.toString() );
+ throw new com.sun.star.uno.Exception( instantiationException );
}
}
@@ -283,11 +281,11 @@ public class FactoryHelper {
else if (targetException instanceof com.sun.star.uno.RuntimeException)
throw (com.sun.star.uno.RuntimeException)targetException;
else
- throw new com.sun.star.uno.Exception( targetException.toString() );
+ throw new com.sun.star.uno.Exception( targetException );
} catch (IllegalAccessException illegalAccessException) {
- throw new com.sun.star.uno.Exception( illegalAccessException.toString() );
+ throw new com.sun.star.uno.Exception( illegalAccessException );
} catch (InstantiationException instantiationException) {
- throw new com.sun.star.uno.Exception( instantiationException.toString() );
+ throw new com.sun.star.uno.Exception( instantiationException );
}
}
diff --git a/jurt/com/sun/star/comp/servicemanager/ServiceManager.java b/jurt/com/sun/star/comp/servicemanager/ServiceManager.java
index 38e5cb30646d..729fda5b2215 100644
--- a/jurt/com/sun/star/comp/servicemanager/ServiceManager.java
+++ b/jurt/com/sun/star/comp/servicemanager/ServiceManager.java
@@ -192,7 +192,7 @@ public class ServiceManager implements XMultiServiceFactory,
return factoriesByServiceNames.keySet().toArray(
new String[ factoriesByServiceNames.size() ] );
} catch(Exception ex) {
- throw new com.sun.star.uno.RuntimeException(ex.toString());
+ throw new com.sun.star.uno.RuntimeException(ex);
}
}
diff --git a/jurt/com/sun/star/lib/connections/socket/socketAcceptor.java b/jurt/com/sun/star/lib/connections/socket/socketAcceptor.java
index 4902d52b9f3f..e3dbea71c14b 100644
--- a/jurt/com/sun/star/lib/connections/socket/socketAcceptor.java
+++ b/jurt/com/sun/star/lib/connections/socket/socketAcceptor.java
@@ -26,6 +26,7 @@ import com.sun.star.connection.XConnection;
import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.lang.XSingleServiceFactory;
import com.sun.star.registry.XRegistryKey;
+
import java.io.IOException;
import java.net.InetAddress;
import java.net.ServerSocket;
@@ -133,7 +134,7 @@ public final class socketAcceptor implements XAcceptor {
host == null ? null
: InetAddress.getByName(host));
} catch (IOException e) {
- throw new ConnectionSetupException(e.toString());
+ throw new ConnectionSetupException(e);
}
acceptingDescription = connectionDescription;
tcpNoDelay = desc.getTcpNoDelay();
@@ -157,7 +158,7 @@ public final class socketAcceptor implements XAcceptor {
return new SocketConnection(acceptingDescription, socket);
}
catch(IOException e) {
- throw new ConnectionSetupException(e.toString());
+ throw new ConnectionSetupException(e);
}
}
@@ -174,7 +175,7 @@ public final class socketAcceptor implements XAcceptor {
serv.close();
}
catch (IOException e) {
- throw new com.sun.star.uno.RuntimeException(e.toString());
+ throw new com.sun.star.uno.RuntimeException(e);
}
}
diff --git a/jurt/com/sun/star/lib/connections/socket/socketConnector.java b/jurt/com/sun/star/lib/connections/socket/socketConnector.java
index ce76eaa4723c..a0c49370c6b2 100644
--- a/jurt/com/sun/star/lib/connections/socket/socketConnector.java
+++ b/jurt/com/sun/star/lib/connections/socket/socketConnector.java
@@ -26,6 +26,7 @@ import com.sun.star.connection.XConnector;
import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.lang.XSingleServiceFactory;
import com.sun.star.registry.XRegistryKey;
+
import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;
@@ -113,7 +114,7 @@ public final class socketConnector implements XConnector {
try {
desc = new ConnectionDescriptor(connectionDescription);
} catch (com.sun.star.lang.IllegalArgumentException e) {
- throw new ConnectionSetupException(e.toString());
+ throw new ConnectionSetupException(e);
}
if (desc.getHost() == null)
@@ -127,7 +128,7 @@ public final class socketConnector implements XConnector {
try {
adr = InetAddress.getAllByName(desc.getHost());
} catch (UnknownHostException e) {
- throw new ConnectionSetupException(e.toString());
+ throw new ConnectionSetupException(e);
}
Socket socket = null;
for (int i = 0; i < adr.length; ++i) {
@@ -136,7 +137,7 @@ public final class socketConnector implements XConnector {
break;
} catch (IOException e) {
if (i == adr.length - 1)
- throw new NoConnectException(e.toString());
+ throw new NoConnectException(e);
}
}
XConnection con;
@@ -146,7 +147,7 @@ public final class socketConnector implements XConnector {
con = new SocketConnection(connectionDescription, socket);
} catch (IOException e) {
- throw new NoConnectException(e.toString());
+ throw new NoConnectException(e);
}
connected = true;
return con;
diff --git a/jurt/com/sun/star/lib/uno/bridges/java_remote/XConnectionInputStream_Adapter.java b/jurt/com/sun/star/lib/uno/bridges/java_remote/XConnectionInputStream_Adapter.java
index 87b3ea19d1fc..48fea08bd216 100644
--- a/jurt/com/sun/star/lib/uno/bridges/java_remote/XConnectionInputStream_Adapter.java
+++ b/jurt/com/sun/star/lib/uno/bridges/java_remote/XConnectionInputStream_Adapter.java
@@ -46,7 +46,7 @@ class XConnectionInputStream_Adapter extends InputStream {
try {
len = _xConnection.read(_bytes, 1);
} catch(com.sun.star.io.IOException ioException) {
- throw new IOException(ioException.toString());
+ throw new IOException(ioException);
}
if(DEBUG) System.err.println("#### " + getClass().getName() + " - one byte read:" + _bytes[0][0]);
@@ -61,7 +61,7 @@ class XConnectionInputStream_Adapter extends InputStream {
try {
len = _xConnection.read(_bytes, len - off);
} catch(com.sun.star.io.IOException ioException) {
- throw new IOException(ioException.toString());
+ throw new IOException(ioException);
}
System.arraycopy(_bytes[0], 0, b, off, len);
diff --git a/jurt/com/sun/star/lib/uno/bridges/java_remote/XConnectionOutputStream_Adapter.java b/jurt/com/sun/star/lib/uno/bridges/java_remote/XConnectionOutputStream_Adapter.java
index 3730722eb12b..954afe8df6a0 100644
--- a/jurt/com/sun/star/lib/uno/bridges/java_remote/XConnectionOutputStream_Adapter.java
+++ b/jurt/com/sun/star/lib/uno/bridges/java_remote/XConnectionOutputStream_Adapter.java
@@ -44,7 +44,7 @@ class XConnectionOutputStream_Adapter extends OutputStream {
try {
_xConnection.write(_bytes);
} catch(com.sun.star.io.IOException ioException) {
- throw new IOException(ioException.toString());
+ throw new IOException(ioException);
}
if(DEBUG) System.err.println("#### " + this.getClass() + " - one byte written:" + _bytes[0]);
@@ -65,7 +65,7 @@ class XConnectionOutputStream_Adapter extends OutputStream {
try {
_xConnection.write(bytes);
} catch(com.sun.star.io.IOException ioException) {
- throw new IOException(ioException.toString());
+ throw new IOException(ioException);
}
}
@@ -74,7 +74,7 @@ class XConnectionOutputStream_Adapter extends OutputStream {
try {
_xConnection.flush();
} catch(com.sun.star.io.IOException ioException) {
- throw new IOException(ioException.toString());
+ throw new IOException(ioException);
}
}
}
diff --git a/jurt/com/sun/star/lib/uno/protocols/urp/Marshal.java b/jurt/com/sun/star/lib/uno/protocols/urp/Marshal.java
index 55c36cd4b7a7..8a42b4a8e831 100644
--- a/jurt/com/sun/star/lib/uno/protocols/urp/Marshal.java
+++ b/jurt/com/sun/star/lib/uno/protocols/urp/Marshal.java
@@ -26,6 +26,7 @@ import com.sun.star.uno.IFieldDescription;
import com.sun.star.uno.Type;
import com.sun.star.uno.TypeClass;
import com.sun.star.uno.XInterface;
+
import java.io.ByteArrayOutputStream;
import java.io.DataOutput;
import java.io.DataOutputStream;
@@ -46,7 +47,7 @@ final class Marshal {
try {
output.writeByte(value);
} catch (IOException e) {
- throw new RuntimeException(e.toString());
+ throw new RuntimeException(e);
}
}
@@ -54,19 +55,23 @@ final class Marshal {
try {
output.writeShort(value);
} catch (IOException e) {
- throw new RuntimeException(e.toString());
+ throw new RuntimeException(e);
}
}
public void writeObjectId(String objectId) {
- if (objectId == null) {
- writeStringValue(null);
- write16Bit(0xFFFF);
- } else {
- boolean[] found = new boolean[1];
- int index = objectIdCache.add(found, objectId);
- writeStringValue(found[0] ? null : objectId);
- write16Bit(index);
+ try {
+ if (objectId == null) {
+ writeStringValue(null);
+ write16Bit(0xFFFF);
+ } else {
+ boolean[] found = new boolean[1];
+ int index = objectIdCache.add(found, objectId);
+ writeStringValue(found[0] ? null : objectId);
+ write16Bit(index);
+ }
+ } catch (IOException e) {
+ throw new RuntimeException(e);
}
}
@@ -75,107 +80,127 @@ final class Marshal {
}
public void writeThreadId(ThreadId threadId) {
- byte[] data = threadId.getBytes();
- boolean[] found = new boolean[1];
- int index = threadIdCache.add(found, data);
- if (found[0]) {
- writeCompressedNumber(0);
- } else {
- writeCompressedNumber(data.length);
- writeBytes(data);
+ try {
+ byte[] data = threadId.getBytes();
+ boolean[] found = new boolean[1];
+ int index = threadIdCache.add(found, data);
+ if (found[0]) {
+ writeCompressedNumber(0);
+ } else {
+ writeCompressedNumber(data.length);
+ writeBytes(data);
+ }
+ write16Bit(index);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
}
- write16Bit(index);
}
public void writeType(TypeDescription type) {
- TypeClass typeClass = type.getTypeClass();
- if (TypeDescription.isTypeClassSimple(typeClass)) {
- write8Bit(typeClass.getValue());
- } else {
- boolean[] found = new boolean[1];
- int index = typeCache.add(found, type.getTypeName());
- write8Bit(typeClass.getValue() | (found[0] ? 0 : 0x80));
- write16Bit(index);
- if (!found[0]) {
- writeStringValue(type.getTypeName());
+ try {
+ TypeClass typeClass = type.getTypeClass();
+ if (TypeDescription.isTypeClassSimple(typeClass)) {
+ write8Bit(typeClass.getValue());
+ } else {
+ boolean[] found = new boolean[1];
+ int index = typeCache.add(found, type.getTypeName());
+ write8Bit(typeClass.getValue() | (found[0] ? 0 : 0x80));
+ write16Bit(index);
+ if (!found[0]) {
+ writeStringValue(type.getTypeName());
+ }
}
+ } catch (IOException e) {
+ throw new RuntimeException(e);
}
}
public void writeValue(TypeDescription type, Object value) {
- switch(type.getTypeClass().getValue()) {
- case TypeClass.VOID_value:
- break;
-
- case TypeClass.BOOLEAN_value:
- writeBooleanValue((Boolean) value);
- break;
-
- case TypeClass.BYTE_value:
- writeByteValue((Byte) value);
- break;
-
- case TypeClass.SHORT_value:
- case TypeClass.UNSIGNED_SHORT_value:
- writeShortValue((Short) value);
- break;
-
- case TypeClass.LONG_value:
- case TypeClass.UNSIGNED_LONG_value:
- writeLongValue((Integer) value);
- break;
-
- case TypeClass.HYPER_value:
- case TypeClass.UNSIGNED_HYPER_value:
- writeHyperValue((Long) value);
- break;
-
- case TypeClass.FLOAT_value:
- writeFloatValue((Float) value);
- break;
-
- case TypeClass.DOUBLE_value:
- writeDoubleValue((Double) value);
- break;
-
- case TypeClass.CHAR_value:
- writeCharValue((Character) value);
- break;
-
- case TypeClass.STRING_value:
- writeStringValue((String) value);
- break;
-
- case TypeClass.TYPE_value:
- writeTypeValue((Type) value);
- break;
-
- case TypeClass.ANY_value:
- writeAnyValue(value);
- break;
-
- case TypeClass.SEQUENCE_value:
- writeSequenceValue(type, value);
- break;
-
- case TypeClass.ENUM_value:
- writeEnumValue(type, (Enum) value);
- break;
-
- case TypeClass.STRUCT_value:
- writeStructValue(type, value);
- break;
-
- case TypeClass.EXCEPTION_value:
- writeExceptionValue(type, (Exception) value);
- break;
-
- case TypeClass.INTERFACE_value:
- writeInterfaceValue(type, (XInterface) value);
- break;
-
- default:
- throw new IllegalArgumentException("Bad type descriptor " + type);
+ try {
+ switch(type.getTypeClass().getValue()) {
+ case TypeClass.VOID_value:
+ break;
+
+ case TypeClass.BOOLEAN_value:
+ writeBooleanValue((Boolean) value);
+ break;
+
+ case TypeClass.BYTE_value:
+ writeByteValue((Byte) value);
+ break;
+
+ case TypeClass.SHORT_value:
+ case TypeClass.UNSIGNED_SHORT_value:
+ writeShortValue((Short) value);
+ break;
+
+ case TypeClass.LONG_value:
+ case TypeClass.UNSIGNED_LONG_value:
+ writeLongValue((Integer) value);
+ break;
+
+ case TypeClass.HYPER_value:
+ case TypeClass.UNSIGNED_HYPER_value:
+ writeHyperValue((Long) value);
+ break;
+
+ case TypeClass.FLOAT_value:
+ writeFloatValue((Float) value);
+ break;
+
+ case TypeClass.DOUBLE_value:
+ writeDoubleValue((Double) value);
+ break;
+
+ case TypeClass.CHAR_value:
+ writeCharValue((Character) value);
+ break;
+
+ case TypeClass.STRING_value:
+ writeStringValue((String) value);
+ break;
+
+ case TypeClass.TYPE_value:
+ writeTypeValue((Type) value);
+ break;
+
+ case TypeClass.ANY_value:
+ writeAnyValue(value);
+ break;
+
+ case TypeClass.SEQUENCE_value:
+ writeSequenceValue(type, value);
+ break;
+
+ case TypeClass.ENUM_value:
+ writeEnumValue(type, (Enum) value);
+ break;
+
+ case TypeClass.STRUCT_value:
+ writeStructValue(type, value);
+ break;
+
+ case TypeClass.EXCEPTION_value:
+ writeExceptionValue(type, (Exception) value);
+ break;
+
+ case TypeClass.INTERFACE_value:
+ writeInterfaceValue(type, (XInterface) value);
+ break;
+
+ default:
+ throw new IllegalArgumentException("Bad type descriptor " + type);
+ }
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException(e);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ } catch (InvocationTargetException e) {
+ throw new RuntimeException(e);
+ } catch (NoSuchMethodException e) {
+ throw new RuntimeException(e);
}
}
@@ -185,12 +210,8 @@ final class Marshal {
return data;
}
- private void writeBooleanValue(Boolean value) {
- try {
- output.writeBoolean(value != null && value.booleanValue());
- } catch (IOException e) {
- throw new RuntimeException(e.toString());
- }
+ private void writeBooleanValue(Boolean value) throws IOException {
+ output.writeBoolean(value != null && value.booleanValue());
}
private void writeByteValue(Byte value) {
@@ -201,78 +222,49 @@ final class Marshal {
write16Bit(value == null ? 0 : value.shortValue());
}
- private void writeLongValue(Integer value) {
+ private void writeLongValue(Integer value) throws IOException {
write32Bit(value == null ? 0 : value.intValue());
}
- private void writeHyperValue(Long value) {
- try {
- output.writeLong(value == null ? 0 : value.longValue());
- } catch (IOException e) {
- throw new RuntimeException(e.toString());
- }
+ private void writeHyperValue(Long value) throws IOException {
+ output.writeLong(value == null ? 0 : value.longValue());
}
- private void writeFloatValue(Float value) {
- try {
- output.writeFloat(value == null ? 0 : value.floatValue());
- } catch (IOException e) {
- throw new RuntimeException(e.toString());
- }
+ private void writeFloatValue(Float value) throws IOException {
+ output.writeFloat(value == null ? 0 : value.floatValue());
}
- private void writeDoubleValue(Double value) {
- try {
- output.writeDouble(value == null ? 0 : value.doubleValue());
- } catch (IOException e) {
- throw new RuntimeException(e.toString());
- }
+ private void writeDoubleValue(Double value) throws IOException {
+ output.writeDouble(value == null ? 0 : value.doubleValue());
}
- private void writeCharValue(Character value) {
- try {
- output.writeChar(value == null ? 0 : value.charValue());
- } catch (IOException e) {
- throw new RuntimeException(e.toString());
- }
+ private void writeCharValue(Character value) throws IOException {
+ output.writeChar(value == null ? 0 : value.charValue());
}
- private void writeStringValue(String value) {
+ private void writeStringValue(String value) throws IOException {
if (value == null) {
writeCompressedNumber(0);
} else {
- byte[] data;
- try {
- data = value.getBytes("UTF8");
- } catch (UnsupportedEncodingException e) {
- throw new RuntimeException(e.toString());
- }
+ byte[] data = value.getBytes("UTF8");
writeCompressedNumber(data.length);
writeBytes(data);
}
}
- private void writeTypeValue(Type value) {
- try {
- writeType(
- TypeDescription.getTypeDescription(
- value == null ? Type.VOID : value));
- } catch (ClassNotFoundException e) {
- throw new RuntimeException(e.toString());
- }
+ private void writeTypeValue(Type value) throws ClassNotFoundException {
+ writeType(
+ TypeDescription.getTypeDescription(
+ value == null ? Type.VOID : value));
}
- private void writeAnyValue(Object value) {
+ private void writeAnyValue(Object value) throws ClassNotFoundException {
TypeDescription type;
if (value == null || value instanceof XInterface) {
type = TypeDescription.getTypeDescription(XInterface.class);
} else if (value instanceof Any) {
Any any = (Any) value;
- try {
- type = TypeDescription.getTypeDescription(any.getType());
- } catch (ClassNotFoundException e) {
- throw new RuntimeException(e.toString());
- }
+ type = TypeDescription.getTypeDescription(any.getType());
value = any.getObject();
} else if (value.getClass() == Object.class) {
// Avoid StackOverflowError:
@@ -285,7 +277,7 @@ final class Marshal {
writeValue(type, value);
}
- private void writeSequenceValue(TypeDescription type, Object value) {
+ private void writeSequenceValue(TypeDescription type, Object value) throws IOException {
if (value == null) {
writeCompressedNumber(0);
} else {
@@ -304,41 +296,29 @@ final class Marshal {
}
}
- private void writeEnumValue(TypeDescription type, Enum value) {
+ private void writeEnumValue(TypeDescription type, Enum value) throws IllegalAccessException, IOException, InvocationTargetException, NoSuchMethodException {
int n;
if (value == null) {
- try {
- n = ((Enum)
- (type.getZClass().getMethod("getDefault", (Class[]) null).
- invoke(null, (Object[]) null))).
- getValue();
- } catch (IllegalAccessException e) {
- throw new RuntimeException(e.toString());
- } catch (InvocationTargetException e) {
- throw new RuntimeException(e.toString());
- } catch (NoSuchMethodException e) {
- throw new RuntimeException(e.toString());
- }
+ n = ((Enum)
+ (type.getZClass().getMethod("getDefault", (Class[]) null).
+ invoke(null, (Object[]) null))).
+ getValue();
} else {
n = value.getValue();
}
write32Bit(n);
}
- private void writeStructValue(TypeDescription type, Object value) {
+ private void writeStructValue(TypeDescription type, Object value) throws IllegalAccessException {
IFieldDescription[] fields = type.getFieldDescriptions();
for (int i = 0; i < fields.length; ++i) {
- try {
- writeValue(
- (TypeDescription) fields[i].getTypeDescription(),
- value == null ? null : fields[i].getField().get(value));
- } catch (IllegalAccessException e) {
- throw new RuntimeException(e.toString());
- }
+ writeValue(
+ (TypeDescription) fields[i].getTypeDescription(),
+ value == null ? null : fields[i].getField().get(value));
}
}
- private void writeExceptionValue(TypeDescription type, Exception value) {
+ private void writeExceptionValue(TypeDescription type, Exception value) throws IllegalAccessException, IOException {
writeStringValue(value == null ? null : value.getMessage());
writeStructValue(type, value);
}
@@ -347,15 +327,11 @@ final class Marshal {
writeInterface(value, new Type(type));
}
- private void write32Bit(int value) {
- try {
- output.writeInt(value);
- } catch (IOException e) {
- throw new RuntimeException(e.toString());
- }
+ private void write32Bit(int value) throws IOException {
+ output.writeInt(value);
}
- private void writeCompressedNumber(int number) {
+ private void writeCompressedNumber(int number) throws IOException {
if (number >= 0 && number < 0xFF) {
write8Bit(number);
} else {
@@ -364,12 +340,8 @@ final class Marshal {
}
}
- private void writeBytes(byte[] data) {
- try {
- output.write(data);
- } catch (IOException e) {
- throw new RuntimeException(e.toString());
- }
+ private void writeBytes(byte[] data) throws IOException {
+ output.write(data);
}
private final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
diff --git a/jurt/com/sun/star/lib/uno/protocols/urp/Unmarshal.java b/jurt/com/sun/star/lib/uno/protocols/urp/Unmarshal.java
index b567c9e19705..48d7630dd7e2 100644
--- a/jurt/com/sun/star/lib/uno/protocols/urp/Unmarshal.java
+++ b/jurt/com/sun/star/lib/uno/protocols/urp/Unmarshal.java
@@ -17,6 +17,13 @@
*/
package com.sun.star.lib.uno.protocols.urp;
+import java.io.ByteArrayInputStream;
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.lang.reflect.Array;
+import java.lang.reflect.InvocationTargetException;
+
import com.sun.star.lib.uno.environments.remote.ThreadId;
import com.sun.star.lib.uno.typedesc.TypeDescription;
import com.sun.star.uno.Any;
@@ -26,12 +33,6 @@ import com.sun.star.uno.IFieldDescription;
import com.sun.star.uno.Type;
import com.sun.star.uno.TypeClass;
import com.sun.star.uno.XInterface;
-import java.io.ByteArrayInputStream;
-import java.io.DataInputStream;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.lang.reflect.Array;
-import java.lang.reflect.InvocationTargetException;
final class Unmarshal {
public Unmarshal(IBridge bridge, int cacheSize) {
@@ -46,7 +47,7 @@ final class Unmarshal {
try {
return input.readUnsignedByte();
} catch (IOException e) {
- throw new RuntimeException(e.toString());
+ throw new RuntimeException(e);
}
}
@@ -54,25 +55,29 @@ final class Unmarshal {
try {
return input.readUnsignedShort();
} catch (IOException e) {
- throw new RuntimeException(e.toString());
+ throw new RuntimeException(e);
}
}
public String readObjectId() {
- String id = readStringValue();
- int index = read16Bit();
- if (index == 0xFFFF) {
- if (id.length() == 0) {
- id = null;
- }
- } else {
- if (id.length() == 0) {
- id = objectIdCache[index];
+ try {
+ String id = readStringValue();
+ int index = read16Bit();
+ if (index == 0xFFFF) {
+ if (id.length() == 0) {
+ id = null;
+ }
} else {
- objectIdCache[index] = id;
+ if (id.length() == 0) {
+ id = objectIdCache[index];
+ } else {
+ objectIdCache[index] = id;
+ }
}
+ return id;
+ } catch (IOException e) {
+ throw new RuntimeException(e);
}
- return id;
}
public Object readInterface(Type type) {
@@ -81,23 +86,27 @@ final class Unmarshal {
}
public ThreadId readThreadId() {
- int len = readCompressedNumber();
- byte[] data ;
- ThreadId id = null;
- if (len != 0) {
- data = new byte[len];
- readBytes(data);
- id = new ThreadId(data);
- }
- int index = read16Bit();
- if (index != 0xFFFF) {
- if (len == 0) {
- id = threadIdCache[index];
- } else {
- threadIdCache[index] = id;
+ try {
+ int len = readCompressedNumber();
+ byte[] data ;
+ ThreadId id = null;
+ if (len != 0) {
+ data = new byte[len];
+ readBytes(data);
+ id = new ThreadId(data);
+ }
+ int index = read16Bit();
+ if (index != 0xFFFF) {
+ if (len == 0) {
+ id = threadIdCache[index];
+ } else {
+ threadIdCache[index] = id;
+ }
}
+ return id;
+ } catch (IOException e) {
+ throw new RuntimeException(e);
}
- return id;
}
public TypeDescription readType() {
@@ -112,8 +121,10 @@ final class Unmarshal {
try {
type = TypeDescription.getTypeDescription(
readStringValue());
+ } catch (IOException e) {
+ throw new RuntimeException(e);
} catch (ClassNotFoundException e) {
- throw new RuntimeException(e.toString());
+ throw new RuntimeException(e);
}
}
if (index != 0xFFFF) {
@@ -128,63 +139,67 @@ final class Unmarshal {
}
public Object readValue(TypeDescription type) {
- switch (type.getTypeClass().getValue()) {
- case TypeClass.VOID_value:
- return null;
+ try {
+ switch (type.getTypeClass().getValue()) {
+ case TypeClass.VOID_value:
+ return null;
- case TypeClass.BOOLEAN_value:
- return readBooleanValue();
+ case TypeClass.BOOLEAN_value:
+ return readBooleanValue();
- case TypeClass.BYTE_value:
- return readByteValue();
+ case TypeClass.BYTE_value:
+ return readByteValue();
- case TypeClass.SHORT_value:
- case TypeClass.UNSIGNED_SHORT_value:
- return readShortValue();
+ case TypeClass.SHORT_value:
+ case TypeClass.UNSIGNED_SHORT_value:
+ return readShortValue();
- case TypeClass.LONG_value:
- case TypeClass.UNSIGNED_LONG_value:
- return readLongValue();
+ case TypeClass.LONG_value:
+ case TypeClass.UNSIGNED_LONG_value:
+ return readLongValue();
- case TypeClass.HYPER_value:
- case TypeClass.UNSIGNED_HYPER_value:
- return readHyperValue();
+ case TypeClass.HYPER_value:
+ case TypeClass.UNSIGNED_HYPER_value:
+ return readHyperValue();
- case TypeClass.FLOAT_value:
- return readFloatValue();
+ case TypeClass.FLOAT_value:
+ return readFloatValue();
- case TypeClass.DOUBLE_value:
- return readDoubleValue();
+ case TypeClass.DOUBLE_value:
+ return readDoubleValue();
- case TypeClass.CHAR_value:
- return readCharValue();
+ case TypeClass.CHAR_value:
+ return readCharValue();
- case TypeClass.STRING_value:
- return readStringValue();
+ case TypeClass.STRING_value:
+ return readStringValue();
- case TypeClass.TYPE_value:
- return readTypeValue();
+ case TypeClass.TYPE_value:
+ return readTypeValue();
- case TypeClass.ANY_value:
- return readAnyValue();
+ case TypeClass.ANY_value:
+ return readAnyValue();
- case TypeClass.SEQUENCE_value:
- return readSequenceValue(type);
+ case TypeClass.SEQUENCE_value:
+ return readSequenceValue(type);
- case TypeClass.ENUM_value:
- return readEnumValue(type);
+ case TypeClass.ENUM_value:
+ return readEnumValue(type);
- case TypeClass.STRUCT_value:
- return readStructValue(type);
+ case TypeClass.STRUCT_value:
+ return readStructValue(type);
- case TypeClass.EXCEPTION_value:
- return readExceptionValue(type);
+ case TypeClass.EXCEPTION_value:
+ return readExceptionValue(type);
- case TypeClass.INTERFACE_value:
- return readInterfaceValue(type);
+ case TypeClass.INTERFACE_value:
+ return readInterfaceValue(type);
- default:
- throw new IllegalArgumentException("Bad type descriptor " + type);
+ default:
+ throw new IllegalArgumentException("Bad type descriptor " + type);
+ }
+ } catch (IOException e) {
+ throw new RuntimeException(e);
}
}
@@ -192,7 +207,7 @@ final class Unmarshal {
try {
return input.available() > 0;
} catch (IOException e) {
- throw new RuntimeException(e.toString());
+ throw new RuntimeException(e);
}
}
@@ -200,78 +215,46 @@ final class Unmarshal {
input = new DataInputStream(new ByteArrayInputStream(data));
}
- private Boolean readBooleanValue() {
- try {
- return input.readBoolean() ? Boolean.TRUE : Boolean.FALSE;
- } catch (IOException e) {
- throw new RuntimeException(e.toString());
- }
+ private Boolean readBooleanValue() throws IOException {
+ return input.readBoolean() ? Boolean.TRUE : Boolean.FALSE;
}
- private Byte readByteValue() {
- try {
- return Byte.valueOf(input.readByte());
- } catch (IOException e) {
- throw new RuntimeException(e.toString());
- }
+ private Byte readByteValue() throws IOException {
+ return Byte.valueOf(input.readByte());
}
- private Short readShortValue() {
- try {
- return Short.valueOf(input.readShort());
- } catch (IOException e) {
- throw new RuntimeException(e.toString());
- }
+ private Short readShortValue() throws IOException {
+ return Short.valueOf(input.readShort());
}
- private Integer readLongValue() {
- try {
- return Integer.valueOf(input.readInt());
- } catch (IOException e) {
- throw new RuntimeException(e.toString());
- }
+ private Integer readLongValue() throws IOException {
+ return Integer.valueOf(input.readInt());
}
- private Long readHyperValue() {
- try {
- return Long.valueOf(input.readLong());
- } catch (IOException e) {
- throw new RuntimeException(e.toString());
- }
+ private Long readHyperValue() throws IOException {
+ return Long.valueOf(input.readLong());
}
- private Float readFloatValue() {
- try {
- return new Float(input.readFloat());
- } catch (IOException e) {
- throw new RuntimeException(e.toString());
- }
+ private Float readFloatValue() throws IOException {
+ return new Float(input.readFloat());
}
- private Double readDoubleValue() {
- try {
- return new Double(input.readDouble());
- } catch (IOException e) {
- throw new RuntimeException(e.toString());
- }
+ private Double readDoubleValue() throws IOException {
+ return new Double(input.readDouble());
}
- private Character readCharValue() {
- try {
- return new Character(input.readChar());
- } catch (IOException e) {
- throw new RuntimeException(e.toString());
- }
+ private Character readCharValue() throws IOException {
+ return new Character(input.readChar());
}
- private String readStringValue() {
+ private String readStringValue() throws IOException {
int len = readCompressedNumber();
byte[] data = new byte[len];
readBytes(data);
try {
return new String(data, "UTF8");
} catch (UnsupportedEncodingException e) {
- throw new RuntimeException(e.toString());
+ throw new RuntimeException(e);
}
}
@@ -279,7 +262,7 @@ final class Unmarshal {
return new Type(readType());
}
- private Object readAnyValue() {
+ private Object readAnyValue() throws IOException {
TypeDescription type = readType();
switch (type.getTypeClass().getValue()) {
case TypeClass.VOID_value:
@@ -373,7 +356,7 @@ final class Unmarshal {
}
}
- private Object readSequenceValue(TypeDescription type) {
+ private Object readSequenceValue(TypeDescription type) throws IOException {
int len = readCompressedNumber();
TypeDescription ctype = (TypeDescription) type.getComponentType();
if (ctype.getTypeClass() == TypeClass.BYTE) {
@@ -391,18 +374,18 @@ final class Unmarshal {
}
}
- private Enum readEnumValue(TypeDescription type) {
+ private Enum readEnumValue(TypeDescription type) throws IOException {
try {
return (Enum)
type.getZClass().getMethod(
"fromInt", new Class[] { int.class }).
invoke(null, new Object[] { readLongValue() });
} catch (IllegalAccessException e) {
- throw new RuntimeException(e.toString());
+ throw new RuntimeException(e);
} catch (InvocationTargetException e) {
- throw new RuntimeException(e.toString());
+ throw new RuntimeException(e);
} catch (NoSuchMethodException e) {
- throw new RuntimeException(e.toString());
+ throw new RuntimeException(e);
}
}
@@ -411,28 +394,28 @@ final class Unmarshal {
try {
value = type.getZClass().newInstance();
} catch (IllegalAccessException e) {
- throw new RuntimeException(e.toString());
+ throw new RuntimeException(e);
} catch (InstantiationException e) {
- throw new RuntimeException(e.toString());
+ throw new RuntimeException(e);
}
readFields(type, value);
return value;
}
- private Exception readExceptionValue(TypeDescription type) {
+ private Exception readExceptionValue(TypeDescription type) throws IOException {
Exception value;
try {
value = (Exception)
type.getZClass().getConstructor(new Class[] { String.class }).
newInstance(new Object[] { readStringValue() });
} catch (IllegalAccessException e) {
- throw new RuntimeException(e.toString());
+ throw new RuntimeException(e);
} catch (InstantiationException e) {
- throw new RuntimeException(e.toString());
+ throw new RuntimeException(e);
} catch (InvocationTargetException e) {
- throw new RuntimeException(e.toString());
+ throw new RuntimeException(e);
} catch (NoSuchMethodException e) {
- throw new RuntimeException(e.toString());
+ throw new RuntimeException(e);
}
readFields(type, value);
return value;
@@ -442,21 +425,13 @@ final class Unmarshal {
return readInterface(new Type(type));
}
- private int readCompressedNumber() {
+ private int readCompressedNumber() throws IOException {
int number = read8Bit();
- try {
- return number < 0xFF ? number : input.readInt();
- } catch (IOException e) {
- throw new RuntimeException(e.toString());
- }
+ return number < 0xFF ? number : input.readInt();
}
- private void readBytes(byte[] data) {
- try {
- input.readFully(data);
- } catch (IOException e) {
- throw new RuntimeException(e.toString());
- }
+ private void readBytes(byte[] data) throws IOException {
+ input.readFully(data);
}
private void readFields(TypeDescription type, Object value) {
@@ -468,7 +443,7 @@ final class Unmarshal {
readValue(
(TypeDescription) fields[i].getTypeDescription()));
} catch (IllegalAccessException e) {
- throw new RuntimeException(e.toString());
+ throw new RuntimeException(e);
}
}
}
diff --git a/jurt/com/sun/star/lib/uno/protocols/urp/urp.java b/jurt/com/sun/star/lib/uno/protocols/urp/urp.java
index f60f697ead51..b527e644c5a2 100644
--- a/jurt/com/sun/star/lib/uno/protocols/urp/urp.java
+++ b/jurt/com/sun/star/lib/uno/protocols/urp/urp.java
@@ -136,7 +136,7 @@ public final class urp implements IProtocol {
monitor.wait();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
- throw new RuntimeException(e.toString());
+ throw new RuntimeException(e);
}
}
if (state == STATE_TERMINATED) {