InvocationTargetException,
InstantiationException,
NoSuchFieldException {
FieldVisitor fv;
MethodVisitor mv;
// get the method bitmask
BitSet mask = traitRegistry.getFieldMask( getTrait().getName(), core.getDefinedClass().getName() );
String name = TraitFactory.getPropertyWrapperName( getTrait(), core );
String masterName = TraitFactory.getProxyName( getTrait(), core );
String internalWrapper = BuildUtils.getInternalType(name);
String internalProxy = BuildUtils.getInternalType(masterName);
String internalCore = Type.getInternalName(core.getDefinedClass());
String descrCore = Type.getDescriptor(core.getDefinedClass());
String internalTrait = Type.getInternalName(getTrait().getDefinedClass());
Class mixinClass = null;
String mixin = null;
Set<Method> mixinMethods = new HashSet<Method>();
Map<String,Method> mixinGetSet = new HashMap<String,Method>();
try {
if ( getTrait().getDefinedClass() != null ) {
Trait annTrait = getAnnotation( getTrait().getDefinedClass(), Trait.class );
if ( hasImpl( annTrait ) ) {
mixinClass = annTrait.impl();
mixin = mixinClass.getSimpleName().substring(0,1).toLowerCase() + mixinClass.getSimpleName().substring(1);
ClassFieldInspector cfi = new ClassFieldInspector( mixinClass );
for ( Method m : mixinClass.getMethods() ) {
try {
getTrait().getDefinedClass().getMethod(m.getName(), m.getParameterTypes() );
if ( cfi.getGetterMethods().containsValue( m )
|| cfi.getSetterMethods().containsValue( m )) {
mixinGetSet.put( m.getName(), m );
} else {
mixinMethods.add( m );
}
} catch ( NoSuchMethodException e ) {
}
}
}
}
} catch ( Exception e ) {
e.printStackTrace();
}
ClassWriter cw = createClassWriter( classLoader,
ACC_PUBLIC + ACC_SUPER,
internalProxy,
null,
Type.getInternalName( proxyBaseClass ),
new String[] { internalTrait, Type.getInternalName( Externalizable.class ) } );
{
fv = cw.visitField( ACC_PRIVATE + ACC_FINAL + ACC_STATIC,
TraitType.traitNameField, Type.getDescriptor( String.class ),
null, null );
fv.visitEnd();
}
{
fv = cw.visitField( ACC_PUBLIC, "object", descrCore, null, null );
fv.visitEnd();
}
{
fv = cw.visitField( ACC_PRIVATE, "store", Type.getDescriptor( TripleStore.class ), null, null );
fv.visitEnd();
}
{
fv = cw.visitField( ACC_PRIVATE, "storeId", Type.getDescriptor( String.class ), null, null);
fv.visitEnd();
}
if ( mixinClass != null ) {
{
fv = cw.visitField( ACC_PRIVATE,
mixin,
Type.getDescriptor( mixinClass ),
null, null);
fv.visitEnd();
}
}
{
mv = cw.visitMethod( ACC_STATIC, "<clinit>", "()V", null, null );