changeset 656:5b1354e63ad9

Object methods are not dispatched correctly by the ProxyHelper class (part two). Added proper dispatching for overloaded versions of Object.wait and enhanced regression test support.
author mcimadamore
date Wed, 25 Aug 2010 11:09:26 +0100
parents d66149a0e03c
children 0ea4e43f5fc4
files src/share/classes/com/sun/runtime/ProxyHelper.java test/tools/javac/lambda/MethodReference12.java
diffstat 2 files changed, 26 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/runtime/ProxyHelper.java	Wed Aug 25 10:34:46 2010 +0100
+++ b/src/share/classes/com/sun/runtime/ProxyHelper.java	Wed Aug 25 11:09:26 2010 +0100
@@ -72,9 +72,12 @@
                     case "notify": notify(); return null;
                     case "notifyAll": notifyAll(); return null;
                     case "toString": return toString();
-                    case "wait0": wait(); return null;
-                    case "wait1": wait((Long)args[0]); return null;
-                    case "wait2": wait((Long)args[0], (Integer)args[1]); return null;
+                    case "wait": switch (method.getParameterTypes().length) {
+                        case 0: wait(); return null;
+                        case 1: wait((Long)args[0]); return null;
+                        case 2: wait((Long)args[0], (Integer)args[1]); return null;
+                        default: throw new AssertionError("Bad call to 'wait' " + method);
+                    }
                     default: throw new AssertionError("Bad Object method " + method);
                 }
             }
--- a/test/tools/javac/lambda/MethodReference12.java	Wed Aug 25 10:34:46 2010 +0100
+++ b/test/tools/javac/lambda/MethodReference12.java	Wed Aug 25 11:09:26 2010 +0100
@@ -50,5 +50,25 @@
     static void test(SAM s) throws Throwable {
         s.equals(null);
         s.toString();
+        try {
+            s.notify(); //will throw IllegalMonitorStateException
+        }
+        catch (final IllegalMonitorStateException e) {  }
+        try {
+            s.notifyAll(); //will throw IllegalMonitorStateException
+        }
+        catch (final IllegalMonitorStateException e) {  }
+        try {
+            s.wait(1); //will throw IllegalMonitorStateException
+        }
+        catch (final IllegalMonitorStateException | InterruptedException e) {  }
+        try {
+            s.wait(1,1); //will throw IllegalMonitorStateException
+        }
+        catch (final IllegalMonitorStateException | InterruptedException e) {  }
+        try {
+            s.wait(); //will throw IllegalMonitorStateException
+        }
+        catch (final IllegalMonitorStateException | InterruptedException e) {  }
     }
 }