本文整理汇总了Java中jdk.internal.org.objectweb.asm.Opcodes.INVOKESPECIAL属性的典型用法代码示例。如果您正苦于以下问题:Java Opcodes.INVOKESPECIAL属性的具体用法?Java Opcodes.INVOKESPECIAL怎么用?Java Opcodes.INVOKESPECIAL使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类jdk.internal.org.objectweb.asm.Opcodes
的用法示例。
在下文中一共展示了Opcodes.INVOKESPECIAL属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doVisitMethodInsn
private void doVisitMethodInsn(int opcode, final String owner,
final String name, final String desc, final boolean itf) {
switch (opcode) {
case Opcodes.INVOKESPECIAL:
invokespecial(owner, name, desc, itf);
break;
case Opcodes.INVOKEVIRTUAL:
invokevirtual(owner, name, desc, itf);
break;
case Opcodes.INVOKESTATIC:
invokestatic(owner, name, desc, itf);
break;
case Opcodes.INVOKEINTERFACE:
invokeinterface(owner, name, desc);
break;
default:
throw new IllegalArgumentException();
}
}
示例2: doVisitMethodInsn
private void doVisitMethodInsn(int opcode, final String owner,
final String name, final String desc, final boolean itf) {
if (mv != null) {
mv.visitMethodInsn(opcode, owner, name, desc, itf);
}
if (this.locals == null) {
labels = null;
return;
}
pop(desc);
if (opcode != Opcodes.INVOKESTATIC) {
Object t = pop();
if (opcode == Opcodes.INVOKESPECIAL && name.charAt(0) == '<') {
Object u;
if (t == Opcodes.UNINITIALIZED_THIS) {
u = this.owner;
} else {
u = uninitializedTypes.get(t);
}
for (int i = 0; i < locals.size(); ++i) {
if (locals.get(i) == t) {
locals.set(i, u);
}
}
for (int i = 0; i < stack.size(); ++i) {
if (stack.get(i) == t) {
stack.set(i, u);
}
}
}
}
pushDesc(desc);
labels = null;
}
示例3: doVisitMethodInsn
private void doVisitMethodInsn(int opcode, final String owner,
final String name, final String desc, final boolean itf) {
checkStartCode();
checkEndCode();
checkOpcode(opcode, 5);
if (opcode != Opcodes.INVOKESPECIAL || !"<init>".equals(name)) {
checkMethodIdentifier(version, name, "name");
}
checkInternalName(owner, "owner");
checkMethodDesc(desc);
if (opcode == Opcodes.INVOKEVIRTUAL && itf) {
throw new IllegalArgumentException(
"INVOKEVIRTUAL can't be used with interfaces");
}
if (opcode == Opcodes.INVOKEINTERFACE && !itf) {
throw new IllegalArgumentException(
"INVOKEINTERFACE can't be used with classes");
}
// Calling super.visitMethodInsn requires to call the correct version
// depending on this.api (otherwise infinite loops can occur). To
// simplify and to make it easier to automatically remove the backward
// compatibility code, we inline the code of the overridden method here.
if (mv != null) {
mv.visitMethodInsn(opcode, owner, name, desc, itf);
}
++insnCount;
}
示例4: getInvokeInstruction
private static int getInvokeInstruction(SelectionResolutionTestCase.InvokeInstruction instr) {
switch (instr) {
case INVOKESTATIC:
return Opcodes.INVOKESTATIC;
case INVOKESPECIAL:
return Opcodes.INVOKESPECIAL;
case INVOKEINTERFACE:
return Opcodes.INVOKEINTERFACE;
case INVOKEVIRTUAL:
return Opcodes.INVOKEVIRTUAL;
default:
throw new AssertionError(instr.name());
}
}
示例5: visit
@Override
public byte[] visit(Function node) {
FunctionInfo info = node.getValue();
boolean needInstance = !info.isStatic() && !info.isConstructor();
if (needInstance) {
node.getChild(0).accept(this); // placing instance on stack
}
// call itself with specific invoke*
String signature = info.argTypes.stream()
.skip(!needInstance ? 0 : 1)
.map(vi -> new String(vi.type.accept(this)))
.collect(Collectors.joining("", "(", ")"))
+ (info.isConstructor() ? "V" : new String(node.getResultType().accept(this)));
int invokeCode = Opcodes.INVOKEVIRTUAL;
if (info.isStatic()) {
invokeCode = Opcodes.INVOKESTATIC;
} else if (info.isConstructor() || info.isPrivate()) {
// TODO : superclass method invocation?
invokeCode = Opcodes.INVOKESPECIAL;
} else {
if (info.owner.isInterface()) {
invokeCode = Opcodes.INVOKEINTERFACE;
}
}
if (info.isConstructor()) {
currentMV.visitTypeInsn(Opcodes.NEW, asInternalName(info.owner.getName()));
currentMV.visitInsn(Opcodes.DUP);
}
// calculating parameters
node.getChildren().stream()
.skip(!needInstance ? 0 : 1)
.forEachOrdered(c -> c.accept(this));
currentMV.visitMethodInsn(invokeCode, asInternalName(info.owner.getName()),
info.isConstructor() ? "<init>" : info.name, signature,
invokeCode == Opcodes.INVOKEINTERFACE);
return EMPTY_BYTE_ARRAY;
}
示例6: refKindOpcode
int refKindOpcode(byte refKind) {
switch (refKind) {
case REF_invokeVirtual: return Opcodes.INVOKEVIRTUAL;
case REF_invokeStatic: return Opcodes.INVOKESTATIC;
case REF_invokeSpecial: return Opcodes.INVOKESPECIAL;
case REF_invokeInterface: return Opcodes.INVOKEINTERFACE;
case REF_getField: return Opcodes.GETFIELD;
case REF_putField: return Opcodes.PUTFIELD;
case REF_getStatic: return Opcodes.GETSTATIC;
case REF_putStatic: return Opcodes.PUTSTATIC;
}
throw new InternalError("refKind="+refKind);
}