Example #1
0
        static JavaMethodHandle GetLambdaMetafactory()
        {
            if (_LambdaMetafactory == null)
            {
                var lookupArg = new JavaFieldRef("",
                                                 new JavaType(0, 0, "java.lang.invoke.MethodHandles$Lookup"));
                var stringArg     = new JavaFieldRef("", JavaType.StringType);
                var methodTypeArg = new JavaFieldRef("",
                                                     new JavaType(0, 0, "java.lang.invoke.MethodType"));
                var methodHandleArg = new JavaFieldRef("",
                                                       new JavaType(0, 0, "java.lang.invoke.MethodHandle"));

                var parameters = new List <JavaFieldRef>();
                parameters.Add(lookupArg);
                parameters.Add(stringArg);
                parameters.Add(methodTypeArg);
                parameters.Add(methodTypeArg);
                parameters.Add(methodHandleArg);
                parameters.Add(methodTypeArg);

                var factory = new JavaMethodHandle();
                factory.Kind   = JavaMethodHandle.HandleKind.InvokeStatic;
                factory.Class  = new JavaType(0, 0, "java.lang.invoke.LambdaMetafactory");
                factory.Method = new JavaMethodRef("metafactory",
                                                   new JavaType(0, 0, "java.lang.invoke.CallSite"),
                                                   parameters);

                _LambdaMetafactory = factory;
            }

            return(_LambdaMetafactory);
        }
Example #2
0
        public ushort ConstField(JavaType vClass, JavaFieldRef vField)
        {
            ushort classIndex       = ConstClass(vClass);
            ushort nameAndTypeIndex = ConstNameAndType(vField.Name, vField.Type.ToDescriptor());

            return((ushort)constants.Put(
                       new JavaConstant.FieldRef(classIndex, nameAndTypeIndex), Where));
        }