changeset 10037:cb15bc14c26a

8037866: Replace the Fun class in tests with lambdas Reviewed-by: martin
author igerasim
date Mon, 02 Jun 2014 19:49:57 +0400
parents e0cd39b72ac5
children 259d5726632f
files test/java/lang/ProcessBuilder/Basic.java test/java/nio/charset/StandardCharsets/Standard.java test/java/util/Collection/BiggernYours.java test/java/util/Collection/IteratorAtEnd.java test/java/util/Collection/MOAT.java test/java/util/Collections/AsLifoQueue.java test/java/util/NavigableMap/LockStep.java test/java/util/PriorityQueue/ForgetMeNot.java test/java/util/concurrent/BlockingQueue/Interrupt.java test/java/util/concurrent/CyclicBarrier/Basic.java test/java/util/concurrent/Executors/Throws.java test/java/util/concurrent/FutureTask/Customized.java test/java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java test/java/util/concurrent/ThreadPoolExecutor/ShutdownNowExecuteRace.java test/sun/nio/cs/FindOneCharEncoderBugs.java
diffstat 15 files changed, 244 insertions(+), 342 deletions(-) [+]
line wrap: on
line diff
--- a/test/java/lang/ProcessBuilder/Basic.java	Mon Jun 02 09:19:59 2014 +0100
+++ b/test/java/lang/ProcessBuilder/Basic.java	Mon Jun 02 19:49:57 2014 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -937,18 +937,13 @@
         equal(pb.redirectError(), Redirect.to(efile));
 
         THROWS(IllegalArgumentException.class,
-            new Fun(){void f() {
-                pb.redirectInput(Redirect.to(ofile)); }},
-            new Fun(){void f() {
-                pb.redirectInput(Redirect.appendTo(ofile)); }},
-            new Fun(){void f() {
-                pb.redirectOutput(Redirect.from(ifile)); }},
-            new Fun(){void f() {
-                pb.redirectError(Redirect.from(ifile)); }});
+               () -> pb.redirectInput(Redirect.to(ofile)),
+               () -> pb.redirectOutput(Redirect.from(ifile)),
+               () -> pb.redirectError(Redirect.from(ifile)));
 
         THROWS(IOException.class,
                // Input file does not exist
-               new Fun(){void f() throws Throwable { pb.start(); }});
+               () -> pb.start());
         setFileContents(ifile, "standard input");
 
         //----------------------------------------------------------------
@@ -1084,18 +1079,15 @@
                 = new FilePermission("<<ALL FILES>>", "read,write,execute");
 
             THROWS(SecurityException.class,
-               new Fun() { void f() throws IOException {
-                   policy.setPermissions(xPermission);
-                   redirectIO(pb, from(tmpFile), PIPE, PIPE);
-                   pb.start();}},
-               new Fun() { void f() throws IOException {
-                   policy.setPermissions(rxPermission);
-                   redirectIO(pb, PIPE, to(ofile), PIPE);
-                   pb.start();}},
-               new Fun() { void f() throws IOException {
-                   policy.setPermissions(rxPermission);
-                   redirectIO(pb, PIPE, PIPE, to(efile));
-                   pb.start();}});
+                   () -> { policy.setPermissions(xPermission);
+                           redirectIO(pb, from(tmpFile), PIPE, PIPE);
+                           pb.start();},
+                   () -> { policy.setPermissions(rxPermission);
+                           redirectIO(pb, PIPE, to(ofile), PIPE);
+                           pb.start();},
+                   () -> { policy.setPermissions(rxPermission);
+                           redirectIO(pb, PIPE, PIPE, to(efile));
+                           pb.start();});
 
             {
                 policy.setPermissions(rxPermission);
@@ -1258,10 +1250,10 @@
         // System.getenv() is read-only.
         //----------------------------------------------------------------
         THROWS(UnsupportedOperationException.class,
-            new Fun(){void f(){ getenv().put("FOO","BAR");}},
-            new Fun(){void f(){ getenv().remove("PATH");}},
-            new Fun(){void f(){ getenv().keySet().remove("PATH");}},
-            new Fun(){void f(){ getenv().values().remove("someValue");}});
+               () -> getenv().put("FOO","BAR"),
+               () -> getenv().remove("PATH"),
+               () -> getenv().keySet().remove("PATH"),
+               () -> getenv().values().remove("someValue"));
 
         try {
             Collection<Map.Entry<String,String>> c = getenv().entrySet();
@@ -1286,19 +1278,17 @@
         {
             final Map<String,String> m = new ProcessBuilder().environment();
             THROWS(IllegalArgumentException.class,
-                new Fun(){void f(){ m.put("FOO=","BAR");}},
-                new Fun(){void f(){ m.put("FOO\u0000","BAR");}},
-                new Fun(){void f(){ m.put("FOO","BAR\u0000");}});
+                   () -> m.put("FOO=","BAR"),
+                   () -> m.put("FOO\u0000","BAR"),
+                   () -> m.put("FOO","BAR\u0000"));
         }
 
         //----------------------------------------------------------------
         // Commands must never be null.
         //----------------------------------------------------------------
         THROWS(NullPointerException.class,
-               new Fun(){void f(){
-                   new ProcessBuilder((List<String>)null);}},
-               new Fun(){void f(){
-                   new ProcessBuilder().command((List<String>)null);}});
+               () -> new ProcessBuilder((List<String>)null),
+               () -> new ProcessBuilder().command((List<String>)null));
 
         //----------------------------------------------------------------
         // Put in a command; get the same one back out.
@@ -1323,25 +1313,18 @@
         // Commands must contain at least one element.
         //----------------------------------------------------------------
         THROWS(IndexOutOfBoundsException.class,
-            new Fun() { void f() throws IOException {
-                new ProcessBuilder().start();}},
-            new Fun() { void f() throws IOException {
-                new ProcessBuilder(new ArrayList<String>()).start();}},
-            new Fun() { void f() throws IOException {
-                Runtime.getRuntime().exec(new String[]{});}});
+               () -> new ProcessBuilder().start(),
+               () -> new ProcessBuilder(new ArrayList<String>()).start(),
+               () -> Runtime.getRuntime().exec(new String[]{}));
 
         //----------------------------------------------------------------
         // Commands must not contain null elements at start() time.
         //----------------------------------------------------------------
         THROWS(NullPointerException.class,
-            new Fun() { void f() throws IOException {
-                new ProcessBuilder("foo",null,"bar").start();}},
-            new Fun() { void f() throws IOException {
-                new ProcessBuilder((String)null).start();}},
-            new Fun() { void f() throws IOException {
-                new ProcessBuilder(new String[]{null}).start();}},
-            new Fun() { void f() throws IOException {
-                new ProcessBuilder(new String[]{"foo",null,"bar"}).start();}});
+               () -> new ProcessBuilder("foo",null,"bar").start(),
+               () -> new ProcessBuilder((String)null).start(),
+               () -> new ProcessBuilder(new String[]{null}).start(),
+               () -> new ProcessBuilder(new String[]{"foo",null,"bar"}).start());
 
         //----------------------------------------------------------------
         // Command lists are growable.
@@ -1358,15 +1341,13 @@
         try {
             final Map<String,String> env = new ProcessBuilder().environment();
             THROWS(NullPointerException.class,
-                new Fun(){void f(){ env.put("foo",null);}},
-                new Fun(){void f(){ env.put(null,"foo");}},
-                new Fun(){void f(){ env.remove(null);}},
-                new Fun(){void f(){
-                    for (Map.Entry<String,String> e : env.entrySet())
-                        e.setValue(null);}},
-                new Fun() { void f() throws IOException {
-                    Runtime.getRuntime().exec(new String[]{"foo"},
-                                              new String[]{null});}});
+                   () -> env.put("foo",null),
+                   () -> env.put(null,"foo"),
+                   () -> env.remove(null),
+                   () -> { for (Map.Entry<String,String> e : env.entrySet())
+                               e.setValue(null);},
+                   () -> Runtime.getRuntime().exec(new String[]{"foo"},
+                                                   new String[]{null}));
         } catch (Throwable t) { unexpected(t); }
 
         //----------------------------------------------------------------
@@ -1375,10 +1356,10 @@
         try {
             final Map<String,String> env = new ProcessBuilder().environment();
             THROWS(ClassCastException.class,
-                new Fun(){void f(){ env.remove(TRUE);}},
-                new Fun(){void f(){ env.keySet().remove(TRUE);}},
-                new Fun(){void f(){ env.values().remove(TRUE);}},
-                new Fun(){void f(){ env.entrySet().remove(TRUE);}});
+                   () -> env.remove(TRUE),
+                   () -> env.keySet().remove(TRUE),
+                   () -> env.values().remove(TRUE),
+                   () -> env.entrySet().remove(TRUE));
         } catch (Throwable t) { unexpected(t); }
 
         //----------------------------------------------------------------
@@ -1394,22 +1375,22 @@
                 // Nulls in environment queries are forbidden.
                 //----------------------------------------------------------------
                 THROWS(NullPointerException.class,
-                    new Fun(){void f(){ getenv(null);}},
-                    new Fun(){void f(){ env.get(null);}},
-                    new Fun(){void f(){ env.containsKey(null);}},
-                    new Fun(){void f(){ env.containsValue(null);}},
-                    new Fun(){void f(){ env.keySet().contains(null);}},
-                    new Fun(){void f(){ env.values().contains(null);}});
+                       () -> getenv(null),
+                       () -> env.get(null),
+                       () -> env.containsKey(null),
+                       () -> env.containsValue(null),
+                       () -> env.keySet().contains(null),
+                       () -> env.values().contains(null));
 
                 //----------------------------------------------------------------
                 // Non-String types in environment queries are forbidden.
                 //----------------------------------------------------------------
                 THROWS(ClassCastException.class,
-                    new Fun(){void f(){ env.get(TRUE);}},
-                    new Fun(){void f(){ env.containsKey(TRUE);}},
-                    new Fun(){void f(){ env.containsValue(TRUE);}},
-                    new Fun(){void f(){ env.keySet().contains(TRUE);}},
-                    new Fun(){void f(){ env.values().contains(TRUE);}});
+                       () -> env.get(TRUE),
+                       () -> env.containsKey(TRUE),
+                       () -> env.containsValue(TRUE),
+                       () -> env.keySet().contains(TRUE),
+                       () -> env.values().contains(TRUE));
 
                 //----------------------------------------------------------------
                 // Illegal String values in environment queries are (grumble) OK
@@ -1427,12 +1408,11 @@
             final Set<Map.Entry<String,String>> entrySet =
                 new ProcessBuilder().environment().entrySet();
             THROWS(NullPointerException.class,
-                   new Fun(){void f(){ entrySet.contains(null);}});
+                   () -> entrySet.contains(null));
             THROWS(ClassCastException.class,
-                new Fun(){void f(){ entrySet.contains(TRUE);}},
-                new Fun(){void f(){
-                    entrySet.contains(
-                        new SimpleImmutableEntry<Boolean,String>(TRUE,""));}});
+                   () -> entrySet.contains(TRUE),
+                   () -> entrySet.contains(
+                             new SimpleImmutableEntry<Boolean,String>(TRUE,"")));
 
             check(! entrySet.contains
                   (new SimpleImmutableEntry<String,String>("", "")));
@@ -1902,8 +1882,7 @@
                 final ProcessBuilder pb =
                     new ProcessBuilder(new String[]{"unliKely"});
                 pb.environment().put("PATH", "suBdiR");
-                THROWS(IOException.class,
-                       new Fun() {void f() throws Throwable {pb.start();}});
+                THROWS(IOException.class, () -> pb.start());
             } catch (Throwable t) { unexpected(t);
             } finally {
                 new File("suBdiR/unliKely").delete();
@@ -1976,10 +1955,8 @@
             equal(SIZE, p.getInputStream().available());
             equal(SIZE, p.getErrorStream().available());
             THROWS(IOException.class,
-                   new Fun(){void f() throws IOException {
-                       p.getOutputStream().write((byte) '!');
-                       p.getOutputStream().flush();
-                       }});
+                   () -> { p.getOutputStream().write((byte) '!');
+                           p.getOutputStream().flush();});
 
             final byte[] bytes = new byte[SIZE + 1];
             equal(SIZE, p.getInputStream().read(bytes));
@@ -2006,12 +1983,9 @@
             InputStream[] streams = { p.getInputStream(), p.getErrorStream() };
             for (final InputStream in : streams) {
                 Fun[] ops = {
-                    new Fun(){void f() throws IOException {
-                        in.read(); }},
-                    new Fun(){void f() throws IOException {
-                        in.read(bytes); }},
-                    new Fun(){void f() throws IOException {
-                        in.available(); }}
+                    () -> in.read(),
+                    () -> in.read(bytes),
+                    () -> in.available()
                 };
                 for (Fun op : ops) {
                     try {
@@ -2215,21 +2189,17 @@
         } catch (Throwable t) { unexpected(t); }
 
         THROWS(SecurityException.class,
-            new Fun() { void f() throws IOException {
-                policy.setPermissions(/* Nothing */);
-                System.getenv("foo");}},
-            new Fun() { void f() throws IOException {
-                policy.setPermissions(/* Nothing */);
-                System.getenv();}},
-            new Fun() { void f() throws IOException {
-                policy.setPermissions(/* Nothing */);
-                new ProcessBuilder("echo").start();}},
-            new Fun() { void f() throws IOException {
-                policy.setPermissions(/* Nothing */);
-                Runtime.getRuntime().exec("echo");}},
-            new Fun() { void f() throws IOException {
-                policy.setPermissions(new RuntimePermission("getenv.bar"));
-                System.getenv("foo");}});
+               () -> { policy.setPermissions(/* Nothing */);
+                       System.getenv("foo");},
+               () -> { policy.setPermissions(/* Nothing */);
+                       System.getenv();},
+               () -> { policy.setPermissions(/* Nothing */);
+                       new ProcessBuilder("echo").start();},
+               () -> { policy.setPermissions(/* Nothing */);
+                       Runtime.getRuntime().exec("echo");},
+               () -> { policy.setPermissions(
+                               new RuntimePermission("getenv.bar"));
+                       System.getenv("foo");});
 
         try {
             policy.setPermissions(new RuntimePermission("getenv.foo"));
@@ -2246,18 +2216,16 @@
             = new FilePermission("<<ALL FILES>>", "execute");
 
         THROWS(SecurityException.class,
-            new Fun() { void f() throws IOException {
-                // environment permission by itself insufficient
-                policy.setPermissions(new RuntimePermission("getenv.*"));
-                ProcessBuilder pb = new ProcessBuilder("env");
-                pb.environment().put("foo","bar");
-                pb.start();}},
-            new Fun() { void f() throws IOException {
-                 // exec permission by itself insufficient
-                 policy.setPermissions(execPermission);
-                 ProcessBuilder pb = new ProcessBuilder("env");
-                 pb.environment().put("foo","bar");
-                 pb.start();}});
+               () -> { // environment permission by itself insufficient
+                       policy.setPermissions(new RuntimePermission("getenv.*"));
+                       ProcessBuilder pb = new ProcessBuilder("env");
+                       pb.environment().put("foo","bar");
+                       pb.start();},
+               () -> { // exec permission by itself insufficient
+                       policy.setPermissions(execPermission);
+                       ProcessBuilder pb = new ProcessBuilder("env");
+                       pb.environment().put("foo","bar");
+                       pb.start();});
 
         try {
             // Both permissions? OK.
@@ -2585,7 +2553,7 @@
         try {realMain(args);} catch (Throwable t) {unexpected(t);}
         System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
         if (failed > 0) throw new AssertionError("Some tests failed");}
-    private static abstract class Fun {abstract void f() throws Throwable;}
+    interface Fun {void f() throws Throwable;}
     static void THROWS(Class<? extends Throwable> k, Fun... fs) {
         for (Fun f : fs)
             try { f.f(); fail("Expected " + k.getName() + " not thrown"); }
--- a/test/java/nio/charset/StandardCharsets/Standard.java	Mon Jun 02 09:19:59 2014 +0100
+++ b/test/java/nio/charset/StandardCharsets/Standard.java	Mon Jun 02 19:49:57 2014 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -99,13 +99,6 @@
         System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
         if (failed > 0) throw new Exception("Some tests failed");
     }
-    private static abstract class Fun {abstract void f() throws Throwable;}
-    private static void THROWS(Class<? extends Throwable> k, Fun... fs) {
-          for (Fun f : fs)
-              try { f.f(); fail("Expected " + k.getName() + " not thrown"); }
-              catch (Throwable t) {
-                  if (k.isAssignableFrom(t.getClass())) pass();
-                  else unexpected(t);}}
     static byte[] serializedForm(Object obj) {
         try {
             ByteArrayOutputStream baos = new ByteArrayOutputStream();
--- a/test/java/util/Collection/BiggernYours.java	Mon Jun 02 09:19:59 2014 +0100
+++ b/test/java/util/Collection/BiggernYours.java	Mon Jun 02 19:49:57 2014 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -236,13 +236,6 @@
         try {realMain(args);} catch (Throwable t) {unexpected(t);}
         System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
         if (failed > 0) throw new AssertionError("Some tests failed");}
-    private static abstract class Fun {abstract void f() throws Throwable;}
-    static void THROWS(Class<? extends Throwable> k, Fun... fs) {
-        for (Fun f : fs)
-            try { f.f(); fail("Expected " + k.getName() + " not thrown"); }
-            catch (Throwable t) {
-                if (k.isAssignableFrom(t.getClass())) pass();
-                else unexpected(t);}}
     private static abstract class CheckedThread extends Thread {
         abstract void realRun() throws Throwable;
         public void run() {
--- a/test/java/util/Collection/IteratorAtEnd.java	Mon Jun 02 09:19:59 2014 +0100
+++ b/test/java/util/Collection/IteratorAtEnd.java	Mon Jun 02 19:49:57 2014 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -84,9 +84,9 @@
         try {
             final Iterator it = c.iterator();
             THROWS(NoSuchElementException.class,
-                   new Fun() {void f() { while (true) it.next(); }});
+                   () -> { while (true) it.next(); });
             try { it.remove(); }
-            catch (UnsupportedOperationException _) { return; }
+            catch (UnsupportedOperationException exc) { return; }
             pass();
         } catch (Throwable t) { unexpected(t); }
 
@@ -96,10 +96,9 @@
                 final ListIterator it = list.listIterator(0);
                 it.next();
                 final Object x = it.previous();
-                THROWS(NoSuchElementException.class,
-                       new Fun() {void f() { it.previous(); }});
+                THROWS(NoSuchElementException.class, () -> it.previous());
                 try { it.remove(); }
-                catch (UnsupportedOperationException _) { return; }
+                catch (UnsupportedOperationException exc) { return; }
                 pass();
                 check(! list.get(0).equals(x));
             } catch (Throwable t) { unexpected(t); }
@@ -108,10 +107,9 @@
                 final ListIterator it = list.listIterator(list.size());
                 it.previous();
                 final Object x = it.next();
-                THROWS(NoSuchElementException.class,
-                       new Fun() {void f() { it.next(); }});
+                THROWS(NoSuchElementException.class, () -> it.next());
                 try { it.remove(); }
-                catch (UnsupportedOperationException _) { return; }
+                catch (UnsupportedOperationException exc) { return; }
                 pass();
                 check(! list.get(list.size()-1).equals(x));
             } catch (Throwable t) { unexpected(t); }
@@ -132,7 +130,7 @@
         try {realMain(args);} catch (Throwable t) {unexpected(t);}
         System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
         if (failed > 0) throw new AssertionError("Some tests failed");}
-    private static abstract class Fun {abstract void f() throws Throwable;}
+    interface Fun {void f() throws Throwable;}
     static void THROWS(Class<? extends Throwable> k, Fun... fs) {
         for (Fun f : fs)
             try { f.f(); fail("Expected " + k.getName() + " not thrown"); }
--- a/test/java/util/Collection/MOAT.java	Mon Jun 02 09:19:59 2014 +0100
+++ b/test/java/util/Collection/MOAT.java	Mon Jun 02 19:49:57 2014 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -117,10 +117,8 @@
         final List<Integer> emptyArray = Arrays.asList(new Integer[]{});
         testCollection(emptyArray);
         testEmptyList(emptyArray);
-        THROWS(IndexOutOfBoundsException.class,
-               new Fun(){void f(){ emptyArray.set(0,1); }});
-        THROWS(UnsupportedOperationException.class,
-               new Fun(){void f(){ emptyArray.add(0,1); }});
+        THROWS(IndexOutOfBoundsException.class, () -> emptyArray.set(0,1));
+        THROWS(UnsupportedOperationException.class, () -> emptyArray.add(0,1));
 
         List<Integer> noOne = nCopies(0,1);
         testCollection(noOne);
@@ -204,8 +202,7 @@
         if (rnd.nextBoolean())
             check(! it.hasNext());
 
-        THROWS(NoSuchElementException.class,
-               new Fun(){void f(){ it.next(); }});
+        THROWS(NoSuchElementException.class, () -> it.next());
 
         try { it.remove(); }
         catch (IllegalStateException ignored) { pass(); }
@@ -232,16 +229,15 @@
 
     private static void testImmutableCollection(final Collection<Integer> c) {
         THROWS(UnsupportedOperationException.class,
-               new Fun(){void f(){ c.add(99); }},
-               new Fun(){void f(){ c.addAll(singleton(99)); }});
+               () -> c.add(99),
+               () -> c.addAll(singleton(99)));
         if (! c.isEmpty()) {
             final Integer first = c.iterator().next();
             THROWS(UnsupportedOperationException.class,
-                   new Fun(){void f(){ c.clear(); }},
-                   new Fun(){void f(){ c.remove(first); }},
-                   new Fun(){void f(){ c.removeAll(singleton(first)); }},
-                   new Fun(){void f(){ c.retainAll(emptyList()); }}
-                   );
+                   () -> c.clear(),
+                   () -> c.remove(first),
+                   () -> c.removeAll(singleton(first)),
+                   () -> c.retainAll(emptyList()));
         }
     }
 
@@ -253,17 +249,17 @@
         testList(c);
         testImmutableCollection(c);
         THROWS(UnsupportedOperationException.class,
-               new Fun(){void f(){ c.set(0,42); }},
-               new Fun(){void f(){ c.add(0,42); }},
-               new Fun(){void f(){ c.addAll(0,singleton(86)); }});
+               () -> c.set(0,42),
+               () -> c.add(0,42),
+               () -> c.addAll(0,singleton(86)));
         if (! c.isEmpty())
             THROWS(UnsupportedOperationException.class,
-                   new Fun(){void f(){
-                           Iterator<Integer> it = c.iterator();
-                           it.next(); it.remove();}},
-                   new Fun(){void f(){
-                           ListIterator<Integer> it = c.listIterator();
-                           it.next(); it.remove();}});
+                   () -> { Iterator<Integer> it = c.iterator();
+                           it.next();
+                           it.remove(); },
+                   () -> { ListIterator<Integer> it = c.listIterator();
+                           it.next();
+                           it.remove(); });
     }
 
     private static void clear(Collection<Integer> c) {
@@ -290,19 +286,19 @@
 
     private static void testImmutableMap(final Map<Integer,Integer> m) {
         THROWS(UnsupportedOperationException.class,
-               new Fun(){void f(){ m.put(1,1); }},
-               new Fun(){void f(){ m.putAll(singletonMap(1,1)); }});
+               () -> m.put(1,1),
+               () -> m.putAll(singletonMap(1,1)));
         if (! m.isEmpty()) {
             final Integer first = m.keySet().iterator().next();
             THROWS(UnsupportedOperationException.class,
-                   new Fun(){void f(){ m.remove(first); }},
-                   new Fun(){void f(){ m.clear(); }});
+                   () -> m.remove(first),
+                   () -> m.clear());
             final Map.Entry<Integer,Integer> me
                 = m.entrySet().iterator().next();
             Integer key = me.getKey();
             Integer val = me.getValue();
             THROWS(UnsupportedOperationException.class,
-                   new Fun(){void f(){ me.setValue(3); }});
+                   () -> me.setValue(3));
             equal(key, me.getKey());
             equal(val, me.getValue());
         }
@@ -492,9 +488,9 @@
             // insert, query, remove element at head
             if (isEmpty) {
                 THROWS(NoSuchElementException.class,
-                       new Fun(){void f(){ deq.getFirst(); }},
-                       new Fun(){void f(){ deq.element(); }},
-                       new Fun(){void f(){ deq.iterator().next(); }});
+                       () -> deq.getFirst(),
+                       () -> deq.element(),
+                       () -> deq.iterator().next());
                 check(deq.peekFirst() == null);
                 check(deq.peek() == null);
             } else {
@@ -546,9 +542,9 @@
             }
             if (isEmpty) {
                 THROWS(NoSuchElementException.class,
-                       new Fun(){void f(){ deq.getFirst(); }},
-                       new Fun(){void f(){ deq.element(); }},
-                       new Fun(){void f(){ deq.iterator().next(); }});
+                       () -> deq.getFirst(),
+                       () -> deq.element(),
+                       () -> deq.iterator().next());
                 check(deq.peekFirst() == null);
                 check(deq.peek() == null);
             } else {
@@ -571,8 +567,7 @@
             // insert, query, remove element at tail
             if (isEmpty) {
                 check(deq.peekLast() == null);
-                THROWS(NoSuchElementException.class,
-                       new Fun(){void f(){ deq.getLast(); }});
+                THROWS(NoSuchElementException.class, () -> deq.getLast());
             } else {
                 check(deq.peekLast() != e);
                 check(deq.getLast() != e);
@@ -615,8 +610,7 @@
             }
             if (isEmpty) {
                 check(deq.peekLast() == null);
-                THROWS(NoSuchElementException.class,
-                       new Fun(){void f(){ deq.getLast(); }});
+                THROWS(NoSuchElementException.class, () -> deq.getLast());
             } else {
                 check(deq.peekLast() != e);
                 check(deq.getLast() != e);
@@ -649,17 +643,17 @@
             if (isList) {
                 check(!asList.listIterator().hasPrevious());
                 THROWS(NoSuchElementException.class,
-                       new Fun(){void f(){ asList.listIterator().previous(); }});
+                       () -> asList.listIterator().previous());
             }
             THROWS(NoSuchElementException.class,
-                   new Fun(){void f(){ deq.iterator().next(); }},
-                   new Fun(){void f(){ deq.element(); }},
-                   new Fun(){void f(){ deq.getFirst(); }},
-                   new Fun(){void f(){ deq.getLast(); }},
-                   new Fun(){void f(){ deq.pop(); }},
-                   new Fun(){void f(){ deq.remove(); }},
-                   new Fun(){void f(){ deq.removeFirst(); }},
-                   new Fun(){void f(){ deq.removeLast(); }});
+                   () -> deq.iterator().next(),
+                   () -> deq.element(),
+                   () -> deq.getFirst(),
+                   () -> deq.getLast(),
+                   () -> deq.pop(),
+                   () -> deq.remove(),
+                   () -> deq.removeFirst(),
+                   () -> deq.removeLast());
 
             check(deq.poll() == null);
             check(deq.pollFirst() == null);
@@ -728,8 +722,8 @@
         l.listIterator(0);
         l.listIterator(l.size());
         THROWS(IndexOutOfBoundsException.class,
-               new Fun(){void f(){l.listIterator(-1);}},
-               new Fun(){void f(){l.listIterator(l.size() + 1);}});
+               () -> l.listIterator(-1),
+               () -> l.listIterator(l.size() + 1));
 
         if (l instanceof AbstractList) {
             try {
@@ -1004,22 +998,22 @@
             ? (ConcurrentMap<T,Integer>) m
             : null;
         List<Fun> fs = new ArrayList<Fun>();
-        fs.add(new Fun(){void f(){ check(! m.containsKey(null));}});
-        fs.add(new Fun(){void f(){ equal(m.remove(null), null);}});
-        fs.add(new Fun(){void f(){ equal(m.get(null), null);}});
-        if (cm != null) {
-            fs.add(new Fun(){void f(){ check(! cm.remove(null,null));}});}
+        fs.add(() -> check(! m.containsKey(null)));
+        fs.add(() -> equal(m.remove(null), null));
+        fs.add(() -> equal(m.get(null), null));
+        if (cm != null)
+            fs.add(() -> check(! cm.remove(null,null)));
         throwsConsistently(NullPointerException.class, fs);
 
         fs.clear();
         final Map<T,Integer> sm = singletonMap(null,1);
-        fs.add(new Fun(){void f(){ equal(m.put(null,1), null); m.clear();}});
-        fs.add(new Fun(){void f(){ m.putAll(sm); m.clear();}});
+        fs.add(() -> { equal(m.put(null,1), null); m.clear();});
+        fs.add(() -> { m.putAll(sm); m.clear();});
         if (cm != null) {
-            fs.add(new Fun(){void f(){ check(! cm.remove(null,null));}});
-            fs.add(new Fun(){void f(){ equal(cm.putIfAbsent(null,1), 1);}});
-            fs.add(new Fun(){void f(){ equal(cm.replace(null,1), null);}});
-            fs.add(new Fun(){void f(){ equal(cm.replace(null,1, 1), 1);}});
+            fs.add(() -> check(! cm.remove(null,null)));
+            fs.add(() -> equal(cm.putIfAbsent(null,1), 1));
+            fs.add(() -> equal(cm.replace(null,1), null));
+            fs.add(() -> equal(cm.replace(null,1, 1), 1));
         }
         throwsConsistently(NullPointerException.class, fs);
     }
@@ -1180,8 +1174,7 @@
             equalNext(it, 3);
             equalNext(it, 1);
             check(! it.hasNext());
-            THROWS(NoSuchElementException.class,
-                   new Fun(){void f(){it.next();}});
+            THROWS(NoSuchElementException.class, () -> it.next());
         }
 
         {
@@ -1191,8 +1184,7 @@
             check(it.hasNext()); equal(it.next().getKey(), 3);
             check(it.hasNext()); equal(it.next().getKey(), 1);
             check(! it.hasNext());
-            THROWS(NoSuchElementException.class,
-                   new Fun(){void f(){it.next();}});
+            THROWS(NoSuchElementException.class, () -> it.next());
         }
 
         prepMapForDescItrTests(m);
@@ -1262,8 +1254,7 @@
             equalNext(it, 3);
             equalNext(it, 1);
             check(! it.hasNext());
-            THROWS(NoSuchElementException.class,
-                   new Fun(){void f(){it.next();}});
+            THROWS(NoSuchElementException.class, () -> it.next());
         }
 
         prepSetForDescItrTests(s);
@@ -1365,7 +1356,7 @@
         System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
         if (failed > 0) throw new Exception("Some tests failed");
     }
-    private static abstract class Fun {abstract void f() throws Throwable;}
+    interface Fun {void f() throws Throwable;}
     private static void THROWS(Class<? extends Throwable> k, Fun... fs) {
           for (Fun f : fs)
               try { f.f(); fail("Expected " + k.getName() + " not thrown"); }
--- a/test/java/util/Collections/AsLifoQueue.java	Mon Jun 02 09:19:59 2014 +0100
+++ b/test/java/util/Collections/AsLifoQueue.java	Mon Jun 02 19:49:57 2014 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -56,8 +56,7 @@
             equal(q.size(), 3);
             check(! q.offer("d"));
             equal(q.size(), 3);
-            THROWS(IllegalStateException.class,
-                   new Fun(){void f(){ q.add("d"); }});
+            THROWS(IllegalStateException.class, () -> q.add("d"));
             equal(q.size(), 3);
             equal(q.toString(), "[c, b, a]");
             equal(q.peek(), "c");
@@ -66,8 +65,7 @@
             equal(q.poll(), "b");
             equal(q.peek(), "a");
             equal(q.remove(), "a");
-            THROWS(NoSuchElementException.class,
-                   new Fun(){void f(){ q.remove(); }});
+            THROWS(NoSuchElementException.class, () -> q.remove());
             equal(q.poll(), null);
             check(q.isEmpty());
             equal(q.size(), 0);
@@ -88,7 +86,7 @@
         try {realMain(args);} catch (Throwable t) {unexpected(t);}
         System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
         if (failed > 0) throw new AssertionError("Some tests failed");}
-    static abstract class Fun { abstract void f() throws Throwable; }
+    interface Fun {void f() throws Throwable;}
     private static void THROWS(Class<? extends Throwable> k, Fun... fs) {
         for (Fun f : fs)
             try { f.f(); fail("Expected " + k.getName() + " not thrown"); }
--- a/test/java/util/NavigableMap/LockStep.java	Mon Jun 02 09:19:59 2014 +0100
+++ b/test/java/util/NavigableMap/LockStep.java	Mon Jun 02 19:49:57 2014 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -236,8 +236,8 @@
         Comparator cmp = comparator(s);
         if (s.isEmpty()) {
             THROWS(NoSuchElementException.class,
-                   new Fun(){void f(){ s.first(); }},
-                   new Fun(){void f(){ s.last();  }});
+                   () -> s.first(),
+                   () -> s.last());
             equal(null, s.lower(1));
             equal(null, s.floor(1));
             equal(null, s.ceiling(1));
@@ -265,8 +265,7 @@
         };
         for (final Iterator it : its)
             if (maybe(4))
-                THROWS(IllegalStateException.class,
-                       new Fun(){void f(){ it.remove(); }});
+                THROWS(IllegalStateException.class, () -> it.remove());
         Object prev = null;
         for (Object e : s) {
             check(s.contains(e));
@@ -284,7 +283,7 @@
         for (final Iterator it : its) {
             if (maybe(2))
                 check(! it.hasNext());
-            Fun fun = new Fun(){void f(){ it.next(); }};
+            Fun fun = () -> it.next();
             THROWS(NoSuchElementException.class, fun, fun, fun);
         }
     }
@@ -380,8 +379,8 @@
         Comparator cmp = comparator(m);
         if (m.isEmpty()) {
             THROWS(NoSuchElementException.class,
-                   new Fun(){void f(){ m.firstKey(); }},
-                   new Fun(){void f(){ m.lastKey();  }});
+                   () -> m.firstKey(),
+                   () -> m.lastKey());
             equal(null, m.firstEntry());
             equal(null, m.lastEntry());
             equal(null, m.pollFirstEntry());
@@ -430,8 +429,7 @@
         Iterator[] its = concat(kits, vits, eits);
         for (final Iterator it : its)
             if (maybe(4))
-                THROWS(IllegalStateException.class,
-                       new Fun(){void f(){ it.remove(); }});
+                THROWS(IllegalStateException.class, () -> it.remove());
         Map.Entry prev = null;
         for (Map.Entry e : (Set<Map.Entry>) m.entrySet()) {
             Object k = e.getKey();
@@ -459,7 +457,7 @@
         for (final Iterator it : its) {
             if (maybe(2))
                 check(! it.hasNext());
-            Fun fun = new Fun(){void f(){ it.next(); }};
+            Fun fun = () -> it.next();
             THROWS(NoSuchElementException.class, fun, fun, fun);
         }
     }
@@ -633,7 +631,7 @@
     }
 
     static Fun remover(final Iterator it) {
-        return new Fun(){void f(){ it.remove(); }};
+        return () -> it.remove();
     }
 
     static MapFrobber randomRemover(NavigableMap m) {
@@ -663,7 +661,7 @@
                         it.remove();
                         if (maybe(2))
                             THROWS(IllegalStateException.class,
-                                   new Fun(){void f(){ it.remove(); }});
+                                   () -> it.remove());
                     }
                 checkUnusedKey(m, k);}},
             new MapFrobber() {void frob(NavigableMap m) {
@@ -673,7 +671,7 @@
                         it.remove();
                         if (maybe(2))
                             THROWS(IllegalStateException.class,
-                                   new Fun(){void f(){ it.remove(); }});
+                                   () -> it.remove());
                     }
                 checkUnusedKey(m, k);}},
             new MapFrobber() {void frob(NavigableMap m) {
@@ -718,7 +716,7 @@
                         it.remove();
                         if (maybe(2))
                             THROWS(IllegalStateException.class,
-                                   new Fun(){void f(){ it.remove(); }});
+                                   () -> it.remove());
                     }
                 checkUnusedElt(s, e);}},
             new SetFrobber() {void frob(NavigableSet s) {
@@ -728,7 +726,7 @@
                         it.remove();
                         if (maybe(2))
                             THROWS(IllegalStateException.class,
-                                   new Fun(){void f(){ it.remove(); }});
+                                   () -> it.remove());
                     }
                 checkUnusedElt(s, e);}},
             new SetFrobber() {void frob(NavigableSet s) {
@@ -738,7 +736,7 @@
                         it.remove();
                         if (maybe(2))
                             THROWS(IllegalStateException.class,
-                                   new Fun(){void f(){ it.remove(); }});
+                                   () -> it.remove());
                     }
                 checkUnusedElt(s, e);}}
         };
@@ -769,12 +767,12 @@
         for (final NavigableMap m : maps) {
             final Object e = usedKey(m);
             THROWS(IllegalArgumentException.class,
-                   new Fun(){void f(){m.subMap(e,true,e,false)
-                                       .subMap(e,true,e,true);}},
-                   new Fun(){void f(){m.subMap(e,false,e,true)
-                                       .subMap(e,true,e,true);}},
-                   new Fun(){void f(){m.tailMap(e,false).tailMap(e,true);}},
-                   new Fun(){void f(){m.headMap(e,false).headMap(e,true);}});
+                   () -> {m.subMap(e,true,e,false)
+                           .subMap(e,true,e,true);},
+                   () -> {m.subMap(e,false,e,true)
+                           .subMap(e,true,e,true);},
+                   () -> m.tailMap(e,false).tailMap(e,true),
+                   () -> m.headMap(e,false).headMap(e,true));
         }
         //System.out.printf("%s%n", m1);
         for (int i = size; i > 0; i--) {
@@ -811,12 +809,12 @@
         for (final NavigableSet s : sets) {
             final Object e = usedElt(s);
             THROWS(IllegalArgumentException.class,
-                   new Fun(){void f(){s.subSet(e,true,e,false)
-                                       .subSet(e,true,e,true);}},
-                   new Fun(){void f(){s.subSet(e,false,e,true)
-                                       .subSet(e,true,e,true);}},
-                   new Fun(){void f(){s.tailSet(e,false).tailSet(e,true);}},
-                   new Fun(){void f(){s.headSet(e,false).headSet(e,true);}});
+                   () -> {s.subSet(e,true,e,false)
+                           .subSet(e,true,e,true);},
+                   () -> {s.subSet(e,false,e,true)
+                           .subSet(e,true,e,true);},
+                   () -> s.tailSet(e,false).tailSet(e,true),
+                   () -> s.headSet(e,false).headSet(e,true));
         }
         //System.out.printf("%s%n", s1);
         for (int i = size; i > 0; i--) {
@@ -847,7 +845,7 @@
         System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
         if (failed > 0) throw new Exception("Some tests failed");
     }
-    static abstract class Fun {abstract void f() throws Throwable;}
+    interface Fun {void f() throws Throwable;}
     static void THROWS(Class<? extends Throwable> k, Fun... fs) {
           for (Fun f : fs)
               try { f.f(); fail("Expected " + k.getName() + " not thrown"); }
--- a/test/java/util/PriorityQueue/ForgetMeNot.java	Mon Jun 02 09:19:59 2014 +0100
+++ b/test/java/util/PriorityQueue/ForgetMeNot.java	Mon Jun 02 19:49:57 2014 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -37,16 +37,14 @@
 
     private static void noMoreElements(final Iterator<Integer> it) {
         for (int j = 0; j < 2; j++) {
-            THROWS(NoSuchElementException.class,
-                   new Fun() { void f() { it.next(); }});
+            THROWS(NoSuchElementException.class, () -> it.next());
             check(! it.hasNext());
         }
     }
 
     private static void removeIsCurrentlyIllegal(final Iterator<Integer> it) {
         for (int j = 0; j < 2; j++) {
-            THROWS(IllegalStateException.class,
-                   new Fun() { void f() { it.remove(); }});
+            THROWS(IllegalStateException.class, () -> it.remove());
         }
     }
 
@@ -146,7 +144,7 @@
         try {realMain(args);} catch (Throwable t) {unexpected(t);}
         System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
         if (failed > 0) throw new AssertionError("Some tests failed");}
-    private static abstract class Fun {abstract void f() throws Throwable;}
+    interface Fun {void f() throws Throwable;}
     static void THROWS(Class<? extends Throwable> k, Fun... fs) {
         for (Fun f : fs)
             try { f.f(); fail("Expected " + k.getName() + " not thrown"); }
--- a/test/java/util/concurrent/BlockingQueue/Interrupt.java	Mon Jun 02 09:19:59 2014 +0100
+++ b/test/java/util/concurrent/BlockingQueue/Interrupt.java	Mon Jun 02 19:49:57 2014 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -69,19 +69,13 @@
                 (BlockingDeque<Object>) q : null;
             q.clear();
             List<Fun> fs = new ArrayList<Fun>();
-            fs.add(new Fun() { void f() throws Throwable
-                    { q.take(); }});
-            fs.add(new Fun() { void f() throws Throwable
-                    { q.poll(60, SECONDS); }});
+            fs.add(() -> q.take());
+            fs.add(() -> q.poll(60, SECONDS));
             if (deq != null) {
-                fs.add(new Fun() { void f() throws Throwable
-                        { deq.takeFirst(); }});
-                fs.add(new Fun() { void f() throws Throwable
-                        { deq.takeLast(); }});
-                fs.add(new Fun() { void f() throws Throwable
-                        { deq.pollFirst(7, SECONDS); }});
-                fs.add(new Fun() { void f() throws Throwable
-                        { deq.pollLast(7, SECONDS); }});
+                fs.add(() -> deq.takeFirst());
+                fs.add(() -> deq.takeLast());
+                fs.add(() -> deq.pollFirst(7, SECONDS));
+                fs.add(() -> deq.pollLast(7, SECONDS));
             }
 
             checkInterrupted(fs);
@@ -92,19 +86,13 @@
                 catch (Throwable t) { unexpected(t); }
 
             fs.clear();
-            fs.add(new Fun() { void f() throws Throwable
-                    { q.put(1); }});
-            fs.add(new Fun() { void f() throws Throwable
-                    { q.offer(1, 7, SECONDS); }});
+            fs.add(() -> q.put(1));
+            fs.add(() -> q.offer(1, 7, SECONDS));
             if (deq != null) {
-                fs.add(new Fun() { void f() throws Throwable
-                        { deq.putFirst(1); }});
-                fs.add(new Fun() { void f() throws Throwable
-                        { deq.putLast(1); }});
-                fs.add(new Fun() { void f() throws Throwable
-                        { deq.offerFirst(1, 7, SECONDS); }});
-                fs.add(new Fun() { void f() throws Throwable
-                        { deq.offerLast(1, 7, SECONDS); }});
+                fs.add(() -> deq.putFirst(1));
+                fs.add(() -> deq.putLast(1));
+                fs.add(() -> deq.offerFirst(1, 7, SECONDS));
+                fs.add(() -> deq.offerLast(1, 7, SECONDS));
             }
             checkInterrupted(fs);
         } catch (Throwable t) {
@@ -135,5 +123,5 @@
         try {realMain(args);} catch (Throwable t) {unexpected(t);}
         System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
         if (failed > 0) throw new AssertionError("Some tests failed");}
-    private abstract static class Fun {abstract void f() throws Throwable;}
+    interface Fun {void f() throws Throwable;}
 }
--- a/test/java/util/concurrent/CyclicBarrier/Basic.java	Mon Jun 02 09:19:59 2014 +0100
+++ b/test/java/util/concurrent/CyclicBarrier/Basic.java	Mon Jun 02 19:49:57 2014 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -40,10 +40,8 @@
         equal(barrier.getNumberWaiting(), 0);
 
         THROWS(BrokenBarrierException.class,
-               new Fun() { public void f() throws Throwable {
-                   barrier.await(); }},
-               new Fun() { public void f() throws Throwable {
-                   barrier.await(100, MILLISECONDS); }});
+               () -> barrier.await(),
+               () -> barrier.await(100, MILLISECONDS));
     }
 
     private static void reset(CyclicBarrier barrier) {
@@ -417,7 +415,7 @@
         try {realMain(args);} catch (Throwable t) {unexpected(t);}
         System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
         if (failed > 0) throw new AssertionError("Some tests failed");}
-    abstract static class Fun { abstract void f() throws Throwable; }
+    interface Fun {void f() throws Throwable;}
     private static void THROWS(Class<? extends Throwable> k, Fun... fs) {
         for (Fun f : fs)
             try { f.f(); fail("Expected " + k.getName() + " not thrown"); }
--- a/test/java/util/concurrent/Executors/Throws.java	Mon Jun 02 09:19:59 2014 +0100
+++ b/test/java/util/concurrent/Executors/Throws.java	Mon Jun 02 19:49:57 2014 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -45,33 +45,31 @@
                                                   ThreadPoolExecutor executor) {}};
         final RejectedExecutionHandler nullHandler = null;
 
-        THROWS(
-            NullPointerException.class,
-            new Fun(){void f(){ newFixedThreadPool(3, null); }},
-            new Fun(){void f(){ newCachedThreadPool(null); }},
-            new Fun(){void f(){ newSingleThreadScheduledExecutor(null); }},
-            new Fun(){void f(){ newScheduledThreadPool(0, null); }},
-            new Fun(){void f(){ unconfigurableExecutorService(null); }},
-            new Fun(){void f(){ unconfigurableScheduledExecutorService(null); }},
-            new Fun(){void f(){ callable(null, "foo"); }},
-            new Fun(){void f(){ callable((Runnable) null); }},
-            new Fun(){void f(){ callable((PrivilegedAction<?>) null); }},
-            new Fun(){void f(){ callable((PrivilegedExceptionAction<?>) null); }},
-            new Fun(){void f(){ privilegedCallable((Callable<?>) null); }},
-            new Fun(){void f(){ new ScheduledThreadPoolExecutor(0, nullFactory); }},
-            new Fun(){void f(){ new ScheduledThreadPoolExecutor(0, nullFactory, reh); }},
-            new Fun(){void f(){ new ScheduledThreadPoolExecutor(0, fac, nullHandler); }});
+        THROWS(NullPointerException.class,
+               () -> newFixedThreadPool(3, null),
+               () -> newCachedThreadPool(null),
+               () -> newSingleThreadScheduledExecutor(null),
+               () -> newScheduledThreadPool(0, null),
+               () -> unconfigurableExecutorService(null),
+               () -> unconfigurableScheduledExecutorService(null),
+               () -> callable(null, "foo"),
+               () -> callable((Runnable) null),
+               () -> callable((PrivilegedAction<?>) null),
+               () -> callable((PrivilegedExceptionAction<?>) null),
+               () -> privilegedCallable((Callable<?>) null),
+               () -> new ScheduledThreadPoolExecutor(0, nullFactory),
+               () -> new ScheduledThreadPoolExecutor(0, nullFactory, reh),
+               () -> new ScheduledThreadPoolExecutor(0, fac, nullHandler));
 
-        THROWS(
-            IllegalArgumentException.class,
-            new Fun(){void f(){ newFixedThreadPool(-42); }},
-            new Fun(){void f(){ newFixedThreadPool(0)  ; }},
-            new Fun(){void f(){ newFixedThreadPool(-42, fac); }},
-            new Fun(){void f(){ newFixedThreadPool(0,   fac); }},
-            new Fun(){void f(){ newScheduledThreadPool(-42); }},
-            new Fun(){void f(){ new ScheduledThreadPoolExecutor(-42); }},
-            new Fun(){void f(){ new ScheduledThreadPoolExecutor(-42, reh); }},
-            new Fun(){void f(){ new ScheduledThreadPoolExecutor(-42, fac, reh); }});
+        THROWS(IllegalArgumentException.class,
+               () -> newFixedThreadPool(-42),
+               () -> newFixedThreadPool(0),
+               () -> newFixedThreadPool(-42, fac),
+               () -> newFixedThreadPool(0,   fac),
+               () -> newScheduledThreadPool(-42),
+               () -> new ScheduledThreadPoolExecutor(-42),
+               () -> new ScheduledThreadPoolExecutor(-42, reh),
+               () -> new ScheduledThreadPoolExecutor(-42, fac, reh));
 
         try { newFixedThreadPool(1).shutdownNow(); pass(); }
         catch (Throwable t) { unexpected(t); }
@@ -122,7 +120,7 @@
         try {realMain(args);} catch (Throwable t) {unexpected(t);}
         System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
         if (failed > 0) throw new AssertionError("Some tests failed");}
-    private abstract static class Fun {abstract void f() throws Throwable;}
+    interface Fun {void f() throws Throwable;}
     static void THROWS(Class<? extends Throwable> k, Fun... fs) {
         for (Fun f : fs)
             try { f.f(); fail("Expected " + k.getName() + " not thrown"); }
--- a/test/java/util/concurrent/FutureTask/Customized.java	Mon Jun 02 09:19:59 2014 +0100
+++ b/test/java/util/concurrent/FutureTask/Customized.java	Mon Jun 02 19:49:57 2014 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -70,8 +70,7 @@
         check(! task.isDone());
         check(! task.isCancelled());
         THROWS(TimeoutException.class,
-               new Fun(){void f() throws Throwable {
-                       task.get(0L, TimeUnit.SECONDS); }});
+               () -> task.get(0L, TimeUnit.SECONDS));
     }
 
     static <V> void checkDone(final FutureTask<V> task) {
@@ -86,20 +85,16 @@
         check(task.isDone());
         check(task.isCancelled());
         THROWS(CancellationException.class,
-           new Fun(){void f() throws Throwable {
-               task.get(0L, TimeUnit.SECONDS); }},
-           new Fun(){void f() throws Throwable {
-               task.get(); }});
+               () -> task.get(0L, TimeUnit.SECONDS),
+               () -> task.get());
     }
 
     static <V> void checkThrew(final FutureTask<V> task) {
         check(task.isDone());
         check(! task.isCancelled());
         THROWS(ExecutionException.class,
-           new Fun(){void f() throws Throwable {
-               task.get(0L, TimeUnit.SECONDS); }},
-           new Fun(){void f() throws Throwable {
-               task.get(); }});
+               () -> task.get(0L, TimeUnit.SECONDS),
+               () -> task.get());
     }
 
     static <V> void cancel(FutureTask<V> task, boolean mayInterruptIfRunning) {
@@ -203,7 +198,7 @@
         try {realMain(args);} catch (Throwable t) {unexpected(t);}
         System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
         if (failed > 0) throw new AssertionError("Some tests failed");}
-    private abstract static class Fun {abstract void f() throws Throwable;}
+    interface Fun {void f() throws Throwable;}
     static void THROWS(Class<? extends Throwable> k, Fun... fs) {
         for (Fun f : fs)
             try { f.f(); fail("Expected " + k.getName() + " not thrown"); }
--- a/test/java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java	Mon Jun 02 09:19:59 2014 +0100
+++ b/test/java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java	Mon Jun 02 19:49:57 2014 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -72,7 +72,7 @@
                     check(((ThreadPoolExecutor) es).isTerminating()
                           || es.isTerminated());
                 THROWS(RejectedExecutionException.class,
-                       new Fun() {void f() {es.execute(nop);}});
+                       () -> es.execute(nop));
             }
         } catch (Throwable t) { unexpected(t); }
     }
@@ -241,7 +241,7 @@
         try {realMain(args);} catch (Throwable t) {unexpected(t);}
         System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
         if (failed > 0) throw new AssertionError("Some tests failed");}
-    private abstract static class Fun {abstract void f() throws Throwable;}
+    interface Fun {void f() throws Throwable;}
     static void THROWS(Class<? extends Throwable> k, Fun... fs) {
         for (Fun f : fs)
             try { f.f(); fail("Expected " + k.getName() + " not thrown"); }
--- a/test/java/util/concurrent/ThreadPoolExecutor/ShutdownNowExecuteRace.java	Mon Jun 02 09:19:59 2014 +0100
+++ b/test/java/util/concurrent/ThreadPoolExecutor/ShutdownNowExecuteRace.java	Mon Jun 02 19:49:57 2014 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -81,13 +81,6 @@
         try {realMain(args);} catch (Throwable t) {unexpected(t);}
         System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
         if (failed > 0) throw new AssertionError("Some tests failed");}
-    private abstract static class Fun {abstract void f() throws Throwable;}
-    static void THROWS(Class<? extends Throwable> k, Fun... fs) {
-        for (Fun f : fs)
-            try { f.f(); fail("Expected " + k.getName() + " not thrown"); }
-            catch (Throwable t) {
-                if (k.isAssignableFrom(t.getClass())) pass();
-                else unexpected(t);}}
     private abstract static class CheckedThread extends Thread {
         abstract void realRun() throws Throwable;
         public void run() {
--- a/test/sun/nio/cs/FindOneCharEncoderBugs.java	Mon Jun 02 09:19:59 2014 +0100
+++ b/test/sun/nio/cs/FindOneCharEncoderBugs.java	Mon Jun 02 19:49:57 2014 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -155,13 +155,6 @@
         try {realMain(args);} catch (Throwable t) {unexpected(t);}
         System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
         if (failed > 0) throw new AssertionError("Some tests failed");}
-    private static abstract class Fun {abstract void f() throws Throwable;}
-    static void THROWS(Class<? extends Throwable> k, Fun... fs) {
-        for (Fun f : fs)
-            try { f.f(); fail("Expected " + k.getName() + " not thrown"); }
-            catch (Throwable t) {
-                if (k.isAssignableFrom(t.getClass())) pass();
-                else unexpected(t);}}
     private static abstract class CheckedThread extends Thread {
         abstract void realRun() throws Throwable;
         public void run() {