01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package org.apache.harmony.drlvm.tests.regression.h3908;
19:
20: import junit.framework.TestCase;
21:
22: import java.lang.reflect.Method;
23:
24: public class InvokeTest extends TestCase {
25:
26: byte b = 0;
27:
28: public static void main(String args[]) {
29: (new InvokeTest()).test();
30: }
31:
32: public void test() {
33: boolean status = false;
34:
35: try {
36: Method method = InvokeTest.class.getDeclaredMethod(
37: "method", new Class[] { Byte.TYPE });
38: method.invoke(new InvokeTest(), new Object[] { new N() });
39: System.out.println("TEST FAILED: no exception");
40: } catch (IllegalArgumentException e) {
41: status = true;
42: System.out.println("TEST PASSED: " + e);
43: } catch (Exception e) {
44: System.out.println("TEST FAILED: unexpected " + e);
45: }
46:
47: assertTrue(status);
48: }
49:
50: public void method(byte b) {
51: this .b = b;
52: }
53: }
54:
55: class N extends Number {
56:
57: public double doubleValue() {
58: return 0;
59: }
60:
61: public float floatValue() {
62: return 0;
63: }
64:
65: public int intValue() {
66: return 0;
67: }
68:
69: public long longValue() {
70: return 0;
71: }
72: }
|