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