1 7 8 package java.awt.dnd; 9 10 import java.io.OutputStream ; 11 import java.io.ObjectOutputStream ; 12 import java.io.IOException ; 13 import java.io.Serializable ; 14 15 22 final class SerializationTester { 23 private static ObjectOutputStream stream; 24 static { 25 try { 26 stream = new ObjectOutputStream (new OutputStream () { 27 public void write(int b) {} 28 }); 29 } catch (IOException cannotHappen) { 30 } 31 } 32 33 static boolean test(Object obj) { 34 if (!(obj instanceof Serializable )) { 35 return false; 36 } 37 38 try { 39 stream.writeObject(obj); 40 } catch (IOException e) { 41 return false; 42 } finally { 43 try { 47 stream.reset(); 48 } catch (IOException e) { 49 } 51 } 52 return true; 53 } 54 55 private SerializationTester() {} 56 } 57 | Popular Tags |