odnoklassniki / one-nio

Unconventional I/O library for Java
Apache License 2.0
655 stars 97 forks source link

java.util.Locale support #64

Closed MacX19 closed 2 weeks ago

MacX19 commented 2 years ago

Do you plan to support java.util.Locale serialization? Or should I use my own Serializer<Locale>?

incubos commented 1 year ago

We do not have any specific plans w.r.t. java.util.Locale. Serializable classes are naturally supported. Could you please clarify the problem you are trying to solve?

MacX19 commented 1 year ago

Oh, I don't remember exactly why. I have already written my own Serializer. I tried now a simple example and got an error:

    byte[] res;
    try (PersistStream stream = new PersistStream()) {
      Locale locale = new Locale("en", "US");
      stream.writeObject(locale);
      res = stream.toByteArray();
    }
    try (DeserializeStream des = new DeserializeStream(res)) {
      System.out.println(des.readObject());
    }
Exception in thread "main" java.io.IOException: writeObject() is not fully supported. See implementation notes.
    at one.nio.serial.gen.NullObjectOutputStream.unsupported(NullObjectOutputStream.java:159)
    at one.nio.serial.gen.NullObjectOutputStream.putFields(NullObjectOutputStream.java:50)
    at java.util.Locale.writeObject(Locale.java:2156)
    at sun.reflect.Delegate0_Locale.write(Unknown Source)
    at one.nio.serial.GeneratedSerializer.write(GeneratedSerializer.java:121)
    at one.nio.serial.PersistStream.writeObject(PersistStream.java:60)
...