Java Code Examples for java.io.ObjectOutputStream.writeByte()

The following are Jave code examples for showing how to use writeByte() of the java.io.ObjectOutputStream class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: jsf-sdk   File: JavaEncoder.java   View Source Code Vote up 6 votes
private void encodeResponse(ResponseMessage res, ObjectOutputStream out) throws IOException{
	if(res.isHeartBeat()){
           out.writeObject(null);
       } else {
           // encode response data or error message.
           Throwable th = res.getException();
           if (th == null) {
               Object ret = res.getResponse();
               if (ret == null) {
                   out.writeByte(DubboAdapter.RESPONSE_NULL_VALUE);
               } else {
                   out.writeByte(DubboAdapter.RESPONSE_VALUE);
                   writeObject(ret, out);
               }
           } else {
               out.writeByte(DubboAdapter.RESPONSE_WITH_EXCEPTION);
               writeObject(th, out);
           }
       }
}
 
Example 2
Project: jdk8u-jdk   File: Bytes.java   View Source Code Vote up 6 votes
/**
 * Run benchmark for given number of batches, with given number of cycles
 * for each batch.
 */
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
            StreamBuffer sbuf, int nbatches, int ncycles)
    throws Exception
{
    for (int i = 0; i < nbatches; i++) {
        sbuf.reset();
        for (int j = 0; j < ncycles; j++) {
            oout.writeByte(0);
        }
        oout.flush();
        for (int j = 0; j < ncycles; j++) {
            oin.readByte();
        }
    }
}
 
Example 3
Project: openjdk-jdk10   File: Bytes.java   View Source Code Vote up 6 votes
/**
 * Run benchmark for given number of batches, with given number of cycles
 * for each batch.
 */
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
            StreamBuffer sbuf, int nbatches, int ncycles)
    throws Exception
{
    for (int i = 0; i < nbatches; i++) {
        sbuf.reset();
        for (int j = 0; j < ncycles; j++) {
            oout.writeByte(0);
        }
        oout.flush();
        for (int j = 0; j < ncycles; j++) {
            oin.readByte();
        }
    }
}
 
Example 4
Project: graphflow   File: EdgeStore.java   View Source Code Vote up 5 votes
@Override
public void serializeMainFile(ObjectOutputStream objectOutputStream) throws IOException {
    objectOutputStream.writeInt(data.length);
    objectOutputStream.writeLong(nextIDNeverYetAssigned);
    objectOutputStream.writeByte(nextBucketOffset);
    objectOutputStream.writeInt(nextBucketId);
    objectOutputStream.writeInt(nextPartitionId);
    objectOutputStream.writeInt(recycledIdsSize);
    objectOutputStream.writeObject(recycledIds);
}
 
Example 5
Project: jsf-sdk   File: JavaEncoder.java   View Source Code Vote up 5 votes
private void writeObject(Object obj, ObjectOutputStream oos) throws IOException {
	if( obj == null ) {
		oos.writeByte(0);
	} else {
		oos.writeByte(1);
		oos.writeObject(obj);
	}
}
 
Example 6
Project: jdk8u-jdk   File: CustomObjTrees.java   View Source Code Vote up 5 votes
private void writeObject(ObjectOutputStream out) throws IOException {
    out.writeBoolean(z);
    out.writeByte(b);
    out.writeChar(c);
    out.writeShort(s);
    out.writeInt(i);
    out.writeFloat(f);
    out.writeLong(j);
    out.writeDouble(d);
    out.writeObject(str);
    out.writeObject(parent);
    out.writeObject(left);
    out.writeObject(right);
}
 
Example 7
Project: openjdk-jdk10   File: CustomObjTrees.java   View Source Code Vote up 5 votes
private void writeObject(ObjectOutputStream out) throws IOException {
    out.writeBoolean(z);
    out.writeByte(b);
    out.writeChar(c);
    out.writeShort(s);
    out.writeInt(i);
    out.writeFloat(f);
    out.writeLong(j);
    out.writeDouble(d);
    out.writeObject(str);
    out.writeObject(parent);
    out.writeObject(left);
    out.writeObject(right);
}
 
Example 8
Project: incubator-netbeans   File: MonitoredNumbersResponse.java   View Source Code Vote up 4 votes
void writeObject(ObjectOutputStream out) throws IOException {
    out.writeInt(mode);
    for (int i = 0; i < generalNumbers.length; i++) {
        out.writeLong(generalNumbers[i]);
    }

    if (mode == CommonConstants.MODE_THREADS_SAMPLING) {
        out.writeInt(nThreads);
        out.writeInt(nThreadStates);
        for (int i = 0; i < nThreads; i++) {
            out.writeInt(threadIds[i]);
        }
        for (int i = 0; i < nThreadStates; i++) {
            out.writeLong(stateTimestamps[i]);
        }
        int len = nThreads * nThreadStates;
        out.write(threadStates, 0, len);
    } else if (mode == CommonConstants.MODE_THREADS_EXACT) {
        out.writeInt(exactThreadStates.length);
        for (int i = 0; i < exactThreadIds.length; i++) {
            out.writeInt(exactThreadIds[i]);
            out.writeByte(exactThreadStates[i]);
            out.writeLong(exactTimeStamps[i]);
        }
    }

    if (nNewThreads == 0) {
        out.writeInt(0);
    } else {
        out.writeInt(nNewThreads);

        for (int i = 0; i < nNewThreads; i++) {
            out.writeInt(newThreadIds[i]);
            out.writeUTF(newThreadNames[i]);
            out.writeUTF(newThreadClassNames[i]);
        }
    }

    out.writeInt(gcStarts.length);

    for (int i = 0; i < gcStarts.length; i++) {
        out.writeLong(gcStarts[i]);
    }

    out.writeInt(gcFinishs.length);

    for (int i = 0; i < gcFinishs.length; i++) {
        out.writeLong(gcFinishs[i]);
    }

    out.writeInt(serverState);
    out.writeInt(serverProgress);
}
 
Example 9
Project: APacheSynapseSimplePOC   File: JRMPListener.java   View Source Code Vote up 4 votes
private void doCall ( DataInputStream in, DataOutputStream out, Object payload ) throws Exception {
    ObjectInputStream ois = new ObjectInputStream(in) {

        @Override
        protected Class<?> resolveClass ( ObjectStreamClass desc ) throws IOException, ClassNotFoundException {
            if ( "[Ljava.rmi.server.ObjID;".equals(desc.getName())) {
                return ObjID[].class;
            } else if ("java.rmi.server.ObjID".equals(desc.getName())) {
                return ObjID.class;
            } else if ( "java.rmi.server.UID".equals(desc.getName())) {
                return UID.class;
            }
            throw new IOException("Not allowed to read object");
        }
    };

    ObjID read;
    try {
        read = ObjID.read(ois);
    }
    catch ( java.io.IOException e ) {
        throw new MarshalException("unable to read objID", e);
    }


    if ( read.hashCode() == 2 ) {
        ois.readInt(); // method
        ois.readLong(); // hash
        System.err.println("Is DGC call for " + Arrays.toString((ObjID[])ois.readObject()));
    }

    System.err.println("Sending return with payload for obj " + read);

    out.writeByte(TransportConstants.Return);// transport op
    ObjectOutputStream oos = new JRMPClient.MarshalOutputStream(out, this.classpathUrl);

    oos.writeByte(TransportConstants.ExceptionalReturn);
    new UID().write(oos);

    BadAttributeValueExpException ex = new BadAttributeValueExpException(null);
    Reflections.setFieldValue(ex, "val", payload);
    oos.writeObject(ex);

    oos.flush();
    out.flush();

    this.hadConnection = true;
    synchronized ( this.waitLock ) {
        this.waitLock.notifyAll();
    }
}
 
Example 10
Project: nano-cuckoo   File: NanoCuckooFilter.java   View Source Code Vote up 4 votes
private void writeObject( ObjectOutputStream out ) throws IOException {

		bucketLocker.lockAllBuckets();

		final Serialization serialization = new Serialization();

		// Write bucket values
		out.writeInt( fpBits );
		out.writeInt( buckets.getEntriesPerBucket() );
		out.writeLong( buckets.getBucketCount() );
		out.writeBoolean( buckets.isCountingDisabled() );
		out.writeLong( buckets.getInsertedCount() );
		buckets.writeMemory( out );

		// Write kicked values
		out.writeInt( kickedValues.getKickedFingerprint() );
		out.writeLong( kickedValues.getKickedBucket() );

		// Write bucket locker values
		out.writeInt( bucketLocker.getConcurrency() );

		// Write swapper values
		out.writeInt( swapper.getMaxKicks() );
		// Write random int provider
		final byte randomIntType = serialization.getRandomIntType( swapper.getRandomInt() );
		out.writeByte( randomIntType );
		if ( serialization.isCustomType( randomIntType ) ) {
			out.writeObject( swapper.getRandomInt() );
		}

		// Write string encoder
		final byte stringEncoderType = serialization.getStringEncoderType( stringEncoder );
		out.writeByte( stringEncoderType );
		if ( serialization.isCustomType( stringEncoderType ) ) {
			out.writeObject( stringEncoder );
		}

		// Write bucket hasher
		final byte bucketHasherType = serialization.getBucketHasherType( bucketHasher );
		out.writeByte( bucketHasherType );
		if ( serialization.isCustomType( bucketHasherType ) ) {
			out.writeObject( bucketHasher );
		} else {
			out.writeInt( bucketHasher.getSeed() );
		}

		// Write fingerprint hasher
		final byte fpHasherType = serialization.getFingerprintHasherType( fpHasher );
		out.writeByte( fpHasherType );
		if ( serialization.isCustomType( fpHasherType ) ) {
			out.writeObject( fpHasher );
		}

		bucketLocker.unlockAllBuckets();
	}
 
Example 11
Project: ysoserial-modified   File: JRMPListener.java   View Source Code Vote up 4 votes
private void doCall ( DataInputStream in, DataOutputStream out, Object payload ) throws Exception {
    ObjectInputStream ois = new ObjectInputStream(in) {

        @Override
        protected Class<?> resolveClass ( ObjectStreamClass desc ) throws IOException, ClassNotFoundException {
            if ( "[Ljava.rmi.server.ObjID;".equals(desc.getName())) {
                return ObjID[].class;
            } else if ("java.rmi.server.ObjID".equals(desc.getName())) {
                return ObjID.class;
            } else if ( "java.rmi.server.UID".equals(desc.getName())) {
                return UID.class;
            }
            throw new IOException("Not allowed to read object");
        }
    };

    ObjID read;
    try {
        read = ObjID.read(ois);
    }
    catch ( java.io.IOException e ) {
        throw new MarshalException("unable to read objID", e);
    }

    
    if ( read.hashCode() == 2 ) {
        ois.readInt(); // method
        ois.readLong(); // hash
        System.err.println("Is DGC call for " + Arrays.toString((ObjID[])ois.readObject()));
    }
    
    System.err.println("Sending return with payload for obj " + read);

    out.writeByte(TransportConstants.Return);// transport op
    ObjectOutputStream oos = new JRMPClient.MarshalOutputStream(out, this.classpathUrl);

    oos.writeByte(TransportConstants.ExceptionalReturn);
    new UID().write(oos);

    BadAttributeValueExpException ex = new BadAttributeValueExpException(null);
    Reflections.setFieldValue(ex, "val", payload);
    oos.writeObject(ex);

    oos.flush();
    out.flush();

    this.hadConnection = true;
    synchronized ( this.waitLock ) {
        this.waitLock.notifyAll();
    }
}
 
Example 12
Project: Meucci   File: ModLoader.java   View Source Code Vote up 4 votes
private void exportType(TypeDef te, ObjectOutputStream out)throws IOException{
    out.writeUTF(te.getName());
    out.writeBoolean(te.classExplicit());
    
    //escludere membri override
    Membro[] i=te.getMembri();
    int l=0;
    for(Membro m:i){
        if(!m.override)
            l++;
    }
    out.writeInt(l);
    for(Membro mem:i){
        if(mem.override)
            continue;
        int perms=0;
        //non ci sono override
        if(mem.gpacked)
            perms=1;
        else if(mem.ghost)
            perms=2;
        perms*=3;
        if(mem.shadow)
            perms+=1;
        if(mem.read)
            perms+=2;
        out.writeByte(perms & 0xFF);
        out.writeObject(mem.getType());
        out.writeUTF(mem.getIdent());
        out.writeInt(mem.params.length);
        for(TypeName t:mem.params)
            out.writeObject(t);
        if(mem.packed==null)
            out.writeBoolean(false);
        else{
            out.writeBoolean(true);
            //Sicuramente NumDich
            out.writeLong(((NumDich)mem.packed).getNum());
        }
    }
    if(te.extend()!=null){
        out.writeBoolean(true);
        out.writeObject(te.extend());
    }
    else
        out.writeBoolean(false);
}
 
Example 13
Project: ysoserial-plus   File: JRMPListener.java   View Source Code Vote up 4 votes
private void doCall ( DataInputStream in, DataOutputStream out, Object payload ) throws Exception {
    ObjectInputStream ois = new ObjectInputStream(in) {

        @Override
        protected Class<?> resolveClass ( ObjectStreamClass desc ) throws IOException, ClassNotFoundException {
            if ( "[Ljava.rmi.server.ObjID;".equals(desc.getName())) {
                return ObjID[].class;
            } else if ("java.rmi.server.ObjID".equals(desc.getName())) {
                return ObjID.class;
            } else if ( "java.rmi.server.UID".equals(desc.getName())) {
                return UID.class;
            }
            throw new IOException("Not allowed to read object");
        }
    };

    ObjID read;
    try {
        read = ObjID.read(ois);
    }
    catch ( java.io.IOException e ) {
        throw new MarshalException("unable to read objID", e);
    }

    
    if ( read.hashCode() == 2 ) {
        ois.readInt(); // method
        ois.readLong(); // hash
        System.err.println("Is DGC call for " + Arrays.toString((ObjID[])ois.readObject()));
    }
    
    System.err.println("Sending return with payload for obj " + read);

    out.writeByte(TransportConstants.Return);// transport op
    ObjectOutputStream oos = new JRMPClient.MarshalOutputStream(out, this.classpathUrl);

    oos.writeByte(TransportConstants.ExceptionalReturn);
    new UID().write(oos);

    BadAttributeValueExpException ex = new BadAttributeValueExpException(null);
    Reflections.setFieldValue(ex, "val", payload);
    oos.writeObject(ex);

    oos.flush();
    out.flush();

    this.hadConnection = true;
    synchronized ( this.waitLock ) {
        this.waitLock.notifyAll();
    }
}