JVM DataFlavor Utility Useless
Closed this issue · 3 comments
The constructor overloads of DataFlavor include a method which takes a class and string name and does not throw class not found exceptions. Discovered this while reviewing how 24759b8 could be cleaned up.
https://docs.oracle.com/javase/7/docs/api/java/awt/datatransfer/DataFlavor.html#DataFlavor(java.lang.Class,%20java.lang.String)
I am incorrect, the constructor that takes a class uses serialization for data transfer. I had to create these utility methods because the interface for defining a JVM local data transfer flavor is crappy. This basically means that we don't intend to transfer EventNode or ResNode outside of LateralGM instances running in a JVM. In other words, we don't want (or need to yet) transfer an event node from LGM to Notepad or Word or etc.
If we do want that later though, it's possible for the transfer handler to support both local and serialization data flavors. This way when you transfer inside a JVM instance, it will be faster because it's just copying references. Then if you need to transfer outside of LGM, it would use serialization.
https://docs.oracle.com/javase/tutorial/uiswing/dnd/dataflavor.html
Further, I found out by digging into the code of DataFlavor that the reason #303 actually happened was in fact because the JVM was confusing them since they both had the same MIME types. If you look at how DataFlavor overrides the equals() method, it only compares the references and the MIME type, but not the human representable name. That's why ResNode and EventNode having different human presentable names was not enough for the JVM to distinguish the two.
NOTE: May be worth fixing all the reference equality in the transfer handlers later on.