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


Java ClassGen类代码示例

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


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

示例1: apply

import org.apache.bcel.generic.ClassGen; //导入依赖的package包/类
@Override
public final void apply(final ClassPath classPath, final ClassNames classNames, final Path workingDirectory) {
    final String cpString = classPath.paths()
        .map(Object::toString)
        .reduce((s1, s2) -> s1 + ":" + s2);

    final ClassPathRepository classPathRepository = new ClassPathRepository(
        new org.apache.bcel.util.ClassPath(
            cpString
        )
    );

    try {
        for (String className : classNames.classNames()) {
            final JavaClass javaClass = classPathRepository.loadClass(className);
            final ClassGen classGen = new ClassGen(javaClass);
            plugin.operateOn(classGen,javaClass, classPathRepository);
        }
    } catch(Exception ex) {
        throw new RuntimeException(ex);
    }
}
 
开发者ID:project-avral,项目名称:oo-atom,代码行数:23,代码来源:BcelStage.java

示例2: generateFields

import org.apache.bcel.generic.ClassGen; //导入依赖的package包/类
private void generateFields(RootClass k, ConstantPoolGen cp, ClassGen cg)
{
   RootMember[] members = k.getMembers();
   for (int i = 0; i < members.length; i++)
   {
      if (cg.containsField(members[i].getName()) == null)
      {
         Type type = ((BasicMember) members[i]).getJavaType();
         if (type != null)
         {
            FieldGen fg = new FieldGen(ACC_PRIVATE, type, members[i].getName(), cp);
            cg.addField(fg.getField());
         }
      }
   }
}
 
开发者ID:diana-hep,项目名称:root4j,代码行数:17,代码来源:ProxyBuilder.java

示例3: createNewClassDeclaration

import org.apache.bcel.generic.ClassGen; //导入依赖的package包/类
/**
 * Method createAndInitializeClass.
 * This method starts creating the class.
 *
 * @param generatedClassName the stub class name
 * @param facadeToStubify
 */
protected void createNewClassDeclaration(String generatedClassName, PublicationItem[] facadesToStubify) {

    String[] facades = new String[facadesToStubify.length + 1];
    for (int i = 0; i < facadesToStubify.length; i++) {
        PublicationItem publicationDescriptionItem = facadesToStubify[i];
        facades[i] = publicationDescriptionItem.getFacadeClass().getName();
    }
    facades[facadesToStubify.length] = "org.codehaus.jremoting.client.Stub";


    classGen = new ClassGen(generatedClassName, "java.lang.Object", generatedClassName + ".java", Constants.ACC_PUBLIC | Constants.ACC_SUPER | Constants.ACC_FINAL, facades);
    constantsPool = classGen.getConstantPool();
    factory = new InstructionFactory(classGen, constantsPool);
    internalFieldRepresentingClasses = new ArrayList<String>();

}
 
开发者ID:paul-hammant,项目名称:JRemoting,代码行数:24,代码来源:BcelStubGenerator.java

示例4: handle_runnable

import org.apache.bcel.generic.ClassGen; //导入依赖的package包/类
private static Set<String> handle_runnable(String invoke_cname, Map<String, ClassGen> map) {
	Set<String> ret = new HashSet<String>();

	// only need to check sub classes
	Set<String> sub_cnames = ClassHierarchyMap.getSubClassNames(invoke_cname);
	if (!sub_cnames.isEmpty()) {
		for (Iterator<String> _iter = sub_cnames.iterator(); _iter.hasNext();) {
			String sub_cname = _iter.next();

			assert (map.containsKey(sub_cname)) : "ERR: " + sub_cname + " not in map";
			ret.add(sub_cname);
		}
	}

	return ret;
}
 
开发者ID:USC-NSL,项目名称:SIF,代码行数:17,代码来源:CallHierarchyBuilder.java

示例5: handle_invokeinterface

import org.apache.bcel.generic.ClassGen; //导入依赖的package包/类
private static Set<String> handle_invokeinterface(String invoke_cname, String invoke_mname, String invoke_msig, Map<String, ClassGen> map) {
	Set<String> ret = new HashSet<String>();

	// only need to check sub classes
	Set<String> sub_cnames = ClassHierarchyMap.getSubClassNames(invoke_cname);
	if (!sub_cnames.isEmpty()) {
		for (Iterator<String> _iter = sub_cnames.iterator(); _iter.hasNext();) {
			String sub_cname = _iter.next();

			assert (map.containsKey(sub_cname)) : "ERR: " + sub_cname + " not in map";

			ClassGen sub_cgen = map.get(sub_cname);
			Method sub_mthd = sub_cgen.containsMethod(invoke_mname, invoke_msig);

			if (sub_mthd != null && !sub_mthd.isAbstract() && (sub_mthd.isPublic() || sub_mthd.isProtected())) {
				ret.add(sub_cname);
			}
		}
	}

	return ret;
}
 
开发者ID:USC-NSL,项目名称:SIF,代码行数:23,代码来源:CallHierarchyBuilder.java

示例6: 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

示例7: generateInitField

import org.apache.bcel.generic.ClassGen; //导入依赖的package包/类
@Override
public void generateInitField(InstructionList il, InstructionFactory ifact, GenScope scope) {
	RequiredQueueJVMGen jvmQ = this;
	ClassGen cg = scope.getClassGen();
	
	il.append(ifact.createNew(jvmQ.getType().getClassName()));
	il.append(new DUP());		

	il.append(ifact.createConstant(jvmQ.getName()));
	// il.append(InstructionConstants.THIS); 
	/*
	il.append(ifact.createInvoke(jvmQ.getClassName(), "<init>",
				Type.VOID, new Type[] { Type.STRING, DefaultTypes.QoolTransformation }, Constants.INVOKESPECIAL));				
	*/
	// required queues do not take a qool transformation, but just delegates in one
	il.append(ifact.createInvoke(jvmQ.getClassName(), "<init>",
			Type.VOID, new Type[] { Type.STRING }, Constants.INVOKESPECIAL));				
	
	// Set the field
	il.append(InstructionConstants.THIS); 
	il.append(InstructionConstants.SWAP); 

	il.append( ifact.createPutField(cg.getClassName(), jvmQ.getFieldName(), jvmQ.getType()) );		
}
 
开发者ID:jesusc,项目名称:eclectic,代码行数:25,代码来源:RequiredQueueJVMGen.java

示例8: generateConfigure

import org.apache.bcel.generic.ClassGen; //导入依赖的package包/类
public void generateConfigure(InstructionList il, InstructionFactory ifact, GenScope scope) {
	RequiredQueueJVMGen jvmQ = this;
	ClassGen cg = scope.getClassGen();
	
	// Set the delegate
	// 1. Get the transformation (as a model)
	// 2. Obtain the queue
	il.append( InstructionFactory.THIS );
	il.append( ifact.createGetField(cg.getClassName(), jvmQ.getFieldName(), jvmQ.getType()) );		
	scope.generateGetModel(getImportedModel().getName());
	il.append(ifact.createCheckCast(DefaultTypes.QoolTransformation));
	il.append(ifact.createConstant(this.getName()));
	il.append(ifact.createInvoke(DefaultTypes.QoolTransformation.getClassName(), "getQueue",
				DefaultTypes.IQueue, new Type[] { Type.STRING }, Constants.INVOKEVIRTUAL));
	//CommonGen.print(il, ifact);
	
	il.append(ifact.createInvoke(jvmQ.getClassName(), "setDelegate",
			Type.VOID, new Type[] { DefaultTypes.IQueue }, Constants.INVOKEVIRTUAL));				
	
}
 
开发者ID:jesusc,项目名称:eclectic,代码行数:21,代码来源:RequiredQueueJVMGen.java

示例9: generateObserverClasses

import org.apache.bcel.generic.ClassGen; //导入依赖的package包/类
private void generateObserverClasses(ClassGen cg, TransformationContext context, MetamodelManager metamodelManager) {
	for (ModelDefinition model : getModels()) {
		if ( model.getKind() == ModelKind.IN && model.getMetamodel() != null ) {
			Object description = metamodelManager.getDescription(model.getMetamodel().getPath());
			if ( description instanceof ApiDescription ) {
				EList<DeclaredElement> declaredElements = ((ApiDescription) description).getDeclaredElements();
				for (DeclaredElement declaredElement : declaredElements) {
					if ( declaredElement instanceof ObserverDescription ) {
						String cname = generateObserverClass(model, (ObserverDescription) declaredElement, context);
						createObserverCreatorMethod(cg, (ObserverDescription) declaredElement, cname);
					}
				}
			}
		}
	}
}
 
开发者ID:jesusc,项目名称:eclectic,代码行数:17,代码来源:QoolTransformationJVMGen.java

示例10: 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

示例11: generateInitField

import org.apache.bcel.generic.ClassGen; //导入依赖的package包/类
@Override
public void generateInitField(InstructionList il, InstructionFactory ifact, GenScope scope) {
	LocalQueueJVMGen jvmQ = this;
	ClassGen cg = scope.getClassGen();
	
	il.append(ifact.createNew(jvmQ.getType().getClassName()));
	il.append(new DUP());		

	il.append(ifact.createConstant(jvmQ.getName()));
	il.append(InstructionConstants.THIS); 
	il.append(ifact.createInvoke(jvmQ.getClassName(), "<init>",
				Type.VOID, new Type[] { Type.STRING, DefaultTypes.QoolTransformation }, Constants.INVOKESPECIAL));				
	
	// Stack: queue
	il.append(InstructionConstants.THIS); 
	il.append(InstructionConstants.SWAP); 

	il.append( ifact.createPutField(cg.getClassName(), jvmQ.getFieldName(), jvmQ.getType()) );		
}
 
开发者ID:jesusc,项目名称:eclectic,代码行数:20,代码来源:LocalQueueJVMGen.java

示例12: 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

示例13: genContinuableCallCode

import org.apache.bcel.generic.ClassGen; //导入依赖的package包/类
public void genContinuableCallCode(GenScope transformationScope, ClassGen cg, MethodGen mg) {
	InstructionList il = mg.getInstructionList();
	InstructionFactory ifact = new InstructionFactory(cg);

	il.append(InstructionConstants.THIS);
	il.append(ifact.createConstant(getSegmentClassName()));
	transformationScope.generateGetTransformation();
	transformationScope.generateGetModelManager();
	il.append(ifact.createInvoke(DefaultTypes.QoolTransformation.getClassName(), "startSegment",
			Type.VOID, new Type[] { Type.STRING, DefaultTypes.IdcTransformation, DefaultTypes.ModelManager }, Constants.INVOKEVIRTUAL));		
	
	/*
	il.append(ifact.createConstant(getSegmentClassName()));
	transformationScope.generateGetTransformation();
	transformationScope.generateGetModelManager();
	il.append(ifact.createInvoke(DefaultTypes.RuntimeUtil.getClassName(), "startSegment",
			Type.VOID, new Type[] { Type.STRING, DefaultTypes.IdcTransformation, DefaultTypes.ModelManager }, Constants.INVOKESTATIC));		
	*/
}
 
开发者ID:jesusc,项目名称:eclectic,代码行数:20,代码来源:QoolSegmentJVMGen.java

示例14: createStartMethod

import org.apache.bcel.generic.ClassGen; //导入依赖的package包/类
private void createStartMethod(GenScope scope, ClassGen cg) {
	InstructionList il = new InstructionList();
	InstructionFactory ifact = new InstructionFactory(cg);
	
	MethodGen startMg = new MethodGen(Constants.ACC_PUBLIC,// access flags
			Type.VOID, // return type
			null, null, // arg
			// names
			START_METHOD, null, // method, class
			il, cg.getConstantPool());
	scope.processMethod(startMg);		
	il.append(InstructionConstants.RETURN);
	
	startMg.setMaxLocals();
	startMg.setMaxStack();
	
	cg.addMethod(startMg.getMethod());		
}
 
开发者ID:jesusc,项目名称:eclectic,代码行数:19,代码来源:MethodLibraryJVMGen.java

示例15: updateEditPanes

import org.apache.bcel.generic.ClassGen; //导入依赖的package包/类
private void updateEditPanes() {
    internalFrame = (BrowserInternalFrame) services;
    ClassFile classFile = services.getClassFile();
    MethodInfo[] methods = classFile.getMethods();
    String contents;
    try {
        JavaClass javaClass = new ClassParser(internalFrame.getFileName()).parse();
        ClassGen cg = new ClassGen(javaClass);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        BCELifier v = new BCELifier(javaClass, out);
        v.start();
        contents = out.toString();
    } catch (Exception e) {
        contents = "Failed to load/bcelify file";
    }
    for (int i = 0; i < methods.length; i++) {
        String methodIndex = Integer.toString(i);
        addEditPane(contents, methodIndex);
    }
}
 
开发者ID:miuirussia,项目名称:KJBE,代码行数:21,代码来源:BCELifyPane.java


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