code: @Override
    public Object getObject(final ClassLoader classLoader) throws ClassNotFoundException {
      if (!prefixedDataAvailable(4)) {
        throw new BufferUnderflowException();
      }
  
      int length = getInt();
      if (length <= 4) {
        throw new BufferDataException("Object length should be greater than 4: " + length);
      }
  
      int oldLimit = limit();
      limit(position() + length);
      try {
        ObjectInputStream in = new ObjectInputStream(asInputStream()) {
          @Override
          protected ObjectStreamClass readClassDescriptor()
              throws IOException, ClassNotFoundException {
            int type = read();
            if (type < 0) {
              throw new EOFException();
            }
            switch (type) {
              case 0: // Primitive types
                return super.readClassDescriptor();
              case 1: // Non-primitive types
                String className = readUTF();
                Class<?> clazz = Class.forName(className, true, classLoader);
                return ObjectStreamClass.lookup(clazz);
              default:
                throw new StreamCorruptedException("Unexpected class descriptor type: " + type);
            }
          }
  
          @Override
          protected Class<?> resolveClass(ObjectStreamClass desc)
              throws IOException, ClassNotFoundException {
            String name = desc.getName();
            try {
              return Class.forName(name, false, classLoader);
            } catch (ClassNotFoundException ex) {
              return super.resolveClass(desc);
            }
          }
        };
        return in.readObject();
      } catch (IOException e) {
        throw new BufferDataException(e);
      } finally {
        limit(oldLimit);
      }
    }
docs: {@inheritDoc}