Code example for NotSerializableException

0
        group = new OpenSSLECGroupContext(NativeCrypto.EC_GROUP_dup(origGroup));
    } 
 
    private void writeObject(ObjectOutputStream stream) throws IOException {
        if (key.isEngineBased()) {
            throw new NotSerializableException("engine-based keys can not be serialized");
        } 
 
        stream.defaultWriteObject();
        stream.writeObject(getEncoded());
    } 
}