本文整理汇总了Java中org.apache.bcel.generic.InstructionFactory类的典型用法代码示例。如果您正苦于以下问题:Java InstructionFactory类的具体用法?Java InstructionFactory怎么用?Java InstructionFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InstructionFactory类属于org.apache.bcel.generic包,在下文中一共展示了InstructionFactory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createNewClassDeclaration
import org.apache.bcel.generic.InstructionFactory; //导入依赖的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
示例2: createHelperMethodForDotClassCalls
import org.apache.bcel.generic.InstructionFactory; //导入依赖的package包/类
/**
* Creates a method class$(String) which is used
* during SomeClass.class instruction
*
* @param generatedClassName the instance class name
*/
protected void createHelperMethodForDotClassCalls(String generatedClassName) {
InstructionList il = new InstructionList();
MethodGen method = new MethodGen(Constants.ACC_STATIC, new ObjectType("java.lang.Class"), new Type[]{Type.STRING}, new String[]{"arg0"}, "class$", generatedClassName, il, constantsPool);
InstructionHandle ih0 = il.append(InstructionFactory.createLoad(Type.OBJECT, 0));
il.append(factory.createInvoke("java.lang.Class", "forName", new ObjectType("java.lang.Class"), new Type[]{Type.STRING}, Constants.INVOKESTATIC));
InstructionHandle ih4 = il.append(InstructionFactory.createReturn(Type.OBJECT));
InstructionHandle ih5 = il.append(InstructionFactory.createStore(Type.OBJECT, 1));
il.append(factory.createNew("java.lang.NoClassDefFoundError"));
il.append(InstructionConstants.DUP);
il.append(InstructionFactory.createLoad(Type.OBJECT, 1));
il.append(factory.createInvoke("java.lang.Throwable", "getMessage", Type.STRING, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
il.append(factory.createInvoke("java.lang.NoClassDefFoundError", "<init>", Type.VOID, new Type[]{Type.STRING}, Constants.INVOKESPECIAL));
il.append(InstructionConstants.ATHROW);
method.addExceptionHandler(ih0, ih4, ih5, new ObjectType("java.lang.ClassNotFoundException"));
method.setMaxStack();
method.setMaxLocals();
classGen.addMethod(method.getMethod());
il.dispose();
}
开发者ID:paul-hammant,项目名称:JRemoting,代码行数:26,代码来源:BcelStubGenerator.java
示例3: generateEqualsMethod
import org.apache.bcel.generic.InstructionFactory; //导入依赖的package包/类
private void generateEqualsMethod(String generatedClassName) {
/* public boolean equals(Object o) {
* return stubHelper.isEquals(this,o);
* }
*/
InstructionList il = new InstructionList();
MethodGen method = new MethodGen(Constants.ACC_PUBLIC, Type.BOOLEAN, new Type[]{Type.OBJECT}, new String[]{"arg0"}, "equals", generatedClassName, il, constantsPool);
il.append(InstructionFactory.createLoad(Type.OBJECT, 0));
il.append(factory.createFieldAccess(generatedClassName, "stubHelper", new ObjectType("org.codehaus.jremoting.client.StubHelper"), Constants.GETFIELD));
il.append(InstructionFactory.createLoad(Type.OBJECT, 0));
il.append(InstructionFactory.createLoad(Type.OBJECT, 1));
il.append(factory.createInvoke("org.codehaus.jremoting.client.StubHelper", "isEquals", Type.BOOLEAN, new Type[]{Type.OBJECT, Type.OBJECT}, Constants.INVOKEINTERFACE));
il.append(InstructionFactory.createReturn(Type.INT));
method.setMaxStack();
method.setMaxLocals();
classGen.addMethod(method.getMethod());
il.dispose();
}
开发者ID:paul-hammant,项目名称:JRemoting,代码行数:24,代码来源:BcelStubGenerator.java
示例4: addTransactionMethod
import org.apache.bcel.generic.InstructionFactory; //导入依赖的package包/类
protected void addTransactionMethod(ParsedMethod pm) {
String et = EntityTransaction.class.getCanonicalName();
GeneratedMethod gm = new GeneratedMethod(pm);
InstructionList il = gm.start();
writeMethodPreamble(gm, il);
il.append(_factory.createInvoke(EM_TYPE, "getTransaction",
new ObjectType(et), Type.NO_ARGS, Constants.INVOKEINTERFACE));
il.append(_factory.createInvoke(et, pm.getMethod().getName(),
Type.VOID, Type.NO_ARGS, Constants.INVOKEINTERFACE));
il.append(InstructionFactory.createReturn(Type.VOID));
gm.done();
}
开发者ID:abassouk,项目名称:autodao,代码行数:17,代码来源:DAOAnalysis.java
示例5: addPassThruMethod
import org.apache.bcel.generic.InstructionFactory; //导入依赖的package包/类
protected void addPassThruMethod(ParsedMethod m) {
GeneratedMethod gm = new GeneratedMethod(m);
InstructionList il = gm.start();
Type returnType = gm.getReturnType();
boolean hasArg = m.getArgumentLength() > 0;
writeMethodPreamble(gm, il);
if (hasArg)
il.append(InstructionFactory.createLoad(Type.OBJECT, 1));
il.append(_factory.createInvoke(EM_TYPE, m.getMethod().getName(),
returnType == Type.VOID ? Type.VOID : Type.OBJECT,
hasArg ? new Type[] { Type.OBJECT } : Type.NO_ARGS,
Constants.INVOKEINTERFACE));
if (returnType != Type.VOID) {
il.append(_factory.createCheckCast(((ReferenceType) returnType)));
}
il.append(InstructionFactory.createReturn(returnType));
gm.done();
}
开发者ID:abassouk,项目名称:autodao,代码行数:23,代码来源:DAOAnalysis.java
示例6: addFindMethod
import org.apache.bcel.generic.InstructionFactory; //导入依赖的package包/类
protected void addFindMethod(ParsedMethod m) {
GeneratedMethod gm = new GeneratedMethod(m);
InstructionList il = gm.start();
writeMethodPreamble(gm, il);
il.append(new PUSH(_cp, (ObjectType) gm.getReturnType()));
m.getArguments()[0].pushAsObject(il);
il.append(_factory.createInvoke(EM_TYPE, "find", Type.OBJECT,
new Type[] { Type.CLASS, Type.OBJECT }, Constants.INVOKEINTERFACE));
il.append(_factory.createCheckCast(((ReferenceType) gm.getReturnType())));
il.append(InstructionFactory.createReturn(gm.getReturnType()));
gm.done();
}
开发者ID:abassouk,项目名称:autodao,代码行数:18,代码来源:DAOAnalysis.java
示例7: generateGetModel
import org.apache.bcel.generic.InstructionFactory; //导入依赖的package包/类
public void generateGetModel(Variable v, GenScope scope) {
InstructionList il = scope.getInstructionList();
InstructionFactory ifact = scope.getInstructionFactory();
try {
String modelName = Processor.getModel(v, scope.getTransformationContext()).getModelName();
generateGetModel(modelName, il, ifact, scope);
} catch ( IdcException e ) {
// System.out.println("Warning: " + e.getMessage());
// no model found! -> obtain model dynamically
generateGetModelManager(il, ifact, scope.getTransformationContext(), scope);
// get the namespace for the EObject
scope.loadVariable(v, il);
il.append(ifact.createInvoke(DefaultTypes.ModelManager.getClassName(),
"getNamespace", DefaultTypes.IModel,
new Type[] { ObjectType.OBJECT },
Constants.INVOKEVIRTUAL));
}
}
开发者ID:jesusc,项目名称:eclectic,代码行数:22,代码来源:CommonGen.java
示例8: genCreate
import org.apache.bcel.generic.InstructionFactory; //导入依赖的package包/类
/**
* <<GET_IMODEL(THIS)>>
* LDC className
* INVOKEINTERFACE createObject
*/
@Override
public void genCreate(Create c, GenScope scope) {
InstructionList il = scope.getInstructionList();
InstructionFactory ifact = scope.getInstructionFactory();
ConstantPoolGen cpg = scope.getConstantPool();
// generate model access
scope.generateGetModel(modelName);
// CommonGen.generateGetModel(modelName, il, ifact, scope.getTransformationContext() );
// push className
il.append(new LDC(cpg.addString(c.getClassName())));
// invoke
il.append(ifact.createInvoke(DefaultTypes.IModel.getClassName(),
"createObject", Type.OBJECT,
new Type[] { Type.STRING },
DefaultTypes.IModelCall));
}
开发者ID:jesusc,项目名称:eclectic,代码行数:26,代码来源:RegularModelStrategy.java
示例9: castIfNeeded
import org.apache.bcel.generic.InstructionFactory; //导入依赖的package包/类
private void castIfNeeded(InstructionList il, InstructionFactory ifact, String paramType) {
if ( paramType.equals("boolean") ) {
il.append(ifact.createCheckCast(new ObjectType(Boolean.class.getName())));
il.append(ifact.createInvoke(Boolean.class.getName(), "booleanValue", Type.BOOLEAN, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
} else if ( paramType.equals("double") ) {
il.append(ifact.createCheckCast(new ObjectType(Double.class.getName())));
il.append(ifact.createInvoke(Double.class.getName(), "doubleValue", Type.DOUBLE, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
} else if ( paramType.equals("int") ) {
il.append(ifact.createInvoke(DefaultTypes.RuntimeUtil.getClassName(), "convertInt", Type.INT, new Type[] { Type.OBJECT }, Constants.INVOKESTATIC));
//il.append(ifact.createCheckCast(new ObjectType(Integer.class.getName())));
//il.append(ifact.createInvoke(Integer.class.getName(), "intValue", Type.INT, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
} else {
ObjectType objectType = new ObjectType(paramType);
il.append(ifact.createCheckCast(objectType));
}
}
开发者ID:jesusc,项目名称:eclectic,代码行数:17,代码来源:ApiModelStrategy.java
示例10: appendMethodCall
import org.apache.bcel.generic.InstructionFactory; //导入依赖的package包/类
private void appendMethodCall(GenScope scope, InstructionList il, InstructionFactory ifact) {
MethodCallJVMGen gen = new MethodCallJVMGen();
gen.setColumn( getColumn() );
gen.setRow( getRow() );
gen.setFile( getFile() );
gen.setName( this.getName() );
gen.setReceptor( this.getReceptor() );
gen.setMethodName( this.getFeatureName() );
gen.generateWithNoVar(scope);
// calling MethodHandler.execute(Object receptor, String methodName, IModel model)
/*
il.append(ifact.createInvoke(DefaultTypes.MethodCallHandler.getClassName(),
"execute", Type.OBJECT, new Type[] {
DefaultTypes.IModel, Type.OBJECT, Type.STRING
}, Constants.INVOKESTATIC));
*/
}
开发者ID:jesusc,项目名称:eclectic,代码行数:20,代码来源:GetJVMGen.java
示例11: generate
import org.apache.bcel.generic.InstructionFactory; //导入依赖的package包/类
@Override
public void generate(GenScope scope) {
QueueJVMGen jvmQ = (QueueJVMGen) this.getQueue();
// Load the closure into
InstructionList il = scope.getInstructionList();
InstructionFactory ifact = scope.getInstructionFactory();
// Get the queue
CommonGen.generateGetQueue(scope, jvmQ);
// Register the closure
scope.loadVariable(this.getValue(), il);
il.append(ifact.createInvoke(jvmQ.getClassName(),
"put", Type.VOID, new Type[] { Type.OBJECT }, Constants.INVOKEVIRTUAL));
}
开发者ID:jesusc,项目名称:eclectic,代码行数:17,代码来源:QEmitJVMGen.java
示例12: generateInitField
import org.apache.bcel.generic.InstructionFactory; //导入依赖的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
示例13: generateConfigure
import org.apache.bcel.generic.InstructionFactory; //导入依赖的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
示例14: generate
import org.apache.bcel.generic.InstructionFactory; //导入依赖的package包/类
@Override
public void generate(GenScope scope) {
QueueJVMGen jvmQ = (QueueJVMGen) this.getQueue();
// Generate a closure that will be called
QForAllContents closureGen = new QForAllContents();
closureGen.generate(scope);
// Load the closure into
InstructionList il = scope.getInstructionList();
InstructionFactory ifact = scope.getInstructionFactory();
// Get the queue
// TODO: I need to find out a better way of getting the transformation
// because when I put some class that is not a closure and the code need
// the transformation this just does not work (and fail in the validation with
// "incompatible argument for function call" !
scope.generateGetTransformation();
il.append(ifact.createCheckCast(new ObjectType(scope.getTransformationContext().getRuntimeClassName())));
il.append(ifact.createGetField(scope.getTransformationContext().getRuntimeClassName(), jvmQ.getFieldName(), jvmQ.getType()));
// Register the closure org.eclectic.idc.jvm.runtime
scope.loadVariable(closureGen, il);
il.append(ifact.createInvoke(jvmQ.getType().getClassName(),
"requestAll", Type.VOID, new Type[] { DefaultTypes.IClosure }, Constants.INVOKEVIRTUAL));
}
开发者ID:jesusc,项目名称:eclectic,代码行数:27,代码来源:QForAllJVMGen.java
示例15: createObserverCreatorMethod
import org.apache.bcel.generic.InstructionFactory; //导入依赖的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
示例16: generateInitField
import org.apache.bcel.generic.InstructionFactory; //导入依赖的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
示例17: generateConfigureOptimizations
import org.apache.bcel.generic.InstructionFactory; //导入依赖的package包/类
@Override
public void generateConfigureOptimizations(InstructionList il, InstructionFactory ifact, GenScope scope) {
if ( getOptimizations().size() > 1 ) throw new UnsupportedOperationException("Only one optimization at a time supported by now");
if ( getOptimizations().size() == 1 ) {
AccessByFeatureOptimization opt = (AccessByFeatureOptimization) getOptimizations().get(0);
il.append(new DUP());
il.append(ifact.createConstant(opt.getFeatureName()));
il.append(ifact.createInvoke(this.getClassName(), "configureAccessByFeatureOptimization",
Type.VOID, new Type[] { Type.STRING }, Constants.INVOKEVIRTUAL));
// TODO: Configure if the access is speculative...
}
// Sets the model of the queue statically
// It is compulsory to have a type for the queue to enable optimizations
if ( getOptimizations().size() > 0 ) {
il.append(new DUP());
scope.generateGetModel(this.getType_().getModel().getName());
il.append(ifact.createInvoke(this.getClassName(), "setModel",
Type.VOID, new Type[] { DefaultTypes.IModel }, Constants.INVOKEVIRTUAL));
}
}
开发者ID:jesusc,项目名称:eclectic,代码行数:25,代码来源:LocalQueueJVMGen.java
示例18: genContinuableCallCode
import org.apache.bcel.generic.InstructionFactory; //导入依赖的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
示例19: createStartMethod
import org.apache.bcel.generic.InstructionFactory; //导入依赖的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
示例20: generateReadCode
import org.apache.bcel.generic.InstructionFactory; //导入依赖的package包/类
public void generateReadCode(InstructionList il, InstructionFactory factory, ConstantPoolGen cp, String className)
{
String leafClassName = getClass().getName();
int arrayDim = getArrayDim();
if (arrayDim == 0)
il.append(factory.createInvoke(leafClassName, "getValue", Type.BOOLEAN, new Type[]
{
Type.LONG
}, INVOKEVIRTUAL));
else
il.append(factory.createInvoke(leafClassName, "getWrappedValue", Type.OBJECT, new Type[]
{
Type.LONG
}, INVOKEVIRTUAL));
}
开发者ID:diana-hep,项目名称:root4j,代码行数:16,代码来源:TLeafORep.java
注:本文中的org.apache.bcel.generic.InstructionFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论