use of org.mvel2.asm.FieldVisitor in project mvel by mikebrock.
the class TraceClassVisitor method visitField.
public FieldVisitor visitField(final int access, final String name, final String desc, final String signature, final Object value) {
buf.setLength(0);
buf.append('\n');
if ((access & Opcodes.ACC_DEPRECATED) != 0) {
buf.append(tab).append("// DEPRECATED\n");
}
buf.append(tab).append("// access flags ").append(access).append('\n');
if (signature != null) {
buf.append(tab);
appendDescriptor(FIELD_SIGNATURE, signature);
TraceSignatureVisitor sv = new TraceSignatureVisitor(0);
SignatureReader r = new SignatureReader(signature);
r.acceptType(sv);
buf.append(tab).append("// declaration: ").append(sv.getDeclaration()).append('\n');
}
buf.append(tab);
appendAccess(access);
appendDescriptor(FIELD_DESCRIPTOR, desc);
buf.append(' ').append(name);
if (value != null) {
buf.append(" = ");
if (value instanceof String) {
buf.append("\"").append(value).append("\"");
} else {
buf.append(value);
}
}
buf.append('\n');
text.add(buf.toString());
TraceFieldVisitor tav = createTraceFieldVisitor();
text.add(tav.getText());
if (cv != null) {
tav.fv = cv.visitField(access, name, desc, signature, value);
}
return tav;
}
use of org.mvel2.asm.FieldVisitor in project drools by kiegroup.
the class TraitMapPropertyWrapperClassBuilderImpl method buildClass.
public byte[] buildClass(ClassDefinition core, ClassLoader classLoader) throws IOException, SecurityException, IllegalArgumentException, ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException, NoSuchFieldException {
FieldVisitor fv;
MethodVisitor mv;
// get the method bitmask
BitSet mask = traitRegistryImpl.getFieldMask(trait.getName(), core.getDefinedClass().getName());
String name = TraitFactoryImpl.getPropertyWrapperName(trait, core);
String internalWrapper = BuildUtils.getInternalType(name);
String descrCore = Type.getDescriptor(core.getDefinedClass());
String internalCore = Type.getInternalName(core.getDefinedClass());
ClassWriter cw = createClassWriter(classLoader, ACC_PUBLIC + ACC_SUPER, internalWrapper, Type.getDescriptor(Object.class) + Type.getDescriptor(Map.class) + Type.getDescriptor(MapWrapper.class), // "Ljava/lang/Object;Ljava/util/Map<Ljava/lang/String;Ljava/lang/Object;>;Lorg/drools/factmodel/traits/MapWrapper;",
Type.getInternalName(Object.class), new String[] { Type.getInternalName(Map.class), Type.getInternalName(MapWrapper.class), Type.getInternalName(Serializable.class) });
cw.visitInnerClass(Type.getInternalName(Map.Entry.class), Type.getInternalName(Map.class), "Entry", ACC_PUBLIC + ACC_STATIC + ACC_ABSTRACT + ACC_INTERFACE);
{
fv = cw.visitField(0, "object", descrCore, null, null);
fv.visitEnd();
}
{
fv = cw.visitField(0, "map", Type.getDescriptor(Map.class), "Ljava/util/Map<Ljava/lang/String;Ljava/lang/Object;>;", null);
fv.visitEnd();
}
{
mv = cw.visitMethod(ACC_PUBLIC, "<init>", "(" + descrCore + Type.getDescriptor(Map.class) + ")V", "(" + descrCore + "Ljava/util/Map<Ljava/lang/String;Ljava/lang/Object;>;)V", null);
mv.visitCode();
mv.visitVarInsn(ALOAD, 0);
mv.visitMethodInsn(INVOKESPECIAL, Type.getInternalName(Object.class), "<init>", "()V", false);
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ALOAD, 1);
mv.visitFieldInsn(PUTFIELD, internalWrapper, "object", descrCore);
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ALOAD, 2);
mv.visitFieldInsn(PUTFIELD, internalWrapper, "map", Type.getDescriptor(Map.class));
mv.visitVarInsn(ALOAD, 1);
mv.visitVarInsn(ALOAD, 2);
mv.visitMethodInsn(INVOKEVIRTUAL, internalCore, "_setDynamicProperties", "(" + Type.getDescriptor(Map.class) + ")V", false);
initSoftFields(mv, trait, core, internalWrapper, mask, 2);
mv.visitInsn(RETURN);
mv.visitMaxs(0, 0);
mv.visitEnd();
}
buildSize(cw, name, core);
buildIsEmpty(cw, name, core);
buildGet(cw, name, core);
buildPut(cw, name, core);
buildClear(cw, name, trait, core, mask);
buildRemove(cw, name, trait, core, mask);
buildContainsKey(cw, name, core);
buildContainsValue(cw, name, trait, core);
buildKeyset(cw, name, core);
buildValues(cw, name, core);
buildEntryset(cw, name, core);
buildCommonMethods(cw, name);
cw.visitEnd();
return cw.toByteArray();
}
use of org.mvel2.asm.FieldVisitor in project drools by kiegroup.
the class TraitTriplePropertyWrapperClassBuilderImpl method buildClass.
public byte[] buildClass(ClassDefinition core, ClassLoader classLoader) throws IOException, SecurityException, IllegalArgumentException, ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException, NoSuchFieldException {
FieldVisitor fv;
MethodVisitor mv;
// get the method bitmask
BitSet mask = traitRegistryImpl.getFieldMask(trait.getName(), core.getDefinedClass().getName());
String name = TraitFactoryImpl.getPropertyWrapperName(trait, core);
String internalWrapper = BuildUtils.getInternalType(name);
String descrCore = Type.getDescriptor(core.getDefinedClass());
ClassWriter cw = createClassWriter(classLoader, ACC_PUBLIC + ACC_SUPER, internalWrapper, null, Type.getInternalName(TripleBasedStruct.class), new String[] { Type.getInternalName(Serializable.class) });
cw.visitInnerClass(Type.getInternalName(Map.Entry.class), Type.getInternalName(Map.class), "Entry", ACC_PUBLIC + ACC_STATIC + ACC_ABSTRACT + ACC_INTERFACE);
{
fv = cw.visitField(0, "object", descrCore, null, null);
fv.visitEnd();
}
{
mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
mv.visitCode();
mv.visitVarInsn(ALOAD, 0);
mv.visitMethodInsn(INVOKESPECIAL, Type.getInternalName(TripleBasedStruct.class), "<init>", "()V", false);
mv.visitInsn(RETURN);
mv.visitMaxs(0, 0);
mv.visitEnd();
}
{
mv = cw.visitMethod(ACC_PUBLIC, "<init>", "(" + descrCore + Type.getDescriptor(TripleStore.class) + Type.getDescriptor(TripleFactory.class) + ")V", null, null);
mv.visitCode();
mv.visitVarInsn(ALOAD, 0);
mv.visitMethodInsn(INVOKESPECIAL, Type.getInternalName(TripleBasedStruct.class), "<init>", "()V", false);
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ALOAD, 1);
mv.visitFieldInsn(PUTFIELD, internalWrapper, "object", descrCore);
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ALOAD, 2);
mv.visitFieldInsn(PUTFIELD, internalWrapper, "store", Type.getDescriptor(TripleStore.class));
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ALOAD, 3);
mv.visitMethodInsn(INVOKEVIRTUAL, Type.getInternalName(TripleBasedStruct.class), "setTripleFactory", "(" + Type.getDescriptor(TripleFactory.class) + ")V", false);
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ALOAD, 2);
mv.visitMethodInsn(INVOKEVIRTUAL, Type.getInternalName(TripleStore.class), "getId", "()" + Type.getDescriptor(String.class), false);
mv.visitFieldInsn(PUTFIELD, internalWrapper, "storeId", Type.getDescriptor(String.class));
mv.visitVarInsn(ALOAD, 0);
mv.visitMethodInsn(INVOKESPECIAL, internalWrapper, "initSoftFields", "()V", false);
mv.visitInsn(RETURN);
mv.visitMaxs(0, 0);
mv.visitEnd();
}
buildInitSoftFields(cw, internalWrapper, trait, core, mask);
buildClearSoftFields(cw, internalWrapper, trait, mask);
buildSize(cw, core);
buildIsEmpty(cw, core);
buildGet(cw, name, core);
buildPut(cw, name, core);
buildClear(cw, name, trait, core);
buildRemove(cw, name, trait, core, mask);
buildContainsKey(cw, core);
buildContainsValue(cw, name, core);
buildKeyset(cw, core);
buildValues(cw, name, core);
buildEntryset(cw, name, core);
buildCommonMethods(cw, name);
buildSpecificMethods(cw, name, core);
cw.visitEnd();
return cw.toByteArray();
}
use of org.mvel2.asm.FieldVisitor in project drools by kiegroup.
the class TraitTripleProxyClassBuilderImpl method buildClass.
public byte[] buildClass(ClassDefinition core, ClassLoader classLoader) throws IOException, SecurityException, IllegalArgumentException, ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException, NoSuchFieldException {
FieldVisitor fv;
MethodVisitor mv;
// get the method bitmask
BitSet mask = traitRegistryImpl.getFieldMask(getTrait().getName(), core.getDefinedClass().getName());
String name = TraitFactoryImpl.getPropertyWrapperName(getTrait(), core);
String proxyName = TraitFactoryImpl.getProxyName(getTrait(), core);
Class<?> traitClass = getTrait().getDefinedClass();
String internalWrapper = BuildUtils.getInternalType(name);
String internalProxy = BuildUtils.getInternalType(proxyName);
String internalCore = Type.getInternalName(core.getDefinedClass());
String descrCore = Type.getDescriptor(core.getDefinedClass());
String internalTrait = Type.getInternalName(getTrait().getDefinedClass());
MixinInfo mixinInfo = findMixinInfo(traitClass);
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 (mixinInfo != null) {
for (Class<?> mixinClass : mixinInfo.mixinClasses) {
{
fv = cw.visitField(ACC_PRIVATE, getMixinName(mixinClass), Type.getDescriptor(mixinClass), null, null);
fv.visitEnd();
}
}
}
{
mv = cw.visitMethod(ACC_PUBLIC, "<init>", "(" + descrCore + Type.getDescriptor(TripleStore.class) + Type.getDescriptor(TripleFactory.class) + Type.getDescriptor(BitSet.class) + Type.getDescriptor(BitSet.class) + Type.getDescriptor(boolean.class) + ")V", null, null);
mv.visitCode();
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ALOAD, 2);
mv.visitMethodInsn(INVOKEVIRTUAL, Type.getInternalName(TripleStore.class), "getId", "()" + Type.getDescriptor(String.class), false);
mv.visitFieldInsn(PUTFIELD, internalProxy, "storeId", Type.getDescriptor(String.class));
buildConstructorCore(mv, internalProxy, internalWrapper, internalCore, descrCore, mixinInfo);
initFields(mv, internalProxy);
mv.visitInsn(RETURN);
mv.visitMaxs(0, 0);
mv.visitEnd();
}
{
mv = cw.visitMethod(ACC_PUBLIC, "setObject", "(" + Type.getDescriptor(Object.class) + ")V", null, null);
mv.visitCode();
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ALOAD, 1);
mv.visitTypeInsn(CHECKCAST, internalCore);
mv.visitFieldInsn(PUTFIELD, internalProxy, "object", descrCore);
mv.visitInsn(RETURN);
mv.visitMaxs(0, 0);
mv.visitEnd();
}
{
mv = cw.visitMethod(ACC_PUBLIC, "writeExternal", "(" + Type.getDescriptor(ObjectOutput.class) + ")V", null, new String[] { Type.getInternalName(IOException.class) });
mv.visitCode();
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ALOAD, 1);
mv.visitMethodInsn(INVOKESPECIAL, Type.getInternalName(proxyBaseClass), "writeExternal", "(" + Type.getDescriptor(ObjectOutput.class) + ")V", false);
mv.visitVarInsn(ALOAD, 1);
mv.visitVarInsn(ALOAD, 0);
mv.visitMethodInsn(INVOKEVIRTUAL, internalProxy, "getObject", "()" + Type.getDescriptor(TraitableBean.class), false);
mv.visitMethodInsn(INVOKEINTERFACE, Type.getInternalName(ObjectOutput.class), "writeObject", "(" + Type.getDescriptor(Object.class) + ")V", true);
mv.visitVarInsn(ALOAD, 1);
mv.visitVarInsn(ALOAD, 0);
mv.visitFieldInsn(GETFIELD, internalProxy, "storeId", Type.getDescriptor(String.class));
mv.visitMethodInsn(INVOKEINTERFACE, Type.getInternalName(ObjectOutput.class), "writeObject", "(" + Type.getDescriptor(Object.class) + ")V", true);
mv.visitVarInsn(ALOAD, 1);
mv.visitVarInsn(ALOAD, 0);
mv.visitFieldInsn(GETFIELD, internalProxy, "store", Type.getDescriptor(TripleStore.class));
mv.visitMethodInsn(INVOKEINTERFACE, Type.getInternalName(ObjectOutput.class), "writeObject", "(" + Type.getDescriptor(Object.class) + ")V", true);
mv.visitInsn(RETURN);
// mv.visitMaxs( 2, 2 );
mv.visitMaxs(0, 0);
mv.visitEnd();
}
{
mv = cw.visitMethod(ACC_PUBLIC, "readExternal", "(" + Type.getDescriptor(ObjectInput.class) + ")V", null, new String[] { Type.getInternalName(IOException.class), Type.getInternalName(ClassNotFoundException.class) });
mv.visitCode();
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ALOAD, 1);
mv.visitMethodInsn(INVOKESPECIAL, Type.getInternalName(proxyBaseClass), "readExternal", "(" + Type.getDescriptor(ObjectInput.class) + ")V", false);
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ALOAD, 1);
mv.visitMethodInsn(INVOKEINTERFACE, Type.getInternalName(ObjectInput.class), "readObject", "()" + Type.getDescriptor(Object.class), true);
mv.visitTypeInsn(CHECKCAST, internalCore);
mv.visitFieldInsn(PUTFIELD, internalProxy, "object", descrCore);
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ALOAD, 1);
mv.visitMethodInsn(INVOKEINTERFACE, Type.getInternalName(ObjectInput.class), "readObject", "()" + Type.getDescriptor(Object.class), true);
mv.visitTypeInsn(CHECKCAST, Type.getInternalName(String.class));
mv.visitFieldInsn(PUTFIELD, internalProxy, "storeId", Type.getDescriptor(String.class));
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ALOAD, 1);
mv.visitMethodInsn(INVOKEINTERFACE, Type.getInternalName(ObjectInput.class), "readObject", "()" + Type.getDescriptor(Object.class), true);
mv.visitTypeInsn(CHECKCAST, Type.getInternalName(TripleStore.class));
mv.visitFieldInsn(PUTFIELD, internalProxy, "store", Type.getDescriptor(TripleStore.class));
mv.visitInsn(RETURN);
// mv.visitMaxs( 3, 2 );
mv.visitMaxs(0, 0);
mv.visitEnd();
}
helpBuildClass(core, cw, internalProxy, descrCore, mask);
buildProxyAccessors(mask, cw, proxyName, core, mixinInfo);
boolean hasKeys = false;
for (FactField ff : getTrait().getFields()) {
if (ff.isKey()) {
hasKeys = true;
break;
}
}
if (!hasKeys) {
buildEqualityMethods(cw, proxyName, core.getClassName());
} else {
buildKeyedEqualityMethods(cw, getTrait(), proxyName);
}
buildMixinMethods(proxyName, mixinInfo, cw);
buildCommonMethods(cw, proxyName);
buildExtendedMethods(cw, getTrait(), core);
buildShadowMethods(cw, trait, core);
cw.visitEnd();
return cw.toByteArray();
}
use of org.mvel2.asm.FieldVisitor in project drools by kiegroup.
the class TraitMapProxyClassBuilderImpl method buildClass.
public byte[] buildClass(ClassDefinition core, ClassLoader classLoader) throws IOException, SecurityException, IllegalArgumentException, ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException, NoSuchFieldException {
FieldVisitor fv;
MethodVisitor mv;
// get the method bitmask
BitSet mask = traitRegistryImpl.getFieldMask(getTrait().getName(), core.getDefinedClass().getName());
String name = TraitFactoryImpl.getPropertyWrapperName(getTrait(), core);
String proxyName = TraitFactoryImpl.getProxyName(getTrait(), core);
Class<?> traitClass = getTrait().getDefinedClass();
String internalWrapper = BuildUtils.getInternalType(name);
String internalProxy = BuildUtils.getInternalType(proxyName);
String descrCore = Type.getDescriptor(core.getDefinedClass());
String internalCore = Type.getInternalName(core.getDefinedClass());
String internalTrait = Type.getInternalName(traitClass);
MixinInfo mixinInfo = findMixinInfo(traitClass);
ClassWriter cw = createClassWriter(classLoader, ACC_PUBLIC + ACC_SUPER, internalProxy, null, Type.getInternalName(proxyBaseClass), new String[] { internalTrait, Type.getInternalName(Serializable.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_PUBLIC, "map", Type.getDescriptor(Map.class), "Ljava/util/Map<Ljava/lang/String;Ljava/lang/Object;>;", null);
fv.visitEnd();
}
if (mixinInfo != null) {
for (Class<?> mixinClass : mixinInfo.mixinClasses) {
{
fv = cw.visitField(ACC_PRIVATE, getMixinName(mixinClass), BuildUtils.getTypeDescriptor(mixinClass.getName()), null, null);
fv.visitEnd();
}
}
}
{
mv = cw.visitMethod(ACC_PUBLIC, "<init>", "(" + descrCore + Type.getDescriptor(Map.class) + Type.getDescriptor(BitSet.class) + Type.getDescriptor(BitSet.class) + Type.getDescriptor(boolean.class) + ")V", "(" + descrCore + "Ljava/util/Map<Ljava/lang/String;Ljava/lang/Object;>;" + Type.getDescriptor(BitSet.class) + Type.getDescriptor(BitSet.class) + Type.getDescriptor(boolean.class) + ")V", null);
mv.visitCode();
mv.visitVarInsn(ALOAD, 0);
mv.visitMethodInsn(INVOKESPECIAL, Type.getInternalName(proxyBaseClass), "<init>", "()V", false);
mv.visitVarInsn(ALOAD, 2);
Label l0 = new Label();
mv.visitJumpInsn(IFNONNULL, l0);
mv.visitTypeInsn(NEW, Type.getInternalName(ExternalizableLinkedHashMap.class));
mv.visitInsn(DUP);
mv.visitMethodInsn(INVOKESPECIAL, Type.getInternalName(ExternalizableLinkedHashMap.class), "<init>", "()V", false);
mv.visitVarInsn(ASTORE, 2);
mv.visitLabel(l0);
if (mixinInfo != null) {
for (Class<?> mixinClass : mixinInfo.mixinClasses) {
String mixin = getMixinName(mixinClass);
try {
Class actualArg = getPossibleConstructor(mixinClass, trait.getDefinedClass());
mv.visitVarInsn(ALOAD, 0);
mv.visitTypeInsn(NEW, Type.getInternalName(mixinClass));
mv.visitInsn(DUP);
mv.visitVarInsn(ALOAD, 0);
mv.visitMethodInsn(INVOKESPECIAL, Type.getInternalName(mixinClass), "<init>", "(" + Type.getDescriptor(actualArg) + ")V", false);
mv.visitFieldInsn(PUTFIELD, internalProxy, mixin, Type.getDescriptor(mixinClass));
} catch (NoSuchMethodException nsme) {
mv.visitVarInsn(ALOAD, 0);
mv.visitTypeInsn(NEW, Type.getInternalName(mixinClass));
mv.visitInsn(DUP);
mv.visitMethodInsn(INVOKESPECIAL, Type.getInternalName(mixinClass), "<init>", "()V", false);
mv.visitFieldInsn(PUTFIELD, internalProxy, mixin, Type.getDescriptor(mixinClass));
}
}
}
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ALOAD, 1);
mv.visitFieldInsn(PUTFIELD, internalProxy, "object", descrCore);
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ALOAD, 2);
mv.visitFieldInsn(PUTFIELD, internalProxy, "map", Type.getDescriptor(Map.class));
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ALOAD, 3);
mv.visitMethodInsn(INVOKEVIRTUAL, internalProxy, "setTypeCode", Type.getMethodDescriptor(Type.VOID_TYPE, Type.getType(BitSet.class)), false);
mv.visitVarInsn(ALOAD, 0);
mv.visitTypeInsn(NEW, internalWrapper);
mv.visitInsn(DUP);
mv.visitVarInsn(ALOAD, 1);
mv.visitVarInsn(ALOAD, 2);
mv.visitMethodInsn(INVOKESPECIAL, internalWrapper, "<init>", "(" + descrCore + Type.getDescriptor(Map.class) + ")V", false);
mv.visitFieldInsn(PUTFIELD, internalProxy, "fields", Type.getDescriptor(Map.class));
mv.visitVarInsn(ALOAD, 1);
mv.visitMethodInsn(INVOKEVIRTUAL, internalCore, "_getDynamicProperties", "()" + Type.getDescriptor(Map.class), false);
Label l1 = new Label();
mv.visitJumpInsn(IFNONNULL, l1);
mv.visitVarInsn(ALOAD, 1);
mv.visitVarInsn(ALOAD, 2);
mv.visitMethodInsn(INVOKEVIRTUAL, internalCore, "_setDynamicProperties", "(" + Type.getDescriptor(Map.class) + ")V", false);
mv.visitLabel(l1);
mv.visitVarInsn(ALOAD, 1);
mv.visitMethodInsn(INVOKEVIRTUAL, internalCore, "_getTraitMap", "()" + Type.getDescriptor(Map.class), false);
Label l2 = new Label();
mv.visitJumpInsn(IFNONNULL, l2);
mv.visitVarInsn(ALOAD, 1);
mv.visitTypeInsn(NEW, Type.getInternalName(TraitTypeMapImpl.class));
mv.visitInsn(DUP);
mv.visitTypeInsn(NEW, Type.getInternalName(ExternalizableLinkedHashMap.class));
mv.visitInsn(DUP);
mv.visitMethodInsn(INVOKESPECIAL, Type.getInternalName(ExternalizableLinkedHashMap.class), "<init>", "()V", false);
mv.visitMethodInsn(INVOKESPECIAL, Type.getInternalName(TraitTypeMapImpl.class), "<init>", "(" + Type.getDescriptor(Map.class) + ")V", false);
mv.visitMethodInsn(INVOKEVIRTUAL, internalCore, "_setTraitMap", "(" + Type.getDescriptor(Map.class) + ")V", false);
mv.visitLabel(l2);
// core._setBottomTypeCode()
mv.visitVarInsn(ALOAD, 1);
mv.visitVarInsn(ALOAD, 4);
mv.visitMethodInsn(INVOKEVIRTUAL, internalCore, "_setBottomTypeCode", Type.getMethodDescriptor(Type.VOID_TYPE, Type.getType(BitSet.class)), false);
// core.addTrait
mv.visitVarInsn(ALOAD, 1);
mv.visitLdcInsn(trait.getName().endsWith(TraitFactoryImpl.SUFFIX) ? trait.getName().replace(TraitFactoryImpl.SUFFIX, "") : trait.getName());
mv.visitVarInsn(ALOAD, 0);
mv.visitMethodInsn(INVOKEVIRTUAL, internalCore, "addTrait", Type.getMethodDescriptor(Type.VOID_TYPE, Type.getType(String.class), Type.getType(Thing.class)), false);
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ILOAD, 5);
mv.visitMethodInsn(INVOKESPECIAL, internalProxy, "synchFields", Type.getMethodDescriptor(Type.VOID_TYPE, Type.BOOLEAN_TYPE), false);
mv.visitInsn(RETURN);
// mv.visitMaxs( 5, 3 );
mv.visitMaxs(0, 0);
mv.visitEnd();
}
{
mv = cw.visitMethod(ACC_PUBLIC, "writeExternal", "(" + Type.getDescriptor(ObjectOutput.class) + ")V", null, new String[] { Type.getInternalName(IOException.class) });
mv.visitCode();
mv.visitVarInsn(ALOAD, 1);
mv.visitVarInsn(ALOAD, 0);
mv.visitMethodInsn(INVOKEVIRTUAL, internalProxy, "getObject", "()" + Type.getDescriptor(TraitableBean.class), false);
mv.visitMethodInsn(INVOKEINTERFACE, Type.getInternalName(ObjectOutput.class), "writeObject", "(" + Type.getDescriptor(Object.class) + ")V", true);
mv.visitVarInsn(ALOAD, 1);
mv.visitVarInsn(ALOAD, 0);
mv.visitFieldInsn(GETFIELD, internalProxy, "map", Type.getDescriptor(Map.class));
mv.visitMethodInsn(INVOKEINTERFACE, Type.getInternalName(ObjectOutput.class), "writeObject", "(" + Type.getDescriptor(Object.class) + ")V", true);
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ALOAD, 1);
mv.visitMethodInsn(INVOKESPECIAL, Type.getInternalName(proxyBaseClass), "writeExternal", "(" + Type.getDescriptor(ObjectOutput.class) + ")V", false);
mv.visitInsn(RETURN);
mv.visitMaxs(0, 0);
mv.visitEnd();
}
{
mv = cw.visitMethod(ACC_PUBLIC, "readExternal", "(" + Type.getDescriptor(ObjectInput.class) + ")V", null, new String[] { Type.getInternalName(IOException.class), Type.getInternalName(ClassNotFoundException.class) });
mv.visitCode();
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ALOAD, 1);
mv.visitMethodInsn(INVOKEINTERFACE, Type.getInternalName(ObjectInput.class), "readObject", "()" + Type.getDescriptor(Object.class), true);
mv.visitTypeInsn(CHECKCAST, internalCore);
mv.visitFieldInsn(PUTFIELD, internalProxy, "object", descrCore);
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ALOAD, 1);
mv.visitMethodInsn(INVOKEINTERFACE, Type.getInternalName(ObjectInput.class), "readObject", "()" + Type.getDescriptor(Object.class), true);
mv.visitTypeInsn(CHECKCAST, Type.getInternalName(Map.class));
mv.visitFieldInsn(PUTFIELD, internalProxy, "map", Type.getDescriptor(Map.class));
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ALOAD, 1);
mv.visitMethodInsn(INVOKESPECIAL, Type.getInternalName(proxyBaseClass), "readExternal", "(" + Type.getDescriptor(ObjectInput.class) + ")V", false);
mv.visitInsn(RETURN);
// mv.visitMaxs( 3, 2 );
mv.visitMaxs(0, 0);
mv.visitEnd();
}
helpBuildClass(core, cw, internalProxy, descrCore, mask);
buildFields(core, mask, proxyName, mixinInfo, cw);
buildKeys(core, proxyName, cw);
buildMixinMethods(proxyName, mixinInfo, cw);
buildCommonMethods(cw, proxyName);
buildExtendedMethods(cw, trait, core);
buildShadowMethods(cw, trait, core);
cw.visitEnd();
return cw.toByteArray();
}
Aggregations