Top Description Inners Fields Constructors Methods
com.google.inject.internal.aop

pack-priv final Class UnsafeClassDefiner

extends Object
implements ClassDefiner
Class Inheritance
All Implemented Interfaces
com.google.inject.internal.aop.ClassDefiner
Static Imports
java.lang.reflect.Modifier.PUBLIC, org.objectweb.asm.ClassWriter.COMPUTE_MAXS, .Opcodes.ACC_SUPER, .Opcodes.ACONST_NULL, .Opcodes.ALOAD, .Opcodes.ARETURN, .Opcodes.ARRAYLENGTH, .Opcodes.CHECKCAST, .Opcodes.ICONST_0, .Opcodes.INVOKESPECIAL, .Opcodes.INVOKEVIRTUAL, .Opcodes.RETURN, .Opcodes.V1_8

ClassDefiner that defines classes using sun.misc.Unsafe.
Author
[email protected] (Stuart McCulloch)

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class

Field Summary

Modifier and TypeField and Description
private static final boolean
private static final String
private static final String
private static final String[]
private static final String
private static final Logger
private static final ClassDefiner

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv static ClassDefiner
accessDefineClass(Class<?> loaderClass)

Generates helper in same package as the ClassLoader so it can access defineClass

private static byte[]
buildDefineClassAccess(Class<?> loaderClass)

ClassLoader helper that sits in the same package and passes on defineClass requests

public static boolean
canDowncastToProxy(Class<?> hostClass)

Returns true if it's possible to downcast to proxies defined from the given host.

public static boolean
canLoadProxyByName(Class<?> hostClass)

Returns true if it's possible to load by name proxies defined from the given host.

public Class<?>
define(Class<?> hostClass, byte[] bytecode)

Implements com.google.inject.internal.aop.ClassDefiner.define.

Defines a new class relative to the host.
private static ClassDefiner
findClassDefiner(ClassLoader hostLoader)

Finds the appropriate class definer for the given class loader.

public static boolean
isAccessible()

Do we have access to sun.misc.Unsafe?

pack-priv static ClassDefiner
tryAccessDefineClass(Class<?> loaderClass)

pack-priv static <T> T
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ALWAYS_DEFINE_ANONYMOUSLYback to summary
private static final boolean ALWAYS_DEFINE_ANONYMOUSLY
BYTE_ARRAY_TYPEback to summary
private static final String BYTE_ARRAY_TYPE
CLASS_LOADER_TYPEback to summary
private static final String CLASS_LOADER_TYPE
DEFINEACCESS_APIback to summary
private static final String[] DEFINEACCESS_API
DEFINEACCESS_BY_GUICE_MARKERback to summary
private static final String DEFINEACCESS_BY_GUICE_MARKER
loggerback to summary
private static final Logger logger
UNSAFE_DEFINERback to summary
private static final ClassDefiner UNSAFE_DEFINER

Constructor Detail

UnsafeClassDefinerback to summary
pack-priv UnsafeClassDefiner()

Method Detail

accessDefineClassback to summary
pack-priv static ClassDefiner accessDefineClass(Class<?> loaderClass) throws Exception

Generates helper in same package as the ClassLoader so it can access defineClass

Annotations
@SuppressWarnings:unchecked
buildDefineClassAccessback to summary
private static byte[] buildDefineClassAccess(Class<?> loaderClass)

ClassLoader helper that sits in the same package and passes on defineClass requests

canDowncastToProxyback to summary
public static boolean canDowncastToProxy(Class<?> hostClass)

Returns true if it's possible to downcast to proxies defined from the given host.

canLoadProxyByNameback to summary
public static boolean canLoadProxyByName(Class<?> hostClass)

Returns true if it's possible to load by name proxies defined from the given host.

defineback to summary
public Class<?> define(Class<?> hostClass, byte[] bytecode) throws Exception

Implements com.google.inject.internal.aop.ClassDefiner.define.

Doc from com.google.inject.internal.aop.ClassDefiner.define.

Defines a new class relative to the host.

Annotations
@Override
findClassDefinerback to summary
private static ClassDefiner findClassDefiner(ClassLoader hostLoader)

Finds the appropriate class definer for the given class loader.

isAccessibleback to summary
public static boolean isAccessible()

Do we have access to sun.misc.Unsafe?

tryAccessDefineClassback to summary
pack-priv static ClassDefiner tryAccessDefineClass(Class<?> loaderClass)
tryPrivilegedback to summary
pack-priv static <T> T tryPrivileged(PrivilegedExceptionAction<T> action, String errorMessage)
com.google.inject.internal.aop back to summary

private Class UnsafeClassDefiner.ClassLoaderDefineClassHolder

extends Object
Class Inheritance
  • java.lang.Object
  • com.google.inject.internal.aop.UnsafeClassDefiner.ClassLoaderDefineClassHolder

Field Summary

Modifier and TypeField and Description
pack-priv static final ClassDefiner

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CLASS_LOADER_DEFINE_CLASSback to summary
pack-priv static final ClassDefiner CLASS_LOADER_DEFINE_CLASS

Constructor Detail

ClassLoaderDefineClassHolderback to summary
private ClassLoaderDefineClassHolder()
com.google.inject.internal.aop back to summary

private Class UnsafeClassDefiner.DefineClassCacheHolder

extends Object
Class Inheritance
  • java.lang.Object
  • com.google.inject.internal.aop.UnsafeClassDefiner.DefineClassCacheHolder

Field Summary

Modifier and TypeField and Description
pack-priv static final LoadingCache<Class<?>, ClassDefiner>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFINE_CLASS_CACHEback to summary
pack-priv static final LoadingCache<Class<?>, ClassDefiner> DEFINE_CLASS_CACHE

Constructor Detail

DefineClassCacheHolderback to summary
private DefineClassCacheHolder()