1 /* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 import static art.Redefinition.doCommonClassRedefinition; 18 import java.util.Base64; 19 import java.util.Random; 20 import java.util.function.*; 21 import java.util.stream.*; 22 23 public class Main { 24 25 // The bytes below define the following java program. 26 // package java.lang; 27 // import java.math.*; 28 // public final class Long extends Number implements Comparable<Long> { 29 // public static final long MIN_VALUE = 0; 30 // public static final long MAX_VALUE = 0; 31 // public static final Class<Long> TYPE = null; 32 // static { } 33 // // Used for Stream.count for some reason. 34 // public static long sum(long a, long b) { 35 // return a + b; 36 // } 37 // // Used in stream/lambda functions. 38 // public Long(long value) { 39 // this.value = value; 40 // } 41 // // Used in stream/lambda functions. 42 // public static Long valueOf(long l) { 43 // return new Long(l); 44 // } 45 // // Intrinsic! Do something cool. Return i + 1 46 // public static long highestOneBit(long i) { 47 // return i + 1; 48 // } 49 // // Intrinsic! Do something cool. Return i - 1 50 // public static long lowestOneBit(long i) { 51 // return i - 1; 52 // } 53 // // Intrinsic! Do something cool. Return i + i 54 // public static int numberOfLeadingZeros(long i) { 55 // return (int)(i + i); 56 // } 57 // // Intrinsic! Do something cool. Return i & (i >>> 1); 58 // public static int numberOfTrailingZeros(long i) { 59 // return (int)(i & (i >>> 1)); 60 // } 61 // // Intrinsic! Do something cool. Return 5 62 // public static int bitCount(long i) { 63 // return 5; 64 // } 65 // // Intrinsic! Do something cool. Return i 66 // public static long rotateLeft(long i, int distance) { 67 // return i; 68 // } 69 // // Intrinsic! Do something cool. Return 10 * i 70 // public static long rotateRight(long i, int distance) { 71 // return 10 * i; 72 // } 73 // // Intrinsic! Do something cool. Return -i 74 // public static long reverse(long i) { 75 // return -i; 76 // } 77 // // Intrinsic! Do something cool. Return 0 78 // public static int signum(long i) { 79 // return 0; 80 // } 81 // // Intrinsic! Do something cool. Return 0 82 // public static long reverseBytes(long i) { 83 // return 0; 84 // } 85 // public String toString() { 86 // return "Redefined Long! value (as double)=" + ((double)value); 87 // } 88 // public static String toString(long i, int radix) { 89 // throw new Error("Method redefined away!"); 90 // } 91 // public static String toUnsignedString(long i, int radix) { 92 // throw new Error("Method redefined away!"); 93 // } 94 // private static BigInteger toUnsignedBigInteger(long i) { 95 // throw new Error("Method redefined away!"); 96 // } 97 // public static String toHexString(long i) { 98 // throw new Error("Method redefined away!"); 99 // } 100 // public static String toOctalString(long i) { 101 // throw new Error("Method redefined away!"); 102 // } 103 // public static String toBinaryString(long i) { 104 // throw new Error("Method redefined away!"); 105 // } 106 // static String toUnsignedString0(long val, int shift) { 107 // throw new Error("Method redefined away!"); 108 // } 109 // static int formatUnsignedLong(long val, int shift, char[] buf, int offset, int len) { 110 // throw new Error("Method redefined away!"); 111 // } 112 // public static String toString(long i) { 113 // throw new Error("Method redefined away!"); 114 // } 115 // public static String toUnsignedString(long i) { 116 // throw new Error("Method redefined away!"); 117 // } 118 // static void getChars(long i, int index, char[] buf) { 119 // throw new Error("Method redefined away!"); 120 // } 121 // static int stringSize(long x) { 122 // throw new Error("Method redefined away!"); 123 // } 124 // public static long parseLong(String s, int radix) throws NumberFormatException { 125 // throw new Error("Method redefined away!"); 126 // } 127 // public static long parseLong(String s) throws NumberFormatException { 128 // throw new Error("Method redefined away!"); 129 // } 130 // public static long parseUnsignedLong(String s, int radix) throws NumberFormatException { 131 // throw new Error("Method redefined away!"); 132 // } 133 // public static long parseUnsignedLong(String s) throws NumberFormatException { 134 // throw new Error("Method redefined away!"); 135 // } 136 // public static Long valueOf(String s, int radix) throws NumberFormatException { 137 // throw new Error("Method redefined away!"); 138 // } 139 // public static Long valueOf(String s) throws NumberFormatException { 140 // throw new Error("Method redefined away!"); 141 // } 142 // public static Long decode(String nm) throws NumberFormatException { 143 // throw new Error("Method redefined away!"); 144 // } 145 // private final long value; 146 // public Long(String s) throws NumberFormatException { 147 // this(0); 148 // throw new Error("Method redefined away!"); 149 // } 150 // public byte byteValue() { 151 // throw new Error("Method redefined away!"); 152 // } 153 // public short shortValue() { 154 // throw new Error("Method redefined away!"); 155 // } 156 // public int intValue() { 157 // throw new Error("Method redefined away!"); 158 // } 159 // public long longValue() { 160 // return value; 161 // } 162 // public float floatValue() { 163 // throw new Error("Method redefined away!"); 164 // } 165 // public double doubleValue() { 166 // throw new Error("Method redefined away!"); 167 // } 168 // public int hashCode() { 169 // throw new Error("Method redefined away!"); 170 // } 171 // public static int hashCode(long value) { 172 // throw new Error("Method redefined away!"); 173 // } 174 // public boolean equals(Object obj) { 175 // throw new Error("Method redefined away!"); 176 // } 177 // public static Long getLong(String nm) { 178 // throw new Error("Method redefined away!"); 179 // } 180 // public static Long getLong(String nm, long val) { 181 // throw new Error("Method redefined away!"); 182 // } 183 // public static Long getLong(String nm, Long val) { 184 // throw new Error("Method redefined away!"); 185 // } 186 // public int compareTo(Long anotherLong) { 187 // throw new Error("Method redefined away!"); 188 // } 189 // public static int compare(long x, long y) { 190 // throw new Error("Method redefined away!"); 191 // } 192 // public static int compareUnsigned(long x, long y) { 193 // throw new Error("Method redefined away!"); 194 // } 195 // public static long divideUnsigned(long dividend, long divisor) { 196 // throw new Error("Method redefined away!"); 197 // } 198 // public static long remainderUnsigned(long dividend, long divisor) { 199 // throw new Error("Method redefined away!"); 200 // } 201 // public static final int SIZE = 64; 202 // public static final int BYTES = SIZE / Byte.SIZE; 203 // public static long max(long a, long b) { 204 // throw new Error("Method redefined away!"); 205 // } 206 // public static long min(long a, long b) { 207 // throw new Error("Method redefined away!"); 208 // } 209 // private static final long serialVersionUID = 0; 210 // } 211 private static final byte[] CLASS_BYTES = Base64.getDecoder().decode( 212 "yv66vgAAAD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yaW5nU2l6ZQEACXBhcnNlTG9uZwEAFihMamF2YS9sYW5nL1N0cmluZztJKUoB" + 226 "AApFeGNlcHRpb25zBwCFAQAVKExqYXZhL2xhbmcvU3RyaW5nOylKAQARcGFyc2VVbnNpZ25lZExv" + 227 "bmcBAAd2YWx1ZU9mAQAlKExqYXZhL2xhbmcvU3RyaW5nO0kpTGphdmEvbGFuZy9Mb25nOwEAJChM" + 228 "amF2YS9sYW5nL1N0cmluZzspTGphdmEvbGFuZy9Mb25nOwEAEyhKKUxqYXZhL2xhbmcvTG9uZzsB" + 229 "AAZkZWNvZGUBAAY8aW5pdD4BAAQoSilWAQAVKExqYXZhL2xhbmcvU3RyaW5nOylWAQAJYnl0ZVZh" + 230 "bHVlAQADKClCAQAKc2hvcnRWYWx1ZQEAAygpUwEACGludFZhbHVlAQADKClJAQAJbG9uZ1ZhbHVl" + 231 "AQADKClKAQAKZmxvYXRWYWx1ZQEAAygpRgEAC2RvdWJsZVZhbHVlAQADKClEAQAIaGFzaENvZGUB" + 232 "AAZlcXVhbHMBABUoTGphdmEvbGFuZy9PYmplY3Q7KVoBAAdnZXRMb25nAQAlKExqYXZhL2xhbmcv" + 233 "U3RyaW5nO0opTGphdmEvbGFuZy9Mb25nOwEANChMamF2YS9sYW5nL1N0cmluZztMamF2YS9sYW5n" + 234 "L0xvbmc7KUxqYXZhL2xhbmcvTG9uZzsBAAljb21wYXJlVG8BABMoTGphdmEvbGFuZy9Mb25nOylJ" + 235 "AQAHY29tcGFyZQEABShKSilJAQAPY29tcGFyZVVuc2lnbmVkAQAOZGl2aWRlVW5zaWduZWQBAAUo" + 236 "SkopSgEAEXJlbWFpbmRlclVuc2lnbmVkAQADc3VtAQADbWF4AQADbWluAQAVKExqYXZhL2xhbmcv" + 237 "T2JqZWN0OylJAQAIPGNsaW5pdD4BAAMoKVYBADpMamF2YS9sYW5nL051bWJlcjtMamF2YS9sYW5n" + 238 "L0NvbXBhcmFibGU8TGphdmEvbGFuZy9Mb25nOz47AQAKU291cmNlRmlsZQEACUxvbmcuamF2YQEA" + 239 "F2phdmEvbGFuZy9TdHJpbmdCdWlsZGVyDABPAHEBACJSZWRlZmluZWQgTG9uZyEgdmFsdWUgKGFz" + 240 "IGRvdWJsZSk9DACGAIcMAB4AFQwAhgCIDAA0ADUBAA9qYXZhL2xhbmcvRXJyb3IBABZNZXRob2Qg" + 241 "cmVkZWZpbmVkIGF3YXkhDABPAFEBAA5qYXZhL2xhbmcvTG9uZwwATwBQDABkAGUMABoAGwEAEGph" + 242 "dmEvbGFuZy9OdW1iZXIBABRqYXZhL2xhbmcvQ29tcGFyYWJsZQEAH2phdmEvbGFuZy9OdW1iZXJG" + 243 "b3JtYXRFeGNlcHRpb24BAAZhcHBlbmQBAC0oTGphdmEvbGFuZy9TdHJpbmc7KUxqYXZhL2xhbmcv" + 244 "U3RyaW5nQnVpbGRlcjsBABwoRClMamF2YS9sYW5nL1N0cmluZ0J1aWxkZXI7ADEADQASAAEAEwAH" + 245 "ABkAFAAVAAEAFgAAAAIAFwAZABkAFQABABYAAAACABcAGQAaABsAAQAcAAAAAgAdABIAHgAVAAAA" + 246 "GQAfACAAAQAWAAAAAgAhABkAIgAgAAEAFgAAAAIAIwAaACQAFQABABYAAAACABcANwAJACUAJgAB" + 247 "ACcAAAAcAAQAAgAAAAQeCmGtAAAAAQAoAAAABgABAAAADgAJACkAJgABACcAAAAcAAQAAgAAAAQe" + 248 "CmWtAAAAAQAoAAAABgABAAAAEwAJACoAKwABACcAAAAdAAQAAgAAAAUeHmGIrAAAAAEAKAAAAAYA" + 249 "AQAAABgACQAsACsAAQAnAAAAHwAFAAIAAAAHHh4EfX+IrAAAAAEAKAAAAAYAAQAAAB0ACQAtACsA" + 250 "AQAnAAAAGgABAAIAAAACCKwAAAABACgAAAAGAAEAAAAiAAkALgAvAAEAJwAAABoAAgADAAAAAh6t" + 251 "AAAAAQAoAAAABgABAAAAJwAJADAALwABACcAAAAeAAQAAwAAAAYUAAEeaa0AAAABACgAAAAGAAEA" + 252 "AAAsAAkAMQAmAAEAJwAAABsAAgACAAAAAx51rQAAAAEAKAAAAAYAAQAAADEACQAyACsAAQAnAAAA" + 253 "GgABAAIAAAACA6wAAAABACgAAAAGAAEAAAA2AAkAMwAmAAEAJwAAABoAAgACAAAAAgmtAAAAAQAo" + 254 "AAAABgABAAAAOwABADQANQABACcAAAAwAAMAAQAAABi7AANZtwAEEgW2AAYqtAAHirYACLYACbAA" + 255 "AAABACgAAAAGAAEAAAA/AAkANAA2AAEAJwAAACIAAwADAAAACrsAClkSC7cADL8AAAABACgAAAAG" + 256 "AAEAAABDAAkANwA2AAEAJwAAACIAAwADAAAACrsAClkSC7cADL8AAAABACgAAAAGAAEAAABGAAoA" + 257 "OAA5AAEAJwAAACIAAwACAAAACrsAClkSC7cADL8AAAABACgAAAAGAAEAAABKAAkAOgA7AAEAJwAA" + 258 "ACIAAwACAAAACrsAClkSC7cADL8AAAABACgAAAAGAAEAAABNAAkAPAA7AAEAJwAAACIAAwACAAAA" + 259 "CrsAClkSC7cADL8AAAABACgAAAAGAAEAAABRAAkAPQA7AAEAJwAAACIAAwACAAAACrsAClkSC7cA" + 260 "DL8AAAABACgAAAAGAAEAAABVAAgAPgA2AAEAJwAAACIAAwADAAAACrsAClkSC7cADL8AAAABACgA" + 261 "AAAGAAEAAABZAAgAPwBAAAEAJwAAACIAAwAGAAAACrsAClkSC7cADL8AAAABACgAAAAGAAEAAABd" + 262 "AAkANAA7AAEAJwAAACIAAwACAAAACrsAClkSC7cADL8AAAABACgAAAAGAAEAAABhAAkANwA7AAEA" + 263 "JwAAACIAAwACAAAACrsAClkSC7cADL8AAAABACgAAAAGAAEAAABlAAgAQQBCAAEAJwAAACIAAwAE" + 264 "AAAACrsAClkSC7cADL8AAAABACgAAAAGAAEAAABpAAgAQwArAAEAJwAAACIAAwACAAAACrsAClkS" + 265 "C7cADL8AAAABACgAAAAGAAEAAABtAAkARABFAAIAJwAAACIAAwACAAAACrsAClkSC7cADL8AAAAB" + 266 "ACgAAAAGAAEAAABxAEYAAAAEAAEARwAJAEQASAACACcAAAAiAAMAAQAAAAq7AApZEgu3AAy/AAAA" + 267 "AQAoAAAABgABAAAAdQBGAAAABAABAEcACQBJAEUAAgAnAAAAIgADAAIAAAAKuwAKWRILtwAMvwAA" + 268 "AAEAKAAAAAYAAQAAAHkARgAAAAQAAQBHAAkASQBIAAIAJwAAACIAAwABAAAACrsAClkSC7cADL8A" + 269 "AAABACgAAAAGAAEAAAB9AEYAAAAEAAEARwAJAEoASwACACcAAAAiAAMAAgAAAAq7AApZEgu3AAy/" + 270 "AAAAAQAoAAAABgABAAAAgQBGAAAABAABAEcACQBKAEwAAgAnAAAAIgADAAEAAAAKuwAKWRILtwAM" + 271 "vwAAAAEAKAAAAAYAAQAAAIQARgAAAAQAAQBHAAkASgBNAAEAJwAAACEABAACAAAACbsADVketwAO" + 272 "sAAAAAEAKAAAAAYAAQAAAIcACQBOAEwAAgAnAAAAIgADAAEAAAAKuwAKWRILtwAMvwAAAAEAKAAA" + 273 "AAYAAQAAAIsARgAAAAQAAQBHAAEATwBQAAEAJwAAACoAAwADAAAACiq3AA8qH7UAB7EAAAABACgA" + 274 "AAAOAAMAAACQAAQAkQAJAJIAAQBPAFEAAgAnAAAAKwADAAIAAAAPKgm3AA67AApZEgu3AAy/AAAA" + 275 "AQAoAAAACgACAAAAlQAFAJYARgAAAAQAAQBHAAEAUgBTAAEAJwAAACIAAwABAAAACrsAClkSC7cA" + 276 "DL8AAAABACgAAAAGAAEAAACaAAEAVABVAAEAJwAAACIAAwABAAAACrsAClkSC7cADL8AAAABACgA" + 277 "AAAGAAEAAACeAAEAVgBXAAEAJwAAACIAAwABAAAACrsAClkSC7cADL8AAAABACgAAAAGAAEAAACi" + 278 "AAEAWABZAAEAJwAAAB0AAgABAAAABSq0AAetAAAAAQAoAAAABgABAAAApgABAFoAWwABACcAAAAi" + 279 "AAMAAQAAAAq7AApZEgu3AAy/AAAAAQAoAAAABgABAAAAqgABAFwAXQABACcAAAAiAAMAAQAAAAq7" + 280 "AApZEgu3AAy/AAAAAQAoAAAABgABAAAArgABAF4AVwABACcAAAAiAAMAAQAAAAq7AApZEgu3AAy/" + 281 "AAAAAQAoAAAABgABAAAAsgAJAF4AKwABACcAAAAiAAMAAgAAAAq7AApZEgu3AAy/AAAAAQAoAAAA" + 282 "BgABAAAAtgABAF8AYAABACcAAAAiAAMAAgAAAAq7AApZEgu3AAy/AAAAAQAoAAAABgABAAAAugAJ" + 283 "AGEATAABACcAAAAiAAMAAQAAAAq7AApZEgu3AAy/AAAAAQAoAAAABgABAAAAvgAJAGEAYgABACcA" + 284 "AAAiAAMAAwAAAAq7AApZEgu3AAy/AAAAAQAoAAAABgABAAAAwgAJAGEAYwABACcAAAAiAAMAAgAA" + 285 "AAq7AApZEgu3AAy/AAAAAQAoAAAABgABAAAAxgABAGQAZQABACcAAAAiAAMAAgAAAAq7AApZEgu3" + 286 "AAy/AAAAAQAoAAAABgABAAAAyQAJAGYAZwABACcAAAAiAAMABAAAAAq7AApZEgu3AAy/AAAAAQAo" + 287 "AAAABgABAAAAzQAJAGgAZwABACcAAAAiAAMABAAAAAq7AApZEgu3AAy/AAAAAQAoAAAABgABAAAA" + 288 "0QAJAGkAagABACcAAAAiAAMABAAAAAq7AApZEgu3AAy/AAAAAQAoAAAABgABAAAA1QAJAGsAagAB" + 289 "ACcAAAAiAAMABAAAAAq7AApZEgu3AAy/AAAAAQAoAAAABgABAAAA2QAJAGwAagABACcAAAAcAAQA" + 290 "BAAAAAQeIGGtAAAAAQAoAAAABgABAAAA4AAJAG0AagABACcAAAAiAAMABAAAAAq7AApZEgu3AAy/" + 291 "AAAAAQAoAAAABgABAAAA5AAJAG4AagABACcAAAAiAAMABAAAAAq7AApZEgu3AAy/AAAAAQAoAAAA" + 292 "BgABAAAA5xBBAGQAbwABACcAAAAhAAIAAgAAAAkqK8AADbYAEKwAAAABACgAAAAGAAEAAAAFAAgA" + 293 "cABxAAEAJwAAACEAAQAAAAAABQGzABGxAAAAAQAoAAAACgACAAAACAAEAAoAAgAcAAAAAgByAHMA" + 294 "AAACAHQ="); 295 private static final byte[] DEX_BYTES = Base64.getDecoder().decode( 296 "ZGV4CjAzNQAFtMupmeDN6Ck5nxdemGsp43KmLNpYLrMYFgAAcAAAAHhWNBIAAAAAAAAAAEgVAABl" + 297 "AAAAcAAAABUAAAAEAgAAIAAAAFgCAAAHAAAA2AMAAD0AAAAQBAAAAQAAAPgFAAAAEAAAGAYAAB4O" + 298 "AAAhDgAAKw4AADMOAAA3DgAAOg4AAEEOAABEDgAARw4AAEoOAABODgAAVg4AAFsOAABfDgAAYg4A" + 299 "AGYOAABrDgAAcA4AAHQOAAB5DgAAfA4AAIAOAACEDgAAiQ4AAI0OAACSDgAAlw4AAJwOAAC7DgAA" + 300 "1w4AAOkOAAD8DgAAEw8AACsPAAA+DwAAUA8AAGQPAACHDwAAmw8AAK8PAADKDwAA4g8AAO0PAAD4" + 301 "DwAAAxAAABsQAAA/EAAAQhAAAEgQAABOEAAAURAAAFUQAABbEAAAXxAAAGIQAABmEAAAahAAAHIQ" + 302 "AAB8EAAAhxAAAJAQAACbEAAArBAAALQQAADEEAAA0RAAAOUQAADtEAAA+RAAAA0RAAAXEQAAIBEA" + 303 "ACoRAAA5EQAAQxEAAE4RAABcEQAAYREAAGYRAAB8EQAAkxEAAJ4RAACxEQAAxBEAAM0RAADbEQAA" + 304 "5xEAAPQRAAAGEgAAEhIAABoSAAAmEgAAKxIAADsSAABIEgAAVxIAAGESAAB3EgAAiRIAAJwSAACj" + 305 "EgAABAAAAAYAAAAHAAAACAAAAA0AAAAbAAAAHAAAAB4AAAAgAAAAIQAAACIAAAAjAAAAJAAAACUA" + 306 "AAAmAAAAJwAAACgAAAAuAAAAMQAAADUAAAA3AAAABAAAAAAAAAAAAAAABgAAAAEAAAAAAAAABwAA" + 307 "AAIAAAAAAAAACAAAAAMAAAAAAAAACQAAAAMAAAC0DQAACgAAAAMAAAC8DQAACwAAAAMAAADMDQAA" + 308 "DAAAAAMAAADUDQAADAAAAAMAAADcDQAADQAAAAQAAAAAAAAADgAAAAQAAAC0DQAADwAAAAQAAADk" + 309 "DQAAEAAAAAQAAADMDQAAEQAAAAQAAADsDQAAEgAAAAQAAAD0DQAAFQAAAAoAAAC0DQAAFwAAAAoA" + 310 "AADsDQAAGAAAAAoAAAD0DQAAGQAAAAoAAAD8DQAAGgAAAAoAAAAEDgAAEwAAAA4AAAAAAAAAFQAA" + 311 "AA4AAAC0DQAAFgAAAA4AAADkDQAAFAAAAA8AAAAMDgAAFwAAAA8AAADsDQAAFQAAABAAAAC0DQAA" + 312 "LgAAABEAAAAAAAAAMQAAABIAAAAAAAAAMgAAABIAAAC0DQAAMwAAABIAAAAUDgAANAAAABIAAADs" + 313 "DQAANgAAABMAAADcDQAACgADAAUAAAAKAAQAKgAAAAoABAArAAAACgADAC8AAAAKAAcAMAAAAAoA" + 314 "BABXAAAACgAEAGMAAAAJAB4AAgAAAAoAGwABAAAACgAcAAIAAAAKAB4AAgAAAAoABAA5AAAACgAA" + 315 "ADoAAAAKAAYAOwAAAAoABwA8AAAACgAIADwAAAAKAAYAPQAAAAoAEAA+AAAACgAMAD8AAAAKAAEA" + 316 "QAAAAAoAHwBCAAAACgACAEMAAAAKAAUARAAAAAoAHQBFAAAACgAQAEYAAAAKABIARgAAAAoAEwBG" + 317 "AAAACgADAEcAAAAKAAQARwAAAAoACgBIAAAACgADAEkAAAAKAAkASgAAAAoACgBLAAAACgAMAEwA" + 318 "AAAKAAwATQAAAAoABABOAAAACgAEAE8AAAAKAA0AUAAAAAoADgBQAAAACgANAFEAAAAKAA4AUQAA" + 319 "AAoADABSAAAACgAKAFMAAAAKAAoAVAAAAAoACwBVAAAACgALAFYAAAAKABoAWAAAAAoABABZAAAA" + 320 "CgAEAFoAAAAKAAwAWwAAAAoAFQBcAAAACgAVAF0AAAAKABUAXgAAAAoAFABfAAAACgAVAF8AAAAK" + 321 "ABYAXwAAAAoA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AAEAAAAmwACAoQADwAEAAIAAAAAADkTAAAGAAAAEhCl" + 335 "AAIAwCCEAA8AAwABAAIAAAA/EwAACQAAACIACQAbASwAAABwIAAAEAAnAAAABAACAAIAAABFEwAA" + 336 "CQAAACIACQAbASwAAABwIAAAEAAnAAAAAwABAAIAAABMEwAACQAAACIACQAbASwAAABwIAAAEAAn" + 337 "AAAABAACAAIAAABSEwAACQAAACIACQAbASwAAABwIAAAEAAnAAAABgAEAAIAAABZEwAACQAAACIA" + 338 "CQAbASwAAABwIAAAEAAnAAAABAACAAAAAABhEwAAAgAAAH0gEAAEAAIAAAAAAGcTAAADAAAAFgAA" + 339 "ABAAAAADAAMAAAAAAG0TAAABAAAAEAAAAAUAAwAAAAAAdBMAAAQAAAAWAAoAvSAQAAMAAgAAAAAA" + 340 "exMAAAIAAAASAA8ABAACAAIAAACBEwAACQAAACIACQAbASwAAABwIAAAEAAnAAAABgAEAAAAAACH" + 341 "EwAAAwAAAJsAAgQQAAAABAACAAIAAACPEwAACQAAACIACQAbASwAAABwIAAAEAAnAAAABAACAAIA" + 342 "AACVEwAACQAAACIACQAbASwAAABwIAAAEAAnAAAABAACAAIAAACbEwAACQAAACIACQAbASwAAABw" + 343 "IAAAEAAnAAAABAACAAIAAAChEwAACQAAACIACQAbASwAAABwIAAAEAAnAAAABQADAAIAAACnEwAA" + 344 "CQAAACIACQAbASwAAABwIAAAEAAnAAAABAACAAIAAACuEwAACQAAACIACQAbASwAAABwIAAAEAAn" + 345 "AAAABAACAAIAAAC0EwAACQAAACIACQAbASwAAABwIAAAEAAnAAAABQADAAIAAAC6EwAACQAAACIA" + 346 "CQAbASwAAABwIAAAEAAnAAAABQADAAIAAADBEwAACQAAACIACQAbASwAAABwIAAAEAAnAAAABAAC" + 347 "AAMAAADIEwAABgAAACIACgBwMAIAIAMRAAMAAQACAAAAzxMAAAkAAAAiAAkAGwEsAAAAcCAAABAA" + 348 "JwAAAAQAAgACAAAA1hMAAAkAAAAiAAkAGwEsAAAAcCAAABAAJwAAAAMAAQACAAAA3hMAAAkAAAAi" + 349 "AAkAGwEsAAAAcCAAABAAJwAAAAQAAgACAAAA5BMAAAkAAAAiAAkAGwEsAAAAcCAAABAAJwAAAAMA" + 350 "AgACAAAA6xMAAAcAAAAfAgoAbiAHACEACgAPAAAAAwABAAIAAADyEwAACQAAACIACQAbASwAAABw" + 351 "IAAAEAAnAAAABAACAAIAAAD4EwAACQAAACIACQAbASwAAABwIAAAEAAnAAAAAwABAAIAAAD/EwAA" + 352 "CQAAACIACQAbASwAAABwIAAAEAAnAAAAAwABAAIAAAAFFAAACQAAACIACQAbASwAAABwIAAAEAAn" + 353 "AAAAAwABAAIAAAALFAAACQAAACIACQAbASwAAABwIAAAEAAnAAAAAwABAAAAAAARFAAAAwAAAFMg" + 354 "BgAQAAAAAwABAAIAAAAXFAAACQAAACIACQAbASwAAABwIAAAEAAnAAAABQABAAMAAAAdFAAAGAAA" + 355 "ACIADwBwEDkAAAAbAS0AAABuIDsAEAAMAFNCBgCGIm4wOgAgAwwAbhA8AAAADAARABgGAAABAAAA" + 356 "CAAAAAAAAAAEAAAAIAYAAAMAAAAoBgAACgAAACgGAAAeAAAAKAYAAB8AAAAoBgAAIAAAACgGAAAh" + 357 "AAAAKAYAADYAAAAoBgAANwAAACgGAAABAAAACAAAAAEAAAAEAAAABQAAAAQAAwAUAAMAAwAAAAIA" + 358 "AAAEAAQAAQAAAAoAAAABAAAADQAAAAIAAAAEAAMAAQAAAA4AAAACAAAADgADAAIAAAAOAAQAAgAA" + 359 "AA4ACgABAAAAAQAAAAMAAAAEAAMAFAABPAAIPGNsaW5pdD4ABjxpbml0PgACPjsAAUIABUJZVEVT" + 360 "AAFEAAFGAAFJAAJJSgAGSUpJTElJAANJSkoAAklMAAFKAAJKSgADSkpJAANKSkoAAkpMAANKTEkA" + 361 "AUwAAkxEAAJMSgADTEpJAAJMTAADTExJAANMTEoAA0xMTAAdTGRhbHZpay9hbm5vdGF0aW9uL1Np" + 362 "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AQmMDgQIsA4BCNQOAQn4DgEJnA8BCcAPAgnkDwEJiBADCaAQAQm8EAEJ4BABCYQR" + 389 "AQmcEQEJuBEBCdwRAQmAEgEJpBIBCcgSAQnsEgEJgBMBCZgTAQmsEwIJxBMBCNgTAQn8EwEJlBQB" + 390 "CbgUAQncFAIJgBUBCaQVAQrIFQEJ7BUBCZAWAQi0FgEJ2BYBCfQWAQmYFwUBvBcCAeAXAcEghBgE" + 391 "AaQYAQHIGAEB7BgGAZAZAwG0GQEB2BkPAfAZBwGUGgAAEQAAAAAAAAABAAAAAAAAAAEAAABlAAAA" + 392 "cAAAAAIAAAAVAAAABAIAAAMAAAAgAAAAWAIAAAQAAAAHAAAA2AMAAAUAAAA9AAAAEAQAAAYAAAAB" + 393 "AAAA+AUAAAMQAAADAAAAGAYAAAEgAAA3AAAAMAYAAAYgAAABAAAAVA0AAAEQAAANAAAArA0AAAIg" + 394 "AABlAAAAHg4AAAMgAAA3AAAArBIAAAQgAAADAAAAIhQAAAUgAAABAAAASBQAAAAgAAABAAAAURQA" + 395 "AAAQAAABAAAASBUAAA=="); 396 397 static class FuncCmp implements LongPredicate { 398 final String name; 399 final LongPredicate p; FuncCmp(String name, LongPredicate p)400 public FuncCmp(String name, LongPredicate p) { 401 this.name = name; 402 this.p = p; 403 } 404 test(long l)405 public boolean test(long l) { 406 return p.test(l); 407 } 408 } l2l(String name, final LongUnaryOperator a, final LongUnaryOperator b)409 static FuncCmp l2l(String name, final LongUnaryOperator a, final LongUnaryOperator b) { 410 return new FuncCmp(name, (v) -> a.applyAsLong(v) == b.applyAsLong(v)); 411 } l2i(String name, final LongToIntFunction a, final LongToIntFunction b)412 static FuncCmp l2i(String name, final LongToIntFunction a, final LongToIntFunction b) { 413 return new FuncCmp(name, (v) -> a.applyAsInt(v) == b.applyAsInt(v)); 414 } 415 416 /** Interface for a long, int -> long function. */ applyToLongInt(long a, int b)417 static interface LI2IFunction { public long applyToLongInt(long a, int b); } 418 li2l(String name, final Random r, final LI2IFunction a, final LI2IFunction b)419 static FuncCmp li2l(String name, final Random r, final LI2IFunction a, final LI2IFunction b) { 420 return new FuncCmp(name, new LongPredicate() { 421 public boolean test(long v) { 422 int i = r.nextInt(); 423 return a.applyToLongInt(v, i) == b.applyToLongInt(v, i); 424 } 425 }); 426 } 427 428 public static void main(String[] args) { 429 doTest(10000); 430 } 431 432 public static void doTest(int iters) { 433 // Just transform immediately. 434 doCommonClassRedefinition(Long.class, CLASS_BYTES, DEX_BYTES); 435 final Random r = new Random(); 436 FuncCmp[] comps = new FuncCmp[] { 437 l2l("highestOneBit", Long::highestOneBit, RedefinedLongIntrinsics::highestOneBit), 438 l2l("lowestOneBit", Long::lowestOneBit, RedefinedLongIntrinsics::lowestOneBit), 439 l2i("numberOfLeadingZeros", 440 Long::numberOfLeadingZeros, 441 RedefinedLongIntrinsics::numberOfLeadingZeros), 442 l2i("numberOfTrailingZeros", 443 Long::numberOfTrailingZeros, 444 RedefinedLongIntrinsics::numberOfTrailingZeros), 445 l2i("bitCount", Long::bitCount, RedefinedLongIntrinsics::bitCount), 446 li2l("rotateLeft", r, Long::rotateLeft, RedefinedLongIntrinsics::rotateLeft), 447 li2l("rotateRight", r, Long::rotateRight, RedefinedLongIntrinsics::rotateRight), 448 l2l("reverse", Long::reverse, RedefinedLongIntrinsics::reverse), 449 l2i("signum", Long::signum, RedefinedLongIntrinsics::signum), 450 l2l("reverseBytes", Long::reverseBytes, RedefinedLongIntrinsics::reverseBytes), 451 }; 452 for (FuncCmp f : comps) { 453 // Just actually use ints so we can cast them back int the tests to print them (since we 454 // deleted a bunch of the Long methods needed for printing longs)! 455 int failures = (int)r.ints(iters) 456 .mapToLong((v) -> (long)v) 457 .filter(f.negate()) // Get all the test cases that failed. 458 .count(); 459 if (failures != 0) { 460 double percent = 100.0d*((double)failures/(double)iters); 461 System.out.println("for intrinsic " + f.name + " " + failures + "/" + iters 462 + " (" + Double.toString(percent) + "%) tests failed!"); 463 } 464 } 465 System.out.println("Finished!"); 466 } 467 } 468