Пример #1
0
            public BootstrapMethods(JavaReader rdr)
            {
                methods = new Item[rdr.Read16()];
                for (int i = 0; i < methods.Length; i++)
                {
                    methods[i].mh = rdr.ConstMethodHandle(rdr.Read16());
                    var args = new object[rdr.Read16()];
                    for (int j = 0; j < args.Length; j++)
                    {
                        var    constantIndex = rdr.Read16();
                        var    constantType  = rdr.ConstType(constantIndex);
                        object value;

                        if (constantType == typeof(JavaConstant.Integer))
                        {
                            value = rdr.ConstInteger(constantIndex);
                        }

                        else if (constantType == typeof(JavaConstant.Float))
                        {
                            value = rdr.ConstFloat(constantIndex);
                        }

                        else if (constantType == typeof(JavaConstant.Long))
                        {
                            value = rdr.ConstLong(constantIndex);
                        }

                        else if (constantType == typeof(JavaConstant.Double))
                        {
                            value = rdr.ConstDouble(constantIndex);
                        }

                        else if (constantType == typeof(JavaConstant.Class))
                        {
                            value = rdr.ConstClass(constantIndex);
                        }

                        else if (constantType == typeof(JavaConstant.String))
                        {
                            value = rdr.ConstString(constantIndex);
                        }

                        else if (constantType == typeof(JavaConstant.MethodHandle))
                        {
                            value = rdr.ConstMethodHandle(constantIndex);
                        }

                        else if (constantType == typeof(JavaConstant.MethodType))
                        {
                            value = rdr.ConstMethodType(constantIndex);
                        }

                        else
                        {
                            throw rdr.Where.Exception($"invalid bootstrap method argument");
                        }

                        args[j] = value;
                    }
                    methods[i].args = args;
                }
            }