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


Java INVOKESPECIAL类代码示例

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


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

示例1: createObserverCreatorMethod

import org.apache.bcel.generic.INVOKESPECIAL; //导入依赖的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

示例2: isNonEscapingConstructor

import org.apache.bcel.generic.INVOKESPECIAL; //导入依赖的package包/类
boolean isNonEscapingConstructor(INVOKESPECIAL invoker) {
    ReferenceType cls = invoker.getReferenceType(methodGen.getConstantPool());

    String className = (cls instanceof ObjectType) ? ((ObjectType) cls).getClassName() : "java.lang.Object";

    JavaClass javaClass;
    try {
        javaClass = Repository.lookupClass(className);
    } catch(ClassNotFoundException e) {
        return false;
    }
    return nonEscapingConstructor(javaClass, invoker.getSignature(methodGen.getConstantPool()));
}
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:14,代码来源:LoadAwareBasicBlock.java

示例3: isStreamOpen

import org.apache.bcel.generic.INVOKESPECIAL; //导入依赖的package包/类
public boolean isStreamOpen(BasicBlock basicBlock, InstructionHandle handle, ConstantPoolGen cpg, ResourceValueFrame frame) {
    if (isOpenOnCreation)
        return false;

    Instruction ins = handle.getInstruction();
    if (!(ins instanceof INVOKESPECIAL))
        return false;

    // Does this instruction open the stream?
    INVOKESPECIAL inv = (INVOKESPECIAL) ins;

    return frame.isValid() && getInstanceValue(frame, inv, cpg).isInstance()
            && matchMethod(inv, cpg, this.getResourceClass(), "<init>");
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:15,代码来源:Stream.java

示例4: visitINVOKESPECIAL

import org.apache.bcel.generic.INVOKESPECIAL; //导入依赖的package包/类
@Override
public void visitINVOKESPECIAL(INVOKESPECIAL obj) {
    if (returnsString(obj))
        handleInstanceMethod(obj);
    else
        super.visitINVOKESPECIAL(obj);
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:8,代码来源:FindRefComparison.java

示例5: visitINVOKESPECIAL

import org.apache.bcel.generic.INVOKESPECIAL; //导入依赖的package包/类
@Override
public void visitINVOKESPECIAL(INVOKESPECIAL obj) {
    // Don't know what this method invocation is doing.
    // Kill all loads.
    killLoadsOfObjectsPassed(obj);
    handleNormalInstruction(obj);
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:8,代码来源:ValueNumberFrameModelingVisitor.java

示例6: createConstructor

import org.apache.bcel.generic.INVOKESPECIAL; //导入依赖的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

示例7: generate

import org.apache.bcel.generic.INVOKESPECIAL; //导入依赖的package包/类
@Override
public void generate(GenScope scope) {
	InstructionList il       = scope.getInstructionList();
	InstructionFactory ifact = scope.getInstructionFactory();		

	NewScopeResult closureClassScope = createClosureClass(scope);
	ClassGen     closureClass = closureClassScope.cg;
	ClosureScope closureScope = (ClosureScope) closureClassScope.scope;
	
	scope.getTransformationContext().addExtraClass(closureClass.getJavaClass());

	LocalVariableGen lvg  = scope.newLocalVariable(this, Type.OBJECT);
	
	// Create the closure instance 
	il.append(ifact.createNew(closureClass.getClassName()));		
	il.append(new DUP());		

	scope.generateGetTransformation();
	scope.generateGetModelManager();		
	il.append(ifact.createInvoke(closureClass.getClassName(), "<init>",
			Type.VOID, new Type[] { DefaultTypes.IdcTransformation, DefaultTypes.ModelManager }, Constants.INVOKESPECIAL));
			//Type.VOID, new Type[] { DefaultTypes.ModelManager }, Constants.INVOKESPECIAL));
			
	// This is a bit hard-wired because the OuterVariableSet 
	// is computed as a result of creating the closureClass...
	OuterVariableSet outers = closureScope.getOuterVariables();
	Set<Variable> o = outers.get();
	for (Variable variable : o) {
		il.append(new DUP());
		scope.loadVariable(variable, il);
		il.append(scope.getInstructionFactory().createPutField(closureClass.getClassName(), variable.getName(), Type.OBJECT));	
	}		
			
	il.append(new ASTORE(lvg.getIndex()));
}
 
开发者ID:jesusc,项目名称:eclectic,代码行数:36,代码来源:ClosureDefJVMGen.java

示例8: createConstructor

import org.apache.bcel.generic.INVOKESPECIAL; //导入依赖的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: createConstructor

import org.apache.bcel.generic.INVOKESPECIAL; //导入依赖的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

示例10: createConstructor

import org.apache.bcel.generic.INVOKESPECIAL; //导入依赖的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

示例11: visitINVOKESPECIAL

import org.apache.bcel.generic.INVOKESPECIAL; //导入依赖的package包/类
/** @see org.apache.bcel.generic.Visitor */
public void visitINVOKESPECIAL(INVOKESPECIAL aINVOKESPECIAL)
{
    addInvokeReference(
        new InvokeReference(aINVOKESPECIAL, mCurrentPoolGen));
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:7,代码来源:ReferenceVisitor.java

示例12: visitINVOKESPECIAL

import org.apache.bcel.generic.INVOKESPECIAL; //导入依赖的package包/类
@Override
public void visitINVOKESPECIAL(INVOKESPECIAL obj) {
    visitInvoke(obj);
}
 
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:5,代码来源:TaintFrameModelingVisitor.java

示例13: noAliasesStoreWithIndexBefore

import org.apache.bcel.generic.INVOKESPECIAL; //导入依赖的package包/类
/**
 * Checks that any store in this basic block to the specified variable is the
 * result of a new() or a null.
 * @param ih handle up to where to investigate.
 * @param localVarIndex the local variable index
 * @return true if all stores are OK or there are no stores.
 */
boolean noAliasesStoreWithIndexBefore(InstructionHandle ih, LocalVariableGen lg) {
    InstructionHandle prev = null;
    for (InstructionContext ic : instructions) {
        InstructionHandle current = ic.getInstruction();
        if (current.equals(ih)) {
            break;
        }

        if (methodGen.instructionStoresTo(current, lg.getIndex())) {
            LocalVariableGen l1 = methodGen.findLocalVar(current, lg.getIndex(), false);
            if (l1 != lg) {
                prev = current;
                continue;
            }
            if (prev != null) {
                Instruction i = prev.getInstruction();
                if (i instanceof INVOKESPECIAL) {
                    INVOKESPECIAL invoker = (INVOKESPECIAL) i;
                    if (invoker.getMethodName(methodGen.getConstantPool()).equals("<init>")
                        && isNonEscapingConstructor(invoker)) {
                        continue;
                    }
                }
                if (i instanceof CHECKCAST) {
            	InstructionHandle pp = prev.getPrev();
            	if (pp != null) {
            	    i = pp.getInstruction();
            	}
                }
                if (i instanceof NEWARRAY
                        || i instanceof ANEWARRAY || i instanceof MULTIANEWARRAY
                        || i instanceof ConstantPushInstruction || i instanceof ACONST_NULL) {
                     prev = current;
                     continue;
                }
            }
            return false;

        }
        prev = current;
    }
    return true;
}
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:51,代码来源:LoadAwareBasicBlock.java

示例14: nonEscapingConstructor

import org.apache.bcel.generic.INVOKESPECIAL; //导入依赖的package包/类
boolean nonEscapingConstructor(JavaClass javaClass, String constructorSignature) {
    if (javaClass.getClassName().equals("java.lang.Object")) {
        return true;
    }
    JavaClass superClass;
    try {
        superClass = javaClass.getSuperClass();
    } catch(ClassNotFoundException e) {
        throw new Error("Superclass of " + javaClass.getClassName()
                + " not found");
    }
    Method[] methods = javaClass.getMethods();
    for (Method method : methods) {
        if (method.getName().equals("<init>") && method.getSignature().equals(constructorSignature)) {
    	if (nonEscapingConstructor(superClass, "()V")) {
    	    ClassGen cg = new ClassGen(javaClass);
    	    MethodGen mg = new MethodGen(method, javaClass.getClassName(), cg.getConstantPool());
    	    // Now check all ALOAD 0 instructions. They may only be used for
    	    // PUTFIELD and for calling super().
    	    InstructionHandle h = mg.getInstructionList().getStart();
    	    while (h != null) {
    		Instruction i = h.getInstruction();
    		if (i instanceof ALOAD && ((ALOAD) i).getIndex() == 0) {
    		    if (! mg.isUsedForPutField(h)) {
    			// Find instructions that consume exactly this load (but not more,
    			// otherwise it could be a parameter to another constructor).
    			InstructionHandle[] users = mg.findExactInstructionConsumers(h);
    			if (users.length != 1) {
    			    return false;
    			}
    	                i = users[0].getInstruction();
    	                if (i instanceof INVOKESPECIAL) {
    	                    INVOKESPECIAL invoker = (INVOKESPECIAL) i;
    	                    if (! invoker.getMethodName(mg.getConstantPool()).equals("<init>")
    	                	    || ! nonEscapingConstructor(superClass, invoker.getSignature(mg.getConstantPool()))) {
    	                	return false;
    	                    }
    	                } else {
    	                    return false;
    	                }
    		    }
    		}
    		h = h.getNext();
    	    }

    	    return true;
    	}
        }
    }
    return false;
}
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:52,代码来源:LoadAwareBasicBlock.java

示例15: run

import org.apache.bcel.generic.INVOKESPECIAL; //导入依赖的package包/类
@Override
public void run() {
	String args[] = EntryPoint.getArgs();
	String inputJarFileName = args[0];
	String outputSrgMappingsFileName = args[1];
	try (
		PrintWriter outputSrgMappingWriter = new PrintWriter(outputSrgMappingsFileName);
		JarFile inputJarFile = new JarFile(inputJarFileName)
	) {
		for (JarEntry jarEntry : new EnumerationIterator<>(inputJarFile.entries())) {
			if (jarEntry.isDirectory() || !jarEntry.getName().endsWith(".class")) {
				continue;
			}
			String original = Utils.stripClassEnding(jarEntry.getName());
			JavaClass clazz = new ClassParser(inputJarFile.getInputStream(jarEntry), original).parse();
			if (clazz.isEnum()) {
				Method staticInit = getCLInit(clazz);
				//skip enums with no static init method
				if (staticInit == null) {
					continue;
				}
				ConstantPoolGen cpGen = new ClassGen(clazz).getConstantPool();
				MethodGen methodGen = new MethodGen(staticInit, clazz.getClassName(), cpGen);
				Iterator<Instruction> instrIter = Arrays.asList(methodGen.getInstructionList().getInstructions()).iterator();
				while (instrIter.hasNext()) {
					//first goes NEW
					Instruction instr = instrIter.next();
					if (!(instr instanceof NEW)) {
						break;
					}
					//but it may actually be another new, so we check if it is for enum constant
					if (!((NEW) instr).getLoadClassType(cpGen).getClassName().equals(clazz.getClassName())) {
						break;
					}
					//then goes dup, skip it
					instrIter.next();
					//LDC with our real enum name
					String realName = (String) ((LDC) instrIter.next()).getValue(cpGen);
					//now skip everything, until we reach invokespecial with <init> for this enum field
					while (true) {
						Instruction nextInstr = instrIter.next();
						if (nextInstr instanceof INVOKESPECIAL) {
							INVOKESPECIAL ispecial = ((INVOKESPECIAL) nextInstr);
							if (ispecial.getMethodName(cpGen).equals("<init>") && (ispecial.getClassName(cpGen).equals(clazz.getClassName()))) {
								break;
							}
						}
					}
					//next is putstatic with our obufscated field name
					PUTSTATIC putstatic = (PUTSTATIC) instrIter.next();
					String obfName = putstatic.getFieldName(cpGen);
					//now print the mapping
					outputSrgMappingWriter.println(MappingUtils.createSRG(clazz.getClassName(), obfName, realName));
				}
			}
		}
	} catch (Throwable t) {
		t.printStackTrace();
	}
}
 
开发者ID:MCCarbon,项目名称:DecompileTools,代码行数:61,代码来源:EnumConstNameRestorer.java


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