sun内部使用的那些东西

sun.misc.Unsafe这个类与并发相关的,提供了硬件上面的原子操作,以及一些其他的功能如:绕过所有的东西,实例化任意类的对象等等,反正Unsafe这个类很重要。

sun.reflect.ReflectionFactory:反射那块使用。

sun.misc.ProxyGenerator: 生成代理类。

 public static byte[] generateProxyClass(final String name,

      320                                             Class[] interfaces)
      321     {
      322         ProxyGenerator gen = new ProxyGenerator(name, interfaces);
      323         final byte[] classFile = gen.generateClassFile();
      324
      325         if (saveGeneratedFiles) {
      326             java.security.AccessController.doPrivileged(
      327             new java.security.PrivilegedAction() {
      328                 public Object run() {
      329                     try {
      330                         FileOutputStream file =
      331                             new FileOutputStream(dotToSlash(name) + ".class");
      332                         file.write(classFile);
      333                         file.close();
      334                         return null;
      335                     } catch (IOException e) {
      336                         throw new InternalError(
      337                             "I/O exception saving generated file: " + e);
      338                     }
      339                 }
      340             });
      341         }
      342
      343         return classFile;
      344     }

sun.misc.Launcher这个类与classloader相关的。看看下面代码:

/**

      246      * The class loader used for loading from java.class.path.
      247      * runs in a restricted security context.
      248      */
      249     static class AppClassLoader extends URLClassLoader {
      250
      251         public static ClassLoader getAppClassLoader(final ClassLoader extcl)
      252             throws IOException
      253         {
      254             final String s = System.getProperty("java.class.path");
      255             final File[] path = (s == null) ? new File[0] : getClassPath(s);
      256
      257             // Note: on bugid 4256530
      258             // Prior implementations of this doPrivileged() block supplied
      259             // a rather restrictive ACC via a call to the private method
      260             // AppClassLoader.getContext(). This proved overly restrictive
      261             // when loading  classes. Specifically it prevent
      262             // accessClassInPackage.sun.* grants from being honored.
      263             //
      264             return (AppClassLoader)
      265                 AccessController.doPrivileged(new PrivilegedAction() {
      266                 public Object run() {
      267                     URL[] urls =
      268                         (s == null) ? new URL[0] : pathToURLs(path);
      269                     return new AppClassLoader(urls, extcl);
      270                 }
      271             });
      272         }
      273
      274         /*
      275          * Creates a new AppClassLoader
      276          */
      277         AppClassLoader(URL[] urls, ClassLoader parent) {
      278             super(urls, parent, factory);
      279         }
      280

 

http://hg.openjdk.java.net/jdk6/jdk6/jdk/file/tip/src/share/classes/sun/

你可能感兴趣的:(sun内部使用的那些东西)