1 /* 2 * Copyright 2018, Google Inc. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: 8 * 9 * * Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * * Redistributions in binary form must reproduce the above 12 * copyright notice, this list of conditions and the following disclaimer 13 * in the documentation and/or other materials provided with the 14 * distribution. 15 * * Neither the name of Google Inc. nor the names of its 16 * contributors may be used to endorse or promote products derived from 17 * this software without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 package org.jf.dexlib2.iface.reference; 33 34 import org.jf.dexlib2.iface.value.EncodedValue; 35 36 import javax.annotation.Nonnull; 37 import javax.annotation.Nullable; 38 import java.util.List; 39 40 /** 41 * This class represents a reference to a call site 42 */ 43 public interface CallSiteReference extends Reference { 44 45 /** 46 * Gets a name for this call site. 47 * 48 * This is an arbitrary synthetic string that serves to differentiate call sites that would otherwise be identical. 49 * 50 * It can be any arbitrary string, with the only requirement being that 2 different, but otherwise identical call 51 * sites in the same dex file must not share the same name. Multiple non-identical call sites may use the same name 52 * however. 53 * 54 * @return The name for this call site. 55 */ getName()56 @Nonnull String getName(); 57 58 /** 59 * Gets a reference to a method handle for the bootstrap linker method 60 * 61 * @return A MethodHandleReference to the bootstrap linker method 62 */ getMethodHandle()63 @Nonnull MethodHandleReference getMethodHandle(); 64 65 /** 66 * @return A method name that the bootstrap linker should resolve. 67 */ getMethodName()68 @Nonnull String getMethodName(); 69 70 /** 71 * @return A MethodProtoReference corresponding to the prototype of the method that the bootstrap linker should 72 * resolve 73 */ getMethodProto()74 @Nonnull MethodProtoReference getMethodProto(); 75 76 /** 77 * @return A list of extra arguments to pass to the bootstrap linker 78 */ getExtraArguments()79 @Nonnull List<? extends EncodedValue> getExtraArguments(); 80 81 /** 82 * Returns a hashcode for this CallSiteReference. 83 * 84 * This hashCode is defined to be the following: 85 * 86 * <pre> 87 * {@code 88 * int hashCode = getName().hashCode(); 89 * hashCode = hashCode*31 + getMethodHandle().hashCode(); 90 * hashCode = hashCode*31 + getMethodName().hashCode(); 91 * hashCode = hashCode*31 + getMethodProto().hashCode(); 92 * hashCode = hashCode*31 + getExtraArguments().hashCode(); 93 * }</pre> 94 * 95 * @return The hash code value for this MethodReference 96 */ hashCode()97 @Override int hashCode(); 98 99 /** 100 * Compares this CallSiteReference to another CallSiteReference for equality. 101 * 102 * This CallSiteReference is equal to another CallSiteReference if all of its fields are equal. That is, if 103 * the return values of getMethodHandle(), getMethodName(), getMethodProto() and getExtraArguments() are all equal. 104 * 105 * @param o The object to be compared for equality with this CallSiteReference 106 * @return true if the specified object is equal to this CallSiteReference 107 */ equals(@ullable Object o)108 @Override boolean equals(@Nullable Object o); 109 } 110