Search in sources :

Example 16 with ClassWriter

use of org.mvel2.asm.ClassWriter in project drools by kiegroup.

the class TraitTriplePropertyWrapperClassBuilderImpl method buildContainsKey.

protected void buildContainsKey(ClassWriter cw, ClassDefinition core) {
    MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "containsKey", "(" + Type.getDescriptor(Object.class) + ")Z", null, null);
    mv.visitCode();
    for (FieldDefinition field : core.getFieldsDefinitions()) {
        invokeContainsKey(mv, field.getName());
    }
    mv.visitVarInsn(ALOAD, 0);
    mv.visitVarInsn(ALOAD, 1);
    mv.visitMethodInsn(INVOKESPECIAL, Type.getInternalName(TripleBasedStruct.class), "containsKey", "(" + Type.getDescriptor(Object.class) + ")Z", false);
    mv.visitInsn(IRETURN);
    mv.visitMaxs(0, 0);
    mv.visitEnd();
}
Also used : FieldDefinition(org.drools.core.factmodel.FieldDefinition) MethodVisitor(org.mvel2.asm.MethodVisitor)

Example 17 with ClassWriter

use of org.mvel2.asm.ClassWriter in project drools by kiegroup.

the class DefaultBeanClassBuilder method implementReactivity.

private void implementReactivity(ClassWriter cw, ClassDefinition classDef) {
    final String LEFT_TUPLES_FIELD_NAME = "_lts";
    final String TYPE_NAME = BuildUtils.getInternalType(classDef.getClassName());
    FieldVisitor fv;
    /*
            private Collection<Tuple> _lts;
         */
    {
        fv = cw.visitField(ACC_PRIVATE, LEFT_TUPLES_FIELD_NAME, "Ljava/util/Collection;", "Ljava/util/Collection<Lorg/drools/core/spi/Tuple;>;", null);
        fv.visitEnd();
    }
    MethodVisitor mv;
    /*
            public void addLeftTuple(Tuple leftTuple) {
                if (_lts == null) {
                    _lts = new HashSet<Tuple>();
                }
                _lts.add(leftTuple);
            }
         */
    {
        mv = cw.visitMethod(ACC_PUBLIC, "addLeftTuple", "(Lorg/drools/core/spi/Tuple;)V", null, null);
        mv.visitCode();
        Label l0 = new Label();
        mv.visitLabel(l0);
        mv.visitLineNumber(30, l0);
        mv.visitVarInsn(ALOAD, 0);
        mv.visitFieldInsn(GETFIELD, TYPE_NAME, LEFT_TUPLES_FIELD_NAME, "Ljava/util/Collection;");
        Label l1 = new Label();
        mv.visitJumpInsn(IFNONNULL, l1);
        Label l2 = new Label();
        mv.visitLabel(l2);
        mv.visitLineNumber(31, l2);
        mv.visitVarInsn(ALOAD, 0);
        mv.visitTypeInsn(NEW, "java/util/HashSet");
        mv.visitInsn(DUP);
        mv.visitMethodInsn(INVOKESPECIAL, "java/util/HashSet", "<init>", "()V", false);
        mv.visitFieldInsn(PUTFIELD, TYPE_NAME, LEFT_TUPLES_FIELD_NAME, "Ljava/util/Collection;");
        mv.visitLabel(l1);
        mv.visitLineNumber(33, l1);
        mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null);
        mv.visitVarInsn(ALOAD, 0);
        mv.visitFieldInsn(GETFIELD, TYPE_NAME, LEFT_TUPLES_FIELD_NAME, "Ljava/util/Collection;");
        mv.visitVarInsn(ALOAD, 1);
        mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Collection", "add", "(Ljava/lang/Object;)Z", true);
        mv.visitInsn(POP);
        Label l3 = new Label();
        mv.visitLabel(l3);
        mv.visitLineNumber(34, l3);
        mv.visitInsn(RETURN);
        Label l4 = new Label();
        mv.visitLabel(l4);
        mv.visitLocalVariable("this", "L" + TYPE_NAME + ";", null, l0, l4, 0);
        mv.visitLocalVariable("leftTuple", "Lorg/drools/core/spi/Tuple;", null, l0, l4, 1);
        mv.visitMaxs(3, 2);
        mv.visitEnd();
    }
    /*
            public Collection<Tuple> getLeftTuples() {             
                return _lts != null ? _lts : Collections.emptyList();
            }                                                      
         */
    {
        mv = cw.visitMethod(ACC_PUBLIC, "getLeftTuples", "()Ljava/util/Collection;", "()Ljava/util/Collection<Lorg/drools/core/spi/Tuple;>;", null);
        mv.visitCode();
        Label l0 = new Label();
        mv.visitLabel(l0);
        mv.visitLineNumber(37, l0);
        mv.visitVarInsn(ALOAD, 0);
        mv.visitFieldInsn(GETFIELD, TYPE_NAME, LEFT_TUPLES_FIELD_NAME, "Ljava/util/Collection;");
        Label l1 = new Label();
        mv.visitJumpInsn(IFNULL, l1);
        mv.visitVarInsn(ALOAD, 0);
        mv.visitFieldInsn(GETFIELD, TYPE_NAME, LEFT_TUPLES_FIELD_NAME, "Ljava/util/Collection;");
        Label l2 = new Label();
        mv.visitJumpInsn(GOTO, l2);
        mv.visitLabel(l1);
        mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null);
        mv.visitMethodInsn(INVOKESTATIC, "java/util/Collections", "emptyList", "()Ljava/util/List;", false);
        mv.visitLabel(l2);
        mv.visitFrame(Opcodes.F_SAME1, 0, null, 1, new Object[] { "java/util/Collection" });
        mv.visitInsn(ARETURN);
        Label l3 = new Label();
        mv.visitLabel(l3);
        mv.visitLocalVariable("this", "L" + TYPE_NAME + ";", null, l0, l3, 0);
        mv.visitMaxs(1, 1);
        mv.visitEnd();
    }
    /*
            protected void notifyModification() {           
                ReactiveObjectUtil.notifyModification(this);
            }                                               
         */
    {
        mv = cw.visitMethod(ACC_PROTECTED, "notifyModification", "()V", null, null);
        mv.visitCode();
        Label l0 = new Label();
        mv.visitLabel(l0);
        mv.visitLineNumber(41, l0);
        mv.visitVarInsn(ALOAD, 0);
        mv.visitMethodInsn(INVOKESTATIC, "org/drools/core/phreak/ReactiveObjectUtil", "notifyModification", "(Lorg/drools/core/phreak/ReactiveObject;)V", false);
        Label l1 = new Label();
        mv.visitLabel(l1);
        mv.visitLineNumber(42, l1);
        mv.visitInsn(RETURN);
        Label l2 = new Label();
        mv.visitLabel(l2);
        mv.visitLocalVariable("this", "L" + TYPE_NAME + ";", null, l0, l2, 0);
        mv.visitMaxs(1, 1);
        mv.visitEnd();
    }
    /*
            public void removeLeftTuple(Tuple leftTuple) {
                _lts.remove(leftTuple);
            }
         */
    {
        mv = cw.visitMethod(ACC_PUBLIC, "removeLeftTuple", "(Lorg/drools/core/spi/Tuple;)V", null, null);
        mv.visitCode();
        Label l0 = new Label();
        mv.visitLabel(l0);
        mv.visitLineNumber(46, l0);
        mv.visitVarInsn(ALOAD, 0);
        mv.visitFieldInsn(GETFIELD, TYPE_NAME, LEFT_TUPLES_FIELD_NAME, "Ljava/util/Collection;");
        mv.visitVarInsn(ALOAD, 1);
        mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Collection", "remove", "(Ljava/lang/Object;)Z", true);
        mv.visitInsn(POP);
        Label l1 = new Label();
        mv.visitLabel(l1);
        mv.visitLineNumber(47, l1);
        mv.visitInsn(RETURN);
        Label l2 = new Label();
        mv.visitLabel(l2);
        mv.visitLocalVariable("this", "Lorg/drools/core/phreak/AbstractReactiveObject;", null, l0, l2, 0);
        mv.visitLocalVariable("leftTuple", "Lorg/drools/core/spi/Tuple;", null, l0, l2, 1);
        mv.visitMaxs(2, 2);
        mv.visitEnd();
    }
}
Also used : Label(org.mvel2.asm.Label) ReactiveObject(org.drools.core.phreak.ReactiveObject) FieldVisitor(org.mvel2.asm.FieldVisitor) MethodVisitor(org.mvel2.asm.MethodVisitor)

Example 18 with ClassWriter

use of org.mvel2.asm.ClassWriter in project drools by kiegroup.

the class DefaultBeanClassBuilder method buildTraitMap.

/**
 * A traitable class is a special class with support for dynamic properties and types.
 *
 * This method builds the trait map, containing the references to the proxies
 * for each trait carried by an object at a given time.
 *
 * @param cw
 * @param classDef
 */
protected void buildTraitMap(ClassWriter cw, ClassDefinition classDef) {
    FieldVisitor fv = cw.visitField(ACC_PRIVATE, TraitableBean.TRAITSET_FIELD_NAME, Type.getDescriptor(Map.class), "Ljava/util/Map<Ljava/lang/String;Lorg/drools/core/factmodel/traits/Thing;>;", null);
    fv.visitEnd();
    MethodVisitor mv;
    mv = cw.visitMethod(ACC_PUBLIC, "_getTraitMap", Type.getMethodDescriptor(Type.getType(Map.class), new Type[] {}), "()Ljava/util/Map<Ljava/lang/String;Lorg/drools/factmodel/traits/Thing;>;", null);
    mv.visitCode();
    mv.visitVarInsn(ALOAD, 0);
    mv.visitFieldInsn(GETFIELD, BuildUtils.getInternalType(classDef.getName()), TraitableBean.TRAITSET_FIELD_NAME, Type.getDescriptor(Map.class));
    mv.visitInsn(ARETURN);
    mv.visitMaxs(0, 0);
    mv.visitEnd();
    mv = cw.visitMethod(ACC_PUBLIC, "_setTraitMap", Type.getMethodDescriptor(Type.getType(void.class), new Type[] { Type.getType(Map.class) }), null, null);
    mv.visitCode();
    mv.visitVarInsn(ALOAD, 0);
    mv.visitVarInsn(ALOAD, 1);
    mv.visitFieldInsn(PUTFIELD, BuildUtils.getInternalType(classDef.getName()), TraitableBean.TRAITSET_FIELD_NAME, Type.getDescriptor(Map.class));
    mv.visitInsn(RETURN);
    mv.visitMaxs(0, 0);
    mv.visitEnd();
    mv = cw.visitMethod(ACC_PUBLIC, "addTrait", Type.getMethodDescriptor(Type.getType(void.class), new Type[] { Type.getType(String.class), Type.getType(Thing.class) }), "(Ljava/lang/String;Lorg/drools/core/factmodel/traits/Thing;)V", null);
    mv.visitCode();
    mv.visitVarInsn(ALOAD, 0);
    mv.visitMethodInsn(INVOKEVIRTUAL, BuildUtils.getInternalType(classDef.getName()), "_getTraitMap", Type.getMethodDescriptor(Type.getType(Map.class), new Type[] {}));
    mv.visitVarInsn(ALOAD, 1);
    mv.visitVarInsn(ALOAD, 2);
    mv.visitMethodInsn(INVOKEINTERFACE, Type.getInternalName(Map.class), "put", Type.getMethodDescriptor(Type.getType(Object.class), new Type[] { Type.getType(Object.class), Type.getType(Object.class) }));
    mv.visitInsn(POP);
    mv.visitInsn(RETURN);
    mv.visitMaxs(0, 0);
    mv.visitEnd();
    mv = cw.visitMethod(ACC_PUBLIC, "getTrait", Type.getMethodDescriptor(Type.getType(Thing.class), new Type[] { Type.getType(String.class) }), Type.getMethodDescriptor(Type.getType(Thing.class), new Type[] { Type.getType(String.class) }), null);
    mv.visitCode();
    mv.visitVarInsn(ALOAD, 0);
    mv.visitMethodInsn(INVOKEVIRTUAL, BuildUtils.getInternalType(classDef.getName()), "_getTraitMap", Type.getMethodDescriptor(Type.getType(Map.class), new Type[] {}));
    mv.visitVarInsn(ALOAD, 1);
    mv.visitMethodInsn(INVOKEINTERFACE, Type.getInternalName(Map.class), "get", Type.getMethodDescriptor(Type.getType(Object.class), new Type[] { Type.getType(Object.class) }));
    mv.visitTypeInsn(CHECKCAST, Type.getInternalName(Thing.class));
    mv.visitInsn(ARETURN);
    mv.visitMaxs(0, 0);
    mv.visitEnd();
    mv = cw.visitMethod(ACC_PUBLIC, "hasTrait", Type.getMethodDescriptor(Type.getType(boolean.class), new Type[] { Type.getType(String.class) }), null, null);
    mv.visitCode();
    mv.visitVarInsn(ALOAD, 0);
    mv.visitMethodInsn(INVOKEVIRTUAL, BuildUtils.getInternalType(classDef.getName()), "_getTraitMap", Type.getMethodDescriptor(Type.getType(Map.class), new Type[] {}));
    Label l0 = new Label();
    mv.visitJumpInsn(IFNONNULL, l0);
    mv.visitInsn(ICONST_0);
    mv.visitInsn(IRETURN);
    mv.visitLabel(l0);
    mv.visitVarInsn(ALOAD, 0);
    mv.visitMethodInsn(INVOKEVIRTUAL, BuildUtils.getInternalType(classDef.getName()), "_getTraitMap", Type.getMethodDescriptor(Type.getType(Map.class), new Type[] {}));
    mv.visitVarInsn(ALOAD, 1);
    mv.visitMethodInsn(INVOKEINTERFACE, Type.getInternalName(Map.class), "containsKey", Type.getMethodDescriptor(Type.getType(boolean.class), new Type[] { Type.getType(Object.class) }));
    mv.visitInsn(IRETURN);
    mv.visitMaxs(0, 0);
    mv.visitEnd();
    mv = cw.visitMethod(ACC_PUBLIC, "hasTraits", Type.getMethodDescriptor(Type.getType(boolean.class), new Type[] {}), null, null);
    mv.visitCode();
    mv.visitVarInsn(ALOAD, 0);
    mv.visitFieldInsn(GETFIELD, BuildUtils.getInternalType(classDef.getName()), TraitableBean.TRAITSET_FIELD_NAME, Type.getDescriptor(Map.class));
    Label l5 = new Label();
    mv.visitJumpInsn(IFNULL, l5);
    mv.visitVarInsn(ALOAD, 0);
    mv.visitFieldInsn(GETFIELD, BuildUtils.getInternalType(classDef.getName()), TraitableBean.TRAITSET_FIELD_NAME, Type.getDescriptor(Map.class));
    mv.visitMethodInsn(INVOKEINTERFACE, Type.getInternalName(Map.class), "isEmpty", Type.getMethodDescriptor(Type.BOOLEAN_TYPE, new Type[] {}));
    mv.visitJumpInsn(IFNE, l5);
    mv.visitInsn(ICONST_1);
    Label l4 = new Label();
    mv.visitJumpInsn(GOTO, l4);
    mv.visitLabel(l5);
    mv.visitInsn(ICONST_0);
    mv.visitLabel(l4);
    mv.visitInsn(IRETURN);
    mv.visitMaxs(0, 0);
    mv.visitEnd();
    mv = cw.visitMethod(ACC_PUBLIC, "removeTrait", Type.getMethodDescriptor(Type.getType(Collection.class), new Type[] { Type.getType(String.class) }), Type.getMethodDescriptor(Type.getType(Collection.class), new Type[] { Type.getType(String.class) }), null);
    mv.visitCode();
    mv.visitVarInsn(ALOAD, 0);
    mv.visitMethodInsn(INVOKEVIRTUAL, BuildUtils.getInternalType(classDef.getName()), "_getTraitMap", Type.getMethodDescriptor(Type.getType(Map.class), new Type[] {}));
    mv.visitTypeInsn(CHECKCAST, Type.getInternalName(TraitTypeMap.class));
    mv.visitVarInsn(ALOAD, 1);
    mv.visitMethodInsn(INVOKEVIRTUAL, Type.getInternalName(TraitTypeMap.class), "removeCascade", Type.getMethodDescriptor(Type.getType(Collection.class), new Type[] { Type.getType(String.class) }));
    mv.visitInsn(ARETURN);
    mv.visitMaxs(0, 0);
    mv.visitEnd();
    mv = cw.visitMethod(ACC_PUBLIC, "removeTrait", Type.getMethodDescriptor(Type.getType(Collection.class), new Type[] { Type.getType(BitSet.class) }), Type.getMethodDescriptor(Type.getType(Collection.class), new Type[] { Type.getType(BitSet.class) }), null);
    mv.visitCode();
    mv.visitVarInsn(ALOAD, 0);
    mv.visitMethodInsn(INVOKEVIRTUAL, BuildUtils.getInternalType(classDef.getName()), "_getTraitMap", Type.getMethodDescriptor(Type.getType(Map.class), new Type[] {}));
    mv.visitTypeInsn(CHECKCAST, Type.getInternalName(TraitTypeMap.class));
    mv.visitVarInsn(ALOAD, 1);
    mv.visitMethodInsn(INVOKEVIRTUAL, Type.getInternalName(TraitTypeMap.class), "removeCascade", Type.getMethodDescriptor(Type.getType(Collection.class), new Type[] { Type.getType(BitSet.class) }));
    mv.visitInsn(ARETURN);
    mv.visitMaxs(0, 0);
    mv.visitEnd();
    mv = cw.visitMethod(ACC_PUBLIC, "getTraits", Type.getMethodDescriptor(Type.getType(Collection.class), new Type[] {}), "()Ljava/util/Collection<Ljava/lang/String;>;", null);
    mv.visitCode();
    mv.visitVarInsn(ALOAD, 0);
    mv.visitMethodInsn(INVOKEVIRTUAL, BuildUtils.getInternalType(classDef.getName()), "_getTraitMap", Type.getMethodDescriptor(Type.getType(Map.class), new Type[] {}));
    mv.visitMethodInsn(INVOKEINTERFACE, Type.getInternalName(Map.class), "keySet", Type.getMethodDescriptor(Type.getType(Set.class), new Type[] {}));
    mv.visitInsn(ARETURN);
    mv.visitMaxs(0, 0);
    mv.visitEnd();
    mv = cw.visitMethod(ACC_PUBLIC, "_setBottomTypeCode", Type.getMethodDescriptor(Type.getType(void.class), new Type[] { Type.getType(BitSet.class) }), null, null);
    mv.visitCode();
    mv.visitVarInsn(ALOAD, 0);
    mv.visitFieldInsn(GETFIELD, BuildUtils.getInternalType(classDef.getName()), TraitableBean.TRAITSET_FIELD_NAME, Type.getDescriptor(Map.class));
    mv.visitTypeInsn(CHECKCAST, Type.getInternalName(TraitTypeMap.class));
    mv.visitVarInsn(ALOAD, 1);
    mv.visitMethodInsn(INVOKEVIRTUAL, Type.getInternalName(TraitTypeMap.class), "setBottomCode", Type.getMethodDescriptor(Type.getType(void.class), new Type[] { Type.getType(BitSet.class) }));
    mv.visitInsn(RETURN);
    mv.visitMaxs(0, 0);
    mv.visitEnd();
    mv = cw.visitMethod(ACC_PUBLIC, "getMostSpecificTraits", Type.getMethodDescriptor(Type.getType(Collection.class), new Type[] {}), "()Ljava/util/Collection<Lorg/drools/core/factmodel/traits/Thing;>;", null);
    mv.visitCode();
    mv.visitVarInsn(ALOAD, 0);
    mv.visitFieldInsn(GETFIELD, BuildUtils.getInternalType(classDef.getName()), TraitableBean.TRAITSET_FIELD_NAME, Type.getDescriptor(Map.class));
    Label l99 = new Label();
    mv.visitJumpInsn(IFNULL, l99);
    mv.visitVarInsn(ALOAD, 0);
    mv.visitFieldInsn(GETFIELD, BuildUtils.getInternalType(classDef.getName()), TraitableBean.TRAITSET_FIELD_NAME, Type.getDescriptor(Map.class));
    mv.visitTypeInsn(CHECKCAST, Type.getInternalName(TraitTypeMap.class));
    mv.visitMethodInsn(INVOKEVIRTUAL, Type.getInternalName(TraitTypeMap.class), "getMostSpecificTraits", Type.getMethodDescriptor(Type.getType(Collection.class), new Type[] {}));
    mv.visitInsn(ARETURN);
    mv.visitLabel(l99);
    mv.visitMethodInsn(INVOKESTATIC, Type.getInternalName(Collections.class), "emptySet", Type.getMethodDescriptor(Type.getType(Set.class), new Type[] {}));
    mv.visitMethodInsn(INVOKESTATIC, Type.getInternalName(Collections.class), "unmodifiableCollection", Type.getMethodDescriptor(Type.getType(Collection.class), new Type[] { Type.getType(Collection.class) }));
    mv.visitInsn(ARETURN);
    mv.visitMaxs(0, 0);
    mv.visitEnd();
    mv = cw.visitMethod(ACC_PUBLIC, "getCurrentTypeCode", Type.getMethodDescriptor(Type.getType(BitSet.class), new Type[] {}), null, null);
    mv.visitCode();
    mv.visitVarInsn(ALOAD, 0);
    mv.visitFieldInsn(GETFIELD, BuildUtils.getInternalType(classDef.getName()), TraitableBean.TRAITSET_FIELD_NAME, Type.getDescriptor(Map.class));
    Label l3 = new Label();
    mv.visitJumpInsn(IFNONNULL, l3);
    mv.visitInsn(ACONST_NULL);
    mv.visitInsn(ARETURN);
    mv.visitLabel(l3);
    mv.visitVarInsn(ALOAD, 0);
    mv.visitFieldInsn(GETFIELD, BuildUtils.getInternalType(classDef.getName()), TraitableBean.TRAITSET_FIELD_NAME, Type.getDescriptor(Map.class));
    mv.visitTypeInsn(CHECKCAST, Type.getInternalName(TraitTypeMap.class));
    mv.visitMethodInsn(INVOKEVIRTUAL, Type.getInternalName(TraitTypeMap.class), "getCurrentTypeCode", Type.getMethodDescriptor(Type.getType(BitSet.class), new Type[] {}));
    mv.visitInsn(ARETURN);
    mv.visitMaxs(0, 0);
    mv.visitEnd();
}
Also used : Type(org.mvel2.asm.Type) Label(org.mvel2.asm.Label) BitSet(java.util.BitSet) Collection(java.util.Collection) TraitTypeMap(org.drools.core.factmodel.traits.TraitTypeMap) Collections(java.util.Collections) FieldVisitor(org.mvel2.asm.FieldVisitor) Map(java.util.Map) TraitTypeMap(org.drools.core.factmodel.traits.TraitTypeMap) Thing(org.drools.core.factmodel.traits.Thing) MethodVisitor(org.mvel2.asm.MethodVisitor)

Example 19 with ClassWriter

use of org.mvel2.asm.ClassWriter in project drools by kiegroup.

the class AbstractProxyClassBuilderImpl method buildShadowMethod.

protected void buildShadowMethod(ClassWriter cw, ClassDefinition trait, ClassDefinition core, Method m) {
    MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, m.getName(), Type.getMethodDescriptor(m), null, null);
    mv.visitCode();
    mv.visitVarInsn(ALOAD, 0);
    mv.visitMethodInsn(INVOKEVIRTUAL, BuildUtils.getInternalType(TraitFactory.getProxyName(trait, core)), "getCore", Type.getMethodDescriptor(Type.getType(core.getDefinedClass())), false);
    for (int j = 0; j < m.getParameterTypes().length; j++) {
        mv.visitVarInsn(BuildUtils.varType(m.getParameterTypes()[j].getName()), j + 1);
    }
    mv.visitMethodInsn(INVOKEVIRTUAL, Type.getInternalName(core.getDefinedClass()), m.getName(), Type.getMethodDescriptor(m), core.getDefinedClass().isInterface());
    mv.visitInsn(BuildUtils.returnType(m.getReturnType().getName()));
    mv.visitMaxs(0, 0);
    mv.visitEnd();
}
Also used : MethodVisitor(org.mvel2.asm.MethodVisitor)

Example 20 with ClassWriter

use of org.mvel2.asm.ClassWriter in project drools by kiegroup.

the class ClassFieldAccessorFactory method buildClassHeader.

/**
 * Builds the class header
 */
protected static ClassWriter buildClassHeader(Class<?> superClass, String className) {
    ClassWriter cw = createClassWriter(superClass.getClassLoader(), Opcodes.ACC_PUBLIC + Opcodes.ACC_SUPER, className, null, Type.getInternalName(superClass), null);
    cw.visitSource(null, null);
    return cw;
}
Also used : ClassWriter(org.mvel2.asm.ClassWriter) ClassGenerator.createClassWriter(org.drools.core.rule.builder.dialect.asm.ClassGenerator.createClassWriter)

Aggregations

MethodVisitor (org.mvel2.asm.MethodVisitor)58 ClassWriter (org.mvel2.asm.ClassWriter)32 FieldDefinition (org.drools.core.factmodel.FieldDefinition)23 FieldVisitor (org.mvel2.asm.FieldVisitor)23 Map (java.util.Map)20 Label (org.mvel2.asm.Label)20 BitSet (java.util.BitSet)12 ClassGenerator.createClassWriter (org.drools.core.rule.builder.dialect.asm.ClassGenerator.createClassWriter)12 ClassGenerator.createClassWriter (org.drools.mvel.asm.ClassGenerator.createClassWriter)12 Serializable (java.io.Serializable)8 Type (org.mvel2.asm.Type)8 IOException (java.io.IOException)7 Method (java.lang.reflect.Method)7 ObjectInput (java.io.ObjectInput)6 ObjectOutput (java.io.ObjectOutput)6 Externalizable (java.io.Externalizable)4 Collection (java.util.Collection)4 Thing (org.drools.core.factmodel.traits.Thing)4 TraitFieldTMS (org.drools.core.factmodel.traits.TraitFieldTMS)3 ReactiveObject (org.drools.core.phreak.ReactiveObject)3