home *** CD-ROM | disk | FTP | other *** search
- package netscape.netcast;
-
- import marimba.persist.PersistentStateClassLoader;
- import netscape.applet.CastanetChannelInfo;
- import netscape.security.PrivilegeManager;
- import netscape.security.Target;
-
- final class ApplicationThreadGroup extends ThreadGroup implements PersistentStateClassLoader {
- CastanetChannelInfo loader;
-
- ApplicationThreadGroup(String name) {
- super(name);
- }
-
- public Class loadPersistentClass(String name) throws ClassNotFoundException {
- return this.loader.loadClass(name);
- }
-
- public Class loadScriptClass(String name, byte[] data) {
- if (name == null) {
- name = this.getClassNameFromScript(data);
- }
-
- PrivilegeManager privMgr = PrivilegeManager.getPrivilegeManager();
- if (privMgr != null) {
- Target target = Target.findTarget("MarimbaInternalTarget");
- if (target != null) {
- privMgr.enablePrivilege(target);
- }
- }
-
- return this.loader.classFromBytes(data, name);
- }
-
- public void close() {
- this.loader = null;
- ((ThreadGroup)this).stop();
- }
-
- private String getClassNameFromScript(byte[] clazz) {
- String result = null;
- int cpoolCount = ((clazz[8] & 255) << 8) + (clazz[9] & 255);
-
- try {
- int[] lookup = new int[cpoolCount];
- int i = 10;
-
- for(int count = 1; count < cpoolCount; ++count) {
- switch (clazz[i]) {
- case 1:
- lookup[count] = i;
- i += ((clazz[i + 1] & 255) << 8) + (clazz[i + 2] & 255) + 3;
- case 2:
- default:
- break;
- case 3:
- case 4:
- case 9:
- case 10:
- case 11:
- case 12:
- i += 5;
- break;
- case 5:
- case 6:
- i += 9;
- ++count;
- break;
- case 7:
- lookup[count] = i;
- case 8:
- i += 3;
- }
- }
-
- i += 2;
- int classIndex = lookup[((clazz[i] & 255) << 8) + (clazz[i + 1] & 255)];
- if (clazz[classIndex] == 7) {
- classIndex = lookup[((clazz[classIndex + 1] & 255) << 8) + (clazz[classIndex + 2] & 255)];
- if (clazz[classIndex] == 1) {
- result = new String(clazz, 0, classIndex + 3, ((clazz[classIndex + 1] & 255) << 8) + (clazz[classIndex + 2] & 255));
- }
- }
- } catch (ArrayIndexOutOfBoundsException var8) {
- }
-
- return result.replace('/', '.');
- }
- }
-