예제 #1
0
 /** 用于更新类名。 */
 public void visit(
     final int version,
     final int access,
     final String name,
     final String signature,
     final String superName,
     final String[] interfaces) {
   // 1.类名
   this.superClassName = name;
   String className = this.classConfig.getClassName();
   className = classConfig.getClassName().replace(".", "/");
   // 2.确定接口
   Set<String> newFaces = new HashSet<String>();
   for (String faces : interfaces) {
     newFaces.add(faces);
   }
   InnerMethodDelegateDefine[] defineArrays = this.classConfig.getNewDelegateList();
   for (InnerMethodDelegateDefine define : defineArrays) {
     Class<?> faceType = define.getFaces();
     newFaces.add(ASMEngineTools.replaceClassName(faceType));
   }
   String[] finalInterfaces = newFaces.toArray(new String[newFaces.size()]);
   //
   super.visit(version, access, className, signature, name, finalInterfaces);
 }
예제 #2
0
 public void visitEnd() {
   InnerMethodDelegateDefine[] defineArrays = this.classConfig.getNewDelegateList();
   for (InnerMethodDelegateDefine define : defineArrays) {
     Class<?> faceType = define.getFaces();
     Method[] faceMethods = faceType.getMethods();
     for (Method tMethod : faceMethods) {
       String mName = tMethod.getName();
       String typeDesc =
           String.format("%s(%s)", mName, ASMEngineTools.toAsmType(tMethod.getParameterTypes()));
       //
       if (this.validMethod.contains(typeDesc) == false) {
         String desc = ASMEngineTools.toAsmDesc(tMethod);
         MethodVisitor mv = super.visitMethod(ACC_PUBLIC, mName, desc, null, null);
         mv.visitCode();
         this.buildInterfaceMethod(mv, mName, desc, faceType);
         mv.visitEnd();
       }
       //
     }
     //
   }
   super.visitEnd();
 }