Package com.apple.misc

Source Code of com.apple.misc.BundleClassLoader

/*     */ package com.apple.misc;
/*     */
/*     */ import com.apple.net.ExtensionURLFilter;
/*     */ import com.apple.security.NullSecurityManager;
/*     */ import com.apple.util.ResourceLocator;
/*     */ import java.io.File;
/*     */ import java.io.FileInputStream;
/*     */ import java.io.IOException;
/*     */ import java.io.InputStream;
/*     */ import java.io.PrintStream;
/*     */ import java.net.URL;
/*     */ import java.util.Hashtable;
/*     */ import java.util.Properties;
/*     */ import java.util.Vector;
/*     */
/*     */ public class BundleClassLoader extends StandardClassLoader
/*     */ {
/*  39 */   private static int _debuglvl = 0;
/*     */
/*     */   public BundleClassLoader()
/*     */   {
/*     */   }
/*     */
/*     */   public BundleClassLoader(ResourceLocator paramResourceLocator)
/*     */   {
/*  97 */     super(paramResourceLocator);
/*     */   }
/*     */
/*     */   public Vector getClasses()
/*     */   {
/* 108 */     return getClassesFromLocations(this._locator.getResources(new ExtensionURLFilter(".class")));
/*     */   }
/*     */
/*     */   public Vector getClassesFromResourceLocator(ResourceLocator paramResourceLocator)
/*     */   {
/* 115 */     return getClassesFromLocations(paramResourceLocator.getResources(new ExtensionURLFilter(".class")));
/*     */   }
/*     */
/*     */   private Vector getClassesFromLocations(URL[] paramArrayOfURL) {
/* 119 */     Vector localVector = new Vector(paramArrayOfURL.length);
/*     */
/* 121 */     for (int i = 0; i < paramArrayOfURL.length; i++) {
/* 122 */       Class localClass = (Class)this._hash.get(paramArrayOfURL[i].toString());
/* 123 */       String str = null;
/*     */
/* 141 */       if (localClass == null) {
/* 142 */         byte[] arrayOfByte = null;
/*     */
/* 144 */         if (_debuglvl >= 1) {
/* 145 */           System.err.println(this + ": debug: loading bytecode from " + paramArrayOfURL[i]);
/*     */         }
/*     */
/* 148 */         InputStream localInputStream = null;
/*     */         try
/*     */         {
/* 151 */           localInputStream = paramArrayOfURL[i].openStream();
/* 152 */           arrayOfByte = getClassImplementation(localInputStream);
/*     */
/* 154 */           if (_debuglvl >= 3) {
/* 155 */             System.err.println(this + ": debug: bytecode for class " + paramArrayOfURL[i] + " is " + arrayOfByte.length + " bytes long");
/*     */           }
/*     */
/* 158 */           localClass = defineClass(str, arrayOfByte, 0, arrayOfByte.length);
/*     */         } catch (Throwable localThrowable) {
/* 160 */           int j = 0;
/*     */
/* 162 */           if (((localThrowable instanceof ClassFormatError)) &&
/* 163 */             (localThrowable.toString().endsWith("Duplicate name"))) {
/* 164 */             j = 1;
/*     */           }
/*     */
/* 168 */           if ((j == 0) || (_debuglvl >= 1)) {
/* 169 */             System.err.println(this + ": " + ((j != 0) && (_debuglvl >= 1) ? "debug: " : "") + "while trying to define " + paramArrayOfURL[i] + ", (" + str + "), got throwable: " + localThrowable);
/* 170 */             localThrowable.printStackTrace(System.err);
/*     */           }
/*     */
/* 173 */           localClass = null;
/*     */         } finally {
/* 175 */           if (localInputStream != null) try {
/* 176 */               localInputStream.close();
/*     */             }
/*     */             catch (IOException localIOException)
/*     */             {
/*     */             }
/*     */         }
/* 181 */         if (localClass != null) {
/* 182 */           if (_debuglvl >= 3) {
/* 183 */             System.err.println(this + ": debug: entering class " + paramArrayOfURL[i] + " (" + localClass + ") into classes cache");
/*     */           }
/* 185 */           this._hash.put(paramArrayOfURL[i].toString(), localClass);
/*     */         }
/* 187 */       } else if (_debuglvl >= 3) {
/* 188 */         System.err.println(this + ": debug: found class " + paramArrayOfURL[i] + " (" + localClass + ") in classes cache");
/*     */       }
/*     */
/* 191 */       if (localClass != null)
/*     */       {
/* 198 */         if (localClass.getSigners() == null) {
/* 199 */           setSigners(localClass, new Object[0]);
/*     */         }
/*     */
/* 207 */         if (_debuglvl >= 2) {
/* 208 */           System.err.println(this + ": debug: resolving " + localClass);
/*     */         }
/* 210 */         resolveClass(localClass);
/*     */
/* 212 */         if (!localClass.isInterface()) {
/* 213 */           localVector.addElement(localClass);
/*     */         }
/*     */       }
/*     */     }
/* 217 */     return localVector;
/*     */   }
/*     */
/*     */   static
/*     */   {
/*  42 */     boolean bool = false;
/*     */     try
/*     */     {
/*  45 */       Properties localProperties = new Properties();
/*     */       try
/*     */       {
/*  48 */         localProperties.load(new FileInputStream(new File(System.getProperty("java.home"), "lib" + File.separator + "javastuff.properties")));
/*     */       } catch (IOException localIOException1) {
/*     */       }
/*     */       try {
/*  52 */         localProperties.load(new FileInputStream(new File(System.getProperty("user.home"), "lib" + File.separator + "javastuff.properties")));
/*     */       }
/*     */       catch (IOException localIOException2) {
/*     */       }
/*     */       try {
/*  57 */         String str1 = localProperties.getProperty("bundleclassloader.debug", "0");
/*  58 */         _debuglvl = Integer.valueOf(str1).intValue();
/*     */       }
/*     */       catch (Exception localException3) {
/*     */       }
/*     */       try {
/*  63 */         String str2 = localProperties.getProperty("bundleclassloader.securitymanager", "false");
/*  64 */         bool = Boolean.valueOf(str2).booleanValue();
/*     */       }
/*     */       catch (Exception localException4)
/*     */       {
/*     */       }
/*     */     }
/*     */     catch (Exception localException1) {
/*     */     }
/*  72 */     if (bool) try {
/*  73 */         NullSecurityManager.installSystemSecurityManager();
/*     */       } catch (Exception localException2) {
/*  75 */         System.err.println("BundleClassLoader: cannot install a security manager, native code for methods might not be accessible");
/*     */       }
/*     */   }
/*     */ }

/* Location:           Z:\System\Library\Java\
* Qualified Name:     com.apple.misc.BundleClassLoader
* JD-Core Version:    0.6.2
*/
TOP

Related Classes of com.apple.misc.BundleClassLoader

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.