1 /* 2 * Copyright (C) 2019 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 package art; 18 19 import java.util.Base64; 20 21 public class Transform1975 { 22 23 static { 24 } 25 26 public static Class<?> CUR_CLASS = Transform1975.class; 27 28 /* Dex file for: 29 * // NB The name NEW_STRING ensures the offset for the REDEFINED_DEX_BYTES field is different. 30 * package art; 31 * public class Transform1975 { 32 * static {} 33 * public static Class<?> CUR_CLASS; 34 * public static byte[] REDEFINED_DEX_BYTES; 35 * public static String NEW_STRING; 36 * public static void doSomething() { 37 * System.out.println("Doing something"); 38 * new_string = "I did something!"; 39 * } 40 * public static void readFields() { 41 * System.out.println("NEW VALUE CUR_CLASS: " + CUR_CLASS); 42 * System.out.println("NEW VALUE REDEFINED_DEX_BYTES: " + Base64.getEncoder().encodeToString(REDEFINED_DEX_BYTES)); 43 * System.out.println("NEW VALUE NEW_STRING: " + NEW_STRING); 44 * } 45 * } 46 */ 47 public static byte[] REDEFINED_DEX_BYTES = 48 Base64.getDecoder() 49 .decode( 50 "ZGV4CjAzNQDNGFvYlmyIt+u4bnNv+OyNVekBxlrJi6EgBwAAcAAAAHhWNBIAAAAAAAAAAFwGAAAm" 51 + "AAAAcAAAAAwAAAAIAQAABwAAADgBAAAEAAAAjAEAAAwAAACsAQAAAQAAAAwCAAD0BAAALAIAAGYD" 52 + "AABrAwAAdQMAAH0DAACIAwAAmQMAAKsDAACuAwAAsgMAAMcDAADmAwAA/QMAABAEAAAjBAAANwQA" 53 + "AEsEAABmBAAAegQAAJYEAACqBAAAwQQAANkEAAD6BAAABgUAABsFAAA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AEA" 80 + "AAAMAgAAASAAAAQAAAAsAgAAAyAAAAQAAAAyAwAAARAAAAMAAABQAwAAAiAAACYAAABmAwAABCAA" 81 + "AAEAAAAOBgAAACAAAAEAAAAYBgAAAxAAAAIAAAA4BgAABiAAAAEAAABEBgAAABAAAAEAAABcBgAA"); 82 doSomething()83 public static void doSomething() { 84 System.out.println("Not doing anything"); 85 } 86 readFields()87 public static void readFields() { 88 System.out.println("ORIGINAL VALUE CUR_CLASS: " + CUR_CLASS); 89 System.out.println( 90 "ORIGINAL VALUE REDEFINED_DEX_BYTES: " 91 + Base64.getEncoder().encodeToString(REDEFINED_DEX_BYTES)); 92 } 93 } 94