2

In my Flink graph, I have certain POJO classes with final fields. These fields are set in an overloaded constructor. Example, I have a Car POJO with final fields, and a HybridCar class that derives from Car as shown below.

public class Car {
   private final int year;
   private final int modelNumber;

   public Car (int year, int modelNumber) {
       this.year = year;
       this.modelNumber = modelNumber;
   }
}

public HybridCar extends Car {

    private final int powerInWatts;

    public HybridCar(int powerInWatts, int year, int modelNumber) {
        super(year, modelNumber);
        this.powerInWatts = powerInWatts;
    }
}

Will this work for Flink? That is, will Flink be able to deserialize this class using its internal serialization/deserialization library?

A related SO question/answer on JVM deserialization says that the JVM "Deserialization is implemented by the JVM on a level below the basic language constructs. Specifically, it does not call any constructor." (or more correctly, it only calls the super class constructor.

victtim
  • 790
  • 5
  • 17

0 Answers0