public void UpdateWithAttributes(AttributeInfo[] attributes) { foreach (AttributeInfo attribute in attributes) { if (attribute.GetType() == typeof(BootstrapMethodsAttribute)) { BootstrapMethod = ((BootstrapMethodsAttribute)attribute).BootstrapMethods[BootstrapMethodAttrIndex]; } } }
protected override void ReadExtends(ClassData classData, ConstantPool constantPool) { this.NumBootstrapMethods = classData.ReadUint16(); var bootstrapMethods = new BootstrapMethod [this.NumBootstrapMethods]; for (var i = 0; i < this.NumBootstrapMethods; i++) { bootstrapMethods[i] = new BootstrapMethod().Read(classData); } this.BootstrapMethods = bootstrapMethods; }
public int GetBootstrapMethodIndex(BootstrapMethod bootstrapMethod) { var info = new BootstrapMethodInfo { MethodRefIndex = (ushort)ConstantPoolBuffer.GetMethodHandleIndex(bootstrapMethod.Handle), }; foreach (var arg in bootstrapMethod.Arguments) { info.Arguments.Add((ushort)ConstantPoolBuffer.GetStaticConstantIndex(arg)); } if (!_bootstrapInfos.TryGetValue(info, out int index)) { var methods = BootstrapMethodsAttribute.BootstrapMethods; index = methods.Count; methods.Add(info); _bootstrapInfos.Add(info, index); } return(index); }
private static BootstrapMethod[] ReadBootstrapMethods(BigEndianBinaryReader br, ClassFile classFile) { BigEndianBinaryReader rdr = br.Section(br.ReadUInt32()); ushort count = rdr.ReadUInt16(); BootstrapMethod[] bsm = new BootstrapMethod[count]; for(int i = 0; i < bsm.Length; i++) { ushort bsm_index = rdr.ReadUInt16(); if(bsm_index >= classFile.constantpool.Length || !(classFile.constantpool[bsm_index] is ConstantPoolItemMethodHandle)) { throw new ClassFormatError("bootstrap_method_index {0} has bad constant type in class file {1}", bsm_index, classFile.Name); } classFile.MarkLinkRequiredConstantPoolItem(bsm_index); ushort argument_count = rdr.ReadUInt16(); ushort[] args = new ushort[argument_count]; for(int j = 0; j < args.Length; j++) { ushort argument_index = rdr.ReadUInt16(); if(!classFile.IsValidConstant(argument_index)) { throw new ClassFormatError("argument_index {0} has bad constant type in class file {1}", argument_index, classFile.Name); } classFile.MarkLinkRequiredConstantPoolItem(argument_index); args[j] = argument_index; } bsm[i] = new BootstrapMethod(bsm_index, args); } if(!rdr.IsAtEnd) { throw new ClassFormatError("Bad length on BootstrapMethods in class file {0}", classFile.Name); } return bsm; }