public void decodeResponse(ClassLoader loader, Class<?> type, DataByteArrayInputStream source, AsyncCallback result) throws IOException, ClassNotFoundException, NoSuchFieldException, IllegalAccessException, NoSuchMethodException, InvocationTargetException, InstantiationException { if( source.readBoolean() ) { String className = source.readUTF(); String message = source.readUTF(); Throwable error; try { // try to build the exception... Constructor<?> ctr = loader.loadClass(className).getConstructor(new Class[]{String.class}); error = (Throwable) ctr.newInstance(message); } catch (Throwable e) { // fallback to something simple.. error = new RuntimeException(className+": "+message); } result.onFailure(error); } else { result.onSuccess(decodeProtobuf(type, source)); } }
@SuppressWarnings("unchecked") public void decodeResponse(ClassLoader loader, Class<?> type, DataByteArrayInputStream source, AsyncCallback result) throws IOException, ClassNotFoundException, NoSuchFieldException, IllegalAccessException, NoSuchMethodException, InvocationTargetException, InstantiationException { if( source.readBoolean() ) { String className = source.readUTF(); String message = source.readUTF(); Throwable error; try { // try to build the exception... Constructor<?> ctr = loader.loadClass(className).getConstructor(new Class[]{String.class}); error = (Throwable) ctr.newInstance(message); } catch (Throwable e) { // fallback to something simple.. error = new RuntimeException(className+": "+message); } result.onFailure(error); } else { result.onSuccess(decodeProtobuf(type, source)); } }