コード例 #1
0
  /**
   * Visits the class.
   *
   * @param access
   * @param name
   * @param signature
   * @param superName
   * @param interfaces
   */
  public void visit(
      final int version,
      final int access,
      final String name,
      final String signature,
      final String superName,
      final String[] interfaces) {
    ExpressionContext ctx = new ExpressionContext(PointcutType.WITHIN, m_classInfo, m_classInfo);
    if (!classFilter(m_classInfo, ctx, m_ctx.getDefinitions())) {
      m_declaringTypeName = name;
      m_mixinFields = new HashMap();

      // populate with fields already present for mixins from previous weaving
      for (int i = 0; i < m_classInfo.getFields().length; i++) {
        FieldInfo fieldInfo = m_classInfo.getFields()[i];
        if (fieldInfo.getName().startsWith(MIXIN_FIELD_NAME)) {
          m_mixinFields.put(fieldInfo.getType(), fieldInfo);
        }
      }

      // add fields and method for (not already there) mixins
      addMixinMembers();
    }
    super.visit(version, access, name, signature, superName, interfaces);
  }
コード例 #2
0
 @Override
 public void visit(
     final int version,
     final int access,
     final String name,
     final String signature,
     final String superName,
     final String[] interfaces) {
   Set<String> interfacesSet = new LinkedHashSet<String>();
   if (interfaces != null) Collections.addAll(interfacesSet, interfaces);
   for (Class extraInterface : classList) {
     if (extraInterface.isInterface())
       interfacesSet.add(BytecodeHelper.getClassInternalName(extraInterface));
   }
   final boolean addGroovyObjectSupport = !GroovyObject.class.isAssignableFrom(superClass);
   if (addGroovyObjectSupport) interfacesSet.add("groovy/lang/GroovyObject");
   super.visit(
       V1_5,
       ACC_PUBLIC,
       proxyName,
       signature,
       BytecodeHelper.getClassInternalName(superClass),
       interfacesSet.toArray(new String[interfacesSet.size()]));
   addDelegateFields();
   if (addGroovyObjectSupport) {
     createGroovyObjectSupport();
   }
   for (Class clazz : classList) {
     visitClass(clazz);
   }
 }
コード例 #3
0
 public void visit(
     final int version,
     final int access,
     final String name,
     final String signature,
     final String superName,
     final String[] interfaces) {
   this.cname = name;
   super.visit(version, access, name, signature, superName, interfaces);
 }
コード例 #4
0
 @Override
 public void visit(
     int version,
     int access,
     String name,
     String signature,
     String superName,
     String[] interfaces) {
   className = name;
   super.visit(version, access, name, signature, superName, interfaces);
 }
コード例 #5
0
 public void visit(
     int version,
     int access,
     String name,
     String signature,
     String superName,
     String[] interfaces) {
   super.visit(version, access, name, signature, superName, interfaces);
   myClassName = name;
   mySuperName = superName;
 }
コード例 #6
0
  /** Creates a new clinit method and adds mixin instantiation if it does not exist. */
  public void visitEnd() {
    if (m_isAdvised && !m_hasClinit) {
      // add the <clinit> method
      MethodVisitor mv =
          cv.visitMethod(
              ACC_STATIC, CLINIT_METHOD_NAME, NO_PARAM_RETURN_VOID_SIGNATURE, null, null);
      for (Iterator i4 = m_mixinFields.values().iterator(); i4.hasNext(); ) {
        MixinFieldInfo fieldInfo = (MixinFieldInfo) i4.next();
        if (fieldInfo.isStatic) {
          initializeStaticMixinField(mv, fieldInfo);
        }
      }

      mv.visitInsn(RETURN);
      mv.visitMaxs(0, 0);
    }
    super.visitEnd();
  }
コード例 #7
0
 @Override
 public void visitEnd() {
   super.visitEnd();
 }
コード例 #8
0
 public void visitInnerClass(String name, String outerName, String innerName, int access) {
   super.visitInnerClass(name, outerName, innerName, access);
   if (myClassName.equals(name)) {
     myIsNotStaticInner = (access & Opcodes.ACC_STATIC) == 0;
   }
 }