Package cn.wensiqun.asmsupport.creator

Source Code of cn.wensiqun.asmsupport.creator.AbstractClassContext

package cn.wensiqun.asmsupport.creator;

import java.util.List;

import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.ClassWriter;

import cn.wensiqun.asmsupport.clazz.AClassFactory;
import cn.wensiqun.asmsupport.loader.ASMClassLoader;


public abstract class AbstractClassContext extends AClassFactory implements IClassContext{

    protected List<IMethodCreator> methodCreaters;

    protected List<IGlobalVariableCreator> fieldCreators;

    protected String classOutPutPath;
 
    protected boolean existedStaticBlock;
 
    protected ClassWriter cw;
   
    protected void checkStaticBlock(){
      if(existedStaticBlock){
        throw new UnsupportedOperationException("the static block has alreay exist this method!");
      }
    }

    @Override
    public final ClassVisitor getClassVisitor() {
        return cw;
    }

  public String getClassOutPutPath() {
    return classOutPutPath;
  }
 
    public final void setClassOutPutPath(String classOutPutPath) {
        this.classOutPutPath = classOutPutPath;
    }

    protected Class<?> loadClass(String name, byte[] b) {
        Class<?> clazz = null;
        try {
          ASMClassLoader loader = ASMClassLoader.asmClassLoader;
          clazz = loader.defineClass(name, b);
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
        return clazz;
    }
}
TOP

Related Classes of cn.wensiqun.asmsupport.creator.AbstractClassContext

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.