本文整理汇总了Java中jdk.internal.org.objectweb.asm.Handle类的典型用法代码示例。如果您正苦于以下问题:Java Handle类的具体用法?Java Handle怎么用?Java Handle使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Handle类属于jdk.internal.org.objectweb.asm包,在下文中一共展示了Handle类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitInvokeDynamicInsn
import jdk.internal.org.objectweb.asm.Handle; //导入依赖的package包/类
@Override
public void visitInvokeDynamicInsn(String name, String desc, Handle bsm,
Object... bsmArgs) {
mv.visitInvokeDynamicInsn(name, desc, bsm, bsmArgs);
if (constructor) {
Type[] types = Type.getArgumentTypes(desc);
for (int i = 0; i < types.length; i++) {
popValue();
if (types[i].getSize() == 2) {
popValue();
}
}
Type returnType = Type.getReturnType(desc);
if (returnType != Type.VOID_TYPE) {
pushValue(OTHER);
if (returnType.getSize() == 2) {
pushValue(OTHER);
}
}
}
}
示例2: visitInvokeDynamicInsn
import jdk.internal.org.objectweb.asm.Handle; //导入依赖的package包/类
@Override
public void visitInvokeDynamicInsn(String name, String desc, Handle bsm,
Object... bsmArgs) {
buf.setLength(0);
buf.append(this.name).append(".visitInvokeDynamicInsn(");
appendConstant(name);
buf.append(", ");
appendConstant(desc);
buf.append(", ");
appendConstant(bsm);
buf.append(", new Object[]{");
for (int i = 0; i < bsmArgs.length; ++i) {
appendConstant(bsmArgs[i]);
if (i != bsmArgs.length - 1) {
buf.append(", ");
}
}
buf.append("});\n");
text.add(buf.toString());
}
示例3: visitInvokeDynamicInsn
import jdk.internal.org.objectweb.asm.Handle; //导入依赖的package包/类
@Override
public void visitInvokeDynamicInsn(String name, String desc, Handle bsm,
Object... bsmArgs) {
checkStartCode();
checkEndCode();
checkMethodIdentifier(version, name, "name");
checkMethodDesc(desc);
if (bsm.getTag() != Opcodes.H_INVOKESTATIC
&& bsm.getTag() != Opcodes.H_NEWINVOKESPECIAL) {
throw new IllegalArgumentException("invalid handle tag "
+ bsm.getTag());
}
for (int i = 0; i < bsmArgs.length; i++) {
checkLDCConstant(bsmArgs[i]);
}
super.visitInvokeDynamicInsn(name, desc, bsm, bsmArgs);
++insnCount;
}
示例4: callSuper
import jdk.internal.org.objectweb.asm.Handle; //导入依赖的package包/类
private void callSuper(final MethodGenerator mi) {
String superClass, superDesc;
mi.loadThis();
if (constructor == null) {
// call ScriptObject.<init>
superClass = SCRIPTOBJECT_TYPE;
superDesc = (memberCount > 0) ? SCRIPTOBJECT_INIT_DESC : DEFAULT_INIT_DESC;
loadMap(mi);
} else {
// call Function.<init>
superClass = SCRIPTFUNCTIONIMPL_TYPE;
superDesc = (memberCount > 0) ? SCRIPTFUNCTIONIMPL_INIT_DESC4 : SCRIPTFUNCTIONIMPL_INIT_DESC3;
mi.loadLiteral(constructor.getName());
mi.visitLdcInsn(new Handle(H_INVOKESTATIC, scriptClassInfo.getJavaName(), constructor.getJavaName(), constructor.getJavaDesc()));
loadMap(mi);
mi.memberInfoArray(scriptClassInfo.getJavaName(), specs); //pushes null if specs empty
}
mi.invokeSpecial(superClass, INIT, superDesc);
}
示例5: memberInfoArray
import jdk.internal.org.objectweb.asm.Handle; //导入依赖的package包/类
void memberInfoArray(final String className, final List<MemberInfo> mis) {
if (mis.isEmpty()) {
pushNull();
return;
}
int pos = 0;
push(mis.size());
newObjectArray(SPECIALIZATION_TYPE);
for (final MemberInfo mi : mis) {
dup();
push(pos++);
visitTypeInsn(NEW, SPECIALIZATION_TYPE);
dup();
visitLdcInsn(new Handle(H_INVOKESTATIC, className, mi.getJavaName(), mi.getJavaDesc()));
final Type linkLogicClass = mi.getLinkLogicClass();
final boolean linkLogic = !linkLogicIsEmpty(linkLogicClass);
final String ctor = linkLogic ? SPECIALIZATION_INIT3 : SPECIALIZATION_INIT2;
if (linkLogic) {
visitLdcInsn(linkLogicClass);
}
visitInsn(mi.isOptimistic() ? ICONST_1 : ICONST_0);
visitMethodInsn(INVOKESPECIAL, SPECIALIZATION_TYPE, INIT, ctor, false);
arrayStore(TYPE_SPECIALIZATION);
}
}
示例6: ldc
import jdk.internal.org.objectweb.asm.Handle; //导入依赖的package包/类
@Override
public Type ldc(final MethodVisitor method, final Object c) {
if (c == null) {
method.visitInsn(ACONST_NULL);
} else if (c instanceof Undefined) {
return loadUndefined(method);
} else if (c instanceof String) {
method.visitLdcInsn(c);
return STRING;
} else if (c instanceof Handle) {
method.visitLdcInsn(c);
return Type.typeFor(MethodHandle.class);
} else {
throw new UnsupportedOperationException("implementation missing for class " + c.getClass() + " value=" + c);
}
return Type.OBJECT;
}
示例7: generateBootstrapMethod
import jdk.internal.org.objectweb.asm.Handle; //导入依赖的package包/类
private Handle generateBootstrapMethod(Handle h) {
String bootstrapName = "bootstrapMethod";
MethodType bootstrapType = MethodType.methodType(CallSite.class, MethodHandles.Lookup.class, String.class, MethodType.class);
MethodVisitor bmv = cv.visitMethod(ACC_PUBLIC | ACC_STATIC, bootstrapName, bootstrapType.toMethodDescriptorString(), null, null);
bmv.visitCode();
String constCallSite = "java/lang/invoke/ConstantCallSite";
bmv.visitTypeInsn(NEW, constCallSite);
bmv.visitInsn(DUP);
bmv.visitLdcInsn(h);
bmv.visitMethodInsn(INVOKESPECIAL, constCallSite, "<init>", "(Ljava/lang/invoke/MethodHandle;)V", false);
bmv.visitInsn(ARETURN);
bmv.visitMaxs(0,0);
bmv.visitEnd();
return new Handle(H_INVOKESTATIC, ownerClassName, bootstrapName, bootstrapType.toMethodDescriptorString());
}
示例8: getClassFile
import jdk.internal.org.objectweb.asm.Handle; //导入依赖的package包/类
static byte[] getClassFile(String suffix) {
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
MethodVisitor mv;
cw.visit(52, ACC_PUBLIC | ACC_SUPER, CLASS_NAME + suffix, null, "java/lang/Object", null);
{
mv = cw.visitMethod(ACC_PUBLIC | ACC_STATIC, METHOD_NAME, TYPE.toMethodDescriptorString(), null, null);
mv.visitCode();
Handle bsm = new Handle(H_INVOKESTATIC,
CallSiteDepContextTest.class.getName().replace(".", "/"),
"bootstrap",
bsmMH.type().toMethodDescriptorString());
mv.visitInvokeDynamicInsn("methodName", TYPE.toMethodDescriptorString(), bsm);
mv.visitInsn(IRETURN);
mv.visitMaxs(0, 0);
mv.visitEnd();
}
cw.visitEnd();
return cw.toByteArray();
}
示例9: callSuper
import jdk.internal.org.objectweb.asm.Handle; //导入依赖的package包/类
private void callSuper(final MethodGenerator mi) {
String superClass, superDesc;
mi.loadThis();
if (constructor == null) {
// call ScriptObject.<init>
superClass = SCRIPTOBJECT_TYPE;
superDesc = (memberCount > 0) ? SCRIPTOBJECT_INIT_DESC : DEFAULT_INIT_DESC;
loadMap(mi);
} else {
// call Function.<init>
superClass = SCRIPTFUNCTION_TYPE;
superDesc = (memberCount > 0) ? SCRIPTFUNCTION_INIT_DESC4 : SCRIPTFUNCTION_INIT_DESC3;
mi.loadLiteral(constructor.getName());
mi.visitLdcInsn(new Handle(H_INVOKESTATIC, scriptClassInfo.getJavaName(), constructor.getJavaName(), constructor.getJavaDesc(), false));
loadMap(mi);
mi.memberInfoArray(scriptClassInfo.getJavaName(), specs); //pushes null if specs empty
}
mi.invokeSpecial(superClass, INIT, superDesc);
}
示例10: callSuper
import jdk.internal.org.objectweb.asm.Handle; //导入依赖的package包/类
@SuppressWarnings("deprecation")
private void callSuper(final MethodGenerator mi) {
String superClass, superDesc;
mi.loadThis();
if (constructor == null) {
// call ScriptObject.<init>
superClass = SCRIPTOBJECT_TYPE;
superDesc = (memberCount > 0) ? SCRIPTOBJECT_INIT_DESC : DEFAULT_INIT_DESC;
loadMap(mi);
} else {
// call Function.<init>
superClass = SCRIPTFUNCTION_TYPE;
superDesc = (memberCount > 0) ? SCRIPTFUNCTION_INIT_DESC4 : SCRIPTFUNCTION_INIT_DESC3;
mi.loadLiteral(constructor.getName());
mi.visitLdcInsn(new Handle(H_INVOKESTATIC, scriptClassInfo.getJavaName(), constructor.getJavaName(), constructor.getJavaDesc()));
loadMap(mi);
mi.memberInfoArray(scriptClassInfo.getJavaName(), specs); //pushes null if specs empty
}
mi.invokeSpecial(superClass, INIT, superDesc);
}
示例11: callSuper
import jdk.internal.org.objectweb.asm.Handle; //导入依赖的package包/类
private void callSuper(final MethodGenerator mi) {
String superClass, superDesc;
mi.loadThis();
if (constructor == null) {
// call ScriptObject.<init>
superClass = SCRIPTOBJECT_TYPE;
superDesc = (memberCount > 0) ? SCRIPTOBJECT_INIT_DESC : DEFAULT_INIT_DESC;
loadMap(mi);
} else {
// call Function.<init>
superClass = SCRIPTFUNCTION_TYPE;
superDesc = (memberCount > 0) ? SCRIPTFUNCTION_INIT_DESC4 : SCRIPTFUNCTION_INIT_DESC3;
mi.loadLiteral(constructor.getName());
mi.visitLdcInsn(new Handle(H_INVOKESTATIC, scriptClassInfo.getJavaName(), constructor.getJavaName(), constructor.getJavaDesc()));
loadMap(mi);
mi.memberInfoArray(scriptClassInfo.getJavaName(), specs); //pushes null if specs empty
}
mi.invokeSpecial(superClass, INIT, superDesc);
}
示例12: visitInvokeDynamicInsn
import jdk.internal.org.objectweb.asm.Handle; //导入依赖的package包/类
@Override
public void visitInvokeDynamicInsn(String name, String desc, Handle bsm,
Object... bsmArgs) {
for (int i = 0; i < bsmArgs.length; i++) {
bsmArgs[i] = remapper.mapValue(bsmArgs[i]);
}
super.visitInvokeDynamicInsn(
remapper.mapInvokeDynamicMethodName(name, desc),
remapper.mapMethodDesc(desc), (Handle) remapper.mapValue(bsm),
bsmArgs);
}
示例13: mapValue
import jdk.internal.org.objectweb.asm.Handle; //导入依赖的package包/类
public Object mapValue(Object value) {
if (value instanceof Type) {
return mapType((Type) value);
}
if (value instanceof Handle) {
Handle h = (Handle) value;
return new Handle(h.getTag(), mapType(h.getOwner()), mapMethodName(
h.getOwner(), h.getName(), h.getDesc()),
mapMethodDesc(h.getDesc()));
}
return value;
}
示例14: visitInvokeDynamicInsn
import jdk.internal.org.objectweb.asm.Handle; //导入依赖的package包/类
@Override
public void visitInvokeDynamicInsn(String name, String desc, Handle bsm,
Object... bsmArgs) {
minSize += 5;
maxSize += 5;
if (mv != null) {
mv.visitInvokeDynamicInsn(name, desc, bsm, bsmArgs);
}
}