dyschemist
Witam. W programie mam tablice obiektów (dziedziczą prosto po Object ) którą próbuje zapisać do pliku za pomocą ObjectOutputStream. Obiekty te mają domyślnie zaimplementowany interfejs Serializable.
import java.io.Serializable;
import net.java.games.jogl.GL;
import net.java.games.jogl.GLU;
public abstract class GLPolygon implements Serializable
...
zapis realizuje kod:
FileOutputStream ostream;
try {
ostream = new FileOutputStream("save.sav");
ObjectOutputStream p = new ObjectOutputStream(ostream);
Iterator<GLPolygon> it = glp_vector.iterator();
p.write(glp_vector.size());
while (it.hasNext() & (glp_vector.size() > 0) ) {
p.writeObject(it.next());
}
p.flush();
ostream.close();
}
catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
na linijce z it.next() wyrzucany jest wyjątek
java.io.NotSerializableException: net.java.games.jogl.impl.windows.WindowsGLImpl
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)
at java.io.ObjectOutputStream.writeSerialData(Unknown Source)
at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.writeObject(Unknown Source)
at MyRenderer.actionPerformed(MyRenderer.java:372)
at java.awt.MenuItem.processActionEvent(Unknown Source)
at java.awt.MenuItem.processEvent(Unknown Source)
at java.awt.MenuComponent.dispatchEventImpl(Unknown Source)
at java.awt.MenuComponent.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Nie wiem czy to ma znaczenie, ale zapis jest wywoływany z klasy:
public class MyRenderer implements GLEventListener, MouseListener, KeyListener,
ActionListener