Reconstruct a serialized object from the specified byte array.

@param buffer the buffer from which the object should be reconstructed
@return a serialized object from the specified byte array
11557
@SuppressWarnings("unchecked")
  private P byteBufferToPage(ByteBuffer buffer) {
    try (InputStream bais = new ByteBufferInputStream(buffer);
        ObjectInputStream ois = new ObjectInputStream(bais)) {
      int type = ois.readInt();
      if (type == EMPTY_PAGE) {
        return null;
      } else if (type == FILLED_PAGE) {
        return (P) ois.readObject();
      } else {
        throw new IllegalArgumentException("Unknown type: " + type);
      }
    } catch (IOException|ClassNotFoundException e) {
      LoggingUtil.exception(e);
      return null;
    }
  }
1374340
public byte[] getBuffer() {
        if(buf == null)
            return null;
        if(offset == 0 && length == buf.length)
            return buf;
        else {
            byte[] retval=new byte[length];
            System.arraycopy(buf, offset, retval, 0, length);
            return retval;
        }
    }
93507
def DeserializeFromDB(buffer):
        
        m = StreamManager.GetStream(buffer)
        reader = BinaryReader(m)
        c = ContractState()
        c.Deserialize(reader)

        StreamManager.ReleaseStream(m)

        return c
742070
protected static byte[] toArray(ByteBuffer... payload) {
        if (payload.length == 1) {
            ByteBuffer buf = payload[0];
            if (buf.hasArray() && buf.arrayOffset() == 0 && buf.position() == 0) {
                return buf.array();
            }
        }
        int size = (int) Buffers.remaining(payload);
        byte[] data = new byte[size];
        for (ByteBuffer buf : payload) {
            buf.get(data);
        }
        return data;
    }
449189
public static Object deserialize(byte[] bytes) {
		
		Object result = null;
		
		if (isEmpty(bytes)) {
			return null;
		}

		try {
			ByteArrayInputStream byteStream = new ByteArrayInputStream(bytes);
			try {
				ObjectInputStream objectInputStream = new ObjectInputStream(byteStream);
				try {
					result = objectInputStream.readObject();
				}
				catch (ClassNotFoundException ex) {
					throw new Exception("Failed to deserialize object type", ex);
				}
			}
			catch (Throwable ex) {
				throw new Exception("Failed to deserialize", ex);
			}
		} catch (Exception e) {
			logger.error("Failed to deserialize",e);
		}
		return result;
	}
234439
public <T> T deserialize(final byte[] bytes) {
    return kryoInputPool.run(input -> {
      input.setInputStream(new ByteArrayInputStream(bytes));
      return kryoPool.run(kryo -> {
        @SuppressWarnings("unchecked")
        T obj = (T) kryo.readClassAndObject(input);
        return obj;
      });
    }, DEFAULT_BUFFER_SIZE);
  }
465944
public static byte[] decompressGZIP(byte[] buffer) throws IOException {
        // Wrap the buffer in a ByteArrayInputStream and extract the decompressed pieces
        // into a ByteArrayOutputStream.
        ByteArrayInputStream bytesIn = new ByteArrayInputStream(buffer);
        GZIPInputStream gzipIn = new GZIPInputStream(bytesIn);
        ByteArrayOutputStream bytesBuffer = new ByteArrayOutputStream();
        byte[] chunkBuffer = new byte[65536];
        for (int bytesRead = gzipIn.read(chunkBuffer);
             bytesRead > 0;
             bytesRead = gzipIn.read(chunkBuffer)) {
            // Push this chunk into the ByteArrayOutputStream
            bytesBuffer.write(chunkBuffer, 0, bytesRead);
        }
        gzipIn.close();
        return bytesBuffer.toByteArray();
    }
1126937
public static byte[] readBytes(ByteBuffer buffer) {
		final int remaining = buffer.remaining();
		byte[] ab = new byte[remaining];
		buffer.get(ab);
		return ab;
	}
1350167
public static byte[] asArray(ByteBuffer byteBuffer) {
        ByteBuffer bb = ByteBufferUtil.clone(byteBuffer);
        byte[] bytes = new byte[bb.remaining()];
        bb.get(bytes);
        return bytes;
    }
33809
private Serializable deserializeObject(byte[] buffer) throws IOException, ClassNotFoundException {

		Serializable theObject = null;
		ObjectInputStream objectIn = null;

		if (buffer != null) {
			objectIn = new ObjectInputStream(new ByteArrayInputStream(buffer));
			theObject = (Serializable)objectIn.readObject();
			objectIn.close();
		}
		return theObject;
	}
491709
public static byte[] array(final ByteBuffer buffer)
    {
        if (buffer.isDirect())
        {
            throw new IllegalArgumentException("buffer must wrap an array");
        }

        return (byte[])UNSAFE.getObject(buffer, BYTE_BUFFER_HB_FIELD_OFFSET);
    }
1024500
def DeserializeFromDB(buffer):
        
        m = StreamManager.GetStream(buffer)
        reader = BinaryReader(m)
        v = StorageItem()
        v.Deserialize(reader)
        StreamManager.ReleaseStream(m)
        return v
429963
public Packet decode(ByteBuffer bytes) {
        return processPacket(Memories.wrap(bytes, memoryProperties.getCheckBounds()));
    }
239134
protected ByteBuffer inputStreamToByteBuffer() throws IOException {
        return byteBuffer == null ? byteBuffer = ByteBuffer.wrap(inputStreamToByteArray()) : byteBuffer;
    }
1037600
public static Buffer wrapAndClone(final byte[] buffer) {
        if (buffer == null || buffer.length == 0) {
            throw new IllegalArgumentException("the buffer cannot be null or empty");
        }

        final byte[] b = new byte[buffer.length];
        System.arraycopy(buffer, 0, b, 0, buffer.length);
        return new ByteBuffer(b);
    }
988184
@SuppressWarnings("unchecked")
  private <T> T readByClass(BufferInput<?> buffer) {
    String name = buffer.readUTF8();
    if (whitelistRequired.get())
      throw new SerializationException("cannot deserialize unregistered type: " + name);

    Class<T> type = (Class<T>) types.get(name);
    if (type == null) {
      try {
        type = (Class<T>) Class.forName(name);
        if (type == null)
          throw new SerializationException("cannot deserialize: unknown type");
        types.put(name, type);
      } catch (ClassNotFoundException e) {
        throw new SerializationException("object class not found: " + name, e);
      }
    }

    TypeSerializer<T> serializer = getSerializer(type);
    if (serializer == null)
      throw new SerializationException("cannot deserialize unregistered type: " + name);

    return serializer.read(type, buffer, this);
  }
945736
@Override
    protected final void unserialize(ByteBuffer bytes)
    {
        int indexDataLength = m_dataOffset_ + m_dataLength_;
        m_index_ = ICUBinary.getChars(bytes, indexDataLength, 0);
        m_data_           = m_index_;
        m_initialValue_   = m_data_[m_dataOffset_];
    }