changeset 39:ea314633878b

meth: convert this test for 6979327
author jrose
date Fri, 24 Sep 2010 11:41:53 -0700
parents fa252dd74a58
children 6552594edb94
files netbeans/meth/test/sun/dyn/util/ValueConversionsTest.java
diffstat 1 files changed, 49 insertions(+), 48 deletions(-) [+]
line wrap: on
line diff
--- a/netbeans/meth/test/sun/dyn/util/ValueConversionsTest.java	Sat May 08 14:35:22 2010 -0700
+++ b/netbeans/meth/test/sun/dyn/util/ValueConversionsTest.java	Fri Sep 24 11:41:53 2010 -0700
@@ -50,22 +50,23 @@
                 switch (w) {
                     case VOID:   assertEquals(box, null); break;
                     case OBJECT: assertEquals(box.getClass(), Integer.class); break;
+                    case SHORT:  assertEquals(box.getClass(), Short.class); break;
                     default:     assertEquals(box.getClass(), w.wrapperType()); break;
                 }
                 MethodHandle unboxer = ValueConversions.unbox(w.primitiveType(), exact);
                 Object expResult = box;
                 Object result = null;
                 switch (w) {
-                    case INT:     result = unboxer.<int   >invoke(box); break;
-                    case LONG:    result = unboxer.<long  >invoke(box); break;
-                    case FLOAT:   result = unboxer.<float >invoke(box); break;
-                    case DOUBLE:  result = unboxer.<double>invoke(box); break;
-                    case CHAR:    result = unboxer.<char  >invoke(box); break;
-                    case BYTE:    result = unboxer.<byte  >invoke(box); break;
-                    case SHORT:   result = unboxer.<short >invoke((Short)box); break;
-                    case OBJECT:  result = unboxer.<Object>invoke(box); break;
-                    case BOOLEAN: result = unboxer.<boolean>invoke(box); break;
-                    case VOID:    result = null; unboxer.<void>invoke(box); break;
+                    case INT:     result = (int)     unboxer.<int     >invokeExact(box); break;
+                    case LONG:    result = (long)    unboxer.<long    >invokeExact(box); break;
+                    case FLOAT:   result = (float)   unboxer.<float   >invokeExact(box); break;
+                    case DOUBLE:  result = (double)  unboxer.<double  >invokeExact(box); break;
+                    case CHAR:    result = (char)    unboxer.<char    >invokeExact(box); break;
+                    case BYTE:    result = (byte)    unboxer.<byte    >invokeExact(box); break;
+                    case SHORT:   result = (short)   unboxer.<short   >invokeExact((Short)box); break;
+                    case OBJECT:  result = (Object)  unboxer.<Object  >invokeExact(box); break;
+                    case BOOLEAN: result = (boolean) unboxer.<boolean >invokeExact(box); break;
+                    case VOID:    result = null;     unboxer.<void    >invokeExact(box); break;
                 }
                 assertEquals("w="+w+" n="+n+" box="+box, expResult, result);
             }
@@ -87,15 +88,15 @@
                 MethodHandle unboxer = ValueConversions.unboxRaw(w.primitiveType(), exact);
                 long result = -1;
                 switch (w) {
-                    case INT:     result = unboxer.<int   >invoke(box); break;
-                    case LONG:    result = unboxer.<long  >invoke(box); break;
-                    case FLOAT:   result = unboxer.<int   >invoke(box); break;
-                    case DOUBLE:  result = unboxer.<long  >invoke(box); break;
-                    case CHAR:    result = unboxer.<int   >invoke(box); break;
-                    case BYTE:    result = unboxer.<int   >invoke(box); break;
-                    case SHORT:   result = unboxer.<int   >invoke((Short)box); break;
-                    case BOOLEAN: result = unboxer.<int   >invoke(box); break;
-                    case VOID:    result = unboxer.<int   >invoke(box); break;
+                    case INT:     result = (int)  unboxer.<int  >invokeExact(box); break;
+                    case LONG:    result = (long) unboxer.<long >invokeExact(box); break;
+                    case FLOAT:   result = (int)  unboxer.<int  >invokeExact(box); break;
+                    case DOUBLE:  result = (long) unboxer.<long >invokeExact(box); break;
+                    case CHAR:    result = (int)  unboxer.<int  >invokeExact(box); break;
+                    case BYTE:    result = (int)  unboxer.<int  >invokeExact(box); break;
+                    case SHORT:   result = (int)  unboxer.<int  >invokeExact((Short)box); break;
+                    case BOOLEAN: result = (int)  unboxer.<int  >invokeExact(box); break;
+                    case VOID:    result = (int)  unboxer.<int  >invokeExact(box); break;
                 }
                 assertEquals("w="+w+" n="+n+" box="+box, expResult, result);
             }
@@ -115,15 +116,15 @@
                 Object expResult = box;
                 Object result = null;
                 switch (w) {
-                    case INT:     result = boxer.<Integer>invoke((int)n); break;
-                    case LONG:    result = boxer.<Long   >invoke((long)n); break;
-                    case FLOAT:   result = boxer.<Float  >invoke((float)n); break;
-                    case DOUBLE:  result = boxer.<Double >invoke((double)n); break;
-                    case CHAR:    result = boxer.<Character>invoke((char)n); break;
-                    case BYTE:    result = boxer.<Byte   >invoke((byte)n); break;
-                    case SHORT:   result = boxer.<Object>invoke((short)n); break;
-                    case OBJECT:  result = boxer.<Object>invoke((Object)n); break;
-                    case BOOLEAN: result = boxer.<Boolean>invoke(n != 0); break;
+                    case INT:     result = (Integer)   boxer.<Integer   >invokeExact((int)n); break;
+                    case LONG:    result = (Long)      boxer.<Long      >invokeExact((long)n); break;
+                    case FLOAT:   result = (Float)     boxer.<Float     >invokeExact((float)n); break;
+                    case DOUBLE:  result = (Double)    boxer.<Double    >invokeExact((double)n); break;
+                    case CHAR:    result = (Character) boxer.<Character >invokeExact((char)n); break;
+                    case BYTE:    result = (Byte)      boxer.<Byte      >invokeExact((byte)n); break;
+                    case SHORT:   result = (Object)    boxer.<Object    >invokeExact((short)n); break;
+                    case OBJECT:  result = (Object)    boxer.<Object    >invokeExact((Object)n); break;
+                    case BOOLEAN: result = (Boolean)   boxer.<Boolean   >invokeExact(n != 0); break;
                 }
                 assertEquals("w="+w+" n="+n+" box="+box, expResult, result);
             }
@@ -145,14 +146,14 @@
                 MethodHandle boxer = ValueConversions.boxRaw(w.primitiveType(), exact);
                 Object result = null;
                 switch (w) {
-                    case INT:     result = boxer.<Integer>invoke((int)raw); break;
-                    case LONG:    result = boxer.<Long   >invoke(raw); break;
-                    case FLOAT:   result = boxer.<Float  >invoke((int)raw); break;
-                    case DOUBLE:  result = boxer.<Double >invoke(raw); break;
-                    case CHAR:    result = boxer.<Character>invoke((int)raw); break;
-                    case BYTE:    result = boxer.<Byte   >invoke((int)raw); break;
-                    case SHORT:   result = boxer.<Object >invoke((int)raw); break;
-                    case BOOLEAN: result = boxer.<Boolean>invoke((int)raw); break;
+                case INT:     result = (Integer)   boxer.<Integer   >invokeExact((int)raw); break;
+                case LONG:    result = (Long)      boxer.<Long      >invokeExact(raw); break;
+                case FLOAT:   result = (Float)     boxer.<Float     >invokeExact((int)raw); break;
+                case DOUBLE:  result = (Double)    boxer.<Double    >invokeExact(raw); break;
+                case CHAR:    result = (Character) boxer.<Character >invokeExact((int)raw); break;
+                case BYTE:    result = (Byte)      boxer.<Byte      >invokeExact((int)raw); break;
+                case SHORT:   result = (Object)    boxer.<Object    >invokeExact((int)raw); break;
+                case BOOLEAN: result = (Boolean)   boxer.<Boolean   >invokeExact((int)raw); break;
                 }
                 assertEquals("w="+w+" n="+n+" box="+box, expResult, result);
             }
@@ -175,14 +176,14 @@
                 MethodHandle boxer = ValueConversions.rebox(w.primitiveType(), exact);
                 Object result = null;
                 switch (w) {
-                    case INT:     result = boxer.<Integer>invoke(raw); break;
-                    case LONG:    result = boxer.<Long   >invoke(raw); break;
-                    case FLOAT:   result = boxer.<Float  >invoke(raw); break;
-                    case DOUBLE:  result = boxer.<Double >invoke(raw); break;
-                    case CHAR:    result = boxer.<Character>invoke(raw); break;
-                    case BYTE:    result = boxer.<Byte   >invoke(raw); break;
-                    case SHORT:   result = boxer.<Object >invoke(raw); break;
-                    case BOOLEAN: result = boxer.<Boolean>invoke(raw); break;
+                case INT:     result = (Integer)   boxer.<Integer   >invokeExact(raw); break;
+                case LONG:    result = (Long)      boxer.<Long      >invokeExact(raw); break;
+                case FLOAT:   result = (Float)     boxer.<Float     >invokeExact(raw); break;
+                case DOUBLE:  result = (Double)    boxer.<Double    >invokeExact(raw); break;
+                case CHAR:    result = (Character) boxer.<Character >invokeExact(raw); break;
+                case BYTE:    result = (Byte)      boxer.<Byte      >invokeExact(raw); break;
+                case SHORT:   result = (Object)    boxer.<Object    >invokeExact(raw); break;
+                case BOOLEAN: result = (Boolean)   boxer.<Boolean   >invokeExact(raw); break;
                 }
                 assertEquals("w="+w+" n="+n+" box="+box, expResult, result);
             }
@@ -210,9 +211,9 @@
                 try {
                     Object result;
                     if (!exactInt)
-                        result = caster.<Object>invoke(obj);
+                        result = caster.invokeExact(obj);
                     else
-                        result = caster.<Integer>invoke(obj);
+                        result = (Integer) caster.<Integer>invokeExact(obj);
                     if (canCast)
                         assertEquals(obj, result);
                     else
@@ -230,8 +231,8 @@
         System.out.println("identity");
         MethodHandle id = ValueConversions.identity();
         Object expResult = "foo";
-        Object result = id.<Object>invoke(expResult);
-        // compiler bug:  ValueConversions.identity().<Object>invoke("bar");
+        Object result = id.invokeExact(expResult);
+        // compiler bug:  ValueConversions.identity().invokeExact("bar");
         assertEquals(expResult, result);
     }