blob: e8a10e0725d45d6c3321d2b4c741bcf30eeb39ba [file] [log] [blame]
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package art;
import java.util.Base64;
public class Test2003 {
public static class Transform {
public String getGreeting() {
return "Hi";
}
}
public static class SubTransform extends Transform {
private int count = 0;
public void sayHi() {
System.out.println(getGreeting() + "(SubTransform called " + (++count) + " times)");
}
}
/**
* base64 encoded class/dex file for
* public static class SubTransform extends Transform {
* private int count = 0;
* public void sayHi() {
* System.out.println(getGreeting() + "(SubTransform called " + (++count) + " times, Transform called " + getCount() + " times)");
* }
* }
*/
private static final byte[] SUBTRANSFORM_DEX_BYTES = Base64.getDecoder().decode(
"ZGV4CjAzNQCh/FHVi1J2bdQclTBNUHHeAbrR2Sy2cWXoBQAAcAAAAHhWNBIAAAAAAAAAACQFAAAh" +
"AAAAcAAAAAsAAAD0AAAABgAAACABAAACAAAAaAEAAAoAAAB4AQAAAQAAAMgBAAAABAAA6AEAAJ4C" +
"AACnAgAAwgIAANkCAADhAgAA5AIAAOcCAADrAgAA7wIAAAwDAAAmAwAANgMAAFoDAAB6AwAAkQMA" +
"AKUDAADAAwAA1AMAAOIDAADxAwAA9AMAAPgDAAAFBAAADQQAABQEAAAeBAAAKwQAADEEAAA2BAAA" +
"PwQAAEYEAABQBAAAVwQAAAQAAAAIAAAACQAAAAoAAAALAAAADAAAAA0AAAAOAAAADwAAABAAAAAT" +
"AAAABAAAAAAAAAAAAAAABQAAAAcAAAAAAAAABgAAAAgAAACQAgAABwAAAAgAAACYAgAAEwAAAAoA" +
"AAAAAAAAFAAAAAoAAACYAgAAAQAAABcA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ImRl" +
"YnVnIiwiaGFzLWNoZWNrc3VtcyI6ZmFsc2UsIm1pbi1hcGkiOjEsInNoYS0xIjoiODViZjE2Yzc1" +
"NjUzZDQwNGE0YzNlZDQzNjA3Yzc3Yjg1YmFmMzFlZSIsInZlcnNpb24iOiIyLjAuNS1kZXYifQAC" +
"BAEfGAMCBQIVBAkaFxEAAQEBAAIAgYAE6AMDAYgEAAAAAAIAAADlBAAA6wQAAAgFAAAAAAAAAAAA" +
"AAAAAAAQAAAAAAAAAAEAAAAAAAAAAQAAACEAAABwAAAAAgAAAAsAAAD0AAAAAwAAAAYAAAAgAQAA" +
"BAAAAAIAAABoAQAABQAAAAoAAAB4AQAABgAAAAEAAADIAQAAASAAAAIAAADoAQAAAyAAAAIAAACC" +
"AgAAARAAAAIAAACQAgAAAiAAACEAAACeAgAABCAAAAIAAADlBAAAACAAAAEAAAD0BAAAAxAAAAIA" +
"AAAEBQAABiAAAAEAAAAUBQAAABAAAAEAAAAkBQAA");
/**
* base64 encoded class/dex file for
* public static class Transform {
* private int count;
* public String getGreeting() {
* incrCount();
* return "Hello";
* }
* protected void incrCount() {
* ++count;
* }
* protected int getCount() {
* return count;
* }
* }
*/
private static final byte[] TRANSFORM_DEX_BYTES = Base64.getDecoder().decode(
"ZGV4CjAzNQCAt16FlKvFzDaE6l56jUkorc7YXyrJmRpsBAAAcAAAAHhWNBIAAAAAAAAAALQDAAAV" +
"AAAAcAAAAAgAAADEAAAAAwAAAOQAAAABAAAACAEAAAUAAAAQAQAAAQAAADgBAAAUAwAAWAEAANQB" +
"AADcAQAA4wEAAOYBAADpAQAAAwIAABMCAAA3AgAAVwIAAGsCAAB/AgAAjgIAAJkCAACcAgAAqQIA" +
"ALACAAC6AgAAxwIAANICAADYAgAA3wIAAAIAAAAEAAAABQAAAAYAAAAHAAAACAAAAAkAAAAMAAAA" +
"AgAAAAAAAAAAAAAAAwAAAAYAAAAAAAAADAAAAAcAAAAAAAAAAQAAAA4AAAABAAIAAAAAAAE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AAEAAAAwgEAAAIgAAAVAAAA1AEAAAQgAAACAAAAbQMA" +
"AAAgAAABAAAAfAMAAAMQAAACAAAAlAMAAAYgAAABAAAApAMAAAAQAAABAAAAtAMAAA==");
public static void run() {
Redefinition.setTestConfiguration(Redefinition.Config.COMMON_REDEFINE);
doTest(new SubTransform());
}
public static void doTest(SubTransform t) {
t.sayHi();
t.sayHi();
t.sayHi();
Redefinition.doMultiStructuralClassRedefinition(
new Redefinition.CommonClassDefinition(SubTransform.class, null, SUBTRANSFORM_DEX_BYTES),
new Redefinition.CommonClassDefinition(Transform.class, null, TRANSFORM_DEX_BYTES));
t.sayHi();
t.sayHi();
t.sayHi();
}
}