public override void ResolveConstant(ConstantPool pool) { if (type == CONSTANT_NameAndType) { elementname = pool.GetPrimitiveConstant(index1).GetString(); descriptor = pool.GetPrimitiveConstant(index2).GetString(); } else if (type == CONSTANT_MethodHandle) { LinkConstant ref_info = pool.GetLinkConstant(index2); classname = ref_info.classname; elementname = ref_info.elementname; descriptor = ref_info.descriptor; } else { if (type != CONSTANT_InvokeDynamic) { classname = pool.GetPrimitiveConstant(index1).GetString(); } LinkConstant nametype = pool.GetLinkConstant(index2); elementname = nametype.elementname; descriptor = nametype.descriptor; } InitConstant(); }
public virtual LinkConstant GetLinkConstant(int index) { LinkConstant ln = (LinkConstant)GetConstant(index); if (ln != null && interceptor != null && (ln.type == ICodeConstants.CONSTANT_Fieldref || ln.type == ICodeConstants.CONSTANT_Methodref || ln.type == ICodeConstants.CONSTANT_InterfaceMethodref )) { string newClassName = BuildNewClassname(ln.classname); string newElement = interceptor.GetName(ln.classname + ' ' + ln.elementname + ' ' + ln.descriptor); string newDescriptor = BuildNewDescriptor(ln.type == ICodeConstants.CONSTANT_Fieldref , ln.descriptor); //TODO: Fix newElement being null caused by ln.classname being a leaf class instead of the class that declared the field/method. //See the comments of IDEA-137253 for more information. if (newClassName != null || newElement != null || newDescriptor != null) { string className = newClassName == null ? ln.classname : newClassName; string elementName = newElement == null ? ln.elementname : newElement.Split(" ")[ 1]; string descriptor = newDescriptor == null ? ln.descriptor : newDescriptor; ln = new LinkConstant(ln.type, className, elementName, descriptor); } } return(ln); }
public override bool Equals(object o) { if (o == this) { return(true); } if (!(o is LinkConstant)) { return(false); } LinkConstant cn = (LinkConstant)o; return(this.type == cn.type && this.elementname.Equals(cn.elementname) && this.descriptor .Equals(cn.descriptor) && (this.type != CONSTANT_NameAndType || this.classname.Equals (cn.classname))); }