< prev index next >

src/java.desktop/share/classes/sun/applet/AppletClassLoader.java

Print this page




  35 import java.net.UnknownHostException;
  36 import java.io.EOFException;
  37 import java.io.File;
  38 import java.io.FilePermission;
  39 import java.io.IOException;
  40 import java.io.BufferedInputStream;
  41 import java.io.InputStream;
  42 import java.util.Enumeration;
  43 import java.util.HashMap;
  44 import java.util.NoSuchElementException;
  45 import java.security.AccessController;
  46 import java.security.AccessControlContext;
  47 import java.security.PrivilegedAction;
  48 import java.security.PrivilegedExceptionAction;
  49 import java.security.PrivilegedActionException;
  50 import java.security.CodeSource;
  51 import java.security.Permission;
  52 import java.security.PermissionCollection;
  53 import sun.awt.AppContext;
  54 import sun.awt.SunToolkit;
  55 import sun.misc.ManagedLocalsThread;
  56 import sun.net.www.ParseUtil;
  57 import sun.security.util.SecurityConstants;
  58 
  59 /**
  60  * This class defines the class loader for loading applet classes and
  61  * resources. It extends URLClassLoader to search the applet code base
  62  * for the class or resource after checking any loaded JAR files.
  63  */
  64 public class AppletClassLoader extends URLClassLoader {
  65     private URL base;   /* applet code base URL */
  66     private CodeSource codesource; /* codesource for the base URL */
  67     private AccessControlContext acc;
  68     private boolean exceptionStatus = false;
  69 
  70     private final Object threadGroupSynchronizer = new Object();
  71     private final Object grabReleaseSynchronizer = new Object();
  72 
  73     private boolean codebaseLookup = true;
  74     private volatile boolean allowRecursiveDirectoryRead = true;
  75 


 841             s = mh.getMessage("fileioexception", name);
 842         } else if (e instanceof ClassFormatError) {
 843             s = mh.getMessage("fileformat", name);
 844         } else if (e instanceof ThreadDeath) {
 845             s = mh.getMessage("filedeath", name);
 846         } else if (e instanceof Error) {
 847             s = mh.getMessage("fileerror", e.toString(), name);
 848         }
 849         if (s != null) {
 850             System.err.println(s);
 851         }
 852     }
 853 }
 854 
 855 /*
 856  * The AppContextCreator class is used to create an AppContext from within
 857  * a Thread belonging to the new AppContext's ThreadGroup.  To wait for
 858  * this operation to complete before continuing, wait for the notifyAll()
 859  * operation on the syncObject to occur.
 860  */
 861 class AppContextCreator extends ManagedLocalsThread {
 862     Object syncObject = new Object();
 863     AppContext appContext = null;
 864     volatile boolean created = false;
 865 







 866     AppContextCreator(ThreadGroup group)  {
 867         super(group, "AppContextCreator");
 868     }
 869 
 870     public void run()  {
 871         appContext = SunToolkit.createNewAppContext();
 872         created = true;
 873         synchronized(syncObject) {
 874             syncObject.notifyAll();
 875         }
 876     } // run()
 877 
 878 } // class AppContextCreator


  35 import java.net.UnknownHostException;
  36 import java.io.EOFException;
  37 import java.io.File;
  38 import java.io.FilePermission;
  39 import java.io.IOException;
  40 import java.io.BufferedInputStream;
  41 import java.io.InputStream;
  42 import java.util.Enumeration;
  43 import java.util.HashMap;
  44 import java.util.NoSuchElementException;
  45 import java.security.AccessController;
  46 import java.security.AccessControlContext;
  47 import java.security.PrivilegedAction;
  48 import java.security.PrivilegedExceptionAction;
  49 import java.security.PrivilegedActionException;
  50 import java.security.CodeSource;
  51 import java.security.Permission;
  52 import java.security.PermissionCollection;
  53 import sun.awt.AppContext;
  54 import sun.awt.SunToolkit;

  55 import sun.net.www.ParseUtil;
  56 import sun.security.util.SecurityConstants;
  57 
  58 /**
  59  * This class defines the class loader for loading applet classes and
  60  * resources. It extends URLClassLoader to search the applet code base
  61  * for the class or resource after checking any loaded JAR files.
  62  */
  63 public class AppletClassLoader extends URLClassLoader {
  64     private URL base;   /* applet code base URL */
  65     private CodeSource codesource; /* codesource for the base URL */
  66     private AccessControlContext acc;
  67     private boolean exceptionStatus = false;
  68 
  69     private final Object threadGroupSynchronizer = new Object();
  70     private final Object grabReleaseSynchronizer = new Object();
  71 
  72     private boolean codebaseLookup = true;
  73     private volatile boolean allowRecursiveDirectoryRead = true;
  74 


 840             s = mh.getMessage("fileioexception", name);
 841         } else if (e instanceof ClassFormatError) {
 842             s = mh.getMessage("fileformat", name);
 843         } else if (e instanceof ThreadDeath) {
 844             s = mh.getMessage("filedeath", name);
 845         } else if (e instanceof Error) {
 846             s = mh.getMessage("fileerror", e.toString(), name);
 847         }
 848         if (s != null) {
 849             System.err.println(s);
 850         }
 851     }
 852 }
 853 
 854 /*
 855  * The AppContextCreator class is used to create an AppContext from within
 856  * a Thread belonging to the new AppContext's ThreadGroup.  To wait for
 857  * this operation to complete before continuing, wait for the notifyAll()
 858  * operation on the syncObject to occur.
 859  */
 860 class AppContextCreator extends Thread {
 861     Object syncObject = new Object();
 862     AppContext appContext = null;
 863     volatile boolean created = false;
 864 
 865     /**
 866      * Must call the 5-args super-class constructor to erase locals.
 867      */
 868     private AppContextCreator() {
 869         throw new UnsupportedOperationException("Must erase locals");
 870     }
 871 
 872     AppContextCreator(ThreadGroup group)  {
 873         super(group, null, "AppContextCreator", 0, false);
 874     }
 875 
 876     public void run()  {
 877         appContext = SunToolkit.createNewAppContext();
 878         created = true;
 879         synchronized(syncObject) {
 880             syncObject.notifyAll();
 881         }
 882     } // run()
 883 
 884 } // class AppContextCreator
< prev index next >