1b5d56e95f27d484ad3098ac18867262e7c8826c1Christian Williams & Phil Goodwinpackage com.xtremelabs.robolectric.bytecode; 26eedf728138e6f79fa898ff3e31bf61c9b1151dChristian Williams & Tyler Schulz 3b5d56e95f27d484ad3098ac18867262e7c8826c1Christian Williams & Phil Goodwinimport com.xtremelabs.robolectric.Robolectric; 4b5d56e95f27d484ad3098ac18867262e7c8826c1Christian Williams & Phil Goodwinimport com.xtremelabs.robolectric.WithoutTestDefaultsRunner; 522e617961e21946fd47d3b96cc670181ccd3a2bdMichael Portuesiimport com.xtremelabs.robolectric.annotation.EnableStrictI18n; 622e617961e21946fd47d3b96cc670181ccd3a2bdMichael Portuesiimport com.xtremelabs.robolectric.internal.Implementation; 722c22c9aa4ca68c2deac6164edc1d82bc9645310Christian Williams & Phil Goodwinimport com.xtremelabs.robolectric.internal.Implements; 8b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williamsimport com.xtremelabs.robolectric.internal.Instrument; 922c22c9aa4ca68c2deac6164edc1d82bc9645310Christian Williams & Phil Goodwinimport com.xtremelabs.robolectric.internal.RealObject; 106eedf728138e6f79fa898ff3e31bf61c9b1151dChristian Williams & Tyler Schulzimport org.junit.Before; 1122e617961e21946fd47d3b96cc670181ccd3a2bdMichael Portuesiimport org.junit.Ignore; 126eedf728138e6f79fa898ff3e31bf61c9b1151dChristian Williams & Tyler Schulzimport org.junit.Test; 136eedf728138e6f79fa898ff3e31bf61c9b1151dChristian Williams & Tyler Schulzimport org.junit.runner.RunWith; 146eedf728138e6f79fa898ff3e31bf61c9b1151dChristian Williams & Tyler Schulz 15190a679566d373fd4964ee7ed9d81e39052a8b30Christian Williams & Phil Goodwinimport java.io.IOException; 16190a679566d373fd4964ee7ed9d81e39052a8b30Christian Williams & Phil Goodwinimport java.io.PrintWriter; 17190a679566d373fd4964ee7ed9d81e39052a8b30Christian Williams & Phil Goodwinimport java.io.StringWriter; 18190a679566d373fd4964ee7ed9d81e39052a8b30Christian Williams & Phil Goodwin 19a3030055b95774b06a963ccc9224fac58c887cb2Christian Williams & Phil Goodwinimport static org.hamcrest.CoreMatchers.instanceOf; 20190a679566d373fd4964ee7ed9d81e39052a8b30Christian Williams & Phil Goodwinimport static org.hamcrest.CoreMatchers.not; 21a3030055b95774b06a963ccc9224fac58c887cb2Christian Williams & Phil Goodwinimport static org.hamcrest.core.StringContains.containsString; 223a15df058f1e3fd7fbff5c3b17126249f1ed909aChristian Williams & Ryan Richardimport static org.junit.Assert.*; 236eedf728138e6f79fa898ff3e31bf61c9b1151dChristian Williams & Tyler Schulz 2407257335f88da163910cc0bd039e6163edc38580Gregg Van Hove & Phil Goodwin@RunWith(WithoutTestDefaultsRunner.class) 25cee7ff89bfcb83d6cd65e6de9b7cafe2c1caf40aChristian Williamspublic class ShadowWranglerTest { 26b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams private String name; 276eedf728138e6f79fa898ff3e31bf61c9b1151dChristian Williams & Tyler Schulz 286eedf728138e6f79fa898ff3e31bf61c9b1151dChristian Williams & Tyler Schulz @Before 296eedf728138e6f79fa898ff3e31bf61c9b1151dChristian Williams & Tyler Schulz public void setUp() throws Exception { 30b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams name = "context"; 316eedf728138e6f79fa898ff3e31bf61c9b1151dChristian Williams & Tyler Schulz } 326eedf728138e6f79fa898ff3e31bf61c9b1151dChristian Williams & Tyler Schulz 336eedf728138e6f79fa898ff3e31bf61c9b1151dChristian Williams & Tyler Schulz @Test 34cee7ff89bfcb83d6cd65e6de9b7cafe2c1caf40aChristian Williams public void testConstructorInvocation_WithDefaultConstructorAndNoConstructorDelegateOnShadowClass() throws Exception { 35b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams Robolectric.bindShadowClass(ShadowFoo_WithDefaultConstructorAndNoConstructorDelegate.class); 366eedf728138e6f79fa898ff3e31bf61c9b1151dChristian Williams & Tyler Schulz 37b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams Foo foo = new Foo(name); 38b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams assertEquals(ShadowFoo_WithDefaultConstructorAndNoConstructorDelegate.class, Robolectric.shadowOf_(foo).getClass()); 396eedf728138e6f79fa898ff3e31bf61c9b1151dChristian Williams & Tyler Schulz } 406eedf728138e6f79fa898ff3e31bf61c9b1151dChristian Williams & Tyler Schulz 416eedf728138e6f79fa898ff3e31bf61c9b1151dChristian Williams & Tyler Schulz @Test 426eedf728138e6f79fa898ff3e31bf61c9b1151dChristian Williams & Tyler Schulz public void testConstructorInvocation() throws Exception { 43b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams Robolectric.bindShadowClass(ShadowFoo.class); 446eedf728138e6f79fa898ff3e31bf61c9b1151dChristian Williams & Tyler Schulz 45b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams Foo foo = new Foo(name); 46b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams assertSame(name, shadowOf(foo).name); 47b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams assertSame(foo, shadowOf(foo).realFooCtor); 481bd18692c4958c09a8daa416137a64ef0bb3d96fChristian Williams } 491bd18692c4958c09a8daa416137a64ef0bb3d96fChristian Williams 501bd18692c4958c09a8daa416137a64ef0bb3d96fChristian Williams @Test 511bd18692c4958c09a8daa416137a64ef0bb3d96fChristian Williams public void testRealObjectAnnotatedFieldsAreSetBeforeConstructorIsCalled() throws Exception { 52b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams Robolectric.bindShadowClass(ShadowFoo.class); 531bd18692c4958c09a8daa416137a64ef0bb3d96fChristian Williams 54b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams Foo foo = new Foo(name); 55b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams assertSame(name, shadowOf(foo).name); 56b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams assertSame(foo, shadowOf(foo).realFooField); 571bd18692c4958c09a8daa416137a64ef0bb3d96fChristian Williams 58b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams assertSame(foo, shadowOf(foo).realFooInConstructor); 59b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams assertSame(foo, shadowOf(foo).realFooInParentConstructor); 606eedf728138e6f79fa898ff3e31bf61c9b1151dChristian Williams & Tyler Schulz } 616eedf728138e6f79fa898ff3e31bf61c9b1151dChristian Williams & Tyler Schulz 626eedf728138e6f79fa898ff3e31bf61c9b1151dChristian Williams & Tyler Schulz @Test 636eedf728138e6f79fa898ff3e31bf61c9b1151dChristian Williams & Tyler Schulz public void testMethodDelegation() throws Exception { 64b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams Robolectric.bindShadowClass(ShadowFoo.class); 656eedf728138e6f79fa898ff3e31bf61c9b1151dChristian Williams & Tyler Schulz 66b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams Foo foo = new Foo(name); 67b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams assertSame(name, foo.getName()); 686eedf728138e6f79fa898ff3e31bf61c9b1151dChristian Williams & Tyler Schulz } 696eedf728138e6f79fa898ff3e31bf61c9b1151dChristian Williams & Tyler Schulz 706eedf728138e6f79fa898ff3e31bf61c9b1151dChristian Williams & Tyler Schulz @Test 713fbe415c50867fd95a2d7c7b1e0b7a08871290b8Christian Williams & Phil Goodwin public void testEqualsMethodDelegation() throws Exception { 72237888bb1e926aea523388de5d511a35f38506efPhil Goodwin & Tyler Schultz Robolectric.bindShadowClass(WithEquals.class); 733fbe415c50867fd95a2d7c7b1e0b7a08871290b8Christian Williams & Phil Goodwin 74b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams Foo foo1 = new Foo(name); 75b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams Foo foo2 = new Foo(name); 76b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams assertEquals(foo1, foo2); 773fbe415c50867fd95a2d7c7b1e0b7a08871290b8Christian Williams & Phil Goodwin } 783fbe415c50867fd95a2d7c7b1e0b7a08871290b8Christian Williams & Phil Goodwin 793fbe415c50867fd95a2d7c7b1e0b7a08871290b8Christian Williams & Phil Goodwin @Test 803fbe415c50867fd95a2d7c7b1e0b7a08871290b8Christian Williams & Phil Goodwin public void testHashCodeMethodDelegation() throws Exception { 81237888bb1e926aea523388de5d511a35f38506efPhil Goodwin & Tyler Schultz Robolectric.bindShadowClass(WithEquals.class); 823fbe415c50867fd95a2d7c7b1e0b7a08871290b8Christian Williams & Phil Goodwin 83b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams Foo foo = new Foo(name); 84b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams assertEquals(42, foo.hashCode()); 853fbe415c50867fd95a2d7c7b1e0b7a08871290b8Christian Williams & Phil Goodwin } 863fbe415c50867fd95a2d7c7b1e0b7a08871290b8Christian Williams & Phil Goodwin 873fbe415c50867fd95a2d7c7b1e0b7a08871290b8Christian Williams & Phil Goodwin @Test 883fbe415c50867fd95a2d7c7b1e0b7a08871290b8Christian Williams & Phil Goodwin public void testToStringMethodDelegation() throws Exception { 89237888bb1e926aea523388de5d511a35f38506efPhil Goodwin & Tyler Schultz Robolectric.bindShadowClass(WithToString.class); 903fbe415c50867fd95a2d7c7b1e0b7a08871290b8Christian Williams & Phil Goodwin 91b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams Foo foo = new Foo(name); 92b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams assertEquals("the expected string", foo.toString()); 933fbe415c50867fd95a2d7c7b1e0b7a08871290b8Christian Williams & Phil Goodwin } 943fbe415c50867fd95a2d7c7b1e0b7a08871290b8Christian Williams & Phil Goodwin 953fbe415c50867fd95a2d7c7b1e0b7a08871290b8Christian Williams & Phil Goodwin @Test 96cee7ff89bfcb83d6cd65e6de9b7cafe2c1caf40aChristian Williams public void testShadowSelectionSearchesSuperclasses() throws Exception { 97b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams Robolectric.bindShadowClass(ShadowFoo.class); 986eedf728138e6f79fa898ff3e31bf61c9b1151dChristian Williams & Tyler Schulz 99b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams TextFoo textFoo = new TextFoo(name); 100b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams assertEquals(ShadowFoo.class, Robolectric.shadowOf_(textFoo).getClass()); 1016eedf728138e6f79fa898ff3e31bf61c9b1151dChristian Williams & Tyler Schulz } 1026eedf728138e6f79fa898ff3e31bf61c9b1151dChristian Williams & Tyler Schulz 1036eedf728138e6f79fa898ff3e31bf61c9b1151dChristian Williams & Tyler Schulz @Test 10407257335f88da163910cc0bd039e6163edc38580Gregg Van Hove & Phil Goodwin public void shouldUseMostSpecificShadow() throws Exception { 105b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams Robolectric.bindShadowClass(ShadowFoo.class); 106b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams Robolectric.bindShadowClass(ShadowTextFoo.class); 1076eedf728138e6f79fa898ff3e31bf61c9b1151dChristian Williams & Tyler Schulz 108b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams TextFoo textFoo = new TextFoo(name); 109b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams assertThat(shadowOf(textFoo), instanceOf(ShadowTextFoo.class)); 1106eedf728138e6f79fa898ff3e31bf61c9b1151dChristian Williams & Tyler Schulz } 1116eedf728138e6f79fa898ff3e31bf61c9b1151dChristian Williams & Tyler Schulz 112d6318af742756246573a88fe2844d59d3c7ee29cJoseph Moore @Test 113d6318af742756246573a88fe2844d59d3c7ee29cJoseph Moore public void testPrimitiveArrays() throws Exception { 114cee7ff89bfcb83d6cd65e6de9b7cafe2c1caf40aChristian Williams Class<?> objArrayClass = ShadowWrangler.loadClass("java.lang.Object[]", getClass().getClassLoader()); 115d6318af742756246573a88fe2844d59d3c7ee29cJoseph Moore assertTrue(objArrayClass.isArray()); 116d6318af742756246573a88fe2844d59d3c7ee29cJoseph Moore assertEquals(Object.class, objArrayClass.getComponentType()); 117d6318af742756246573a88fe2844d59d3c7ee29cJoseph Moore 118cee7ff89bfcb83d6cd65e6de9b7cafe2c1caf40aChristian Williams Class<?> intArrayClass = ShadowWrangler.loadClass("int[]", getClass().getClassLoader()); 119d6318af742756246573a88fe2844d59d3c7ee29cJoseph Moore assertTrue(intArrayClass.isArray()); 120d6318af742756246573a88fe2844d59d3c7ee29cJoseph Moore assertEquals(Integer.TYPE, intArrayClass.getComponentType()); 121d6318af742756246573a88fe2844d59d3c7ee29cJoseph Moore } 122d6318af742756246573a88fe2844d59d3c7ee29cJoseph Moore 123190a679566d373fd4964ee7ed9d81e39052a8b30Christian Williams & Phil Goodwin @Test 124190a679566d373fd4964ee7ed9d81e39052a8b30Christian Williams & Phil Goodwin public void shouldRemoveNoiseFromStackTraces() throws Exception { 125b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams Robolectric.bindShadowClass(ExceptionThrowingShadowFoo.class); 126b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams Foo foo = new Foo(null); 127190a679566d373fd4964ee7ed9d81e39052a8b30Christian Williams & Phil Goodwin 128190a679566d373fd4964ee7ed9d81e39052a8b30Christian Williams & Phil Goodwin Exception e = null; 129190a679566d373fd4964ee7ed9d81e39052a8b30Christian Williams & Phil Goodwin try { 130b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams foo.getName(); 131190a679566d373fd4964ee7ed9d81e39052a8b30Christian Williams & Phil Goodwin } catch (Exception e1) { 132190a679566d373fd4964ee7ed9d81e39052a8b30Christian Williams & Phil Goodwin e = e1; 133190a679566d373fd4964ee7ed9d81e39052a8b30Christian Williams & Phil Goodwin } 134190a679566d373fd4964ee7ed9d81e39052a8b30Christian Williams & Phil Goodwin 135190a679566d373fd4964ee7ed9d81e39052a8b30Christian Williams & Phil Goodwin assertNotNull(e); 136190a679566d373fd4964ee7ed9d81e39052a8b30Christian Williams & Phil Goodwin assertEquals(IOException.class, e.getClass()); 137190a679566d373fd4964ee7ed9d81e39052a8b30Christian Williams & Phil Goodwin assertEquals("fake exception", e.getMessage()); 138190a679566d373fd4964ee7ed9d81e39052a8b30Christian Williams & Phil Goodwin StringWriter stringWriter = new StringWriter(); 139190a679566d373fd4964ee7ed9d81e39052a8b30Christian Williams & Phil Goodwin e.printStackTrace(new PrintWriter(stringWriter)); 140190a679566d373fd4964ee7ed9d81e39052a8b30Christian Williams & Phil Goodwin String stackTrace = stringWriter.getBuffer().toString(); 141190a679566d373fd4964ee7ed9d81e39052a8b30Christian Williams & Phil Goodwin 142190a679566d373fd4964ee7ed9d81e39052a8b30Christian Williams & Phil Goodwin assertThat(stackTrace, containsString("fake exception")); 143b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams assertThat(stackTrace, containsString(ExceptionThrowingShadowFoo.class.getName() + ".getName(")); 144b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams assertThat(stackTrace, containsString(Foo.class.getName() + ".getName(")); 145190a679566d373fd4964ee7ed9d81e39052a8b30Christian Williams & Phil Goodwin assertThat(stackTrace, containsString(ShadowWranglerTest.class.getName() + ".shouldRemoveNoiseFromStackTraces")); 146190a679566d373fd4964ee7ed9d81e39052a8b30Christian Williams & Phil Goodwin 147190a679566d373fd4964ee7ed9d81e39052a8b30Christian Williams & Phil Goodwin assertThat(stackTrace, not(containsString("sun.reflect"))); 148190a679566d373fd4964ee7ed9d81e39052a8b30Christian Williams & Phil Goodwin assertThat(stackTrace, not(containsString("java.lang.reflect"))); 149190a679566d373fd4964ee7ed9d81e39052a8b30Christian Williams & Phil Goodwin assertThat(stackTrace, not(containsString(ShadowWrangler.class.getName() + "."))); 150190a679566d373fd4964ee7ed9d81e39052a8b30Christian Williams & Phil Goodwin assertThat(stackTrace, not(containsString(RobolectricInternals.class.getName() + "."))); 151190a679566d373fd4964ee7ed9d81e39052a8b30Christian Williams & Phil Goodwin } 15222e617961e21946fd47d3b96cc670181ccd3a2bdMichael Portuesi 15322e617961e21946fd47d3b96cc670181ccd3a2bdMichael Portuesi @Test(expected=RuntimeException.class) 15422e617961e21946fd47d3b96cc670181ccd3a2bdMichael Portuesi @EnableStrictI18n 15522e617961e21946fd47d3b96cc670181ccd3a2bdMichael Portuesi public void shouldThrowExceptionOnI18nStrictMode() { 15622e617961e21946fd47d3b96cc670181ccd3a2bdMichael Portuesi Robolectric.bindShadowClass(ShadowFooI18n.class); 15722e617961e21946fd47d3b96cc670181ccd3a2bdMichael Portuesi Foo foo = new Foo(null); 15822e617961e21946fd47d3b96cc670181ccd3a2bdMichael Portuesi foo.getName(); 15922e617961e21946fd47d3b96cc670181ccd3a2bdMichael Portuesi } 160190a679566d373fd4964ee7ed9d81e39052a8b30Christian Williams & Phil Goodwin 161b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams private ShadowFoo shadowOf(Foo foo) { 162b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams return (ShadowFoo) Robolectric.shadowOf_(foo); 1636eedf728138e6f79fa898ff3e31bf61c9b1151dChristian Williams & Tyler Schulz } 1646eedf728138e6f79fa898ff3e31bf61c9b1151dChristian Williams & Tyler Schulz 165b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams private ShadowTextFoo shadowOf(TextFoo foo) { 166b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams return (ShadowTextFoo) Robolectric.shadowOf_(foo); 1676eedf728138e6f79fa898ff3e31bf61c9b1151dChristian Williams & Tyler Schulz } 1686eedf728138e6f79fa898ff3e31bf61c9b1151dChristian Williams & Tyler Schulz 169b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams @Implements(Foo.class) 170537f38b99433fee0ee08d7c634763e7381942f58Phil Goodwin public static class WithEquals { 1713fbe415c50867fd95a2d7c7b1e0b7a08871290b8Christian Williams & Phil Goodwin @Override 1723fbe415c50867fd95a2d7c7b1e0b7a08871290b8Christian Williams & Phil Goodwin public boolean equals(Object o) { 1733fbe415c50867fd95a2d7c7b1e0b7a08871290b8Christian Williams & Phil Goodwin return true; 1743fbe415c50867fd95a2d7c7b1e0b7a08871290b8Christian Williams & Phil Goodwin } 1753fbe415c50867fd95a2d7c7b1e0b7a08871290b8Christian Williams & Phil Goodwin 176b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams 1773fbe415c50867fd95a2d7c7b1e0b7a08871290b8Christian Williams & Phil Goodwin @Override 1783fbe415c50867fd95a2d7c7b1e0b7a08871290b8Christian Williams & Phil Goodwin public int hashCode() { 1793fbe415c50867fd95a2d7c7b1e0b7a08871290b8Christian Williams & Phil Goodwin return 42; 1803fbe415c50867fd95a2d7c7b1e0b7a08871290b8Christian Williams & Phil Goodwin } 1813fbe415c50867fd95a2d7c7b1e0b7a08871290b8Christian Williams & Phil Goodwin 1823fbe415c50867fd95a2d7c7b1e0b7a08871290b8Christian Williams & Phil Goodwin } 1833fbe415c50867fd95a2d7c7b1e0b7a08871290b8Christian Williams & Phil Goodwin 184b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams @Implements(Foo.class) 185537f38b99433fee0ee08d7c634763e7381942f58Phil Goodwin public static class WithToString { 1863fbe415c50867fd95a2d7c7b1e0b7a08871290b8Christian Williams & Phil Goodwin @Override 1873fbe415c50867fd95a2d7c7b1e0b7a08871290b8Christian Williams & Phil Goodwin public String toString() { 1883fbe415c50867fd95a2d7c7b1e0b7a08871290b8Christian Williams & Phil Goodwin return "the expected string"; 1893fbe415c50867fd95a2d7c7b1e0b7a08871290b8Christian Williams & Phil Goodwin } 1903fbe415c50867fd95a2d7c7b1e0b7a08871290b8Christian Williams & Phil Goodwin } 1913fbe415c50867fd95a2d7c7b1e0b7a08871290b8Christian Williams & Phil Goodwin 192b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams @Implements(TextFoo.class) 193b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams public static class ShadowTextFoo { 194b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams } 1956eedf728138e6f79fa898ff3e31bf61c9b1151dChristian Williams & Tyler Schulz 196b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams @Instrument 197b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams public static class TextFoo extends Foo { 198b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams public TextFoo(String s) { 199b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams super(s); 2006eedf728138e6f79fa898ff3e31bf61c9b1151dChristian Williams & Tyler Schulz } 2016eedf728138e6f79fa898ff3e31bf61c9b1151dChristian Williams & Tyler Schulz } 20222e617961e21946fd47d3b96cc670181ccd3a2bdMichael Portuesi 20322e617961e21946fd47d3b96cc670181ccd3a2bdMichael Portuesi @Implements(Foo.class) 20422e617961e21946fd47d3b96cc670181ccd3a2bdMichael Portuesi public static class ShadowFooI18n { 20522e617961e21946fd47d3b96cc670181ccd3a2bdMichael Portuesi String name; 20622e617961e21946fd47d3b96cc670181ccd3a2bdMichael Portuesi 20722e617961e21946fd47d3b96cc670181ccd3a2bdMichael Portuesi public void __constructor__(String name) { 20822e617961e21946fd47d3b96cc670181ccd3a2bdMichael Portuesi this.name = name; 20922e617961e21946fd47d3b96cc670181ccd3a2bdMichael Portuesi } 21022e617961e21946fd47d3b96cc670181ccd3a2bdMichael Portuesi 21122e617961e21946fd47d3b96cc670181ccd3a2bdMichael Portuesi @Implementation(i18nSafe=false) 21222e617961e21946fd47d3b96cc670181ccd3a2bdMichael Portuesi public String getName() { 21322e617961e21946fd47d3b96cc670181ccd3a2bdMichael Portuesi return name; 21422e617961e21946fd47d3b96cc670181ccd3a2bdMichael Portuesi } 21522e617961e21946fd47d3b96cc670181ccd3a2bdMichael Portuesi } 2161bd18692c4958c09a8daa416137a64ef0bb3d96fChristian Williams 217b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams @Implements(Foo.class) 218b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams public static class ShadowFooParent { 2191bd18692c4958c09a8daa416137a64ef0bb3d96fChristian Williams @RealObject 220b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams private Foo realFoo; 221b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams Foo realFooInParentConstructor; 2221bd18692c4958c09a8daa416137a64ef0bb3d96fChristian Williams 223b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams public void __constructor__(String name) { 224b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams realFooInParentConstructor = realFoo; 2251bd18692c4958c09a8daa416137a64ef0bb3d96fChristian Williams } 2261bd18692c4958c09a8daa416137a64ef0bb3d96fChristian Williams } 227adfaceabbda4c8c51f24a0def8926075bd7306adChristian Williams 228b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams @Implements(Foo.class) 229b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams public static class ShadowFoo_WithDefaultConstructorAndNoConstructorDelegate { 2306eedf728138e6f79fa898ff3e31bf61c9b1151dChristian Williams & Tyler Schulz } 231190a679566d373fd4964ee7ed9d81e39052a8b30Christian Williams & Phil Goodwin 232b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams @Implements(Foo.class) 233b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams public static class ExceptionThrowingShadowFoo { 234190a679566d373fd4964ee7ed9d81e39052a8b30Christian Williams & Phil Goodwin @SuppressWarnings({"UnusedDeclaration"}) 235b5bb7765edf3500ebe861742b3adb6ab24a2fdbaChristian Williams public String getName() throws IOException { 236190a679566d373fd4964ee7ed9d81e39052a8b30Christian Williams & Phil Goodwin throw new IOException("fake exception"); 237190a679566d373fd4964ee7ed9d81e39052a8b30Christian Williams & Phil Goodwin } 238190a679566d373fd4964ee7ed9d81e39052a8b30Christian Williams & Phil Goodwin } 2396eedf728138e6f79fa898ff3e31bf61c9b1151dChristian Williams & Tyler Schulz} 240