当前位置: 首页>>代码示例>>Java>>正文


Java ClassGen.getClassName方法代码示例

本文整理汇总了Java中org.apache.bcel.generic.ClassGen.getClassName方法的典型用法代码示例。如果您正苦于以下问题:Java ClassGen.getClassName方法的具体用法?Java ClassGen.getClassName怎么用?Java ClassGen.getClassName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.bcel.generic.ClassGen的用法示例。


在下文中一共展示了ClassGen.getClassName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createCallMethod

import org.apache.bcel.generic.ClassGen; //导入方法依赖的package包/类
private MethodGen createCallMethod(ClassGen closureClass, ClosureScope scope, GenScope parentScope) {
	InstructionList il = new InstructionList();
	MethodGen mg = new MethodGen(Constants.ACC_PUBLIC,// access flags
			Type.OBJECT, // return type
			getParameterTypes(), getParameterNames(), // arg
			// names
			"call", closureClass.getClassName(), // method, class
			il, closureClass.getConstantPool());
	
	// TODO: Do it directly in the constructor!!
	scope.processMethod(mg);
	
	GenUtil.generate(this, closureClass, mg, scope, true);

	// Create proper fields in the class, they will be set when the
	// instance is created
	Set<Variable> o = scope.getOuterVariables().get();
	for (Variable variable : o) {
		closureClass.addField(new FieldGen(Constants.ACC_PUBLIC, Type.OBJECT, variable.getName(), closureClass.getConstantPool()).getField());
	}

	return mg;
}
 
开发者ID:jesusc,项目名称:eclectic,代码行数:24,代码来源:ClosureDefJVMGen.java

示例2: createObserverCreatorMethod

import org.apache.bcel.generic.ClassGen; //导入方法依赖的package包/类
private void createObserverCreatorMethod(ClassGen cg, ObserverDescription observer, String observerClassName) {
	final String methodName = "create" + observer.getName();
	InstructionList il = new InstructionList();
	InstructionFactory ifact = new InstructionFactory(cg);
	MethodGen mg = new MethodGen(Constants.ACC_PUBLIC, new ObjectType(observerClassName), new Type[] { } , null, methodName,
               cg.getClassName(), il, cg.getConstantPool());
	
	il.append(ifact.createNew(observerClassName));
	il.append(InstructionConstants.DUP);
	il.append(InstructionConstants.THIS);
	il.append(ifact.createInvoke(observerClassName, "<init>",
			Type.VOID, new Type[] { DefaultTypes.QoolTransformation }, Constants.INVOKESPECIAL));
			
	il.append(InstructionFactory.ARETURN);	
	
	mg.setMaxLocals();
	mg.setMaxStack();
	
	cg.addMethod(mg.getMethod());		
}
 
开发者ID:jesusc,项目名称:eclectic,代码行数:21,代码来源:QoolTransformationJVMGen.java

示例3: generate

import org.apache.bcel.generic.ClassGen; //导入方法依赖的package包/类
public void generate(ClassGen cg, GenScope scope, String methodName) {
	InstructionList il = new InstructionList();

	MethodGen mg = new MethodGen(Constants.ACC_PUBLIC,// access flags
			Type.VOID, // return type
			null, null, // arg
			// names
			methodName, cg.getClassName(), // method, class
			il, cg.getConstantPool());
	
	scope.processMethod(mg);
	
	GenUtil.generate(this, cg, mg, scope);
	
	cg.addMethod(mg.getMethod());
}
 
开发者ID:jesusc,项目名称:eclectic,代码行数:17,代码来源:QoolSegmentJVMGen.java

示例4: main1

import org.apache.bcel.generic.ClassGen; //导入方法依赖的package包/类
public static void main1(String[] args) throws Throwable {
    ClassParser cp = new ClassParser("/home/kinow/Development/java/apache/tests-for-commons/target/classes/br/eti/kinoshita/commons/bcel/Test.class");
    ClassGen cg = new ClassGen(cp.parse());
    MethodGen mg = new MethodGen(cg.getMethodAt(0), cg.getClassName(), cg.getConstantPool());
    mg.getAnnotationsOnParameter(0);
    System.out.println("OK!");
}
 
开发者ID:kinow,项目名称:commons-sandbox,代码行数:8,代码来源:BCEL_289.java

示例5: main

import org.apache.bcel.generic.ClassGen; //导入方法依赖的package包/类
public static void main(String[] args) throws Throwable {
    ClassParser cp = new ClassParser("/home/kinow/Development/java/apache/tests-for-commons/target/classes/br/eti/kinoshita/commons/bcel/Test$Inner.class");
    ClassGen cg = new ClassGen(cp.parse());
    MethodGen mg = new MethodGen(cg.getMethodAt(0), cg.getClassName(), cg.getConstantPool());
    // here..args.
    System.out.println(mg.getAnnotationsOnParameter(0));
    System.out.println("OK!");
}
 
开发者ID:kinow,项目名称:commons-sandbox,代码行数:9,代码来源:BCEL_289.java

示例6: nullAdaptClass

import org.apache.bcel.generic.ClassGen; //导入方法依赖的package包/类
byte[] nullAdaptClass(final InputStream is, final String name)
        throws Exception
{
    JavaClass jc = new ClassParser(is, name + ".class").parse();
    ClassGen cg = new ClassGen(jc);
    ConstantPoolGen cp = cg.getConstantPool();
    Method[] ms = cg.getMethods();
    for (int j = 0; j < ms.length; ++j) {
        MethodGen mg = new MethodGen(ms[j], cg.getClassName(), cp);
        boolean lv = ms[j].getLocalVariableTable() == null;
        boolean ln = ms[j].getLineNumberTable() == null;
        if (lv) {
            mg.removeLocalVariables();
        }
        if (ln) {
            mg.removeLineNumbers();
        }
        mg.stripAttributes(skipDebug);
        InstructionList il = mg.getInstructionList();
        if (il != null) {
            InstructionHandle ih = il.getStart();
            while (ih != null) {
                ih = ih.getNext();
            }
            if (compute) {
                mg.setMaxStack();
                mg.setMaxLocals();
            }
        }
        cg.replaceMethod(ms[j], mg.getMethod());
    }
    return cg.getJavaClass().getBytes();
}
 
开发者ID:typetools,项目名称:annotation-tools,代码行数:34,代码来源:BCELPerfTest.java

示例7: createConstructor

import org.apache.bcel.generic.ClassGen; //导入方法依赖的package包/类
private void createConstructor(GenScope scope, ClassGen cg) {
	InstructionList il = new InstructionList();
	InstructionFactory ifact = new InstructionFactory(cg);

	// Call super
       il.append(InstructionConstants.THIS); 
       il.append(new INVOKESPECIAL(cg.getConstantPool().addMethodref(cg.getSuperclassName(), "<init>", "()V")));
       
       // Instantiate and register each transformation to be executed 
	for (TransformationExecution exec : getExecutions()) {
		// TODO: Ensure the name obtained with "getTransformationName" is the one of the generated transformation (weak link now!)
		String transformationClassName = exec.getTransformationName();
		// TODO: Find out the class package name!!
		transformationClassName = "eclectic." + transformationClassName;
		
		il.append(ifact.createNew(transformationClassName)); 
		il.append(new DUP());		
		il.append(ifact.createInvoke(transformationClassName, "<init>",
				Type.VOID, new Type[] { }, Constants.INVOKESPECIAL));

		il.append(InstructionConstants.THIS); 
		il.append(InstructionConstants.SWAP); 
		il.append(ifact.createInvoke(cg.getClassName(), "register",
					Type.VOID, new Type[] { DefaultTypes.IdcTransformation }, Constants.INVOKEVIRTUAL));				
	}
		
       il.append(InstructionConstants.RETURN);

       MethodGen mg = new MethodGen(Constants.ACC_PUBLIC, Type.VOID, new Type[] { } , null, "<init>",
               cg.getClassName(), il, cg.getConstantPool());
       mg.setMaxStack();
       cg.addMethod(mg.getMethod());		
}
 
开发者ID:jesusc,项目名称:eclectic,代码行数:34,代码来源:ParallelTransformationJVMGen.java

示例8: createConstructor

import org.apache.bcel.generic.ClassGen; //导入方法依赖的package包/类
private void createConstructor(GenScope scope, ClassGen closureClass) {
       InstructionList il = new InstructionList();
       il.append(InstructionConstants.THIS); // Push `this'
       il.append(new INVOKESPECIAL(closureClass.getConstantPool().addMethodref(closureClass.getSuperclassName(), "<init>", "()V")));
       
       il.append(InstructionConstants.THIS); // Push `this'   
       il.append(scope.getInstructionFactory().createConstant(this.getFormalParameters().size()));
       il.append(scope.getInstructionFactory().createPutField(DefaultTypes.IClosure.getClassName(), "numParameters_", Type.INT));

       il.append(InstructionConstants.THIS); // Push `this'
       il.append(new ALOAD(1)); // first parameter
       il.append(scope.getInstructionFactory().createPutField(DefaultTypes.IClosure.getClassName(), "transformation_", DefaultTypes.IdcTransformation));	
       
       il.append(InstructionConstants.THIS); // Push `this'
       il.append(new ALOAD(2)); // second parameter
       il.append(scope.getInstructionFactory().createPutField(DefaultTypes.IClosure.getClassName(), "modelManager_", DefaultTypes.ModelManager));	
   	// TODO: It would be nice to have cross-checking between code being generated and framework code
       
       /*
       il.append(InstructionConstants.THIS); // Push `this'
       il.append(new ALOAD(1)); // first parameter
       il.append(scope.getInstructionFactory().createPutField(DefaultTypes.IClosure.getClassName(), "modelManager_", DefaultTypes.ModelManager));       
         */
               
       il.append(InstructionConstants.RETURN);

       MethodGen mg = new MethodGen(Constants.ACC_PUBLIC, Type.VOID, new Type[] { DefaultTypes.IdcTransformation, DefaultTypes.ModelManager } , null, "<init>",
       		closureClass.getClassName(), il, closureClass.getConstantPool());
       
       // mg.setMaxStack(3);
       mg.setMaxStack();
       
       
       closureClass.addMethod(mg.getMethod());		
}
 
开发者ID:jesusc,项目名称:eclectic,代码行数:36,代码来源:ClosureDefJVMGen.java

示例9: createRunMethod

import org.apache.bcel.generic.ClassGen; //导入方法依赖的package包/类
private MethodGen createRunMethod(ClassGen closureClass, ClosureScope scope, GenScope parentScope) {
	InstructionList il = new InstructionList();
	MethodGen mg = new MethodGen(Constants.ACC_PUBLIC,// access flags
			Type.VOID, 
			Type.NO_ARGS, new String[] {}, 
			"run", closureClass.getClassName(), // method, class
			il, closureClass.getConstantPool());

	scope.processMethod(mg);
	InstructionFactory ifact = scope.getInstructionFactory();		
	
	il.append(InstructionFactory.THIS);
	
	for(int i = 0; i < formalParameters.size(); i++) {
		il.append(InstructionFactory.THIS);
		// with this, I get class-circularity-error
		// il.append(ifact.createGetField(DefaultTypes.RunnableClosure.getClassName(), "params", DefaultTypes.ArrayList));
		il.append(ifact.createGetField(closureClass.getClassName(), "params", DefaultTypes.ArrayList));
		il.append(new ICONST(i));
		il.append(ifact.createInvoke(DefaultTypes.ArrayList.getClassName(), "get",
				Type.OBJECT, new Type[] { Type.INT }, Constants.INVOKEVIRTUAL));
	}
	
	il.append(ifact.createInvoke(closureClass.getClassName(), "call",
			Type.OBJECT, getParameterTypes(), Constants.INVOKEVIRTUAL));

	il.append(InstructionFactory.THIS);
	il.append(InstructionConstants.SWAP);
	il.append(ifact.createPutField(closureClass.getClassName(), "result", Type.OBJECT));

	InstructionHandle end = il.append(InstructionConstants.RETURN);

	// TODO: Line numbers
	mg.setMaxStack();
	mg.setMaxLocals();

	return mg;
}
 
开发者ID:jesusc,项目名称:eclectic,代码行数:39,代码来源:ClosureDefJVMGen.java

示例10: createConstructor

import org.apache.bcel.generic.ClassGen; //导入方法依赖的package包/类
private void createConstructor(GenScope scope, ClassGen cg) {
	InstructionList il = new InstructionList();
	InstructionFactory ifact = new InstructionFactory(cg);


       MethodGen mg = new MethodGen(Constants.ACC_PUBLIC, Type.VOID, new Type[] { } , null, "<init>",
               cg.getClassName(), il, cg.getConstantPool());
       scope.processMethod(mg);
	// call super
       il.append(InstructionConstants.THIS); // Push `this'
       il.append(new INVOKESPECIAL(cg.getConstantPool().addMethodref(cg.getSuperclassName(), "<init>", "()V")));

       // Set name
       il.append( InstructionConstants.THIS );
	il.append( ifact.createConstant(this.getName()) );
       il.append( ifact.createPutField(cg.getClassName(), "name", Type.STRING) );

       Collection<Queue> queues = CommonGen.allQueues(this);
	for (Queue q : queues) {
		QueueJVMGen jvmQ = (QueueJVMGen) q;
		jvmQ.generateInitField(il, ifact, scope);
	}
	
               
       il.append(InstructionConstants.RETURN);

       mg.setMaxStack();
       cg.addMethod(mg.getMethod());		
}
 
开发者ID:jesusc,项目名称:eclectic,代码行数:30,代码来源:QoolTransformationJVMGen.java

示例11: createConstructor

import org.apache.bcel.generic.ClassGen; //导入方法依赖的package包/类
private void createConstructor(GenScope scope, ClassGen cg) {
	InstructionList il = new InstructionList();
	InstructionFactory ifact = new InstructionFactory(cg);

	MethodGen mg = new MethodGen(Constants.ACC_PUBLIC, Type.VOID, new Type[] { } , null, "<init>",
               cg.getClassName(), il, cg.getConstantPool());
       scope.processMethod(mg);		
       
	// call super
       il.append(InstructionConstants.THIS); // Push `this'
       il.append(new INVOKESPECIAL(cg.getConstantPool().addMethodref(cg.getSuperclassName(), "<init>", "()V")));
	        
       // Set name
       il.append( InstructionConstants.THIS );
	il.append( ifact.createConstant(this.getName()) );
       il.append( ifact.createPutField(cg.getClassName(), "name", Type.STRING) );
       
       Collection<Queue> queues = CommonGen.getImportedQueues(this);
	for (Queue q : queues) {
		QueueJVMGen jvmQ = (QueueJVMGen) q;
		jvmQ.generateInitField(il, ifact, scope);
	}
       
       il.append(InstructionConstants.RETURN);

       mg.setMaxStack();
       cg.addMethod(mg.getMethod());	
}
 
开发者ID:jesusc,项目名称:eclectic,代码行数:29,代码来源:MethodLibraryJVMGen.java

示例12: generate

import org.apache.bcel.generic.ClassGen; //导入方法依赖的package包/类
/**
 * Generates one method in the given ClassGen.
 */
@Override
public void generate(ClassGen cg, GenScope parentScope) {
	GenScope scope = new GenScope(parentScope, cg);
	
	/*
	ClassGen cg = new ClassGen(name, NormalFunctionAux.class.getName(),
			this.getFile(), Constants.ACC_PUBLIC | Constants.ACC_SUPER,
			new String[] {});

	cg.addEmptyConstructor(Constants.ACC_PUBLIC);
	*/
	InstructionList il = new InstructionList();
	InstructionFactory ifact = new InstructionFactory(cg);

	MethodGen mg = new MethodGen(Constants.ACC_PUBLIC,// access flags
			Type.VOID, // return type
			null, null, // arg
			// names
			this.getName(), cg.getClassName(), // method, class
			il, cg.getConstantPool());
	
	scope.processMethod(mg);
	
	GenUtil.generate(this, cg, mg, scope);
	
	cg.addMethod(mg.getMethod());		
}
 
开发者ID:jesusc,项目名称:eclectic,代码行数:31,代码来源:NormalFunctionJVMGen.java

示例13: createInitialFrame

import org.apache.bcel.generic.ClassGen; //导入方法依赖的package包/类
/**
 * Creates a {@link Frame} object that represents the state of the stack frame
 * at the beginning of a method.
 */
private Frame createInitialFrame(MethodGen method, ClassGen clazz) {
    final Frame vanillaFrame = new Frame(method.getMaxLocals(), method.getMaxStack());
    if (!method.isStatic()) {
        if (method.getName().equals(Constants.CONSTRUCTOR_NAME)) {
            Frame._this = new UninitializedObjectType(new ObjectType(clazz.getClassName()));
            vanillaFrame.getLocals().set(0, new UninitializedObjectType(new ObjectType(clazz.getClassName())));
        } else {
            Frame._this = null;
            vanillaFrame.getLocals().set(0, new ObjectType(clazz.getClassName()));
        }
    }
    // fill local variables with parameter types
    final Type[] argtypes = method.getArgumentTypes();
    int twoslotoffset = 0;
    for (int j = 0; j < argtypes.length; j++) {
        if ((argtypes[j] == Type.SHORT) || (argtypes[j] == Type.BYTE) || (argtypes[j] == Type.CHAR) || (argtypes[j] == Type.BOOLEAN)) {
            argtypes[j] = Type.INT;
        }
        vanillaFrame.getLocals().set(twoslotoffset + j + (method.isStatic() ? 0 : 1), argtypes[j]);
        if (argtypes[j].getSize() == 2) {
            twoslotoffset++;
            vanillaFrame.getLocals().set(twoslotoffset + j + (method.isStatic() ? 0 : 1), Type.UNKNOWN);
        }
    }

    return vanillaFrame;
}
 
开发者ID:jesusc,项目名称:eclectic,代码行数:32,代码来源:BcelClassTransformer.java

示例14: generateMain

import org.apache.bcel.generic.ClassGen; //导入方法依赖的package包/类
void generateMain(ClassGen clg, Method origMain) {

        InstructionList il = new InstructionList();

        MethodGen new_main = new MethodGen(Constants.ACC_STATIC
            | Constants.ACC_PUBLIC, Type.VOID, new Type[] { new ArrayType(
            Type.STRING, 1) }, new String[] { "argv" }, "main", clg
            .getClassName(), il, clg.getConstantPool());

        il.append(ins_f.createNew(cashmereType));
        il.append(new DUP());
        il.append(ins_f.createInvoke("ibis.cashmere.impl.Cashmere", "<init>",
            Type.VOID, Type.NO_ARGS, Constants.INVOKESPECIAL));
        il.append(ins_f.createInvoke("ibis.cashmere.impl.Cashmere", "isMaster",
            Type.BOOLEAN, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
        BranchHandle ifcmp = il.append(new IFEQ(null));

        InstructionHandle origMain_handle = il.append(new ALOAD(0));
        
        InstructionHandle try_start = il.append(ins_f.createInvoke(clg
            .getClassName(), origMain.getName(), Type.VOID,
            new Type[] { new ArrayType(Type.STRING, 1) },
            Constants.INVOKESTATIC));

        BranchHandle try_end = il.append(new GOTO(null));

        InstructionHandle e_handler = il.append(getCashmere(ins_f));
        il.append(new SWAP());
        il.append(ins_f.createInvoke("ibis.cashmere.impl.Cashmere", "exit",
                Type.VOID, new Type[] { new ObjectType("java.lang.Throwable")},
                Constants.INVOKEVIRTUAL));

        BranchHandle gto2 = il.append(new GOTO(null));

        InstructionHandle ifeq_target = il.append(getCashmere(ins_f));
        ifcmp.setTarget(ifeq_target);
        il.append(ins_f.createInvoke("ibis.cashmere.impl.Cashmere", "client",
            Type.VOID, Type.NO_ARGS, Constants.INVOKEVIRTUAL));

        il.append(getCashmere(ins_f));
        il.append(ins_f.createInvoke("ibis.cashmere.impl.Cashmere", "isMaster",
            Type.BOOLEAN, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
        il.append(new IFNE(origMain_handle));

        InstructionHandle gto_target = il.append(getCashmere(ins_f));
        try_end.setTarget(gto_target);

        il.append(ins_f.createInvoke("ibis.cashmere.impl.Cashmere", "exit",
            Type.VOID, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
        InstructionHandle gto2_target = il.append(new RETURN());
        gto2.setTarget(gto2_target);

        new_main.addExceptionHandler(try_start, try_end, e_handler,
            new ObjectType("java.lang.Throwable"));
        new_main.setMaxStack();
        new_main.setMaxLocals();

        new_main.addLocalVariable("argv", new ArrayType(Type.STRING, 1), 0,
            origMain_handle, null);

        removeLocalTypeTables(new_main);

        Method main = new_main.getMethod();
        gen_c.addMethod(main);
    }
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:66,代码来源:Cashmerec.java

示例15: counterAdaptClass

import org.apache.bcel.generic.ClassGen; //导入方法依赖的package包/类
byte[] counterAdaptClass(final InputStream is, final String name)
        throws Exception
{
    JavaClass jc = new ClassParser(is, name + ".class").parse();
    ClassGen cg = new ClassGen(jc);
    ConstantPoolGen cp = cg.getConstantPool();
    if (!cg.isInterface()) {
        FieldGen fg = new FieldGen(ACC_PUBLIC,
                Type.getType("I"),
                "_counter",
                cp);
        cg.addField(fg.getField());
    }
    Method[] ms = cg.getMethods();
    for (int j = 0; j < ms.length; ++j) {
        MethodGen mg = new MethodGen(ms[j], cg.getClassName(), cp);
        if (!mg.getName().equals("<init>") && !mg.isStatic()
                && !mg.isAbstract() && !mg.isNative())
        {
            if (mg.getInstructionList() != null) {
                InstructionList il = new InstructionList();
                il.append(new ALOAD(0));
                il.append(new ALOAD(0));
                il.append(new GETFIELD(cp.addFieldref(name, "_counter", "I")));
                il.append(new ICONST(1));
                il.append(new IADD());
                il.append(new PUTFIELD(cp.addFieldref(name, "_counter", "I")));
                mg.getInstructionList().insert(il);
                mg.setMaxStack(Math.max(mg.getMaxStack(), 2));
                boolean lv = ms[j].getLocalVariableTable() == null;
                boolean ln = ms[j].getLineNumberTable() == null;
                if (lv) {
                    mg.removeLocalVariables();
                }
                if (ln) {
                    mg.removeLineNumbers();
                }
                cg.replaceMethod(ms[j], mg.getMethod());
            }
        }
    }
    return cg.getJavaClass().getBytes();
}
 
开发者ID:typetools,项目名称:annotation-tools,代码行数:44,代码来源:BCELPerfTest.java


注:本文中的org.apache.bcel.generic.ClassGen.getClassName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。