code: @Override
      public void writeExternal(ObjectOutput s) throws IOException {
          if (!removedFromLeakDetection) {
              if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
                  Tr.event(tc,
                           "Buffer being serialized but removeFromLeakDetection has not been called: " + this);
              }
          }
  
          if (oByteBuffer.isDirect()) {
              // hard code as local strings to help performance.
              // Strings are used here and and in the readObject routines
              s.writeObject("D");
          } else {
              s.writeObject("ND");
          }
          if (oByteBuffer.order() == java.nio.ByteOrder.BIG_ENDIAN) {
              s.writeObject("B");
          } else {
              s.writeObject("L");
          }
  
          int startPosition = oByteBuffer.position();
          int startLimit = oByteBuffer.limit();
  
          // set position to 0 and limit to capacity, so we can serialize
          // the entire buffer
          this.oByteBuffer.position(0);
          this.oByteBuffer.limit(this.oByteBuffer.capacity());
  
          if (oByteBuffer.hasArray() && oByteBuffer.arrayOffset() == 0) {
              s.writeObject(oByteBuffer.array());
          } else {
              byte[] bytes = new byte[oByteBuffer.limit()];
              this.oByteBuffer.get(bytes);
              s.writeObject(bytes);
          }
  
          this.oByteBuffer.position(startPosition);
          this.oByteBuffer.limit(startLimit);
  
          s.writeObject(Integer.toString(startPosition));
          s.writeObject(Integer.toString(startLimit));
  
          if (this.readOnly) {
              s.writeObject("R");
          } else {
              s.writeObject("RW");
          }
      }
docs: /*
  @see java.io.Externalizable#writeExternal(java.io.ObjectOutput)