java.lang.invoke无法解析导入android?

时间:2017-12-05 07:07:53

标签: java android

我添加此代码我的app项目和编译后错误显示无法解析导入,我怎样才能使用此代码android API 9,

import java.lang.invoke.ConstantCallSite;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;

public class BootstrapMethod{

    public static Object bootstrap(MethodHandles.Lookup lookup, String callerName, MethodType callerType,
            int originalOpcode, String originalClassName, String originalMethodName, String originalMethodSignature) {

        MethodHandle mh = null;
        try {
            // variables initialization
            Class clazz = Class.forName(originalClassName);
            ClassLoader currentClassLoader = BootstrapMethod.class.getClassLoader();
            MethodType originalMethodType = MethodType.fromMethodDescriptorString(originalMethodSignature,
                    currentClassLoader);
            // lookup method handle
            switch (originalOpcode) {
            case 0xB8: // invokestatic opcode
                mh = lookup.findStatic(clazz, originalMethodName, originalMethodType);
                break;
            case 0xB6: // invokevirtual opcode
            case 0xB9: // invokeinterface opcode
                mh = lookup.findVirtual(clazz, originalMethodName, originalMethodType);
                break;
            default:
                throw new BootstrapMethodError();
            }
            mh = mh.asType(callerType);
        } catch (Exception ex) {
            throw new BootstrapMethodError();
        }
        return new ConstantCallSite(mh);
    }
}

解决和使用此代码android API 9的任何其他库和解决方案?

0 个答案:

没有答案