From 96849cec52b598b22e0a9e62d5ec37f39f9b9af5 Mon Sep 17 00:00:00 2001 From: Andreas Gampe Date: Mon, 2 Jun 2014 11:23:43 -0700 Subject: [PATCH] ART: Add another proxy test Change-Id: Ie5beda276a40067b7246001720cc5eea2fa7585a --- test/044-proxy/expected.txt | 1 + test/044-proxy/src/FloatSelect.java | 43 +++++++++++++++++++++++++++++++++++++ test/044-proxy/src/Main.java | 1 + 3 files changed, 45 insertions(+) create mode 100644 test/044-proxy/src/FloatSelect.java diff --git a/test/044-proxy/expected.txt b/test/044-proxy/expected.txt index 105d9296f..bcce01945 100644 --- a/test/044-proxy/expected.txt +++ b/test/044-proxy/expected.txt @@ -92,3 +92,4 @@ Invoking foo using I1 type: 1 Invocation of public abstract java.lang.String NarrowingTest$I2.foo() Got expected exception Proxy narrowed invocation return type passed +5.8 diff --git a/test/044-proxy/src/FloatSelect.java b/test/044-proxy/src/FloatSelect.java new file mode 100644 index 000000000..febe69781 --- /dev/null +++ b/test/044-proxy/src/FloatSelect.java @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2014 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. + */ + +import java.lang.reflect.*; + +/** + * Test java.lang.reflect.Proxy + */ +public class FloatSelect { + + public interface FloatSelectI { + public float method(float a, float b); + } + + static class FloatSelectIInvoke1 implements InvocationHandler { + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + return args[1]; + } + } + + public static void main(String[] args) { + FloatSelectI proxyObject = (FloatSelectI) Proxy.newProxyInstance( + FloatSelectI.class.getClassLoader(), + new Class[] { FloatSelectI.class }, + new FloatSelectIInvoke1()); + + float floatResult = proxyObject.method(2.1f, 5.8f); + System.out.println(floatResult); + } +} diff --git a/test/044-proxy/src/Main.java b/test/044-proxy/src/Main.java index 078569f12..958087143 100644 --- a/test/044-proxy/src/Main.java +++ b/test/044-proxy/src/Main.java @@ -27,5 +27,6 @@ public class Main { Clash4.main(null); WrappedThrow.main(null); NarrowingTest.main(null); + FloatSelect.main(null); } } -- 2.11.0