< prev index next >

src/com/sun/javatest/agent/AgentClassLoader2.java

Print this page
rev 145 : 7902237: Fixing raw use of parameterized class
Reviewed-by: jjg


  81         }
  82         return pd;
  83     }
  84 
  85 
  86     /*
  87      * Returns shared instance of classloader for tests where it is required.
  88      */
  89     public static AgentClassLoader2 getInstance(Agent.Task parent) {
  90         if (instance == null) {
  91             synchronized (AgentClassLoader2.class) {
  92                 if (instance == null) {
  93                     instance = new AgentClassLoader2(parent);
  94                 }
  95             }
  96         }
  97         instance.parent = parent;
  98         return instance;
  99     }
 100 
 101     public Class loadClassLocal(String name) throws ClassNotFoundException {
 102         Class target = null;
 103 System.out.println("FORCE REMOTE " + name);
 104         try {
 105             target = findClass(name);
 106         } catch (ClassNotFoundException e) {
 107             // not found remote, search locally
 108             // this is reverse of normal CL operation
 109             target = super.loadClass(name);
 110             //target = findSystemClass(name);
 111         } catch (NoClassDefFoundError e2) {
 112             target = super.loadClass(name);
 113             //target = findSystemClass(name);
 114         }
 115 
 116         return target;
 117     }
 118 
 119 
 120     @Override
 121     public Class findClass(String className) throws ClassNotFoundException {
 122         if (className != null) {
 123             int i = className.lastIndexOf('.');
 124             if (i > 0) {
 125                 String pkgName = className.substring(0, i);
 126                 if (getPackage(pkgName) == null) {
 127                     definePackage(pkgName, null, null, null, null, null, null, null);
 128                 }
 129             }
 130             AgentRemoteClassData classData = parent.getClassData(className);
 131             ProtectionDomain pd = null;
 132             if (classData != null && classData.getCodeSource() != null) {
 133                 try {
 134                     pd = getProtectionDomain(new CodeSource(new URL("file:" + classData.getCodeSource()), (CodeSigner[]) null));
 135                 } catch (IOException e) {
 136                     // ProtectionDomain will be replaced
 137                 }
 138             }
 139             if (pd == null) {
 140                 pd = getProtectionDomain(cs);
 141             }




  81         }
  82         return pd;
  83     }
  84 
  85 
  86     /*
  87      * Returns shared instance of classloader for tests where it is required.
  88      */
  89     public static AgentClassLoader2 getInstance(Agent.Task parent) {
  90         if (instance == null) {
  91             synchronized (AgentClassLoader2.class) {
  92                 if (instance == null) {
  93                     instance = new AgentClassLoader2(parent);
  94                 }
  95             }
  96         }
  97         instance.parent = parent;
  98         return instance;
  99     }
 100 
 101     public Class<?> loadClassLocal(String name) throws ClassNotFoundException {
 102         Class<?> target = null;
 103 System.out.println("FORCE REMOTE " + name);
 104         try {
 105             target = findClass(name);
 106         } catch (ClassNotFoundException e) {
 107             // not found remote, search locally
 108             // this is reverse of normal CL operation
 109             target = super.loadClass(name);
 110             //target = findSystemClass(name);
 111         } catch (NoClassDefFoundError e2) {
 112             target = super.loadClass(name);
 113             //target = findSystemClass(name);
 114         }
 115 
 116         return target;
 117     }
 118 
 119 
 120     @Override
 121     public Class<?> findClass(String className) throws ClassNotFoundException {
 122         if (className != null) {
 123             int i = className.lastIndexOf('.');
 124             if (i > 0) {
 125                 String pkgName = className.substring(0, i);
 126                 if (getPackage(pkgName) == null) {
 127                     definePackage(pkgName, null, null, null, null, null, null, null);
 128                 }
 129             }
 130             AgentRemoteClassData classData = parent.getClassData(className);
 131             ProtectionDomain pd = null;
 132             if (classData != null && classData.getCodeSource() != null) {
 133                 try {
 134                     pd = getProtectionDomain(new CodeSource(new URL("file:" + classData.getCodeSource()), (CodeSigner[]) null));
 135                 } catch (IOException e) {
 136                     // ProtectionDomain will be replaced
 137                 }
 138             }
 139             if (pd == null) {
 140                 pd = getProtectionDomain(cs);
 141             }


< prev index next >