本文整理汇总了Java中org.apache.bcel.generic.InstructionConstants类的典型用法代码示例。如果您正苦于以下问题:Java InstructionConstants类的具体用法?Java InstructionConstants怎么用?Java InstructionConstants使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InstructionConstants类属于org.apache.bcel.generic包,在下文中一共展示了InstructionConstants类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createHelperMethodForDotClassCalls
import org.apache.bcel.generic.InstructionConstants; //导入依赖的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
示例2: storeLocal
import org.apache.bcel.generic.InstructionConstants; //导入依赖的package包/类
public void storeLocal(int pc, int slot) {
boolean isupval = pi.isUpvalueAssign(pc, slot);
int index = findSlotIndex( slot, isupval );
if (isupval) {
boolean isupcreate = pi.isUpvalueCreate(pc, slot);
if ( isupcreate ) {
append(factory.createInvoke(classname, "newupe", TYPE_LOCALUPVALUE, ARG_TYPES_NONE, Constants.INVOKESTATIC));
append(InstructionConstants.DUP);
append(new ASTORE(index));
} else {
append(new ALOAD(index));
}
append(InstructionConstants.SWAP);
append(new PUSH(cp, 0));
append(InstructionConstants.SWAP);
append(InstructionConstants.AASTORE);
} else {
append(new ASTORE(index));
}
}
开发者ID:gnosygnu,项目名称:luaj_xowa,代码行数:21,代码来源:JavaBuilder.java
示例3: generateInitField
import org.apache.bcel.generic.InstructionConstants; //导入依赖的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
示例4: createObserverCreatorMethod
import org.apache.bcel.generic.InstructionConstants; //导入依赖的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
示例5: generateInitField
import org.apache.bcel.generic.InstructionConstants; //导入依赖的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
示例6: genContinuableCallCode
import org.apache.bcel.generic.InstructionConstants; //导入依赖的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
示例7: createStartMethod
import org.apache.bcel.generic.InstructionConstants; //导入依赖的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
示例8: generateStreamer
import org.apache.bcel.generic.InstructionConstants; //导入依赖的package包/类
protected void generateStreamer(ConstantPoolGen cp, InstructionList il, InstructionFactory factory, String className, boolean hasHeader)
{
il.append(InstructionConstants.ALOAD_0);
il.append(InstructionConstants.ALOAD_1);
il.append(InstructionConstants.DUP2);
il.append(factory.createInvoke("org.dianahep.root4j.core.RootInput", "readInt", Type.INT, Type.NO_ARGS, INVOKEINTERFACE));
il.append(InstructionConstants.DUP_X1);
il.append(factory.createPutField(className, "fN", Type.INT));
il.append(new NEWARRAY(Type.FLOAT));
il.append(InstructionConstants.DUP_X1);
il.append(factory.createInvoke("org.dianahep.root4j.core.RootInput", "readFixedArray", Type.VOID, arrayArgType, INVOKEINTERFACE));
il.append(factory.createPutField(className, "fArray", RootType.FLOATARRAY));
}
开发者ID:diana-hep,项目名称:root4j,代码行数:14,代码来源:TArrayF.java
示例9: generateStreamer
import org.apache.bcel.generic.InstructionConstants; //导入依赖的package包/类
protected void generateStreamer(ConstantPoolGen cp, InstructionList il, InstructionFactory factory, String className, boolean hasHeader)
{
il.append(InstructionConstants.ALOAD_0);
il.append(InstructionConstants.ALOAD_1);
il.append(InstructionConstants.DUP2);
il.append(factory.createInvoke("org.dianahep.root4j.core.RootInput", "readInt", Type.INT, Type.NO_ARGS, INVOKEINTERFACE));
il.append(InstructionConstants.DUP_X1);
il.append(factory.createPutField(className, "fN", Type.INT));
il.append(new NEWARRAY(Type.CHAR));
il.append(InstructionConstants.DUP_X1);
il.append(factory.createInvoke("org.dianahep.root4j.core.RootInput", "readFixedArray", Type.VOID, arrayArgType, INVOKEINTERFACE));
il.append(factory.createPutField(className, "fArray", RootType.CHARARRAY));
}
开发者ID:diana-hep,项目名称:root4j,代码行数:14,代码来源:TArrayC.java
示例10: generateStreamer
import org.apache.bcel.generic.InstructionConstants; //导入依赖的package包/类
protected void generateStreamer(ConstantPoolGen cp, InstructionList il, InstructionFactory factory, String className, boolean hasHeader)
{
il.append(InstructionConstants.ALOAD_0);
il.append(InstructionConstants.ALOAD_1);
il.append(InstructionConstants.DUP2);
il.append(factory.createInvoke("org.dianahep.root4j.core.RootInput", "readInt", Type.INT, Type.NO_ARGS, INVOKEINTERFACE));
il.append(InstructionConstants.DUP_X1);
il.append(factory.createPutField(className, "fN", Type.INT));
il.append(new NEWARRAY(Type.DOUBLE));
il.append(InstructionConstants.DUP_X1);
il.append(factory.createInvoke("org.dianahep.root4j.core.RootInput", "readFixedArray", Type.VOID, arrayArgType, INVOKEINTERFACE));
il.append(factory.createPutField(className, "fArray", RootType.DOUBLEARRAY));
}
开发者ID:diana-hep,项目名称:root4j,代码行数:14,代码来源:TArrayD.java
示例11: generateStreamer
import org.apache.bcel.generic.InstructionConstants; //导入依赖的package包/类
protected void generateStreamer(ConstantPoolGen cp, InstructionList il, InstructionFactory factory, String className, boolean hasHeader)
{
il.append(InstructionConstants.ALOAD_0);
il.append(InstructionConstants.ALOAD_1);
il.append(InstructionConstants.DUP2);
il.append(factory.createInvoke("org.dianahep.root4j.core.RootInput", "readInt", Type.INT, Type.NO_ARGS, INVOKEINTERFACE));
il.append(InstructionConstants.DUP_X1);
il.append(factory.createPutField(className, "fN", Type.INT));
il.append(new NEWARRAY(Type.INT));
il.append(InstructionConstants.DUP_X1);
il.append(factory.createInvoke("org.dianahep.root4j.core.RootInput", "readFixedArray", Type.VOID, arrayArgType, INVOKEINTERFACE));
il.append(factory.createPutField(className, "fArray", RootType.INTARRAY));
}
开发者ID:diana-hep,项目名称:root4j,代码行数:14,代码来源:TArrayI.java
示例12: generateReadCode
import org.apache.bcel.generic.InstructionConstants; //导入依赖的package包/类
public void generateReadCode(InstructionList il, InstructionFactory factory, ConstantPoolGen cp, String className)
{
if (pointer)
{
((GenericRootClass) varClass).generateReadPointerCode(il, factory, cp);
}
else if (dim == 0)
{
varClass.generateReadCode(il, factory, cp);
}
else if (varCounter == null)
{
((IntrinsicRootClass) varClass).generateReadArrayCode(il, factory, cp, 1, new int[]{index});
}
else
{
BasicMember varMember = getMember(varCounter);
if (varMember == null) throw new RuntimeException("Cannot find variable counter "+varCounter);
Type varMemberType = varMember.getJavaType();
il.append(InstructionConstants.ALOAD_0);
il.append(factory.createInvoke(className, nameMangler.mangleMember(varCounter), varMemberType, Type.NO_ARGS, INVOKESPECIAL));
if (varMemberType != Type.INT && varMemberType != Type.BYTE && varMemberType != Type.CHAR && varMemberType != Type.SHORT)
il.append(factory.createCast(varMemberType, Type.INT));
BasicType type = (BasicType) varClass.getJavaType();
il.append(new NEWARRAY(type));
il.append(InstructionConstants.DUP_X1);
Type[] arrayArgType = new Type[] { new ArrayType(type, 1) };
il.append(factory.createInvoke("org.dianahep.root4j.core.RootInput", "readFixedArray", Type.VOID, arrayArgType, INVOKEINTERFACE));
}
if (varClass.getConvertMethod() != null)
{
il.append(factory.createInvoke("org.dianahep.root4j.interfaces." + varClass.getClassName(), varClass.getConvertMethod(), varClass.getJavaTypeForMethod(), Type.NO_ARGS, INVOKEINTERFACE));
}
}
开发者ID:diana-hep,项目名称:root4j,代码行数:37,代码来源:StreamerInfoString.java
示例13: generateMethods
import org.apache.bcel.generic.InstructionConstants; //导入依赖的package包/类
private static void generateMethods(RootClass k, ConstantPoolGen cp, InstructionList il, InstructionFactory factory, ClassGen cg, String className, String clonesClassName)
{
RootMember[] members = k.getMembers();
for (int i = 0; i < members.length; i++)
{
BasicMember member = (BasicMember) members[i];
Type type = member.getJavaType();
Type arrayType = new ArrayType(type, 1);
MethodGen mg = new MethodGen(ACC_PUBLIC, type, null, null, nameMangler.mangleMember(member.getName()), className, il, cp);
il.append(InstructionConstants.ALOAD_0);
il.append(factory.createGetField(className, "clones", new ObjectType(clonesClassName)));
il.append(InstructionConstants.ALOAD_0);
il.append(factory.createGetField(className, "index", Type.INT));
il.append(factory.createInvoke(clonesClassName, nameMangler.mangleMember(member.getName()), type, new Type[]
{
Type.INT
}, INVOKEVIRTUAL));
il.append(InstructionFactory.createReturn(type));
mg.setMaxStack();
mg.setMaxLocals();
cg.addMethod(mg.getMethod());
il.dispose();
}
}
开发者ID:diana-hep,项目名称:root4j,代码行数:29,代码来源:Clone2Builder.java
示例14: injectCommonExceptionCatchBlock
import org.apache.bcel.generic.InstructionConstants; //导入依赖的package包/类
/**
* Inject common exception catch blocks
*/
public void injectCommonExceptionCatchBlock(InstructionList il, MethodGen method, int variableIndex) {
il.append(new INSTANCEOF(constantsPool.addClass(new ObjectType("java.lang.RuntimeException"))));
BranchInstruction b1 = InstructionFactory.createBranchInstruction(Constants.IFEQ, null);
il.append(b1);
il.append(InstructionFactory.createLoad(Type.OBJECT, variableIndex));
il.append(factory.createCheckCast(new ObjectType("java.lang.RuntimeException")));
il.append(InstructionConstants.ATHROW);
InstructionHandle ih1 = il.append(InstructionFactory.createLoad(Type.OBJECT, variableIndex));
il.append(new INSTANCEOF(constantsPool.addClass(new ObjectType("java.lang.Error"))));
BranchInstruction b2 = InstructionFactory.createBranchInstruction(Constants.IFEQ, null);
il.append(b2);
il.append(InstructionFactory.createLoad(Type.OBJECT, variableIndex));
il.append(factory.createCheckCast(new ObjectType("java.lang.Error")));
il.append(InstructionConstants.ATHROW);
InstructionHandle ih2 = il.append(InstructionFactory.createLoad(Type.OBJECT, variableIndex));
il.append(factory.createInvoke("java.lang.Throwable", "printStackTrace", Type.VOID, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
il.append(factory.createNew("org.codehaus.jremoting.client.InvocationException"));
il.append(InstructionConstants.DUP);
il.append(factory.createNew("java.lang.StringBuffer"));
il.append(InstructionConstants.DUP);
il.append(new PUSH(constantsPool, "Should never get here: "));
il.append(factory.createInvoke("java.lang.StringBuffer", "<init>", Type.VOID, new Type[]{Type.STRING}, Constants.INVOKESPECIAL));
il.append(InstructionFactory.createLoad(Type.OBJECT, variableIndex));
il.append(factory.createInvoke("java.lang.Throwable", "getMessage", Type.STRING, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
il.append(factory.createInvoke("java.lang.StringBuffer", "append", Type.STRINGBUFFER, new Type[]{Type.STRING}, Constants.INVOKEVIRTUAL));
il.append(factory.createInvoke("java.lang.StringBuffer", "toString", Type.STRING, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
il.append(factory.createInvoke("org.codehaus.jremoting.client.InvocationException", "<init>", Type.VOID, new Type[]{Type.STRING}, Constants.INVOKESPECIAL));
il.append(InstructionConstants.ATHROW);
b1.setTarget(ih1);
b2.setTarget(ih2);
}
开发者ID:paul-hammant,项目名称:JRemoting,代码行数:37,代码来源:BcelStubGenerator.java
示例15: change1
import org.apache.bcel.generic.InstructionConstants; //导入依赖的package包/类
private boolean change1(MethodGen mg)
{
InstructionList il = mg.getInstructionList();
InstructionFinder f = new InstructionFinder(il);
String pat = "[LDC_W|LDC] INVOKEVIRTUAL IFNE ICONST_1 GOTO ICONST_0";
boolean changed = false;
for(Iterator j = f.search(pat, new IsLdcClass()); j.hasNext(); )
{
InstructionHandle[] match = (InstructionHandle[]) j.next();
// replace
// LDC_W <class>
// INVOKEVIRTUAL Class.desiredAssertionStatus
// IFNE
// ICONST_1
// goto
// ICONST_0
// with
// ICONST_1
changed = true;
match[0].setInstruction(InstructionConstants.ICONST_1);
try
{
il.delete(match[1], match[5]);
// System.out.println(il);
}
catch (TargetLostException e)
{
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
}
return changed;
}
开发者ID:BowlerHatLLC,项目名称:feathers-sdk,代码行数:36,代码来源:Downgrader.java
示例16: loadLocal
import org.apache.bcel.generic.InstructionConstants; //导入依赖的package包/类
public void loadLocal(int pc, int slot) {
boolean isupval = pi.isUpvalueRefer(pc, slot);
int index = findSlotIndex( slot, isupval );
append(new ALOAD(index));
if (isupval) {
append(new PUSH(cp, 0));
append(InstructionConstants.AALOAD);
}
}
开发者ID:gnosygnu,项目名称:luaj_xowa,代码行数:10,代码来源:JavaBuilder.java
示例17: loadUpvalue
import org.apache.bcel.generic.InstructionConstants; //导入依赖的package包/类
public void loadUpvalue(int upindex) {
boolean isrw = pi.isReadWriteUpvalue( pi.upvals[upindex] );
append(InstructionConstants.THIS);
if ( isrw ) {
append(factory.createFieldAccess(classname, upvalueName(upindex), TYPE_LOCALUPVALUE, Constants.GETFIELD));
append(new PUSH(cp,0));
append(InstructionConstants.AALOAD);
} else {
append(factory.createFieldAccess(classname, upvalueName(upindex), TYPE_LUAVALUE, Constants.GETFIELD));
}
}
开发者ID:gnosygnu,项目名称:luaj_xowa,代码行数:12,代码来源:JavaBuilder.java
示例18: storeUpvalue
import org.apache.bcel.generic.InstructionConstants; //导入依赖的package包/类
public void storeUpvalue(int pc, int upindex, int slot) {
boolean isrw = pi.isReadWriteUpvalue( pi.upvals[upindex] );
append(InstructionConstants.THIS);
if ( isrw ) {
append(factory.createFieldAccess(classname, upvalueName(upindex), TYPE_LOCALUPVALUE, Constants.GETFIELD));
append(new PUSH(cp,0));
loadLocal(pc, slot);
append(InstructionConstants.AASTORE);
} else {
loadLocal(pc, slot);
append(factory.createFieldAccess(classname, upvalueName(upindex), TYPE_LUAVALUE, Constants.PUTFIELD));
}
}
开发者ID:gnosygnu,项目名称:luaj_xowa,代码行数:14,代码来源:JavaBuilder.java
示例19: loadArrayArgs
import org.apache.bcel.generic.InstructionConstants; //导入依赖的package包/类
public void loadArrayArgs(int pc, int firstslot, int nargs) {
append(new PUSH(cp, nargs));
append(new ANEWARRAY(cp.addClass(STR_LUAVALUE)));
for ( int i=0; i<nargs; i++ ) {
append(InstructionConstants.DUP);
append(new PUSH(cp, i));
loadLocal(pc, firstslot++);
append(new AASTORE());
}
}
开发者ID:gnosygnu,项目名称:luaj_xowa,代码行数:11,代码来源:JavaBuilder.java
示例20: closureInitUpvalueFromUpvalue
import org.apache.bcel.generic.InstructionConstants; //导入依赖的package包/类
public void closureInitUpvalueFromUpvalue(String protoname, int newup, int upindex) {
boolean isrw = pi.isReadWriteUpvalue( pi.upvals[upindex] );
Type uptype = isrw? (Type) TYPE_LOCALUPVALUE: (Type) TYPE_LUAVALUE;
String srcname = upvalueName(upindex);
String destname = upvalueName(newup);
append(InstructionConstants.THIS);
append(factory.createFieldAccess(classname, srcname, uptype, Constants.GETFIELD));
append(factory.createFieldAccess(protoname, destname, uptype, Constants.PUTFIELD));
}
开发者ID:gnosygnu,项目名称:luaj_xowa,代码行数:10,代码来源:JavaBuilder.java
注:本文中的org.apache.bcel.generic.InstructionConstants类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论