home *** CD-ROM | disk | FTP | other *** search
- package java.io;
-
- import java.lang.reflect.InvocationTargetException;
-
- public class ObjectOutputStream extends OutputStream implements ObjectOutput, ObjectStreamConstants {
- private boolean blockDataMode;
- private byte[] buf;
- private int count;
- private OutputStream out;
- private DataOutputStream dos;
- private IOException abortIOException = null;
- private HandleTable handleTable;
- private Object currentObject;
- private ObjectStreamClass currentClassDesc;
- private Stack classDescStack;
- private PutField currentPutFields;
- private Object[] writeObjectArglist = new Object[]{this};
- private static final int INITIAL_BUFFER_SIZE = 64;
- private byte[] data;
- private static final int CDATA_MAX_LEN = 1024;
- private char[] cdata;
- boolean enableReplace;
- private Object[] replaceObjects;
- private int nextReplaceOffset;
- private static final boolean REPLACEABLE = true;
- private static final boolean NOT_REPLACEABLE = false;
- private int recursionDepth = 0;
- boolean useDeprecatedExternalizableFormat = false;
- private boolean enableSubclassImplementation;
- // $FF: synthetic field
- static Class class$java$lang$String;
-
- public ObjectOutputStream(OutputStream var1) throws IOException {
- this.enableSubclassImplementation = false;
- this.out = var1;
- this.dos = new DataOutputStream(this);
- this.buf = new byte[1024];
- this.writeStreamHeader();
- this.resetStream();
- }
-
- protected ObjectOutputStream() throws IOException, SecurityException {
- SecurityManager var1 = System.getSecurityManager();
- if (var1 != null) {
- var1.checkPermission(ObjectStreamConstants.SUBCLASS_IMPLEMENTATION_PERMISSION);
- }
-
- this.enableSubclassImplementation = true;
- }
-
- protected void writeObjectOverride(Object var1) throws IOException {
- }
-
- public void useProtocolVersion(int var1) throws IOException {
- if (this.handleTable.size() != 0) {
- throw new IllegalStateException("Must call useProtocolVersion before writing any objects to the stream");
- } else {
- switch (var1) {
- case 1:
- this.useDeprecatedExternalizableFormat = true;
- case 2:
- return;
- default:
- throw new IllegalArgumentException("unknown version:" + var1);
- }
- }
- }
-
- public final void writeObject(Object var1) throws IOException {
- if (this.enableSubclassImplementation) {
- this.writeObjectOverride(var1);
- } else {
- Object var2 = this.currentObject;
- ObjectStreamClass var3 = this.currentClassDesc;
- boolean var4 = this.setBlockData(false);
- ++this.recursionDepth;
-
- try {
- if (this.serializeNullAndRepeat(var1, true)) {
- return;
- }
-
- if (this.checkSpecialClasses(var1)) {
- return;
- }
-
- Class var17 = var1.getClass();
- Class var6 = null;
- Object var7 = var1;
- this.currentClassDesc = ObjectStreamClass.lookupInternal(var17);
-
- while(this.currentClassDesc != null && this.currentClassDesc.isReplaceable() && var17 != var6) {
- var7 = ObjectStreamClass.invokeMethod(this.currentClassDesc.writeReplaceMethod, var7, (Object[])null);
- var6 = var17;
- if (var7 != null) {
- var17 = var7.getClass();
- this.currentClassDesc = ObjectStreamClass.lookupInternal(var17);
- } else {
- var17 = null;
- this.currentClassDesc = null;
- }
- }
-
- if (this.enableReplace) {
- var7 = this.replaceObject(var7);
- this.currentClassDesc = var7 != null ? ObjectStreamClass.lookupInternal(var7.getClass()) : null;
- }
-
- if (var1 != var7) {
- if (var7 != null && !(var7 instanceof Serializable)) {
- String var8 = var7.getClass().getName();
- throw new NotSerializableException(var8);
- }
-
- if (this.serializeNullAndRepeat(var7, true)) {
- this.addReplacement(var1, var7);
- return;
- }
-
- this.addReplacement(var1, var7);
- if (this.checkSpecialClasses(var7)) {
- return;
- }
-
- var1 = var7;
- }
-
- if (this.checkSubstitutableSpecialClasses(var1, this.currentClassDesc.forClass())) {
- return;
- }
-
- this.outputObject(var1);
- } catch (IOException var15) {
- IOException var5 = var15;
- if (this.abortIOException == null) {
- try {
- this.setBlockData(false);
- this.writeCode(123);
- this.resetStream();
- this.setBlockData(false);
- this.currentClassDesc = ObjectStreamClass.lookupInternal(var5.getClass());
- this.outputObject(var5);
- this.resetStream();
- this.abortIOException = var5;
- } catch (IOException var14) {
- this.abortIOException = new StreamCorruptedException(((Throwable)var14).getMessage());
- }
- }
- } finally {
- --this.recursionDepth;
- this.currentObject = var2;
- this.currentClassDesc = var3;
- this.setBlockData(var4);
- }
-
- IOException var18 = this.abortIOException;
- if (this.recursionDepth == 0) {
- this.abortIOException = null;
- }
-
- if (var18 != null) {
- throw var18;
- }
- }
- }
-
- private boolean checkSpecialClasses(Object var1) throws IOException {
- if (var1 instanceof Class) {
- this.outputClass((Class)var1);
- return true;
- } else if (var1 instanceof ObjectStreamClass) {
- this.outputClassDescriptor((ObjectStreamClass)var1);
- return true;
- } else {
- return false;
- }
- }
-
- private boolean checkSubstitutableSpecialClasses(Object var1, Class var2) throws IOException {
- if (var2 == (class$java$lang$String == null ? (class$java$lang$String = class$("java.lang.String")) : class$java$lang$String)) {
- this.outputString((String)var1);
- return true;
- } else if (var2.isArray()) {
- this.outputArray(var1);
- return true;
- } else {
- return false;
- }
- }
-
- public void defaultWriteObject() throws IOException {
- if (this.currentObject != null && this.currentClassDesc != null) {
- ObjectStreamField[] var1 = this.currentClassDesc.getFieldsNoCopy();
- if (var1.length > 0) {
- boolean var2 = this.setBlockData(false);
- this.outputClassFields(this.currentObject, this.currentClassDesc.forClass(), var1);
- this.setBlockData(var2);
- }
-
- } else {
- throw new NotActiveException("defaultWriteObject");
- }
- }
-
- public PutField putFields() throws IOException {
- if (this.currentObject != null && this.currentClassDesc != null) {
- this.currentPutFields = new PutFieldImpl(this.currentClassDesc);
- return this.currentPutFields;
- } else {
- throw new NotActiveException("putFields");
- }
- }
-
- public void writeFields() throws IOException {
- if (this.currentObject != null && this.currentClassDesc != null && this.currentPutFields != null) {
- boolean var1 = this.setBlockData(false);
- this.currentPutFields.write(this);
- this.setBlockData(var1);
- } else {
- throw new NotActiveException("writeFields");
- }
- }
-
- public void reset() throws IOException {
- if (this.currentObject == null && this.currentClassDesc == null) {
- this.setBlockData(false);
- this.writeCode(121);
- this.resetStream();
- this.abortIOException = null;
- } else {
- throw new IOException("Illegal call to reset");
- }
- }
-
- private void resetStream() throws IOException {
- if (this.handleTable == null) {
- this.handleTable = new HandleTable();
- } else {
- this.handleTable.clear();
- }
-
- if (this.classDescStack == null) {
- this.classDescStack = new Stack((1)null);
- } else {
- this.classDescStack.setSize(0);
- }
-
- for(int var1 = 0; var1 < this.nextReplaceOffset; ++var1) {
- this.replaceObjects[var1] = null;
- }
-
- this.nextReplaceOffset = 0;
- this.setBlockData(true);
- }
-
- protected void annotateClass(Class var1) throws IOException {
- }
-
- protected void annotateProxyClass(Class var1) throws IOException {
- }
-
- protected Object replaceObject(Object var1) throws IOException {
- return var1;
- }
-
- protected boolean enableReplaceObject(boolean var1) throws SecurityException {
- boolean var2 = this.enableReplace;
- if (var1) {
- SecurityManager var3 = System.getSecurityManager();
- if (var3 != null) {
- var3.checkPermission(ObjectStreamConstants.SUBSTITUTION_PERMISSION);
- }
-
- this.enableReplace = true;
- } else {
- this.enableReplace = false;
- }
-
- return var2;
- }
-
- protected void writeStreamHeader() throws IOException {
- this.writeShort(-21267);
- this.writeShort(5);
- }
-
- private void outputString(String var1) throws IOException {
- int var4 = var1.length();
- this.handleTable.assignWireOffset(var1);
- if (this.cdata != null && this.cdata.length >= var4) {
- var1.getChars(0, var4, this.cdata, 0);
- } else {
- this.cdata = var1.toCharArray();
- }
-
- long var2 = getUTFLength(this.cdata, var4);
- if (var2 <= 65535L) {
- this.writeCode(116);
- this.writeShort((int)var2);
- } else {
- this.writeCode(124);
- this.writeLong(var2);
- }
-
- this.writeUTFBody(this.cdata, var4);
- if (var4 > 1024) {
- this.cdata = null;
- }
-
- }
-
- private static long getUTFLength(char[] var0, int var1) {
- long var2 = 0L;
-
- for(int var4 = 0; var4 < var1; ++var4) {
- char var5 = var0[var4];
- if (var5 >= 1 && var5 <= 127) {
- ++var2;
- } else if (var5 > 2047) {
- var2 += 3L;
- } else {
- var2 += 2L;
- }
- }
-
- return var2;
- }
-
- private void writeUTFBody(char[] var1, int var2) throws IOException {
- int var4 = this.buf.length - 2;
-
- for(int var6 = 0; var6 < var2; ++var6) {
- char var5 = var1[var6];
- if (this.count >= var4) {
- if (this.blockDataMode) {
- if (var5 >= 1 && var5 <= 127) {
- this.write(var5);
- } else if (var5 > 2047) {
- this.write(224 | var5 >> 12 & 15);
- this.write(128 | var5 >> 6 & 63);
- this.write(128 | var5 >> 0 & 63);
- } else {
- this.write(192 | var5 >> 6 & 31);
- this.write(128 | var5 >> 0 & 63);
- }
- continue;
- }
-
- this.drain();
- }
-
- if (var5 >= 1 && var5 <= 127) {
- this.buf[this.count++] = (byte)var5;
- } else if (var5 > 2047) {
- this.buf[this.count++] = (byte)(224 | var5 >> 12 & 15);
- this.buf[this.count++] = (byte)(128 | var5 >> 6 & 63);
- this.buf[this.count++] = (byte)(128 | var5 >> 0 & 63);
- } else {
- this.buf[this.count++] = (byte)(192 | var5 >> 6 & 31);
- this.buf[this.count++] = (byte)(128 | var5 >> 0 & 63);
- }
- }
-
- }
-
- private void outputClass(Class var1) throws IOException {
- this.writeCode(118);
- ObjectStreamClass var2 = ObjectStreamClass.lookupInternal(var1);
- if (var2 == null) {
- throw new NotSerializableException(var1.getName());
- } else {
- this.outputClassDescriptor(var2);
- this.handleTable.assignWireOffset(var1);
- }
- }
-
- private void writeClassDescriptor0(ObjectStreamClass var1) throws IOException {
- this.writeUTF(var1.getName());
- this.writeLong(var1.getSerialVersionUID());
- var1.write(this);
- }
-
- protected void writeClassDescriptor(ObjectStreamClass var1) throws IOException {
- this.writeClassDescriptor0(var1);
- }
-
- private void outputClassDescriptor(ObjectStreamClass var1) throws IOException {
- if (!this.serializeNullAndRepeat(var1, false)) {
- Class var2 = var1.forClass();
- if (!var1.forProxyClass) {
- this.writeCode(114);
- this.handleTable.assignWireOffset(var1);
- if (this.useDeprecatedExternalizableFormat) {
- this.writeClassDescriptor0(var1);
- } else {
- this.writeClassDescriptor(var1);
- }
-
- boolean var3 = this.setBlockData(true);
- this.annotateClass(var2);
- this.setBlockData(var3);
- this.writeCode(120);
- ObjectStreamClass var4 = var1.getSuperclass();
- this.outputClassDescriptor(var4);
- } else {
- this.writeCode(125);
- this.handleTable.assignWireOffset(var1);
- Class[] var6 = var2.getInterfaces();
- this.writeInt(var6.length);
-
- for(int var7 = 0; var7 < var6.length; ++var7) {
- this.writeUTF(var6[var7].getName());
- }
-
- boolean var5 = this.setBlockData(true);
- this.annotateProxyClass(var2);
- this.setBlockData(var5);
- this.writeCode(120);
- this.outputClassDescriptor(var1.getSuperclass());
- }
-
- }
- }
-
- private void outputArray(Object var1) throws IOException {
- Class var2 = this.currentClassDesc.forClass();
- this.writeCode(117);
- this.outputClassDescriptor(this.currentClassDesc);
- this.handleTable.assignWireOffset(var1);
- Class var6 = var2.getComponentType();
- if (var6.isPrimitive()) {
- if (var6 == Integer.TYPE) {
- int[] var7 = (int[])var1;
- int var4 = var7.length;
- int var5 = this.buf.length - 4;
- this.writeInt(var4);
-
- for(int var3 = 0; var3 < var4; ++var3) {
- if (this.count > var5) {
- this.drain();
- }
-
- int var8 = var7[var3];
- this.buf[this.count++] = (byte)(var8 >>> 24);
- this.buf[this.count++] = (byte)(var8 >>> 16);
- this.buf[this.count++] = (byte)(var8 >>> 8);
- this.buf[this.count++] = (byte)(var8 >>> 0);
- }
- } else if (var6 == Byte.TYPE) {
- byte[] var28 = (byte[])var1;
- int var16 = var28.length;
- this.writeInt(var16);
- this.writeInternal(var28, 0, var16, true);
- } else if (var6 == Long.TYPE) {
- long[] var29 = (long[])var1;
- int var17 = var29.length;
- int var24 = this.buf.length - 8;
- this.writeInt(var17);
-
- for(int var11 = 0; var11 < var17; ++var11) {
- if (this.count > var24) {
- this.drain();
- }
-
- long var36 = var29[var11];
- this.buf[this.count++] = (byte)((int)(var36 >>> 56));
- this.buf[this.count++] = (byte)((int)(var36 >>> 48));
- this.buf[this.count++] = (byte)((int)(var36 >>> 40));
- this.buf[this.count++] = (byte)((int)(var36 >>> 32));
- this.buf[this.count++] = (byte)((int)(var36 >>> 24));
- this.buf[this.count++] = (byte)((int)(var36 >>> 16));
- this.buf[this.count++] = (byte)((int)(var36 >>> 8));
- this.buf[this.count++] = (byte)((int)(var36 >>> 0));
- }
- } else if (var6 == Float.TYPE) {
- float[] var30 = (float[])var1;
- int var18 = var30.length;
- this.writeInt(var18);
- int var37 = 0;
-
- while(var18 > 0) {
- int var9 = this.buf.length - this.count >> 2;
- if (var9 > 0) {
- int var10 = var18 < var9 ? var18 : var9;
- floatsToBytes(var30, var37, this.buf, this.count, var10);
- var37 += var10;
- var18 -= var10;
- this.count += var10 << 2;
- } else {
- this.drain();
- }
- }
- } else if (var6 == Double.TYPE) {
- double[] var31 = (double[])var1;
- int var19 = var31.length;
- this.writeInt(var19);
- int var38 = 0;
-
- while(var19 > 0) {
- int var41 = this.buf.length - this.count >> 3;
- if (var41 > 0) {
- int var42 = var19 < var41 ? var19 : var41;
- doublesToBytes(var31, var38, this.buf, this.count, var42);
- var38 += var42;
- var19 -= var42;
- this.count += var42 << 3;
- } else {
- this.drain();
- }
- }
- } else if (var6 == Short.TYPE) {
- short[] var32 = (short[])var1;
- int var20 = var32.length;
- int var25 = this.buf.length - 2;
- this.writeInt(var20);
-
- for(int var12 = 0; var12 < var20; ++var12) {
- if (this.count > var25) {
- this.drain();
- }
-
- short var39 = var32[var12];
- this.buf[this.count++] = (byte)(var39 >>> 8);
- this.buf[this.count++] = (byte)(var39 >>> 0);
- }
- } else if (var6 == Character.TYPE) {
- char[] var33 = (char[])var1;
- int var21 = var33.length;
- int var26 = this.buf.length - 2;
- this.writeInt(var21);
-
- for(int var13 = 0; var13 < var21; ++var13) {
- if (this.count > var26) {
- this.drain();
- }
-
- char var40 = var33[var13];
- this.buf[this.count++] = (byte)(var40 >>> 8);
- this.buf[this.count++] = (byte)(var40 >>> 0);
- }
- } else {
- if (var6 != Boolean.TYPE) {
- throw new InvalidClassException(var2.getName());
- }
-
- boolean[] var34 = (boolean[])var1;
- int var22 = var34.length;
- int var27 = this.buf.length - 1;
- this.writeInt(var22);
-
- for(int var14 = 0; var14 < var22; ++var14) {
- if (this.count > var27) {
- this.drain();
- }
-
- this.buf[this.count++] = (byte)(var34[var14] ? 1 : 0);
- }
- }
- } else {
- Object[] var35 = var1;
- int var23 = var35.length;
- this.writeInt(var23);
-
- for(int var15 = 0; var15 < var23; ++var15) {
- this.writeObject(var35[var15]);
- }
- }
-
- }
-
- private static native void floatsToBytes(float[] var0, int var1, byte[] var2, int var3, int var4);
-
- private static native void doublesToBytes(double[] var0, int var1, byte[] var2, int var3, int var4);
-
- void writeTypeString(String var1) throws IOException {
- int var2 = this.handleTable.findWireOffset(var1);
- if (var2 >= 0) {
- this.writeCode(113);
- this.writeInt(var2 + 8257536);
- } else {
- this.handleTable.assignWireOffset(var1);
- this.writeCode(116);
- this.writeUTF(var1);
- }
-
- }
-
- private void outputObject(Object var1) throws IOException {
- this.currentObject = var1;
- if (this.currentClassDesc.isNonSerializable()) {
- throw new NotSerializableException(this.currentClassDesc.getName());
- } else {
- this.writeCode(115);
- this.outputClassDescriptor(this.currentClassDesc);
- this.handleTable.assignWireOffset(var1);
- if (this.currentClassDesc.isExternalizable()) {
- Externalizable var2 = (Externalizable)var1;
- if (this.useDeprecatedExternalizableFormat) {
- var2.writeExternal(this);
- } else {
- this.setBlockData(true);
-
- try {
- var2.writeExternal(this);
- } finally {
- this.setBlockData(false);
- this.writeCode(120);
- }
- }
- } else {
- int var13 = this.classDescStack.size();
-
- try {
- ObjectStreamClass var3;
- while((var3 = this.currentClassDesc.getSuperclass()) != null) {
- this.classDescStack.push(this.currentClassDesc);
- this.currentClassDesc = var3;
- }
-
- do {
- if (this.currentClassDesc.hasWriteObject()) {
- this.setBlockData(true);
- this.invokeObjectWriter(var1);
- this.setBlockData(false);
- this.writeCode(120);
- } else {
- this.defaultWriteObject();
- }
- } while(this.classDescStack.size() > var13 && (this.currentClassDesc = (ObjectStreamClass)this.classDescStack.pop()) != null);
- } finally {
- this.classDescStack.setSize(var13);
- }
- }
-
- }
- }
-
- private Object lookupReplace(Object var1) {
- for(int var2 = 0; var2 < this.nextReplaceOffset; var2 += 2) {
- if (this.replaceObjects[var2] == var1) {
- return this.replaceObjects[var2 + 1];
- }
- }
-
- return var1;
- }
-
- private boolean serializeNullAndRepeat(Object var1, boolean var2) throws IOException {
- if (var1 == null) {
- this.writeCode(112);
- return true;
- } else {
- if (var2 && this.replaceObjects != null) {
- var1 = this.lookupReplace(var1);
- }
-
- int var3 = this.handleTable.findWireOffset(var1);
- if (var3 >= 0) {
- this.writeCode(113);
- this.writeInt(var3 + 8257536);
- return true;
- } else {
- return false;
- }
- }
- }
-
- private void addReplacement(Object var1, Object var2) {
- if (this.replaceObjects == null) {
- this.replaceObjects = new Object[10];
- }
-
- if (this.nextReplaceOffset == this.replaceObjects.length) {
- Object[] var3 = this.replaceObjects;
- this.replaceObjects = new Object[2 + this.nextReplaceOffset * 2];
- System.arraycopy(var3, 0, this.replaceObjects, 0, this.nextReplaceOffset);
- }
-
- this.replaceObjects[this.nextReplaceOffset++] = var1;
- this.replaceObjects[this.nextReplaceOffset++] = var2;
- }
-
- private void writeCode(int var1) throws IOException {
- this.writeByte(var1);
- }
-
- public void write(int var1) throws IOException {
- if (this.count >= this.buf.length) {
- this.drain();
- }
-
- this.buf[this.count++] = (byte)var1;
- }
-
- public void write(byte[] var1) throws IOException {
- this.write(var1, 0, var1.length);
- }
-
- private void writeInternal(byte[] var1, int var2, int var3, boolean var4) throws IOException {
- if (var3 >= 0 && var2 >= 0 && var2 + var3 <= var1.length) {
- if (var3 != 0) {
- if (this.blockDataMode) {
- this.writeCanonical(var1, var2, var3);
- } else {
- int var5 = this.buf.length - this.count;
- if (var3 <= var5) {
- System.arraycopy(var1, var2, this.buf, this.count, var3);
- this.count += var3;
- } else if (var4) {
- this.bufferedWrite(var1, var2, var3);
- } else {
- this.drain();
- this.out.write(var1, var2, var3);
- }
- }
-
- }
- } else {
- throw new IndexOutOfBoundsException();
- }
- }
-
- public void write(byte[] var1, int var2, int var3) throws IOException {
- this.writeInternal(var1, var2, var3, false);
- }
-
- private void bufferedWrite(byte[] var1, int var2, int var3) throws IOException {
- int var4 = this.buf.length - this.count;
- int var5 = var3;
- if (var3 > var4) {
- System.arraycopy(var1, var2, this.buf, this.count, var4);
- var2 += var4;
- var5 = var3 - var4;
- this.out.write(this.buf, 0, this.buf.length);
-
- for(this.count = 0; var5 >= this.buf.length; var5 -= this.buf.length) {
- System.arraycopy(var1, var2, this.buf, 0, this.buf.length);
- this.out.write(this.buf, 0, this.buf.length);
- var2 += this.buf.length;
- }
- }
-
- if (var5 != 0) {
- System.arraycopy(var1, var2, this.buf, this.count, var5);
- this.count += var5;
- }
-
- }
-
- public void flush() throws IOException {
- this.drain();
- this.out.flush();
- }
-
- protected void drain() throws IOException {
- if (this.count != 0) {
- if (this.blockDataMode) {
- this.writeBlockDataHeader(this.count);
- }
-
- this.out.write(this.buf, 0, this.count);
- this.count = 0;
- }
- }
-
- public void close() throws IOException {
- this.flush();
- this.out.close();
- }
-
- private boolean setBlockData(boolean var1) throws IOException {
- if (this.blockDataMode == var1) {
- return var1;
- } else {
- this.drain();
- this.blockDataMode = var1;
- return !var1;
- }
- }
-
- private void writeBlockDataHeader(int var1) throws IOException {
- if (var1 <= 255) {
- this.out.write(119);
- this.out.write((byte)var1);
- } else {
- this.out.write(122);
- this.out.write((byte)(var1 >> 24 & 255));
- this.out.write((byte)(var1 >> 16 & 255));
- this.out.write((byte)(var1 >> 8 & 255));
- this.out.write((byte)(var1 & 255));
- }
-
- }
-
- private void writeCanonical(byte[] var1, int var2, int var3) throws IOException {
- int var4 = this.buf.length - this.count;
- int var5 = var3;
- if (var3 > var4) {
- this.writeBlockDataHeader(this.buf.length);
- this.out.write(this.buf, 0, this.count);
- this.out.write(var1, var2, var4);
- this.count = 0;
- var2 += var4;
-
- for(var5 = var3 - var4; var5 >= this.buf.length; var5 -= this.buf.length) {
- if (this.blockDataMode) {
- this.writeBlockDataHeader(this.buf.length);
- }
-
- this.out.write(var1, var2, this.buf.length);
- var2 += this.buf.length;
- }
- }
-
- if (var5 != 0) {
- System.arraycopy(var1, var2, this.buf, this.count, var5);
- this.count += var5;
- }
-
- }
-
- public void writeBoolean(boolean var1) throws IOException {
- if (this.count >= this.buf.length) {
- this.dos.writeBoolean(var1);
- } else {
- this.buf[this.count++] = (byte)(var1 ? 1 : 0);
- }
- }
-
- public void writeByte(int var1) throws IOException {
- if (this.count >= this.buf.length) {
- this.dos.writeByte(var1);
- } else {
- this.buf[this.count++] = (byte)var1;
- }
- }
-
- public void writeShort(int var1) throws IOException {
- if (this.count + 2 > this.buf.length) {
- this.dos.writeShort(var1);
- } else {
- this.buf[this.count++] = (byte)(var1 >>> 8);
- this.buf[this.count++] = (byte)(var1 >>> 0);
- }
- }
-
- public void writeChar(int var1) throws IOException {
- if (this.count + 2 > this.buf.length) {
- this.dos.writeChar(var1);
- } else {
- this.buf[this.count++] = (byte)(var1 >>> 8);
- this.buf[this.count++] = (byte)(var1 >>> 0);
- }
- }
-
- public void writeInt(int var1) throws IOException {
- if (this.count + 4 > this.buf.length) {
- this.dos.writeInt(var1);
- } else {
- this.buf[this.count++] = (byte)(var1 >>> 24);
- this.buf[this.count++] = (byte)(var1 >>> 16);
- this.buf[this.count++] = (byte)(var1 >>> 8);
- this.buf[this.count++] = (byte)(var1 >>> 0);
- }
- }
-
- public void writeLong(long var1) throws IOException {
- if (this.count + 8 > this.buf.length) {
- this.dos.writeLong(var1);
- } else {
- this.buf[this.count++] = (byte)((int)(var1 >>> 56));
- this.buf[this.count++] = (byte)((int)(var1 >>> 48));
- this.buf[this.count++] = (byte)((int)(var1 >>> 40));
- this.buf[this.count++] = (byte)((int)(var1 >>> 32));
- this.buf[this.count++] = (byte)((int)(var1 >>> 24));
- this.buf[this.count++] = (byte)((int)(var1 >>> 16));
- this.buf[this.count++] = (byte)((int)(var1 >>> 8));
- this.buf[this.count++] = (byte)((int)(var1 >>> 0));
- }
- }
-
- public void writeFloat(float var1) throws IOException {
- int var2 = Float.floatToIntBits(var1);
- if (this.count + 4 > this.buf.length) {
- this.dos.writeFloat(var1);
- } else {
- this.buf[this.count++] = (byte)(var2 >>> 24);
- this.buf[this.count++] = (byte)(var2 >>> 16);
- this.buf[this.count++] = (byte)(var2 >>> 8);
- this.buf[this.count++] = (byte)(var2 >>> 0);
- }
- }
-
- public void writeDouble(double var1) throws IOException {
- long var3 = Double.doubleToLongBits(var1);
- if (this.count + 8 > this.buf.length) {
- this.dos.writeDouble(var1);
- } else {
- this.buf[this.count++] = (byte)((int)(var3 >>> 56));
- this.buf[this.count++] = (byte)((int)(var3 >>> 48));
- this.buf[this.count++] = (byte)((int)(var3 >>> 40));
- this.buf[this.count++] = (byte)((int)(var3 >>> 32));
- this.buf[this.count++] = (byte)((int)(var3 >>> 24));
- this.buf[this.count++] = (byte)((int)(var3 >>> 16));
- this.buf[this.count++] = (byte)((int)(var3 >>> 8));
- this.buf[this.count++] = (byte)((int)(var3 >>> 0));
- }
- }
-
- public void writeBytes(String var1) throws IOException {
- char[] var2 = var1.toCharArray();
- int var3 = var2.length;
- int var4 = this.buf.length;
-
- for(int var5 = 0; var5 < var3; ++var5) {
- if (this.count >= var4) {
- this.drain();
- }
-
- this.buf[this.count++] = (byte)var2[var5];
- }
-
- }
-
- public void writeChars(String var1) throws IOException {
- char[] var2 = var1.toCharArray();
- int var3 = var2.length;
- int var4 = this.buf.length - 2;
-
- for(int var6 = 0; var6 < var3; ++var6) {
- char var5 = var2[var6];
- if (this.count > var4) {
- this.dos.writeChar(var5);
- } else {
- this.buf[this.count++] = (byte)(var5 >>> 8);
- this.buf[this.count++] = (byte)(var5 >>> 0);
- }
- }
-
- }
-
- public void writeUTF(String var1) throws IOException {
- int var4 = var1.length();
- if (this.cdata != null && this.cdata.length >= var4) {
- var1.getChars(0, var4, this.cdata, 0);
- } else {
- this.cdata = var1.toCharArray();
- }
-
- long var2 = getUTFLength(this.cdata, var4);
- if (var2 > 65535L) {
- throw new UTFDataFormatException();
- } else {
- this.writeShort((int)var2);
- this.writeUTFBody(this.cdata, var4);
- if (var4 > 1024) {
- this.cdata = null;
- }
-
- }
- }
-
- private void outputClassFields(Object var1, Class var2, ObjectStreamField[] var3) throws IOException, InvalidClassException {
- int var4 = this.currentClassDesc.numPrimBytes;
- if (var4 > 0) {
- if (this.data == null) {
- this.data = new byte[Math.max(var4, 64)];
- } else if (this.data.length < var4) {
- this.data = new byte[var4];
- }
-
- getPrimitiveFieldValues(var1, this.currentClassDesc.primFieldIDs, this.currentClassDesc.primFieldTypecodes, this.data);
- this.writeInternal(this.data, 0, var4, false);
- }
-
- int var5 = var3.length - this.currentClassDesc.numObjFields;
- long[] var6 = this.currentClassDesc.objFieldIDs;
-
- for(int var7 = 0; var7 < this.currentClassDesc.numObjFields; ++var7) {
- Object var8;
- try {
- var8 = getObjectFieldValue(var1, var6[var7]);
- } catch (Exception var10) {
- throw new InvalidClassException(var2.getName(), "Invalid field " + var3[var5 + var7].getName());
- }
-
- this.writeObject(var8);
- }
-
- }
-
- private static native void getPrimitiveFieldValues(Object var0, long[] var1, char[] var2, byte[] var3);
-
- private static native Object getObjectFieldValue(Object var0, long var1);
-
- private void invokeObjectWriter(Object var1) throws IOException {
- try {
- this.currentClassDesc.writeObjectMethod.invoke(var1, this.writeObjectArglist);
- } catch (InvocationTargetException var4) {
- Throwable var3 = var4.getTargetException();
- if (var3 instanceof IOException) {
- throw (IOException)var3;
- } else if (var3 instanceof RuntimeException) {
- throw (RuntimeException)var3;
- } else if (var3 instanceof Error) {
- throw (Error)var3;
- } else {
- throw new Error("internal error");
- }
- } catch (IllegalAccessException var5) {
- throw new InternalError("Unable to access writeObject method");
- }
- }
-
- // $FF: synthetic method
- static Class class$(String var0) {
- try {
- return Class.forName(var0);
- } catch (ClassNotFoundException var2) {
- throw new NoClassDefFoundError(((Throwable)var2).getMessage());
- }
- }
- }
-