1 21 22 package org.apache.derby.impl.services.reflect; 23 24 import org.apache.derby.iapi.services.loader.GeneratedByteCode; 25 import org.apache.derby.iapi.services.loader.GeneratedClass; 26 import org.apache.derby.iapi.services.loader.ClassFactory; 27 28 import org.apache.derby.iapi.services.context.Context; 29 30 import org.apache.derby.iapi.error.StandardException; 31 import org.apache.derby.iapi.reference.SQLState; 32 33 import org.apache.derby.iapi.services.loader.ClassInfo; 34 35 36 public abstract class LoadedGeneratedClass 37 implements GeneratedClass 38 { 39 40 43 44 private final ClassInfo ci; 45 private final int classLoaderVersion; 46 47 50 51 public LoadedGeneratedClass(ClassFactory cf, Class jvmClass) { 52 ci = new ClassInfo(jvmClass); 53 classLoaderVersion = cf.getClassLoaderVersion(); 54 } 55 56 59 60 public String getName() { 61 return ci.getClassName(); 62 } 63 64 public Object newInstance(Context context) throws StandardException { 65 66 Throwable t; 67 try { 68 GeneratedByteCode ni = (GeneratedByteCode) ci.getNewInstance(); 69 ni.initFromContext(context); 70 ni.setGC(this); 71 ni.postConstructor(); 72 return ni; 73 74 } catch (InstantiationException ie) { 75 t = ie; 76 } catch (IllegalAccessException iae) { 77 t = iae; 78 } catch (java.lang.reflect.InvocationTargetException ite) { 79 t = ite; 80 } catch (LinkageError le) { 81 t = le; 82 } 83 84 throw StandardException.newException(SQLState.GENERATED_CLASS_INSTANCE_ERROR, t, getName()); 85 } 86 87 public final int getClassLoaderVersion() { 88 return classLoaderVersion; 89 } 90 91 94 protected Class getJVMClass() { 95 return ci.getClassObject(); 96 } 97 } 98 | Popular Tags |