lives-group / APEG

2 stars 0 forks source link

Serialization of ast #38

Closed DeiversonMAP closed 2 years ago

DeiversonMAP commented 2 years ago

I'm having problem in the reading of serialization of a AST object here is my methods of wirte and read:

private void writeBinFile(APEG data) throws IOException {

  try( ObjectOutputStream oos = new ObjectOutputStream(
    new FileOutputStream(pth.getRelativePath()))
  ){
    oos.writeObject(data);
  }  catch (IOException e){
    return;
  }
}

private APEG readBinFile() throws IOException {
 try(
     ObjectInputStream ois = new ObjectInputStream(
    new FileInputStream(pth.getRelativePath()) ) 
    ) 
      {
        // System.out.println(  ois.readObject().toString());
        System.out.println("entrou aqui");
        APEG a =  (APEG) ois.readObject();
        System.out.println("entrou aqui2");
        return  a; 
      } 
       catch (Exception e){
        e.printStackTrace();
        return null;
      }
}

The root class have the Serializable implemententation as the SymInfo class as well And I'm getting the following error :

java.lang.NullPointerException: Cannot invoke "Object.toString()" because "apeg" is null

DeiversonMAP commented 2 years ago

To solve it was necessary to implement the Serializable class in the CharInterval class