136efe4ab6422c34c98e196eee7022fecf52c7534Elliott Hughes/*
236efe4ab6422c34c98e196eee7022fecf52c7534Elliott Hughes * Copyright (C) 2009 The Android Open Source Project
3f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes *
436efe4ab6422c34c98e196eee7022fecf52c7534Elliott Hughes * Licensed under the Apache License, Version 2.0 (the "License");
536efe4ab6422c34c98e196eee7022fecf52c7534Elliott Hughes * you may not use this file except in compliance with the License.
636efe4ab6422c34c98e196eee7022fecf52c7534Elliott Hughes * You may obtain a copy of the License at
7f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes *
836efe4ab6422c34c98e196eee7022fecf52c7534Elliott Hughes *      http://www.apache.org/licenses/LICENSE-2.0
9f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes *
1036efe4ab6422c34c98e196eee7022fecf52c7534Elliott Hughes * Unless required by applicable law or agreed to in writing, software
1136efe4ab6422c34c98e196eee7022fecf52c7534Elliott Hughes * distributed under the License is distributed on an "AS IS" BASIS,
1236efe4ab6422c34c98e196eee7022fecf52c7534Elliott Hughes * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1336efe4ab6422c34c98e196eee7022fecf52c7534Elliott Hughes * See the License for the specific language governing permissions and
1436efe4ab6422c34c98e196eee7022fecf52c7534Elliott Hughes * limitations under the License.
1536efe4ab6422c34c98e196eee7022fecf52c7534Elliott Hughes */
1636efe4ab6422c34c98e196eee7022fecf52c7534Elliott Hughes
174557728efb66c455a52b7669a8eefef7a9e54854Jesse Wilsonpackage libcore.java.lang.reflect;
184557728efb66c455a52b7669a8eefef7a9e54854Jesse Wilson
194557728efb66c455a52b7669a8eefef7a9e54854Jesse Wilsonimport java.lang.reflect.Method;
2011229f6af89fc54e70675fcab098b1572d6e539eJesse Wilsonimport junit.framework.TestCase;
2136efe4ab6422c34c98e196eee7022fecf52c7534Elliott Hughes
2211229f6af89fc54e70675fcab098b1572d6e539eJesse Wilsonpublic final class MethodTest extends TestCase {
23a365feb9c9cef4ceaa99f9265b3f1d64047e8d18Elliott Hughes    // Check that the VM gives useful detail messages.
24a365feb9c9cef4ceaa99f9265b3f1d64047e8d18Elliott Hughes    public void test_invokeExceptions() throws Exception {
25a365feb9c9cef4ceaa99f9265b3f1d64047e8d18Elliott Hughes        Method m = String.class.getMethod("charAt", int.class);
26a365feb9c9cef4ceaa99f9265b3f1d64047e8d18Elliott Hughes        try {
27a365feb9c9cef4ceaa99f9265b3f1d64047e8d18Elliott Hughes            m.invoke("hello"); // Wrong number of arguments.
28a365feb9c9cef4ceaa99f9265b3f1d64047e8d18Elliott Hughes            fail();
29a365feb9c9cef4ceaa99f9265b3f1d64047e8d18Elliott Hughes        } catch (IllegalArgumentException iae) {
30a365feb9c9cef4ceaa99f9265b3f1d64047e8d18Elliott Hughes            assertEquals("wrong number of arguments; expected 1, got 0", iae.getMessage());
31a365feb9c9cef4ceaa99f9265b3f1d64047e8d18Elliott Hughes        }
32a365feb9c9cef4ceaa99f9265b3f1d64047e8d18Elliott Hughes        try {
33a365feb9c9cef4ceaa99f9265b3f1d64047e8d18Elliott Hughes            m.invoke("hello", "world"); // Wrong type.
34a365feb9c9cef4ceaa99f9265b3f1d64047e8d18Elliott Hughes            fail();
35a365feb9c9cef4ceaa99f9265b3f1d64047e8d18Elliott Hughes        } catch (IllegalArgumentException iae) {
36a365feb9c9cef4ceaa99f9265b3f1d64047e8d18Elliott Hughes            assertEquals("argument 1 should have type int, got java.lang.String", iae.getMessage());
37a365feb9c9cef4ceaa99f9265b3f1d64047e8d18Elliott Hughes        }
38a365feb9c9cef4ceaa99f9265b3f1d64047e8d18Elliott Hughes        try {
39a365feb9c9cef4ceaa99f9265b3f1d64047e8d18Elliott Hughes            m.invoke("hello", (Object) null); // Null for a primitive argument.
40a365feb9c9cef4ceaa99f9265b3f1d64047e8d18Elliott Hughes            fail();
41a365feb9c9cef4ceaa99f9265b3f1d64047e8d18Elliott Hughes        } catch (IllegalArgumentException iae) {
42a365feb9c9cef4ceaa99f9265b3f1d64047e8d18Elliott Hughes            assertEquals("argument 1 should have type int, got null", iae.getMessage());
43a365feb9c9cef4ceaa99f9265b3f1d64047e8d18Elliott Hughes        }
446187e1bf832ebf9372e993454fbd48b1694731beElliott Hughes        try {
456187e1bf832ebf9372e993454fbd48b1694731beElliott Hughes            m.invoke(new Integer(5)); // Wrong type for 'this'.
466187e1bf832ebf9372e993454fbd48b1694731beElliott Hughes            fail();
476187e1bf832ebf9372e993454fbd48b1694731beElliott Hughes        } catch (IllegalArgumentException iae) {
48d5598fe780f71bd5de8d79e7a723683e17b8feb7Elliott Hughes            assertEquals("expected receiver of type java.lang.String, but got java.lang.Integer", iae.getMessage());
496187e1bf832ebf9372e993454fbd48b1694731beElliott Hughes        }
506187e1bf832ebf9372e993454fbd48b1694731beElliott Hughes        try {
516187e1bf832ebf9372e993454fbd48b1694731beElliott Hughes            m.invoke(null); // Null for 'this'.
526187e1bf832ebf9372e993454fbd48b1694731beElliott Hughes            fail();
536187e1bf832ebf9372e993454fbd48b1694731beElliott Hughes        } catch (NullPointerException npe) {
54907c03d7c033039de50644f1f27c16c6732ebf5bJesse Wilson            assertEquals("expected receiver of type java.lang.String, but got null",
5529e0638aca737dd1093dac55216982b5af7d59a7Jesse Wilson                    npe.getMessage());
566187e1bf832ebf9372e993454fbd48b1694731beElliott Hughes        }
57a365feb9c9cef4ceaa99f9265b3f1d64047e8d18Elliott Hughes    }
58a365feb9c9cef4ceaa99f9265b3f1d64047e8d18Elliott Hughes
5936efe4ab6422c34c98e196eee7022fecf52c7534Elliott Hughes    public void test_getExceptionTypes() throws Exception {
6036efe4ab6422c34c98e196eee7022fecf52c7534Elliott Hughes        Method method = MethodTestHelper.class.getMethod("m1", new Class[0]);
6136efe4ab6422c34c98e196eee7022fecf52c7534Elliott Hughes        Class[] exceptions = method.getExceptionTypes();
6236efe4ab6422c34c98e196eee7022fecf52c7534Elliott Hughes        assertEquals(1, exceptions.length);
6336efe4ab6422c34c98e196eee7022fecf52c7534Elliott Hughes        assertEquals(IndexOutOfBoundsException.class, exceptions[0]);
6436efe4ab6422c34c98e196eee7022fecf52c7534Elliott Hughes        // Check that corrupting our array doesn't affect other callers.
6536efe4ab6422c34c98e196eee7022fecf52c7534Elliott Hughes        exceptions[0] = NullPointerException.class;
6636efe4ab6422c34c98e196eee7022fecf52c7534Elliott Hughes        exceptions = method.getExceptionTypes();
6736efe4ab6422c34c98e196eee7022fecf52c7534Elliott Hughes        assertEquals(1, exceptions.length);
6836efe4ab6422c34c98e196eee7022fecf52c7534Elliott Hughes        assertEquals(IndexOutOfBoundsException.class, exceptions[0]);
6936efe4ab6422c34c98e196eee7022fecf52c7534Elliott Hughes    }
7036efe4ab6422c34c98e196eee7022fecf52c7534Elliott Hughes
7136efe4ab6422c34c98e196eee7022fecf52c7534Elliott Hughes    public void test_getParameterTypes() throws Exception {
7236efe4ab6422c34c98e196eee7022fecf52c7534Elliott Hughes        Class[] expectedParameters = new Class[] { Object.class };
7336efe4ab6422c34c98e196eee7022fecf52c7534Elliott Hughes        Method method = MethodTestHelper.class.getMethod("m2", expectedParameters);
7436efe4ab6422c34c98e196eee7022fecf52c7534Elliott Hughes        Class[] parameters = method.getParameterTypes();
7536efe4ab6422c34c98e196eee7022fecf52c7534Elliott Hughes        assertEquals(1, parameters.length);
7636efe4ab6422c34c98e196eee7022fecf52c7534Elliott Hughes        assertEquals(expectedParameters[0], parameters[0]);
7736efe4ab6422c34c98e196eee7022fecf52c7534Elliott Hughes        // Check that corrupting our array doesn't affect other callers.
7836efe4ab6422c34c98e196eee7022fecf52c7534Elliott Hughes        parameters[0] = String.class;
7936efe4ab6422c34c98e196eee7022fecf52c7534Elliott Hughes        parameters = method.getParameterTypes();
8036efe4ab6422c34c98e196eee7022fecf52c7534Elliott Hughes        assertEquals(1, parameters.length);
8136efe4ab6422c34c98e196eee7022fecf52c7534Elliott Hughes        assertEquals(expectedParameters[0], parameters[0]);
8236efe4ab6422c34c98e196eee7022fecf52c7534Elliott Hughes    }
8336efe4ab6422c34c98e196eee7022fecf52c7534Elliott Hughes
8411229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson    public void testGetMethodWithPrivateMethodAndInterfaceMethod() throws Exception {
8511229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson        assertEquals(InterfaceA.class, Sub.class.getMethod("a").getDeclaringClass());
8611229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson    }
8711229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson
8811229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson    public void testGetMethodReturnsIndirectlyImplementedInterface() throws Exception {
8911229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson        assertEquals(InterfaceA.class, ImplementsC.class.getMethod("a").getDeclaringClass());
9011229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson        assertEquals(InterfaceA.class, ExtendsImplementsC.class.getMethod("a").getDeclaringClass());
9111229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson    }
9211229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson
9311229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson    public void testGetDeclaredMethodReturnsIndirectlyImplementedInterface() throws Exception {
9411229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson        try {
9511229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson            ImplementsC.class.getDeclaredMethod("a").getDeclaringClass();
9611229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson            fail();
9711229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson        } catch (NoSuchMethodException expected) {
9811229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson        }
9911229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson        try {
10011229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson            ExtendsImplementsC.class.getDeclaredMethod("a").getDeclaringClass();
10111229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson            fail();
10211229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson        } catch (NoSuchMethodException expected) {
10311229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson        }
10411229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson    }
10511229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson
10611229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson    public void testGetMethodWithConstructorName() throws Exception {
10711229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson        try {
10811229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson            MethodTestHelper.class.getMethod("<init>");
10911229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson            fail();
11011229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson        } catch (NoSuchMethodException expected) {
11111229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson        }
11211229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson    }
11311229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson
11411229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson    public void testGetMethodWithNullName() throws Exception {
11511229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson        try {
11611229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson            MethodTestHelper.class.getMethod(null);
11711229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson            fail();
11811229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson        } catch (NullPointerException expected) {
11911229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson        }
12011229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson    }
12111229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson
12211229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson    public void testGetMethodWithNullArgumentsArray() throws Exception {
12311229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson        Method m1 = MethodTestHelper.class.getMethod("m1", (Class[]) null);
12411229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson        assertEquals(0, m1.getParameterTypes().length);
12511229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson    }
12611229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson
12711229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson    public void testGetMethodWithNullArgument() throws Exception {
12811229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson        try {
12911229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson            MethodTestHelper.class.getMethod("m2", new Class[] { null });
13011229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson            fail();
13111229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson        } catch (NoSuchMethodException expected) {
13211229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson        }
13311229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson    }
13411229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson
13511229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson    public void testGetMethodReturnsInheritedStaticMethod() throws Exception {
13611229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson        Method b = Sub.class.getMethod("b");
13711229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson        assertEquals(void.class, b.getReturnType());
13811229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson    }
13911229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson
14011229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson    public void testGetDeclaredMethodReturnsPrivateMethods() throws Exception {
14111229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson        Method method = Super.class.getDeclaredMethod("a");
14211229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson        assertEquals(void.class, method.getReturnType());
14311229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson    }
14411229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson
14511229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson    public void testGetDeclaredMethodDoesNotReturnSuperclassMethods() throws Exception {
14611229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson        try {
14711229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson            Sub.class.getDeclaredMethod("a");
14811229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson            fail();
14911229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson        } catch (NoSuchMethodException expected) {
15011229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson        }
15111229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson    }
15211229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson
15311229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson    public void testGetDeclaredMethodDoesNotReturnImplementedInterfaceMethods() throws Exception {
15411229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson        try {
15511229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson            InterfaceB.class.getDeclaredMethod("a");
15611229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson            fail();
15711229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson        } catch (NoSuchMethodException expected) {
15811229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson        }
15911229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson    }
16011229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson
161a9781911abb1d8239ed77ac5e39bc789b7632ce6Jesse Wilson    public void testImplementedInterfaceMethodOfAnonymousClass() throws Exception {
162a9781911abb1d8239ed77ac5e39bc789b7632ce6Jesse Wilson        Object anonymous = new InterfaceA() {
163a9781911abb1d8239ed77ac5e39bc789b7632ce6Jesse Wilson            @Override public void a() {
164a9781911abb1d8239ed77ac5e39bc789b7632ce6Jesse Wilson            }
165a9781911abb1d8239ed77ac5e39bc789b7632ce6Jesse Wilson        };
166a9781911abb1d8239ed77ac5e39bc789b7632ce6Jesse Wilson        Method method = anonymous.getClass().getMethod("a");
167a9781911abb1d8239ed77ac5e39bc789b7632ce6Jesse Wilson        assertEquals(anonymous.getClass(), method.getDeclaringClass());
168a9781911abb1d8239ed77ac5e39bc789b7632ce6Jesse Wilson    }
169a9781911abb1d8239ed77ac5e39bc789b7632ce6Jesse Wilson
170a9781911abb1d8239ed77ac5e39bc789b7632ce6Jesse Wilson    public void testPublicMethodOfAnonymousClass() throws Exception {
171a9781911abb1d8239ed77ac5e39bc789b7632ce6Jesse Wilson        Object anonymous = new Object() {
172a9781911abb1d8239ed77ac5e39bc789b7632ce6Jesse Wilson            public void a() {
173a9781911abb1d8239ed77ac5e39bc789b7632ce6Jesse Wilson            }
174a9781911abb1d8239ed77ac5e39bc789b7632ce6Jesse Wilson        };
175a9781911abb1d8239ed77ac5e39bc789b7632ce6Jesse Wilson        Method method = anonymous.getClass().getMethod("a");
176a9781911abb1d8239ed77ac5e39bc789b7632ce6Jesse Wilson        assertEquals(anonymous.getClass(), method.getDeclaringClass());
177a9781911abb1d8239ed77ac5e39bc789b7632ce6Jesse Wilson    }
178a9781911abb1d8239ed77ac5e39bc789b7632ce6Jesse Wilson
179a9781911abb1d8239ed77ac5e39bc789b7632ce6Jesse Wilson    public void testGetMethodDoesNotReturnPrivateMethodOfAnonymousClass() throws Exception {
180a9781911abb1d8239ed77ac5e39bc789b7632ce6Jesse Wilson        Object anonymous = new Object() {
181a9781911abb1d8239ed77ac5e39bc789b7632ce6Jesse Wilson            private void a() {
182a9781911abb1d8239ed77ac5e39bc789b7632ce6Jesse Wilson            }
183a9781911abb1d8239ed77ac5e39bc789b7632ce6Jesse Wilson        };
184a9781911abb1d8239ed77ac5e39bc789b7632ce6Jesse Wilson        try {
185a9781911abb1d8239ed77ac5e39bc789b7632ce6Jesse Wilson            anonymous.getClass().getMethod("a");
186a9781911abb1d8239ed77ac5e39bc789b7632ce6Jesse Wilson            fail();
187a9781911abb1d8239ed77ac5e39bc789b7632ce6Jesse Wilson        } catch (NoSuchMethodException expected) {
188a9781911abb1d8239ed77ac5e39bc789b7632ce6Jesse Wilson        }
189a9781911abb1d8239ed77ac5e39bc789b7632ce6Jesse Wilson    }
190a9781911abb1d8239ed77ac5e39bc789b7632ce6Jesse Wilson
191a9781911abb1d8239ed77ac5e39bc789b7632ce6Jesse Wilson    public void testGetDeclaredMethodReturnsPrivateMethodOfAnonymousClass() throws Exception {
192a9781911abb1d8239ed77ac5e39bc789b7632ce6Jesse Wilson        Object anonymous = new Object() {
193a9781911abb1d8239ed77ac5e39bc789b7632ce6Jesse Wilson            private void a() {
194a9781911abb1d8239ed77ac5e39bc789b7632ce6Jesse Wilson            }
195a9781911abb1d8239ed77ac5e39bc789b7632ce6Jesse Wilson        };
196a9781911abb1d8239ed77ac5e39bc789b7632ce6Jesse Wilson        Method method = anonymous.getClass().getDeclaredMethod("a");
197a9781911abb1d8239ed77ac5e39bc789b7632ce6Jesse Wilson        assertEquals(anonymous.getClass(), method.getDeclaringClass());
198a9781911abb1d8239ed77ac5e39bc789b7632ce6Jesse Wilson    }
199a9781911abb1d8239ed77ac5e39bc789b7632ce6Jesse Wilson
200a0ee76b0850774edeb0c67204070b89d117573bcJesse Wilson    // http://b/1045939
201a0ee76b0850774edeb0c67204070b89d117573bcJesse Wilson    public void testMethodToString() throws Exception {
202a0ee76b0850774edeb0c67204070b89d117573bcJesse Wilson        assertEquals("public final native void java.lang.Object.notify()",
203a0ee76b0850774edeb0c67204070b89d117573bcJesse Wilson                Object.class.getMethod("notify", new Class[] { }).toString());
204a0ee76b0850774edeb0c67204070b89d117573bcJesse Wilson        assertEquals("public java.lang.String java.lang.Object.toString()",
205a0ee76b0850774edeb0c67204070b89d117573bcJesse Wilson                Object.class.getMethod("toString", new Class[] { }).toString());
206a0ee76b0850774edeb0c67204070b89d117573bcJesse Wilson        assertEquals("public final native void java.lang.Object.wait(long,int)"
207a0ee76b0850774edeb0c67204070b89d117573bcJesse Wilson                + " throws java.lang.InterruptedException",
208a0ee76b0850774edeb0c67204070b89d117573bcJesse Wilson                Object.class.getMethod("wait", new Class[] { long.class, int.class }).toString());
209a0ee76b0850774edeb0c67204070b89d117573bcJesse Wilson        assertEquals("public boolean java.lang.Object.equals(java.lang.Object)",
210a0ee76b0850774edeb0c67204070b89d117573bcJesse Wilson                Object.class.getMethod("equals", new Class[] { Object.class }).toString());
211a0ee76b0850774edeb0c67204070b89d117573bcJesse Wilson        assertEquals("public static java.lang.String java.lang.String.valueOf(char[])",
212a0ee76b0850774edeb0c67204070b89d117573bcJesse Wilson                String.class.getMethod("valueOf", new Class[] { char[].class }).toString());
213a0ee76b0850774edeb0c67204070b89d117573bcJesse Wilson        assertEquals( "public java.lang.Process java.lang.Runtime.exec(java.lang.String[])"
214a0ee76b0850774edeb0c67204070b89d117573bcJesse Wilson                + " throws java.io.IOException",
215a0ee76b0850774edeb0c67204070b89d117573bcJesse Wilson                Runtime.class.getMethod("exec", new Class[] { String[].class }).toString());
216a0ee76b0850774edeb0c67204070b89d117573bcJesse Wilson    }
217a0ee76b0850774edeb0c67204070b89d117573bcJesse Wilson
21811229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson    public static class MethodTestHelper {
21936efe4ab6422c34c98e196eee7022fecf52c7534Elliott Hughes        public void m1() throws IndexOutOfBoundsException { }
22036efe4ab6422c34c98e196eee7022fecf52c7534Elliott Hughes        public void m2(Object o) { }
22136efe4ab6422c34c98e196eee7022fecf52c7534Elliott Hughes    }
22211229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson
22311229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson    public static class Super {
22411229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson        private void a() {}
22511229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson        public static void b() {}
22611229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson    }
22711229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson    public static interface InterfaceA {
22811229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson        void a();
22911229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson    }
23011229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson    public static abstract class Sub extends Super implements InterfaceA {
23111229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson    }
23211229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson
23311229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson    public static interface InterfaceB extends InterfaceA {}
23411229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson    public static interface InterfaceC extends InterfaceB {}
23511229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson    public static abstract class ImplementsC implements InterfaceC {}
23611229f6af89fc54e70675fcab098b1572d6e539eJesse Wilson    public static abstract class ExtendsImplementsC extends ImplementsC {}
23736efe4ab6422c34c98e196eee7022fecf52c7534Elliott Hughes}
238