There is an ObjectInputStream, I need to add logging to it and add all the objects that are written to the stack. The solution is to extend the existing class, but, it should be done in the same java.io package, but it is read-only.

  • one
    I wonder why you need to declare the class in the standard package. Maybe you will reveal what problem you are trying to solve? - default locale
  • 3
    Why add a new class to java.io ? - Regent
  • Yes, there is a serialization and falling. Serialize a very large object consisting of sheets. We need to understand which sheet throws a stackoverflowerror in order to resolve circular references for it - Roberto
  • so the idea is to add to the standard output stream save the call stack or at least logging. - Roberto
  • one
    These are hardly circular references, the built-in serialization can work with them (and toString() for collections will overflow the stack), just the nesting depth is big. What you want is the -Xbootclasspath option ( example ), but it may be easier to set up a breakpoint in the IDE when throwing a StackOverflowError and look for something familiar in the contents of the collections. You can also make your object its own readObject / writeObject with logs and other things (see doc on Serializable ) - zRrr

1 answer 1

@VladislavOsipenkov is a very bad idea. No need to try, because of your particular problem, to try to embed your code in Java SE.

Why it is impossible to inherit from ObjectInputStream and make your own class, which will be your logging?

What is the problem then?