本文整理了Java中org.apache.bcel.generic.INVOKESPECIAL
类的一些代码示例,展示了INVOKESPECIAL
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。INVOKESPECIAL
类的具体详情如下:
包路径:org.apache.bcel.generic.INVOKESPECIAL
类名称:INVOKESPECIAL
[英]INVOKESPECIAL - Invoke instance method; special handling for superclass, private and instance initialization method invocations
Stack: ..., objectref, [arg1, [arg2 ...]] -> ...
[中]INVOKESPECIAL-调用实例方法;超类、私有和实例初始化方法调用的特殊处理
Stack: ..., objectref, [arg1, [arg2 ...]] -> ...
代码示例来源:origin: xalan/xalan
/**
* Expects a double on the stack and pushes a boxed double. Boxed
* double are represented by an instance of java.lang.Double
.
*
* @see org.apache.xalan.xsltc.compiler.util.Type#translateTo
*/
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
ReferenceType type) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
il.append(new NEW(cpg.addClass(DOUBLE_CLASS)));
il.append(DUP_X2);
il.append(DUP_X2);
il.append(POP);
il.append(new INVOKESPECIAL(cpg.addMethodref(DOUBLE_CLASS,
"
}
代码示例来源:origin: find-sec-bugs/find-sec-bugs
if (("javax.crypto.Cipher").equals(invoke.getClassName(cpg)) &&
"init".equals(invoke.getMethodName(cpg))) {
ICONST icOnst= ByteCode.getPrevInstruction(location.getHandle(), ICONST.class);
if (iconst != null) {
else if (("javax.crypto.Cipher").equals(invoke.getClassName(cpg)) &&
"getIV".equals(invoke.getMethodName(cpg))) {
ivFetchFromCipher = true;
if (("javax.crypto.spec.IvParameterSpec").equals(invoke.getClassName(cpg)) &&
"
代码示例来源:origin: find-sec-bugs/find-sec-bugs
if(invoke.getMethodName(cpg).equals("
invoke.getSignature(cpg).equals("(Ljava/lang/String;)V")) {
return getConstantLDC(h.getPrev(), cpg, clazz);
代码示例来源:origin: find-sec-bugs/find-sec-bugs
if(inst instanceof INVOKESPECIAL) {
INVOKESPECIAL invoke = (INVOKESPECIAL) inst;
if ("javax.servlet.http.COOKIE".equals(invoke.getClassName(cpg)) &&
"
代码示例来源:origin: xalan/xalan
final InstructionList newIL = new InstructionList();
InstructionList oldMethCopyInIL = new InstructionList();
InstructionList oldMethCopyOutIL = new InstructionList();
InstructionList newMethCopyInIL = new InstructionList();
InstructionList newMethCopyOutIL = new InstructionList();
oldMethCopyInIL.append(new NEW(cpg.addClass(argTypeName)));
oldMethCopyInIL.append(InstructionConstants.DUP);
oldMethCopyInIL.append(InstructionConstants.DUP);
oldMethCopyInIL.append(
new INVOKESPECIAL(cpg.addMethodref(argTypeName, "
outlinedMethodRef =
oldMethCopyOutIL.append(
new INVOKESTATIC(cpg.addMethodref(
classGen.getClassName(),
outlinedMethodName,
outlinedMethodRef =
oldMethCopyOutIL.append(
new INVOKEVIRTUAL(cpg.addMethodref(
classGen.getClassName(),
outlinedMethodName,
代码示例来源:origin: xalan/xalan
/**
* Create a constructor for the new class. Updates the reference to the
* collator in the super calls only when the stylesheet specifies a new
* language in xsl:sort.
*/
private static MethodGenerator compileInit(Vector sortObjects,
NodeSortRecordGenerator sortRecord,
ConstantPoolGen cpg,
String className)
{
final InstructionList il = new InstructionList();
final MethodGenerator init =
new MethodGenerator(ACC_PUBLIC,
org.apache.bcel.generic.Type.VOID,
null, null, "
il, cpg);
// Call the constructor in the NodeSortRecord superclass
il.append(ALOAD_0);
il.append(new INVOKESPECIAL(cpg.addMethodref(NODE_SORT_RECORD,
"
il.append(RETURN);
return init;
}
代码示例来源:origin: xalan/xalan
cpg.addUtf8(var.getEscapedName()),
cpg.addUtf8(var.getType().toSignature()),
null, cpg.getConstantPool()));
dups.add(varRef);
InstructionList il = new InstructionList();
final MethodGenerator cOnstructor=
new MethodGenerator(ACC_PUBLIC,
il.append(ALOAD_0);
il.append(ALOAD_1);
il.append(ALOAD_2);
il.append(new ALOAD(3));
il.append(new ALOAD(6));
il.append(new ALOAD(7));
il.append(new INVOKESPECIAL(cpg.addMethodref(NODE_SORT_FACTORY,
"
"(" + DOM_INTF_SIG
il.append(ILOAD_1);
il.append(ILOAD_2);
il.append(new INVOKESPECIAL(cpg.addMethodref(NODE_SORT_FACTORY,
"makeNodeSortRecord", "(II)" + NODE_SORT_RECORD_SIG)));
il.append(DUP);
代码示例来源:origin: xalan/xalan
final String methodName = _mergeSet.getMethodName();
il.append(classGen.loadTranslet());
il.append(methodGen.loadDOM());
il.append(methodGen.loadIterator());
il.append(methodGen.loadHandler());
final int method = cpg.addMethodref(classGen.getClassName(),
methodName, ATTR_SET_SIG);
il.append(new INVOKESPECIAL(method));
代码示例来源:origin: bcel/bcel
/** Create an invoke instruction.
*
* @param class_name name of the called class
* @param name name of the called method
* @param ret_type return type of method
* @param arg_types argument types of method
* @param kind how to invoke, i.e., INVOKEINTERFACE, INVOKESTATIC, INVOKEVIRTUAL,
* or INVOKESPECIAL
* @see Constants
*/
public InvokeInstruction createInvoke(String class_name, String name, Type ret_type,
Type[] arg_types, short kind) {
int index;
int nargs = 0;
String signature = Type.getMethodSignature(ret_type, arg_types);
for(int i=0; i
if(kind == Constants.INVOKEINTERFACE)
index = cp.addInterfaceMethodref(class_name, name, signature);
else
index = cp.addMethodref(class_name, name, signature);
switch(kind) {
case Constants.INVOKESPECIAL: return new INVOKESPECIAL(index);
case Constants.INVOKEVIRTUAL: return new INVOKEVIRTUAL(index);
case Constants.INVOKESTATIC: return new INVOKESTATIC(index);
case Constants.INVOKEINTERFACE: return new INVOKEINTERFACE(index, nargs + 1);
default:
throw new RuntimeException("Oops: Unknown invoke kind:" + kind);
}
}
代码示例来源:origin: blackarbiter/Android_Code_Arbiter
if ("java.security.KeyPairGenerator".equals(invoke.getClassName(cpg)) && "initialize".equals(invoke.getMethodName(cpg))) {
Number n = null;
if ("(I)V".equals(invoke.getSignature(cpg))) {
n = ByteCode.getPushNumber(location.getHandle().getPrev());
if ("java.security.spec.RSAKeyGenParameterSpec".equals(invoke.getClassName(cpg)) && "
Number n = null;
if ("(ILjava/math/BigInteger;)V".equals(invoke.getSignature(cpg))) {
SIPUSH push = ByteCode.getPrevInstruction(location.getHandle(), SIPUSH.class);
if (push != null) {
代码示例来源:origin: com.mebigfatguy.fb-contrib/fb-contrib
INVOKESPECIAL is = (INVOKESPECIAL) ins;
ReferenceType rt = is.getReferenceType(cpg);
if (Values.CONSTRUCTOR.equals(is.getMethodName(cpg))) {
if ((rt instanceof ObjectType)
&& ((ObjectType) rt).getClassName().startsWith(clsContext.getJavaClass().getClassName() + Values.INNER_CLASS_SEPARATOR)) {
INVOKEVIRTUAL is = (INVOKEVIRTUAL) ins;
ReferenceType rt = is.getReferenceType(cpg);
if ((rt instanceof ObjectType) && ((ObjectType) rt).getClassName().equals(clsName)) {
String methodDesc = is.getName(cpg) + is.getSignature(cpg);
Set
if (fields != null) {
代码示例来源:origin: bcel/bcel
String classname = o.getClassName(cpg);
JavaClass jc = Repository.lookupClass(classname);
Method[] ms = jc.getMethods();
Method m = null;
for (int i=0; i
(Type.getReturnType(ms[i].getSignature()).equals(o.getReturnType(cpg))) &&
(objarrayequals(Type.getArgumentTypes(ms[i].getSignature()), o.getArgumentTypes(cpg))) ){
m = ms[i];
break;
constraintViolated(o, "Referenced method '"+o.getMethodName(cpg)+"' with expected signature not found in class '"+jc.getClassName()+"'. The native verfier does allow the method to be declared in some superclass or implemented interface, which the Java Virtual Machine Specification, Second Edition does not.");
if (! (o.getMethodName(cpg).equals(Constants.CONSTRUCTOR_NAME) )){
if ( (meths[i].getName().equals(o.getMethodName(cpg))) &&
(Type.getReturnType(meths[i].getSignature()).equals(o.getReturnType(cpg))) &&
(objarrayequals(Type.getArgumentTypes(meths[i].getSignature()), o.getArgumentTypes(cpg))) ){
meth = meths[i];
break;
constraintViolated(o, "ACC_SUPER special lookup procedure not successful: method '"+o.getMethodName(cpg)+"' with proper signature not declared in superclass hierarchy.");
代码示例来源:origin: bcel/bcel
if ( (o.getMethodName(cpg).equals(Constants.CONSTRUCTOR_NAME)) && (!(stack().peek(o.getArgumentTypes(cpg).length) instanceof UninitializedObjectType)) ){
constraintViolated(o, "Possibly initializing object twice. A valid instruction sequence must not have an uninitialized object on the operand stack or in a local variable during a backwards branch, or in a local variable in code protected by an exception handler. Please see The Java Virtual Machine Specification, Second Edition, 4.9.4 (pages 147 and 148) for details.");
Type t = o.getType(cpg);
if (t instanceof ObjectType){
String name = ((ObjectType)t).getClassName();
Type[] argtypes = o.getArgumentTypes(cpg);
int nargs = argtypes.length;
if ( !(o.getMethodName(cpg).equals(Constants.CONSTRUCTOR_NAME))){
referenceTypeIsInitialized(o, (ReferenceType) objref);
if (!(objref instanceof ObjectType)){
String theClass = o.getClassName(cpg);
if ( ! Repository.instanceOf(objref_classname, theClass) ){
constraintViolated(o, "The 'objref' item '"+objref+"' does not implement '"+theClass+"' as expected.");
代码示例来源:origin: bcel/bcel
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
public void visitINVOKESPECIAL(INVOKESPECIAL o){
if (o.getMethodName(cpg).equals(Constants.CONSTRUCTOR_NAME)){
UninitializedObjectType t = (UninitializedObjectType) stack().peek(o.getArgumentTypes(cpg).length);
if (t == frame._this){
frame._this = null;
}
stack().initializeObject(t);
locals().initializeObject(t);
}
stack().pop(); //objectref
for (int i=0; i
}
// We are sure the invoked method will xRETURN eventually
// We simulate xRETURNs functionality here because we
// don't really "jump into" and simulate the invoked
// method.
if (o.getReturnType(cpg) != Type.VOID){
Type t = o.getReturnType(cpg);
if ( t.equals(Type.BOOLEAN) ||
t.equals(Type.CHAR) ||
t.equals(Type.BYTE) ||
t.equals(Type.SHORT) )
t = Type.INT;
stack().push(t);
}
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
代码示例来源:origin: contra/JMD
public static String getCallMethodName(Instruction ins, ConstantPoolGen cp) {
if (ins instanceof INVOKESTATIC) {
INVOKESTATIC invst = (INVOKESTATIC) ins;
return invst.getMethodName(cp);
} else if (ins instanceof INVOKEVIRTUAL) {
INVOKEVIRTUAL invst = (INVOKEVIRTUAL) ins;
return invst.getMethodName(cp);
} else if (ins instanceof INVOKEINTERFACE) {
INVOKEINTERFACE invst = (INVOKEINTERFACE) ins;
return invst.getMethodName(cp);
} else if (ins instanceof INVOKESPECIAL) {
INVOKESPECIAL invst = (INVOKESPECIAL) ins;
return invst.getMethodName(cp);
} else {
return null;
}
}
代码示例来源:origin: spotbugs/spotbugs
if ((prevIns instanceof INVOKESPECIAL && Const.CONSTRUCTOR_NAME.equals(((INVOKESPECIAL) prevIns).getMethodName(methodGen.getConstantPool())))
|| prevIns instanceof ANEWARRAY
|| prevIns instanceof NEWARRAY
代码示例来源:origin: contra/JMD
public static String getCallClassName(Instruction ins, ConstantPoolGen cp) {
if (ins instanceof INVOKESTATIC) {
INVOKESTATIC invst = (INVOKESTATIC) ins;
return invst.getClassName(cp);
} else if (ins instanceof INVOKEVIRTUAL) {
INVOKEVIRTUAL invst = (INVOKEVIRTUAL) ins;
return invst.getClassName(cp);
} else if (ins instanceof INVOKEINTERFACE) {
INVOKEINTERFACE invst = (INVOKEINTERFACE) ins;
return invst.getClassName(cp);
} else if (ins instanceof INVOKESPECIAL) {
INVOKESPECIAL invst = (INVOKESPECIAL) ins;
return invst.getClassName(cp);
} else {
return null;
}
}
代码示例来源:origin: contra/JMD
public static String getCallSignature(Instruction ins, ConstantPoolGen cp) {
if (ins instanceof INVOKESTATIC) {
INVOKESTATIC invst = (INVOKESTATIC) ins;
return invst.getSignature(cp);
} else if (ins instanceof INVOKEVIRTUAL) {
INVOKEVIRTUAL invst = (INVOKEVIRTUAL) ins;
return invst.getSignature(cp);
} else if (ins instanceof INVOKEINTERFACE) {
INVOKEINTERFACE invst = (INVOKEINTERFACE) ins;
return invst.getSignature(cp);
} else if (ins instanceof INVOKESPECIAL) {
INVOKESPECIAL invst = (INVOKESPECIAL) ins;
return invst.getSignature(cp);
} else {
return null;
}
}
代码示例来源:origin: contra/JMD
public static Type[] getCallArgTypes(Instruction ins, ConstantPoolGen cp) {
if (ins instanceof INVOKESTATIC) {
INVOKESTATIC invst = (INVOKESTATIC) ins;
return invst.getArgumentTypes(cp);
} else if (ins instanceof INVOKEVIRTUAL) {
INVOKEVIRTUAL invst = (INVOKEVIRTUAL) ins;
return invst.getArgumentTypes(cp);
} else if (ins instanceof INVOKEINTERFACE) {
INVOKEINTERFACE invst = (INVOKEINTERFACE) ins;
return invst.getArgumentTypes(cp);
} else if (ins instanceof INVOKESPECIAL) {
INVOKESPECIAL invst = (INVOKESPECIAL) ins;
return invst.getArgumentTypes(cp);
} else {
return null;
}
}
代码示例来源:origin: contra/JMD
public static String getCallReturnType(Instruction ins, ConstantPoolGen cp) {
if (ins instanceof INVOKESTATIC) {
INVOKESTATIC invst = (INVOKESTATIC) ins;
return invst.getReturnType(cp).toString();
} else if (ins instanceof INVOKEVIRTUAL) {
INVOKEVIRTUAL invst = (INVOKEVIRTUAL) ins;
return invst.getReturnType(cp).toString();
} else if (ins instanceof INVOKEINTERFACE) {
INVOKEINTERFACE invst = (INVOKEINTERFACE) ins;
return invst.getReturnType(cp).toString();
} else if (ins instanceof INVOKESPECIAL) {
INVOKESPECIAL invst = (INVOKESPECIAL) ins;
return invst.getReturnType(cp).toString();
} else {
return null;
}
}