+2016-07-13 Matthew Fortune <matthew.fortune@imgtec.com>
+
+ * java/lang/reflect/natVMProxy.cc (unbox): Use ffi_arg for
+ integer return types smaller than a word.
+ * testsuite/libjava.jar/ReturnInvocationHandler.java: New file.
+ * testsuite/libjava.jar/ReturnProxyTest.jar: Likewise.
+ * testsuite/libjava.jar/ReturnProxyTest.java: Likewise.
+ * testsuite/libjava.jar/ReturnProxyTest.out: Likewise.
+ * testsuite/libjava.jar/ReturnProxyTest.xfail: Likewise.
+ * testsuite/libjava.jar/ReturnTypes.java: Likewise.
+ * testsuite/libjava.jar/ReturnTypesImpl.java: Likewise.
+
2016-07-13 Matthew Fortune <matthew.fortune@imgtec.com>
* interpret-run.cc: Use ffi_arg for FFI integer return types.
if (klass == JvPrimClass (byte))
{
_Jv_CheckCast (&Byte::class$, o);
- *(jbyte*)rvalue = ((Byte*)o)->byteValue();
+ *(ffi_arg*)rvalue = ((Byte*)o)->byteValue();
}
else if (klass == JvPrimClass (short))
{
_Jv_CheckCast (&Short::class$, o);
- *(jshort*)rvalue = ((Short*)o)->shortValue();
+ *(ffi_arg*)rvalue = ((Short*)o)->shortValue();
}
else if (klass == JvPrimClass (int))
{
_Jv_CheckCast (&Integer::class$, o);
- *(jint*)rvalue = ((Integer*)o)->intValue();
+ *(ffi_arg*)rvalue = ((Integer*)o)->intValue();
}
else if (klass == JvPrimClass (long))
{
else if (klass == JvPrimClass (boolean))
{
_Jv_CheckCast (&Boolean::class$, o);
- *(jboolean*)rvalue = ((Boolean*)o)->booleanValue();
+ *(ffi_arg*)rvalue = ((Boolean*)o)->booleanValue();
}
else if (klass == JvPrimClass (char))
{
_Jv_CheckCast (&Character::class$, o);
- *(jchar*)rvalue = ((Character*)o)->charValue();
+ *(ffi_arg*)rvalue = ((Character*)o)->charValue();
}
else
JvFail ("Bad ffi type in proxy");
--- /dev/null
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+
+public class ReturnInvocationHandler implements InvocationHandler
+{
+ private Object obj;
+ public ReturnInvocationHandler(Object obj)
+ {
+ this.obj = obj;
+ }
+ public Object invoke(Object proxy, Method m, Object[] args) throws Throwable
+ {
+ Object result;
+ try
+ {
+ result = m.invoke(obj, args);
+ }
+ catch (Exception e)
+ {
+ throw e;
+ }
+ return result;
+ }
+}
--- /dev/null
+import java.lang.reflect.Proxy;
+
+public class ReturnProxyTest
+{
+ public static void main(String[] args)
+ {
+ ReturnTypes orig = new ReturnTypesImpl();
+ Object o = Proxy.newProxyInstance(orig.getClass().getClassLoader(),
+ new Class<?>[] { ReturnTypes.class },
+ new ReturnInvocationHandler(orig));
+ ReturnTypes rt = (ReturnTypes)o;
+
+ System.out.println(orig.getBoolean());
+ System.out.println(orig.getChar());
+ System.out.println(orig.getByte());
+ System.out.println(orig.getShort());
+ System.out.println(orig.getInt());
+ System.out.println(orig.getLong());
+
+ System.out.println(rt.getBoolean());
+ System.out.println(rt.getChar());
+ System.out.println(rt.getByte());
+ System.out.println(rt.getShort());
+ System.out.println(rt.getInt());
+ System.out.println(rt.getLong());
+ }
+}
--- /dev/null
+false
+a
+-1
+-1
+-1
+-1
+false
+a
+-1
+-1
+-1
+-1
--- /dev/null
+main=ReturnProxyTest
--- /dev/null
+public interface ReturnTypes
+{
+ public short getShort();
+ public char getChar();
+ public byte getByte();
+ public int getInt();
+ public long getLong();
+ public boolean getBoolean();
+}
--- /dev/null
+public class ReturnTypesImpl implements ReturnTypes
+{
+ public short getShort()
+ {
+ return -1;
+ }
+ public char getChar()
+ {
+ return 'a';
+ }
+ public byte getByte()
+ {
+ return -1;
+ }
+ public int getInt()
+ {
+ return -1;
+ }
+ public long getLong()
+ {
+ return -1;
+ }
+ public boolean getBoolean()
+ {
+ return false;
+ }
+}