diff options
| author | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-07-16 00:30:23 +0000 |
|---|---|---|
| committer | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-07-16 00:30:23 +0000 |
| commit | c8875fb97fc03779a5bba09872227b1d08e5d52a (patch) | |
| tree | a0b991cf5866ae1d616639b906ac001811d74508 /libjava/classpath/test/native/lib/PrimlibTest.java | |
| parent | c40c1730800ed292b6db39a83d592476fa59623c (diff) | |
| download | ppe42-gcc-c8875fb97fc03779a5bba09872227b1d08e5d52a.tar.gz ppe42-gcc-c8875fb97fc03779a5bba09872227b1d08e5d52a.zip | |
Initial revision
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@102074 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/classpath/test/native/lib/PrimlibTest.java')
| -rw-r--r-- | libjava/classpath/test/native/lib/PrimlibTest.java | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/libjava/classpath/test/native/lib/PrimlibTest.java b/libjava/classpath/test/native/lib/PrimlibTest.java new file mode 100644 index 00000000000..94b2fb41c3e --- /dev/null +++ b/libjava/classpath/test/native/lib/PrimlibTest.java @@ -0,0 +1,88 @@ +public class PrimlibTest { + static { + System.loadLibrary("jnilinktest"); + } + + public static void main(String args[]) { + Object[] o = new Object[8]; + o[0] = new Boolean(true); + o[1] = new Byte((byte)1); + o[2] = new Short((short)2); + o[3] = new Character((char)3); + o[4] = new Integer(4); + o[5] = new Long(5L); + o[6] = new Float(6F); + o[7] = new Double(7D); + + String[] s = {"boolean", "byte", "short", "char", "int", "long", "float", "double"}; + for(int i=0;i<8;i++) { + try { + System.out.println(PrimlibInterface.unwrapBoolean(o[i]) ? "CONVERTED: UnwrapBoolean(" + s[i] + ")" : "INCORRECT: UnwrapBoolean(" + s[i] + ")"); + } catch(Exception E) { + System.out.println("EXCEPTION: UnwrapBoolean(" + s[i] + ")"); + } + + try { + System.out.println(PrimlibInterface.unwrapByte(o[i]) == i ? "CONVERTED: UnwrapByte(" + s[i] + ")" : "INCORRECT: UnwrapByte(" + s[i] + ")"); + } catch(Exception E) { + System.out.println("EXCEPTION: UnwrapByte(" + s[i] + ")"); + } + + try { + System.out.println(PrimlibInterface.unwrapShort(o[i]) == i ? "CONVERTED: UnwrapShort(" + s[i] + ")" : "INCORRECT: UnwrapShort(" + s[i] + ")"); + } catch(Exception E) { + System.out.println("EXCEPTION: UnwrapShort(" + s[i] + ")"); + } + + try { + System.out.println(PrimlibInterface.unwrapChar(o[i]) == i ? "CONVERTED: UnwrapChar(" + s[i] + ")" : "INCORRECT: UnwrapChar(" + s[i] + ")"); + } catch(Exception E) { + System.out.println("EXCEPTION: UnwrapChar(" + s[i] + ")"); + } + + try { + System.out.println(PrimlibInterface.unwrapInt(o[i]) == i ? "CONVERTED: UnwrapInt(" + s[i] + ")" : "INCORRECT: UnwrapInt(" + s[i] + ")"); + } catch(Exception E) { + System.out.println("EXCEPTION: UnwrapInt(" + s[i] + ")"); + } + + try { + System.out.println(PrimlibInterface.unwrapLong(o[i]) == i ? "CONVERTED: UnwrapLong(" + s[i] + ")" : "INCORRECT: UnwrapLong(" + s[i] + ")"); + } catch(Exception E) { + System.out.println("EXCEPTION: UnwrapLong(" + s[i] + ")"); + } + + try { + System.out.println(PrimlibInterface.unwrapFloat(o[i]) == i ? "CONVERTED: UnwrapFloat(" + s[i] + ")" : "INCORRECT: UnwrapFloat(" + s[i] + ")"); + } catch(Exception E) { + System.out.println("EXCEPTION: UnwrapFloat(" + s[i] + ")"); + } + + try { + System.out.println(PrimlibInterface.unwrapDouble(o[i]) == i ? "CONVERTED: UnwrapDouble(" + s[i] + ")" : "INCORRECT: UnwrapDouble(" + s[i] + ")"); + } catch(Exception E) { + System.out.println("EXCEPTION: UnwrapDouble(" + s[i] + ")"); + } + } + } +} + +class PrimlibInterface { + static native boolean unwrapBoolean(Object o); + static native byte unwrapByte(Object o); + static native short unwrapShort(Object o); + static native char unwrapChar(Object o); + static native int unwrapInt(Object o); + static native long unwrapLong(Object o); + static native float unwrapFloat(Object o); + static native double unwrapDouble(Object o); + + static native Boolean wrapBoolean(boolean val); + static native Byte wrapByte(byte val); + static native Short wrapShort(short val); + static native Character wrapChar(char val); + static native Integer wrapInt(int val); + static native Long wrapLong(long val); + static native Float wrapFloat(float val); + static native Double wrapDouble(double val); +} |

