1 22 package org.jboss.tools; 23 24 import java.io.ObjectStreamClass ; 25 import java.io.Serializable ; 26 27 33 public class ClassVersionInfo implements Serializable 34 { 35 static final long serialVersionUID = 2036506209171911437L; 36 37 38 private long serialVersion; 39 40 private String name; 41 private boolean hasExplicitSerialVersionUID; 42 43 public ClassVersionInfo(String name, ClassLoader loader) 44 throws ClassNotFoundException 45 { 46 this.name = name; 47 Class c = loader.loadClass(name); 48 if( c.isInterface() == false ) 49 { 50 ObjectStreamClass osc = ObjectStreamClass.lookup(c); 51 if( osc != null ) 52 { 53 serialVersion = osc.getSerialVersionUID(); 54 try 55 { 56 c.getDeclaredField("serialVersionUID"); 57 hasExplicitSerialVersionUID = true; 58 } 59 catch(NoSuchFieldException e) 60 { 61 hasExplicitSerialVersionUID = false; 62 } 63 } 64 } 65 } 66 67 public long getSerialVersion() 68 { 69 return serialVersion; 70 } 71 public boolean getHasExplicitSerialVersionUID() 72 { 73 return hasExplicitSerialVersionUID; 74 } 75 public String getName() 76 { 77 return name; 78 } 79 80 public String toString() 81 { 82 StringBuffer tmp = new StringBuffer ("ClassVersionInfo"); 83 tmp.append('{'); 84 tmp.append("serialVersion="); 85 tmp.append(serialVersion); 86 tmp.append(", hasExplicitSerialVersionUID="); 87 tmp.append(hasExplicitSerialVersionUID); 88 tmp.append(", name="); 89 tmp.append(name); 90 tmp.append('}'); 91 return tmp.toString(); 92 } 93 } 94 | Popular Tags |