You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2017/06/02 16:23:02 UTC

[2/4] karaf git commit: [KARAF-5178] Use lambdas where appropriate

http://git-wip-us.apache.org/repos/asf/karaf/blob/bf666631/management/server/src/test/java/org/apache/karaf/management/KarafMBeanServerGuardTest.java
----------------------------------------------------------------------
diff --git a/management/server/src/test/java/org/apache/karaf/management/KarafMBeanServerGuardTest.java b/management/server/src/test/java/org/apache/karaf/management/KarafMBeanServerGuardTest.java
index 882c048..5880d3c 100644
--- a/management/server/src/test/java/org/apache/karaf/management/KarafMBeanServerGuardTest.java
+++ b/management/server/src/test/java/org/apache/karaf/management/KarafMBeanServerGuardTest.java
@@ -462,12 +462,10 @@ public class KarafMBeanServerGuardTest extends TestCase {
     public void testCurrentUserHasRole() throws Exception {
         Subject subject = loginWithTestRoles("test");
 
-        Subject.doAs(subject, new PrivilegedAction<Void>() {
-            public Void run() {
-                assertTrue(JaasHelper.currentUserHasRole("test"));
-                assertFalse(JaasHelper.currentUserHasRole("toast"));
-                return null;
-            }
+        Subject.doAs(subject, (PrivilegedAction<Void>) () -> {
+            assertTrue(JaasHelper.currentUserHasRole("test"));
+            assertFalse(JaasHelper.currentUserHasRole("toast"));
+            return null;
         });
     }
 
@@ -478,12 +476,10 @@ public class KarafMBeanServerGuardTest extends TestCase {
         lm.login();
         lm.commit();
 
-        Subject.doAs(subject, new PrivilegedAction<Void>() {
-            public Void run() {
-                assertTrue(JaasHelper.currentUserHasRole(TestRolePrincipal.class.getCanonicalName() + ":foo"));
-                assertFalse(JaasHelper.currentUserHasRole("foo"));
-                return null;
-            }
+        Subject.doAs(subject, (PrivilegedAction<Void>) () -> {
+            assertTrue(JaasHelper.currentUserHasRole(TestRolePrincipal.class.getCanonicalName() + ":foo"));
+            assertFalse(JaasHelper.currentUserHasRole("foo"));
+            return null;
         });
     }
 
@@ -497,33 +493,31 @@ public class KarafMBeanServerGuardTest extends TestCase {
         guard.setConfigAdmin(ca);
 
         Subject subject = loginWithTestRoles("editor", "admin");
-        Subject.doAs(subject, new PrivilegedAction<Void>() {
-            public Void run() {
+        Subject.doAs(subject, (PrivilegedAction<Void>) () -> {
+            try {
+                Method im = MBeanServer.class.getMethod("invoke", ObjectName.class, String.class, Object[].class, String[].class);
+
+                ObjectName on = ObjectName.getInstance("foo.bar:type=Test");
+
+                // The following operation should not throw an exception
+                guard.invoke(null, im, new Object[]{on, "someMethod", new Object[]{"test"}, new String[]{"java.lang.String"}});
+
+                try {
+                    guard.invoke(null, im, new Object[]{on, "someOtherMethod", new Object[]{}, new String[]{}});
+                    fail("Should not have allowed the invocation");
+                } catch (SecurityException se) {
+                    // good
+                }
+
                 try {
-                    Method im = MBeanServer.class.getMethod("invoke", ObjectName.class, String.class, Object[].class, String[].class);
-
-                    ObjectName on = ObjectName.getInstance("foo.bar:type=Test");
-
-                    // The following operation should not throw an exception
-                    guard.invoke(null, im, new Object[]{on, "someMethod", new Object[]{"test"}, new String[]{"java.lang.String"}});
-
-                    try {
-                        guard.invoke(null, im, new Object[]{on, "someOtherMethod", new Object[]{}, new String[]{}});
-                        fail("Should not have allowed the invocation");
-                    } catch (SecurityException se) {
-                        // good
-                    }
-
-                    try {
-                        guard.invoke(null, im, new Object[]{on, "somemethingElse", new Object[]{}, new String[]{}});
-                        fail("Should not have allowed the invocation");
-                    } catch (SecurityException se) {
-                        // good
-                    }
-                    return null;
-                } catch (Throwable ex) {
-                    throw new RuntimeException(ex);
+                    guard.invoke(null, im, new Object[]{on, "somemethingElse", new Object[]{}, new String[]{}});
+                    fail("Should not have allowed the invocation");
+                } catch (SecurityException se) {
+                    // good
                 }
+                return null;
+            } catch (Throwable ex) {
+                throw new RuntimeException(ex);
             }
         });
     }
@@ -553,26 +547,24 @@ public class KarafMBeanServerGuardTest extends TestCase {
         guard.setConfigAdmin(ca);
 
         Subject subject = loginWithTestRoles("editor", "admin");
-        Subject.doAs(subject, new PrivilegedAction<Void>() {
-            public Void run() {
+        Subject.doAs(subject, (PrivilegedAction<Void>) () -> {
+            try {
+                Method im = MBeanServer.class.getMethod("getAttribute", ObjectName.class, String.class);
+
+                // The following operations should not throw an exception
+                guard.invoke(mbs, im, new Object[]{on, "Toast"});
+                guard.invoke(mbs, im, new Object[]{on, "TestAttr"});
+
                 try {
-                    Method im = MBeanServer.class.getMethod("getAttribute", ObjectName.class, String.class);
-
-                    // The following operations should not throw an exception
-                    guard.invoke(mbs, im, new Object[]{on, "Toast"});
-                    guard.invoke(mbs, im, new Object[]{on, "TestAttr"});
-
-                    try {
-                        guard.invoke(mbs, im, new Object[]{on, "Butter"});
-                        fail("Should not have allowed the invocation");
-                    } catch (SecurityException se) {
-                        // good
-                    }
-
-                    return null;
-                } catch (Throwable ex) {
-                    throw new RuntimeException(ex);
+                    guard.invoke(mbs, im, new Object[]{on, "Butter"});
+                    fail("Should not have allowed the invocation");
+                } catch (SecurityException se) {
+                    // good
                 }
+
+                return null;
+            } catch (Throwable ex) {
+                throw new RuntimeException(ex);
             }
         });
     }
@@ -601,26 +593,24 @@ public class KarafMBeanServerGuardTest extends TestCase {
         guard.setConfigAdmin(ca);
 
         Subject subject = loginWithTestRoles("editor", "admin");
-        Subject.doAs(subject, new PrivilegedAction<Void>() {
-            public Void run() {
+        Subject.doAs(subject, (PrivilegedAction<Void>) () -> {
+            try {
+                Method im = MBeanServer.class.getMethod("getAttributes", ObjectName.class, String[].class);
+
+                // The following operations should not throw an exception
+                guard.invoke(mbs, im, new Object[]{on, new String[]{"Toast"}});
+                guard.invoke(mbs, im, new Object[]{on, new String[]{"TestSomething", "Toast"}});
+
                 try {
-                    Method im = MBeanServer.class.getMethod("getAttributes", ObjectName.class, String[].class);
-
-                    // The following operations should not throw an exception
-                    guard.invoke(mbs, im, new Object[]{on, new String[]{"Toast"}});
-                    guard.invoke(mbs, im, new Object[]{on, new String[]{"TestSomething", "Toast"}});
-
-                    try {
-                        guard.invoke(mbs, im, new Object[]{on, new String[]{"Butter", "Toast"}});
-                        fail("Should not have allowed the invocation");
-                    } catch (SecurityException se) {
-                        // good
-                    }
-
-                    return null;
-                } catch (Throwable ex) {
-                    throw new RuntimeException(ex);
+                    guard.invoke(mbs, im, new Object[]{on, new String[]{"Butter", "Toast"}});
+                    fail("Should not have allowed the invocation");
+                } catch (SecurityException se) {
+                    // good
                 }
+
+                return null;
+            } catch (Throwable ex) {
+                throw new RuntimeException(ex);
             }
         });
     }
@@ -651,26 +641,24 @@ public class KarafMBeanServerGuardTest extends TestCase {
         guard.setConfigAdmin(ca);
 
         Subject subject = loginWithTestRoles("editor", "admin");
-        Subject.doAs(subject, new PrivilegedAction<Void>() {
-            public Void run() {
+        Subject.doAs(subject, (PrivilegedAction<Void>) () -> {
+            try {
+                Method im = MBeanServer.class.getMethod("getAttributes", ObjectName.class, String[].class);
+
+                // The following operations should not throw an exception
+                guard.invoke(mbs, im, new Object[]{on, new String[]{"Toast"}});
+                guard.invoke(mbs, im, new Object[]{on, new String[]{"TestSomething", "Toast"}});
+
                 try {
-                    Method im = MBeanServer.class.getMethod("getAttributes", ObjectName.class, String[].class);
-
-                    // The following operations should not throw an exception
-                    guard.invoke(mbs, im, new Object[]{on, new String[]{"Toast"}});
-                    guard.invoke(mbs, im, new Object[]{on, new String[]{"TestSomething", "Toast"}});
-
-                    try {
-                        guard.invoke(mbs, im, new Object[]{on, new String[]{"Butter", "Toast"}});
-                        fail("Should not have allowed the invocation");
-                    } catch (SecurityException se) {
-                        // good
-                    }
-
-                    return null;
-                } catch (Throwable ex) {
-                    throw new RuntimeException(ex);
+                    guard.invoke(mbs, im, new Object[]{on, new String[]{"Butter", "Toast"}});
+                    fail("Should not have allowed the invocation");
+                } catch (SecurityException se) {
+                    // good
                 }
+
+                return null;
+            } catch (Throwable ex) {
+                throw new RuntimeException(ex);
             }
         });
     }
@@ -700,33 +688,31 @@ public class KarafMBeanServerGuardTest extends TestCase {
         guard.setConfigAdmin(ca);
 
         Subject subject = loginWithTestRoles("editor", "admin");
-        Subject.doAs(subject, new PrivilegedAction<Void>() {
-            public Void run() {
+        Subject.doAs(subject, (PrivilegedAction<Void>) () -> {
+            try {
+                Method im = MBeanServer.class.getMethod("setAttribute", ObjectName.class, Attribute.class);
+
+                // The following operations should not throw an exception
+                guard.invoke(mbs, im, new Object[]{on, new Attribute("Something", "v1")});
+                guard.invoke(mbs, im, new Object[]{on, new Attribute("Value", 42L)});
+
+                try {
+                    guard.invoke(mbs, im, new Object[]{on, new Attribute("Other", Boolean.TRUE)});
+                    fail("Should not have allowed the invocation");
+                } catch (SecurityException se) {
+                    // good
+                }
+
                 try {
-                    Method im = MBeanServer.class.getMethod("setAttribute", ObjectName.class, Attribute.class);
-
-                    // The following operations should not throw an exception
-                    guard.invoke(mbs, im, new Object[]{on, new Attribute("Something", "v1")});
-                    guard.invoke(mbs, im, new Object[]{on, new Attribute("Value", 42L)});
-
-                    try {
-                        guard.invoke(mbs, im, new Object[]{on, new Attribute("Other", Boolean.TRUE)});
-                        fail("Should not have allowed the invocation");
-                    } catch (SecurityException se) {
-                        // good
-                    }
-
-                    try {
-                        guard.invoke(mbs, im, new Object[]{on, new Attribute("NonExistent", "v4")});
-                        fail("Should not have found the MBean Declaration");
-                    } catch (IllegalStateException ise) {
-                        // good
-                    }
-
-                    return null;
-                } catch (Throwable ex) {
-                    throw new RuntimeException(ex);
+                    guard.invoke(mbs, im, new Object[]{on, new Attribute("NonExistent", "v4")});
+                    fail("Should not have found the MBean Declaration");
+                } catch (IllegalStateException ise) {
+                    // good
                 }
+
+                return null;
+            } catch (Throwable ex) {
+                throw new RuntimeException(ex);
             }
         });
     }
@@ -756,37 +742,35 @@ public class KarafMBeanServerGuardTest extends TestCase {
         guard.setConfigAdmin(ca);
 
         Subject subject = loginWithTestRoles("editor", "admin");
-        Subject.doAs(subject, new PrivilegedAction<Void>() {
-            public Void run() {
+        Subject.doAs(subject, (PrivilegedAction<Void>) () -> {
+            try {
+                Method im = MBeanServer.class.getMethod("setAttributes", ObjectName.class, AttributeList.class);
+
+                // The following operations should not throw an exception
+                Attribute a1 = new Attribute("Something", "v1");
+                Attribute a2 = new Attribute("Value", 42L);
+                guard.invoke(mbs, im, new Object[]{on, new AttributeList(Arrays.asList(a1))});
+                guard.invoke(mbs, im, new Object[]{on, new AttributeList(Arrays.asList(a2, a1))});
+
+                Attribute a3 = new Attribute("Other", Boolean.TRUE);
+                try {
+                    guard.invoke(mbs, im, new Object[]{on, new AttributeList(Arrays.asList(a1, a3))});
+                    fail("Should not have allowed the invocation");
+                } catch (SecurityException se) {
+                    // good
+                }
+
                 try {
-                    Method im = MBeanServer.class.getMethod("setAttributes", ObjectName.class, AttributeList.class);
-
-                    // The following operations should not throw an exception
-                    Attribute a1 = new Attribute("Something", "v1");
-                    Attribute a2 = new Attribute("Value", 42L);
-                    guard.invoke(mbs, im, new Object[]{on, new AttributeList(Arrays.asList(a1))});
-                    guard.invoke(mbs, im, new Object[]{on, new AttributeList(Arrays.asList(a2, a1))});
-
-                    Attribute a3 = new Attribute("Other", Boolean.TRUE);
-                    try {
-                        guard.invoke(mbs, im, new Object[]{on, new AttributeList(Arrays.asList(a1, a3))});
-                        fail("Should not have allowed the invocation");
-                    } catch (SecurityException se) {
-                        // good
-                    }
-
-                    try {
-                        Attribute a4 = new Attribute("NonExistent", "v4");
-                        guard.invoke(mbs, im, new Object[]{on, new AttributeList(Arrays.asList(a4))});
-                        fail("Should not have found the MBean Declaration");
-                    } catch (IllegalStateException ise) {
-                        // good
-                    }
-
-                    return null;
-                } catch (Throwable ex) {
-                    throw new RuntimeException(ex);
+                    Attribute a4 = new Attribute("NonExistent", "v4");
+                    guard.invoke(mbs, im, new Object[]{on, new AttributeList(Arrays.asList(a4))});
+                    fail("Should not have found the MBean Declaration");
+                } catch (IllegalStateException ise) {
+                    // good
                 }
+
+                return null;
+            } catch (Throwable ex) {
+                throw new RuntimeException(ex);
             }
         });
     }
@@ -826,16 +810,14 @@ public class KarafMBeanServerGuardTest extends TestCase {
 
         Subject subject = loginWithTestRoles("viewer");
 
-        Subject.doAs(subject, new PrivilegedAction<Void>() {
-            public Void run() {
-                try {
-                    assertTrue(guard.canInvoke(mbs, on));
-                    assertFalse(guard.canInvoke(mbs, on2));
+        Subject.doAs(subject, (PrivilegedAction<Void>) () -> {
+            try {
+                assertTrue(guard.canInvoke(mbs, on));
+                assertFalse(guard.canInvoke(mbs, on2));
 
-                    return null;
-                } catch (Throwable th) {
-                    throw new RuntimeException(th);
-                }
+                return null;
+            } catch (Throwable th) {
+                throw new RuntimeException(th);
             }
         });
     }
@@ -869,15 +851,13 @@ public class KarafMBeanServerGuardTest extends TestCase {
 
         Subject subject = loginWithTestRoles("viewer");
 
-        Subject.doAs(subject, new PrivilegedAction<Void>() {
-            public Void run() {
-                try {
-                    assertFalse(guard.canInvoke(mbs, on));
+        Subject.doAs(subject, (PrivilegedAction<Void>) () -> {
+            try {
+                assertFalse(guard.canInvoke(mbs, on));
 
-                    return null;
-                } catch (Throwable th) {
-                    throw new RuntimeException(th);
-                }
+                return null;
+            } catch (Throwable th) {
+                throw new RuntimeException(th);
             }
         });
     }
@@ -909,15 +889,13 @@ public class KarafMBeanServerGuardTest extends TestCase {
         guard.setConfigAdmin(ca);
 
         Subject subject = loginWithTestRoles("viewer");
-        Subject.doAs(subject, new PrivilegedAction<Void>() {
-            public Void run() {
-                try {
-                    assertTrue(guard.canInvoke(mbs, on, "doit"));
+        Subject.doAs(subject, (PrivilegedAction<Void>) () -> {
+            try {
+                assertTrue(guard.canInvoke(mbs, on, "doit"));
 
-                    return null;
-                } catch (Throwable th) {
-                    throw new RuntimeException(th);
-                }
+                return null;
+            } catch (Throwable th) {
+                throw new RuntimeException(th);
             }
         });
     }
@@ -950,15 +928,13 @@ public class KarafMBeanServerGuardTest extends TestCase {
         guard.setConfigAdmin(ca);
 
         Subject subject = loginWithTestRoles("viewer");
-        Subject.doAs(subject, new PrivilegedAction<Void>() {
-            public Void run() {
-                try {
-                    assertFalse(guard.canInvoke(mbs, on, "doit"));
+        Subject.doAs(subject, (PrivilegedAction<Void>) () -> {
+            try {
+                assertFalse(guard.canInvoke(mbs, on, "doit"));
 
-                    return null;
-                } catch (Throwable th) {
-                    throw new RuntimeException(th);
-                }
+                return null;
+            } catch (Throwable th) {
+                throw new RuntimeException(th);
             }
         });
     }
@@ -984,15 +960,13 @@ public class KarafMBeanServerGuardTest extends TestCase {
         guard.setConfigAdmin(ca);
 
         Subject subject = loginWithTestRoles("viewer");
-        Subject.doAs(subject, new PrivilegedAction<Void>() {
-            public Void run() {
-                try {
-                    assertFalse(guard.canInvoke(mbs, on, "doit"));
+        Subject.doAs(subject, (PrivilegedAction<Void>) () -> {
+            try {
+                assertFalse(guard.canInvoke(mbs, on, "doit"));
 
-                    return null;
-                } catch (Throwable th) {
-                    throw new RuntimeException(th);
-                }
+                return null;
+            } catch (Throwable th) {
+                throw new RuntimeException(th);
             }
         });
     }
@@ -1020,15 +994,13 @@ public class KarafMBeanServerGuardTest extends TestCase {
         guard.setConfigAdmin(ca);
 
         Subject subject = loginWithTestRoles("viewer");
-        Subject.doAs(subject, new PrivilegedAction<Void>() {
-            public Void run() {
-                try {
-                    assertTrue(guard.canInvoke(mbs, on, "getFoo"));
+        Subject.doAs(subject, (PrivilegedAction<Void>) () -> {
+            try {
+                assertTrue(guard.canInvoke(mbs, on, "getFoo"));
 
-                    return null;
-                } catch (Throwable th) {
-                    throw new RuntimeException(th);
-                }
+                return null;
+            } catch (Throwable th) {
+                throw new RuntimeException(th);
             }
         });
     }
@@ -1056,15 +1028,13 @@ public class KarafMBeanServerGuardTest extends TestCase {
         guard.setConfigAdmin(ca);
 
         Subject subject = loginWithTestRoles("viewer");
-        Subject.doAs(subject, new PrivilegedAction<Void>() {
-            public Void run() {
-                try {
-                    assertFalse(guard.canInvoke(mbs, on, "getFoo"));
+        Subject.doAs(subject, (PrivilegedAction<Void>) () -> {
+            try {
+                assertFalse(guard.canInvoke(mbs, on, "getFoo"));
 
-                    return null;
-                } catch (Throwable th) {
-                    throw new RuntimeException(th);
-                }
+                return null;
+            } catch (Throwable th) {
+                throw new RuntimeException(th);
             }
         });
     }
@@ -1093,15 +1063,13 @@ public class KarafMBeanServerGuardTest extends TestCase {
         guard.setConfigAdmin(ca);
 
         Subject subject = loginWithTestRoles("viewer");
-        Subject.doAs(subject, new PrivilegedAction<Void>() {
-            public Void run() {
-                try {
-                    assertTrue(guard.canInvoke(mbs, on, "isFoo"));
+        Subject.doAs(subject, (PrivilegedAction<Void>) () -> {
+            try {
+                assertTrue(guard.canInvoke(mbs, on, "isFoo"));
 
-                    return null;
-                } catch (Throwable th) {
-                    throw new RuntimeException(th);
-                }
+                return null;
+            } catch (Throwable th) {
+                throw new RuntimeException(th);
             }
         });
     }
@@ -1130,15 +1098,13 @@ public class KarafMBeanServerGuardTest extends TestCase {
         guard.setConfigAdmin(ca);
 
         Subject subject = loginWithTestRoles("viewer");
-        Subject.doAs(subject, new PrivilegedAction<Void>() {
-            public Void run() {
-                try {
-                    assertFalse(guard.canInvoke(mbs, on, "isFoo"));
+        Subject.doAs(subject, (PrivilegedAction<Void>) () -> {
+            try {
+                assertFalse(guard.canInvoke(mbs, on, "isFoo"));
 
-                    return null;
-                } catch (Throwable th) {
-                    throw new RuntimeException(th);
-                }
+                return null;
+            } catch (Throwable th) {
+                throw new RuntimeException(th);
             }
         });
     }
@@ -1166,15 +1132,13 @@ public class KarafMBeanServerGuardTest extends TestCase {
         guard.setConfigAdmin(ca);
 
         Subject subject = loginWithTestRoles("viewer");
-        Subject.doAs(subject, new PrivilegedAction<Void>() {
-            public Void run() {
-                try {
-                    assertTrue(guard.canInvoke(mbs, on, "setFoo"));
+        Subject.doAs(subject, (PrivilegedAction<Void>) () -> {
+            try {
+                assertTrue(guard.canInvoke(mbs, on, "setFoo"));
 
-                    return null;
-                } catch (Throwable th) {
-                    throw new RuntimeException(th);
-                }
+                return null;
+            } catch (Throwable th) {
+                throw new RuntimeException(th);
             }
         });
     }
@@ -1202,15 +1166,13 @@ public class KarafMBeanServerGuardTest extends TestCase {
         guard.setConfigAdmin(ca);
 
         Subject subject = loginWithTestRoles("viewer");
-        Subject.doAs(subject, new PrivilegedAction<Void>() {
-            public Void run() {
-                try {
-                    assertFalse(guard.canInvoke(mbs, on, "setFoo"));
+        Subject.doAs(subject, (PrivilegedAction<Void>) () -> {
+            try {
+                assertFalse(guard.canInvoke(mbs, on, "setFoo"));
 
-                    return null;
-                } catch (Throwable th) {
-                    throw new RuntimeException(th);
-                }
+                return null;
+            } catch (Throwable th) {
+                throw new RuntimeException(th);
             }
         });
     }
@@ -1240,15 +1202,13 @@ public class KarafMBeanServerGuardTest extends TestCase {
 
         Subject subject = loginWithTestRoles("viewer");
 
-        Subject.doAs(subject, new PrivilegedAction<Void>() {
-            public Void run() {
-                try {
-                    assertTrue(guard.canInvoke(mbs, on));
+        Subject.doAs(subject, (PrivilegedAction<Void>) () -> {
+            try {
+                assertTrue(guard.canInvoke(mbs, on));
 
-                    return null;
-                } catch (Throwable th) {
-                    throw new RuntimeException(th);
-                }
+                return null;
+            } catch (Throwable th) {
+                throw new RuntimeException(th);
             }
         });
     }
@@ -1278,15 +1238,13 @@ public class KarafMBeanServerGuardTest extends TestCase {
 
         Subject subject = loginWithTestRoles("viewer");
 
-        Subject.doAs(subject, new PrivilegedAction<Void>() {
-            public Void run() {
-                try {
-                    assertFalse(guard.canInvoke(mbs, on));
+        Subject.doAs(subject, (PrivilegedAction<Void>) () -> {
+            try {
+                assertFalse(guard.canInvoke(mbs, on));
 
-                    return null;
-                } catch (Throwable th) {
-                    throw new RuntimeException(th);
-                }
+                return null;
+            } catch (Throwable th) {
+                throw new RuntimeException(th);
             }
         });
     }
@@ -1316,15 +1274,13 @@ public class KarafMBeanServerGuardTest extends TestCase {
 
         Subject subject = loginWithTestRoles("viewer");
 
-        Subject.doAs(subject, new PrivilegedAction<Void>() {
-            public Void run() {
-                try {
-                    assertTrue(guard.canInvoke(mbs, on));
+        Subject.doAs(subject, (PrivilegedAction<Void>) () -> {
+            try {
+                assertTrue(guard.canInvoke(mbs, on));
 
-                    return null;
-                } catch (Throwable th) {
-                    throw new RuntimeException(th);
-                }
+                return null;
+            } catch (Throwable th) {
+                throw new RuntimeException(th);
             }
         });
     }
@@ -1354,15 +1310,13 @@ public class KarafMBeanServerGuardTest extends TestCase {
 
         Subject subject = loginWithTestRoles("viewer");
 
-        Subject.doAs(subject, new PrivilegedAction<Void>() {
-            public Void run() {
-                try {
-                    assertTrue(guard.canInvoke(mbs, on));
+        Subject.doAs(subject, (PrivilegedAction<Void>) () -> {
+            try {
+                assertTrue(guard.canInvoke(mbs, on));
 
-                    return null;
-                } catch (Throwable th) {
-                    throw new RuntimeException(th);
-                }
+                return null;
+            } catch (Throwable th) {
+                throw new RuntimeException(th);
             }
         });
     }
@@ -1392,15 +1346,13 @@ public class KarafMBeanServerGuardTest extends TestCase {
 
         Subject subject = loginWithTestRoles("viewer");
 
-        Subject.doAs(subject, new PrivilegedAction<Void>() {
-            public Void run() {
-                try {
-                    assertFalse(guard.canInvoke(mbs, on));
+        Subject.doAs(subject, (PrivilegedAction<Void>) () -> {
+            try {
+                assertFalse(guard.canInvoke(mbs, on));
 
-                    return null;
-                } catch (Throwable th) {
-                    throw new RuntimeException(th);
-                }
+                return null;
+            } catch (Throwable th) {
+                throw new RuntimeException(th);
             }
         });
     }
@@ -1422,20 +1374,18 @@ public class KarafMBeanServerGuardTest extends TestCase {
 
         Subject subject = loginWithTestRoles("viewer");
 
-        Subject.doAs(subject, new PrivilegedAction<Void>() {
-            public Void run() {
-                try {
-                    assertTrue(guard.canInvoke(null, on, "dodo", new String[]{"java.lang.String"}));
-                    assertTrue(guard.canInvoke(null, on, "doit", new String[]{"java.lang.String", "java.lang.String"}));
-                    assertTrue(guard.canInvoke(null, on, "doit", new String[]{"java.lang.String"}));
-                    assertFalse(guard.canInvoke(null, on, "doit", new String[]{"int"}));
-                    assertFalse(guard.canInvoke(null, on, "doit", new String[]{}));
-                    assertFalse(guard.canInvoke(null, on, "uuuh", new String[]{"java.lang.String"}));
-
-                    return null;
-                } catch (Throwable th) {
-                    throw new RuntimeException(th);
-                }
+        Subject.doAs(subject, (PrivilegedAction<Void>) () -> {
+            try {
+                assertTrue(guard.canInvoke(null, on, "dodo", new String[]{"java.lang.String"}));
+                assertTrue(guard.canInvoke(null, on, "doit", new String[]{"java.lang.String", "java.lang.String"}));
+                assertTrue(guard.canInvoke(null, on, "doit", new String[]{"java.lang.String"}));
+                assertFalse(guard.canInvoke(null, on, "doit", new String[]{"int"}));
+                assertFalse(guard.canInvoke(null, on, "doit", new String[]{}));
+                assertFalse(guard.canInvoke(null, on, "uuuh", new String[]{"java.lang.String"}));
+
+                return null;
+            } catch (Throwable th) {
+                throw new RuntimeException(th);
             }
         });
     }
@@ -1457,20 +1407,18 @@ public class KarafMBeanServerGuardTest extends TestCase {
 
         Subject subject = loginWithTestRoles("viewer");
 
-        Subject.doAs(subject, new PrivilegedAction<Void>() {
-            public Void run() {
-                try {
-                    assertTrue(guard.canInvoke(null, on, "doit", new String[]{"java.lang.String"}));
-                    assertTrue(guard.canInvoke(null, on, "doit", new String[]{}));
-                    assertTrue(guard.canInvoke(null, on, "doit", new String[]{"int"}));
-                    assertFalse(guard.canInvoke(null, on, "doit", new String[]{"java.lang.String", "java.lang.String"}));
-                    assertFalse(guard.canInvoke(null, on, "dodo", new String[]{"java.lang.String"}));
-                    assertFalse(guard.canInvoke(null, on, "uuuh", new String[]{"java.lang.String"}));
-
-                    return null;
-                } catch (Throwable th) {
-                    throw new RuntimeException(th);
-                }
+        Subject.doAs(subject, (PrivilegedAction<Void>) () -> {
+            try {
+                assertTrue(guard.canInvoke(null, on, "doit", new String[]{"java.lang.String"}));
+                assertTrue(guard.canInvoke(null, on, "doit", new String[]{}));
+                assertTrue(guard.canInvoke(null, on, "doit", new String[]{"int"}));
+                assertFalse(guard.canInvoke(null, on, "doit", new String[]{"java.lang.String", "java.lang.String"}));
+                assertFalse(guard.canInvoke(null, on, "dodo", new String[]{"java.lang.String"}));
+                assertFalse(guard.canInvoke(null, on, "uuuh", new String[]{"java.lang.String"}));
+
+                return null;
+            } catch (Throwable th) {
+                throw new RuntimeException(th);
             }
         });
     }

http://git-wip-us.apache.org/repos/asf/karaf/blob/bf666631/profile/src/main/java/org/apache/karaf/profile/impl/ProfileServiceImpl.java
----------------------------------------------------------------------
diff --git a/profile/src/main/java/org/apache/karaf/profile/impl/ProfileServiceImpl.java b/profile/src/main/java/org/apache/karaf/profile/impl/ProfileServiceImpl.java
index c83e29a..9b3b99b 100644
--- a/profile/src/main/java/org/apache/karaf/profile/impl/ProfileServiceImpl.java
+++ b/profile/src/main/java/org/apache/karaf/profile/impl/ProfileServiceImpl.java
@@ -71,12 +71,7 @@ public class ProfileServiceImpl implements ProfileService {
         } catch (InterruptedException ex) {
             throw new IllegalStateException(message, ex);
         }
-        return new LockHandle() {
-            @Override
-            public void close() {
-                lock.unlock();
-            }
-        };
+        return lock::unlock;
     }
 
     protected ReadWriteLock getLock() {

http://git-wip-us.apache.org/repos/asf/karaf/blob/bf666631/service/guard/src/main/java/org/apache/karaf/service/guard/impl/GuardProxyCatalog.java
----------------------------------------------------------------------
diff --git a/service/guard/src/main/java/org/apache/karaf/service/guard/impl/GuardProxyCatalog.java b/service/guard/src/main/java/org/apache/karaf/service/guard/impl/GuardProxyCatalog.java
index 4dbb1a8..3be00bc 100644
--- a/service/guard/src/main/java/org/apache/karaf/service/guard/impl/GuardProxyCatalog.java
+++ b/service/guard/src/main/java/org/apache/karaf/service/guard/impl/GuardProxyCatalog.java
@@ -548,28 +548,25 @@ public class GuardProxyCatalog implements ServiceListener {
         }
 
         private Thread newProxyProducingThread(final ProxyManager proxyManager) {
-            Thread t = new Thread(new Runnable() {
-                @Override
-                public void run() {
-                    while (runProxyCreator) {
-                        CreateProxyRunnable proxyCreator = null;
-                        try {
-                            proxyCreator = createProxyQueue.take(); // take waits until there is something on the queue
-                        } catch (InterruptedException ie) {
-                            // part of normal behaviour
-                        }
+            Thread t = new Thread(() -> {
+                while (runProxyCreator) {
+                    CreateProxyRunnable proxyCreator = null;
+                    try {
+                        proxyCreator = createProxyQueue.take(); // take waits until there is something on the queue
+                    } catch (InterruptedException ie) {
+                        // part of normal behaviour
+                    }
 
-                        if (proxyCreator != null) {
-                            try {
-                                proxyCreator.run(proxyManager);
-                            } catch (Exception e) {
-                                LOG.warn("Problem creating secured service proxy", e);
-                            }
+                    if (proxyCreator != null) {
+                        try {
+                            proxyCreator.run(proxyManager);
+                        } catch (Exception e) {
+                            LOG.warn("Problem creating secured service proxy", e);
                         }
                     }
-                    // finished running
-                    proxyCreatorThread = null;
                 }
+                // finished running
+                proxyCreatorThread = null;
             });
             t.setName(PROXY_CREATOR_THREAD_NAME);
             t.setDaemon(true);

http://git-wip-us.apache.org/repos/asf/karaf/blob/bf666631/service/guard/src/main/java/org/apache/karaf/service/guard/tools/ACLConfigurationParser.java
----------------------------------------------------------------------
diff --git a/service/guard/src/main/java/org/apache/karaf/service/guard/tools/ACLConfigurationParser.java b/service/guard/src/main/java/org/apache/karaf/service/guard/tools/ACLConfigurationParser.java
index 2bf6f03..626a4d4 100644
--- a/service/guard/src/main/java/org/apache/karaf/service/guard/tools/ACLConfigurationParser.java
+++ b/service/guard/src/main/java/org/apache/karaf/service/guard/tools/ACLConfigurationParser.java
@@ -281,11 +281,9 @@ public class ACLConfigurationParser {
     }
 
     private static List<String> getMethodNameWildcardRoles(Dictionary<String, Object> properties, String methodName) {
-        SortedMap<String, String> wildcardRules = new TreeMap<>(new Comparator<String>() {
-            public int compare(String s1, String s2) {
-                // returns longer entries before shorter ones...
-                return s2.length() - s1.length();
-            }
+        SortedMap<String, String> wildcardRules = new TreeMap<>((s1, s2) -> {
+            // returns longer entries before shorter ones...
+            return s2.length() - s1.length();
         });
         
         for (Enumeration<String> e = properties.keys(); e.hasMoreElements(); ) {

http://git-wip-us.apache.org/repos/asf/karaf/blob/bf666631/service/guard/src/test/java/org/apache/karaf/service/guard/impl/ActivatorTest.java
----------------------------------------------------------------------
diff --git a/service/guard/src/test/java/org/apache/karaf/service/guard/impl/ActivatorTest.java b/service/guard/src/test/java/org/apache/karaf/service/guard/impl/ActivatorTest.java
index 9670eb3..f81a235 100644
--- a/service/guard/src/test/java/org/apache/karaf/service/guard/impl/ActivatorTest.java
+++ b/service/guard/src/test/java/org/apache/karaf/service/guard/impl/ActivatorTest.java
@@ -20,11 +20,9 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 
 import org.easymock.EasyMock;
-import org.easymock.IAnswer;
 import org.junit.Test;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.Filter;
 import org.osgi.framework.FrameworkUtil;
 import org.osgi.framework.hooks.service.EventListenerHook;
 import org.osgi.framework.hooks.service.FindHook;
@@ -50,12 +48,8 @@ public class ActivatorTest {
 
             BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
             EasyMock.expect(bc.getBundle()).andReturn(b).anyTimes();
-            EasyMock.expect(bc.createFilter(EasyMock.anyObject(String.class))).andAnswer(new IAnswer<Filter>() {
-                @Override
-                public Filter answer() throws Throwable {
-                    return FrameworkUtil.createFilter((String) EasyMock.getCurrentArguments()[0]);
-                }
-            }).anyTimes();
+            EasyMock.expect(bc.createFilter(EasyMock.anyObject(String.class))).andAnswer(
+                    () -> FrameworkUtil.createFilter((String) EasyMock.getCurrentArguments()[0])).anyTimes();
 
             EasyMock.expect(bc.registerService(
                     EasyMock.eq(EventListenerHook.class), EasyMock.isA(EventListenerHook.class), EasyMock.isNull(Dictionary.class)))

http://git-wip-us.apache.org/repos/asf/karaf/blob/bf666631/service/guard/src/test/java/org/apache/karaf/service/guard/impl/GuardProxyCatalogTest.java
----------------------------------------------------------------------
diff --git a/service/guard/src/test/java/org/apache/karaf/service/guard/impl/GuardProxyCatalogTest.java b/service/guard/src/test/java/org/apache/karaf/service/guard/impl/GuardProxyCatalogTest.java
index 9045ec9..c1dfd34 100644
--- a/service/guard/src/test/java/org/apache/karaf/service/guard/impl/GuardProxyCatalogTest.java
+++ b/service/guard/src/test/java/org/apache/karaf/service/guard/impl/GuardProxyCatalogTest.java
@@ -227,12 +227,7 @@ public class GuardProxyCatalogTest {
         testCreateProxy(Object.class, new TestObjectWithoutInterface());
         testCreateProxy(Object.class, new CombinedTestService());
         testCreateProxy(Object.class, new FinalTestService());
-        testCreateProxy(TestServiceAPI.class, new TestServiceAPI() {
-            @Override
-            public String doit() {
-                return "Doing it";
-            }
-        });
+        testCreateProxy(TestServiceAPI.class, (TestServiceAPI) () -> "Doing it");
         testCreateProxy(Object.class, new ClassWithFinalMethod());
         testCreateProxy(Object.class, new ClassWithPrivateMethod());
     }
@@ -343,21 +338,18 @@ public class GuardProxyCatalogTest {
         // Run with the right credentials so we can test the expected roles
         Subject subject = new Subject();
         subject.getPrincipals().add(new RolePrincipal("b"));
-        Subject.doAs(subject, new PrivilegedAction<Object>() {
-            @Override
-            public Object run() {
-                assertEquals("Doing it", ((TestServiceAPI) proxy).doit());
-                if (!runningUnderCoverage) {
-                    try {
-                        ((TestObjectWithoutInterface) proxy).compute(44L);
-                        fail("Should have been blocked");
-                    } catch (SecurityException se) {
-                        // good
-                    }
+        Subject.doAs(subject, (PrivilegedAction<Object>) () -> {
+            assertEquals("Doing it", ((TestServiceAPI) proxy).doit());
+            if (!runningUnderCoverage) {
+                try {
+                    ((TestObjectWithoutInterface) proxy).compute(44L);
+                    fail("Should have been blocked");
+                } catch (SecurityException se) {
+                    // good
                 }
-
-                return null;
             }
+
+            return null;
         });
     }
 
@@ -377,21 +369,18 @@ public class GuardProxyCatalogTest {
         // Run with the right credentials so we can test the expected roles
         Subject subject = new Subject();
         subject.getPrincipals().add(new RolePrincipal("b"));
-        Subject.doAs(subject, new PrivilegedAction<Object>() {
-            @Override
-            public Object run() {
-                if (!runningUnderCoverage) {
-                    assertEquals(-42L, ((TestObjectWithoutInterface) proxy).compute(42L));
-                    try {
-                        ((TestObjectWithoutInterface) proxy).compute(44L);
-                        fail("Should have been blocked");
-                    } catch (SecurityException se) {
-                        // good
-                    }
+        Subject.doAs(subject, (PrivilegedAction<Object>) () -> {
+            if (!runningUnderCoverage) {
+                assertEquals(-42L, ((TestObjectWithoutInterface) proxy).compute(42L));
+                try {
+                    ((TestObjectWithoutInterface) proxy).compute(44L);
+                    fail("Should have been blocked");
+                } catch (SecurityException se) {
+                    // good
                 }
-
-                return null;
             }
+
+            return null;
         });
     }
 
@@ -425,35 +414,29 @@ public class GuardProxyCatalogTest {
         // Run with the right credentials so we can test the expected roles
         Subject subject = new Subject();
         subject.getPrincipals().add(new RolePrincipal("c"));
-        Subject.doAs(subject, new PrivilegedAction<Object>() {
-            @Override
-            public Object run() {
-                assertEquals("Doing it", ((TestServiceAPI) proxy).doit());
-                return null;
-            }
+        Subject.doAs(subject, (PrivilegedAction<Object>) () -> {
+            assertEquals("Doing it", ((TestServiceAPI) proxy).doit());
+            return null;
         });
 
         Subject subject2 = new Subject();
         subject2.getPrincipals().add(new RolePrincipal("b"));
         subject2.getPrincipals().add(new RolePrincipal("f"));
-        Subject.doAs(subject2, new PrivilegedAction<Object>() {
-            @Override
-            public Object run() {
-                try {
-                    assertEquals("Doing it", ((TestServiceAPI) proxy).doit());
-                    fail("Should have been blocked");
-                } catch (SecurityException se) {
-                    // good
-                }
-                assertEquals("aaT", ((TestServiceAPI2) proxy).doit("Taa"));
-                try {
-                    ((TestServiceAPI2) proxy).doit("t");
-                    fail("Should have been blocked");
-                } catch (SecurityException se) {
-                    // good
-                }
-                return null;
+        Subject.doAs(subject2, (PrivilegedAction<Object>) () -> {
+            try {
+                assertEquals("Doing it", ((TestServiceAPI) proxy).doit());
+                fail("Should have been blocked");
+            } catch (SecurityException se) {
+                // good
             }
+            assertEquals("aaT", ((TestServiceAPI2) proxy).doit("Taa"));
+            try {
+                ((TestServiceAPI2) proxy).doit("t");
+                fail("Should have been blocked");
+            } catch (SecurityException se) {
+                // good
+            }
+            return null;
         });
     }
 
@@ -467,17 +450,14 @@ public class GuardProxyCatalogTest {
         // Run with the right credentials so we can test the expected roles
         Subject subject = new Subject();
         subject.getPrincipals().add(new RolePrincipal("b"));
-        Subject.doAs(subject, new PrivilegedAction<Object>() {
-            @Override
-            public Object run() {
-                assertEquals("Doing it", ((TestServiceAPI) proxy).doit());
-                if (!runningUnderCoverage) {
-                    assertEquals(42L, ((TestObjectWithoutInterface) proxy).compute(-42L));
-                    assertEquals(-44L, ((TestObjectWithoutInterface) proxy).compute(44L));
-                }
-
-                return null;
+        Subject.doAs(subject, (PrivilegedAction<Object>) () -> {
+            assertEquals("Doing it", ((TestServiceAPI) proxy).doit());
+            if (!runningUnderCoverage) {
+                assertEquals(42L, ((TestObjectWithoutInterface) proxy).compute(-42L));
+                assertEquals(-44L, ((TestObjectWithoutInterface) proxy).compute(44L));
             }
+
+            return null;
         });
     }
 
@@ -492,23 +472,16 @@ public class GuardProxyCatalogTest {
 
         BundleContext bc = mockConfigAdminBundleContext(c1);
 
-        final Object proxy = testCreateProxy(bc, new Class [] {TestServiceAPI2.class}, new TestServiceAPI2() {
-            @Override
-            public String doit(String s) {
-                return s.toUpperCase();
-            }
-        });
+        final Object proxy = testCreateProxy(bc, new Class [] {TestServiceAPI2.class},
+                (TestServiceAPI2) String::toUpperCase);
 
         // Invoke the service with role 'c'.
         Subject subject = new Subject();
         subject.getPrincipals().add(new RolePrincipal("c"));
-        Subject.doAs(subject, new PrivilegedAction<Object>() {
-            @Override
-            public Object run() {
-                assertEquals("The invocation under role 'c' should be ok, as there are no rules specified "
-                        + "for this service at all.", "HELLO", ((TestServiceAPI2) proxy).doit("hello"));
-                return null;
-            }
+        Subject.doAs(subject, (PrivilegedAction<Object>) () -> {
+            assertEquals("The invocation under role 'c' should be ok, as there are no rules specified "
+                    + "for this service at all.", "HELLO", ((TestServiceAPI2) proxy).doit("hello"));
+            return null;
         });
     }
 
@@ -526,29 +499,22 @@ public class GuardProxyCatalogTest {
 
         BundleContext bc = mockConfigAdminBundleContext(c1, c2);
 
-        final Object proxy = testCreateProxy(bc, new Class [] {TestServiceAPI2.class}, new TestServiceAPI2() {
-            @Override
-            public String doit(String s) {
-                return s.toUpperCase();
-            }
-        });
+        final Object proxy = testCreateProxy(bc, new Class [] {TestServiceAPI2.class},
+                (TestServiceAPI2) String::toUpperCase);
 
         // Invoke the service with role 'c'.
         Subject subject = new Subject();
         subject.getPrincipals().add(new RolePrincipal("a"));
         subject.getPrincipals().add(new RolePrincipal("b"));
         subject.getPrincipals().add(new RolePrincipal("c"));
-        Subject.doAs(subject, new PrivilegedAction<Object>() {
-            @Override
-            public Object run() {
-                try {
-                    ((TestServiceAPI2) proxy).doit("hello");
-                    fail("The invocation should not process as the 'doit' operation has no roles associated with it");
-                } catch (SecurityException se) {
-                    // good
-                }
-                return null;
+        Subject.doAs(subject, (PrivilegedAction<Object>) () -> {
+            try {
+                ((TestServiceAPI2) proxy).doit("hello");
+                fail("The invocation should not process as the 'doit' operation has no roles associated with it");
+            } catch (SecurityException se) {
+                // good
             }
+            return null;
         });
     }
 
@@ -567,41 +533,35 @@ public class GuardProxyCatalogTest {
         final Object proxy = testCreateProxy(bc, new Class [] {TestServiceAPI3.class}, new TestService3());
 
         Subject s1 = new Subject();
-        Subject.doAs(s1, new PrivilegedAction<Object>() {
-            @Override
-            public Object run() {
-                TestServiceAPI3 obj = (TestServiceAPI3) proxy;
-                assertEquals("Should have allowed this invocation for any (or no) role", -7, obj.foo(7));
-                try {
-                    obj.foo();
-                    fail("Should have been blocked");
-                } catch (SecurityException se) {
-                    // good
-                }
-                try {
-                    obj.bar();
-                    fail("Should have been blocked");
-                } catch (SecurityException se) {
-                    // good
-                }
-
-                return null;
+        Subject.doAs(s1, (PrivilegedAction<Object>) () -> {
+            TestServiceAPI3 obj = (TestServiceAPI3) proxy;
+            assertEquals("Should have allowed this invocation for any (or no) role", -7, obj.foo(7));
+            try {
+                obj.foo();
+                fail("Should have been blocked");
+            } catch (SecurityException se) {
+                // good
+            }
+            try {
+                obj.bar();
+                fail("Should have been blocked");
+            } catch (SecurityException se) {
+                // good
             }
+
+            return null;
         });
 
         Subject s2 = new Subject();
         s2.getPrincipals().add(new RolePrincipal("a"));
         s2.getPrincipals().add(new RolePrincipal("b"));
         s2.getPrincipals().add(new RolePrincipal("d"));
-        Subject.doAs(s2, new PrivilegedAction<Object>() {
-            @Override
-            public Object run() {
-                TestServiceAPI3 obj = (TestServiceAPI3) proxy;
-                assertEquals(42, obj.foo());
-                assertEquals(99, obj.bar());
-                assertEquals(-32767, obj.foo(32767));
-                return null;
-            }
+        Subject.doAs(s2, (PrivilegedAction<Object>) () -> {
+            TestServiceAPI3 obj = (TestServiceAPI3) proxy;
+            assertEquals(42, obj.foo());
+            assertEquals(99, obj.bar());
+            assertEquals(-32767, obj.foo(32767));
+            return null;
         });
     }
 
@@ -625,39 +585,30 @@ public class GuardProxyCatalogTest {
 
         Subject s1 = new Subject();
         s1.getPrincipals().add(new RolePrincipal("role1"));
-        Subject.doAs(s1, new PrivilegedAction<Object>() {
-            @Override
-            public Object run() {
-                try {
-                    ((TestServiceAPI) proxy).doit();
-                    fail("Should have prevented this invocation as the custom role is required");
-                } catch (SecurityException se) {
-                    // good
-                }
-                return null;
+        Subject.doAs(s1, (PrivilegedAction<Object>) () -> {
+            try {
+                ((TestServiceAPI) proxy).doit();
+                fail("Should have prevented this invocation as the custom role is required");
+            } catch (SecurityException se) {
+                // good
             }
+            return null;
         });
 
 
         Subject s2 = new Subject();
         s2.getPrincipals().add(new MyRolePrincipal());
-        Subject.doAs(s2, new PrivilegedAction<Object>() {
-            @Override
-            public Object run() {
-                ((TestServiceAPI) proxy).doit(); // Should work, the custom role is there
-                return null;
-            }
+        Subject.doAs(s2, (PrivilegedAction<Object>) () -> {
+            ((TestServiceAPI) proxy).doit(); // Should work, the custom role is there
+            return null;
         });
 
         Subject s3 = new Subject();
         s3.getPrincipals().add(new MyRolePrincipal());
         s3.getPrincipals().add(new RolePrincipal("role1"));
-        Subject.doAs(s3, new PrivilegedAction<Object>() {
-            @Override
-            public Object run() {
-                ((TestServiceAPI) proxy).doit(); // Should work, the custom role is there
-                return null;
-            }
+        Subject.doAs(s3, (PrivilegedAction<Object>) () -> {
+            ((TestServiceAPI) proxy).doit(); // Should work, the custom role is there
+            return null;
         });
     }
 
@@ -683,22 +634,15 @@ public class GuardProxyCatalogTest {
 
         BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
         EasyMock.expect(bc.getBundle()).andReturn(b).anyTimes();
-        EasyMock.expect(bc.createFilter(EasyMock.isA(String.class))).andAnswer(new IAnswer<Filter>() {
-            @Override
-            public Filter answer() throws Throwable {
-                return FrameworkUtil.createFilter((String) EasyMock.getCurrentArguments()[0]);
-            }
-        }).anyTimes();
+        EasyMock.expect(bc.createFilter(EasyMock.isA(String.class))).andAnswer(
+                () -> FrameworkUtil.createFilter((String) EasyMock.getCurrentArguments()[0])).anyTimes();
         final ServiceListener [] pmListenerHolder = new ServiceListener [1];
         String pmFilter = "(&(objectClass=" + ProxyManager.class.getName() + ")" +
                 "(!(" + GuardProxyCatalog.PROXY_SERVICE_KEY + "=*)))";
         bc.addServiceListener(EasyMock.isA(ServiceListener.class), EasyMock.eq(pmFilter));
-        EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
-            @Override
-            public Object answer() throws Throwable {
-                pmListenerHolder[0] = (ServiceListener) EasyMock.getCurrentArguments()[0];
-                return null;
-            }
+        EasyMock.expectLastCall().andAnswer(() -> {
+            pmListenerHolder[0] = (ServiceListener) EasyMock.getCurrentArguments()[0];
+            return null;
         }).anyTimes();
         EasyMock.expect(bc.getServiceReferences(EasyMock.anyObject(String.class),
                 EasyMock.contains(ConfigurationAdmin.class.getName()))).andReturn(new ServiceReference[] {cmSref}).anyTimes();
@@ -725,28 +669,21 @@ public class GuardProxyCatalogTest {
         EasyMock.expect(providerBC.registerService(
                 EasyMock.isA(String[].class),
                 EasyMock.anyObject(),
-                EasyMock.isA(Dictionary.class))).andAnswer(new IAnswer() {
-            @Override
-            public ServiceRegistration answer() throws Throwable {
-                Dictionary<String,Object> props = (Dictionary<String, Object>) EasyMock.getCurrentArguments()[2];
-                ServiceRegistration reg = EasyMock.createMock(ServiceRegistration.class);
-                ServiceReference sr = mockServiceReference(props);
-                EasyMock.expect(reg.getReference()).andReturn(sr).anyTimes();
-                reg.unregister();
-                EasyMock.expectLastCall().once();
-                EasyMock.replay(reg);
-
-                serviceMap.put(sr, EasyMock.getCurrentArguments()[1]);
-
-                return reg;
-            }
-        }).once();
-        EasyMock.expect(providerBC.getService(EasyMock.isA(ServiceReference.class))).andAnswer(new IAnswer<Object>() {
-            @Override
-            public Object answer() throws Throwable {
-                return serviceMap.get(EasyMock.getCurrentArguments()[0]);
-            }
-        }).anyTimes();
+                EasyMock.isA(Dictionary.class))).andAnswer((IAnswer) () -> {
+                    Dictionary<String,Object> props = (Dictionary<String, Object>) EasyMock.getCurrentArguments()[2];
+                    ServiceRegistration reg = EasyMock.createMock(ServiceRegistration.class);
+                    ServiceReference sr = mockServiceReference(props);
+                    EasyMock.expect(reg.getReference()).andReturn(sr).anyTimes();
+                    reg.unregister();
+                    EasyMock.expectLastCall().once();
+                    EasyMock.replay(reg);
+
+                    serviceMap.put(sr, EasyMock.getCurrentArguments()[1]);
+
+                    return reg;
+                }).once();
+        EasyMock.expect(providerBC.getService(EasyMock.isA(ServiceReference.class))).andAnswer(
+                () -> serviceMap.get(EasyMock.getCurrentArguments()[0])).anyTimes();
         EasyMock.replay(providerBC);
 
         // In some cases the proxy-creating code is looking for a classloader (e.g. when run through
@@ -858,19 +795,15 @@ public class GuardProxyCatalogTest {
         EasyMock.expect(providerBC.registerService(
                 EasyMock.aryEq(new String [] {TestServiceAPI.class.getName(), TestServiceAPI2.class.getName()}),
                 EasyMock.anyObject(),
-                EasyMock.anyObject(Dictionary.class))).andAnswer(new IAnswer() {
-            @Override
-            public Object answer() throws Throwable {
-                final Dictionary props = (Dictionary) EasyMock.getCurrentArguments()[2];
-                assertEquals(Boolean.TRUE, props.get(GuardProxyCatalog.PROXY_SERVICE_KEY));
-
-                ServiceRegistration reg = EasyMock.createMock(ServiceRegistration.class);
-                ServiceReference sr = mockServiceReference(props);
-                EasyMock.expect(reg.getReference()).andReturn(sr).anyTimes();
-                reg.setProperties(EasyMock.isA(Dictionary.class));
-                EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
-                    @Override
-                    public Object answer() throws Throwable {
+                EasyMock.anyObject(Dictionary.class))).andAnswer((IAnswer) () -> {
+                    final Dictionary props = (Dictionary) EasyMock.getCurrentArguments()[2];
+                    assertEquals(Boolean.TRUE, props.get(GuardProxyCatalog.PROXY_SERVICE_KEY));
+
+                    ServiceRegistration reg = EasyMock.createMock(ServiceRegistration.class);
+                    ServiceReference sr = mockServiceReference(props);
+                    EasyMock.expect(reg.getReference()).andReturn(sr).anyTimes();
+                    reg.setProperties(EasyMock.isA(Dictionary.class));
+                    EasyMock.expectLastCall().andAnswer(() -> {
                         // Push the update into the service reference
                         ArrayList<String> oldKeys = Collections.list(props.keys());
                         for (String key : oldKeys) {
@@ -881,13 +814,11 @@ public class GuardProxyCatalogTest {
                             props.put(key, newProps.get(key));
                         }
                         return null;
-                    }
-                }).once();
-                EasyMock.replay(reg);
+                    }).once();
+                    EasyMock.replay(reg);
 
-                return reg;
-            }
-        }).anyTimes();
+                    return reg;
+                }).anyTimes();
 
         EasyMock.replay(providerBC);
 
@@ -956,19 +887,15 @@ public class GuardProxyCatalogTest {
         EasyMock.expect(providerBC.registerService(
                 EasyMock.aryEq(new String [] {TestServiceAPI.class.getName()}),
                 EasyMock.anyObject(),
-                EasyMock.anyObject(Dictionary.class))).andAnswer(new IAnswer() {
-            @Override
-            public Object answer() throws Throwable {
-                final Dictionary props = (Dictionary) EasyMock.getCurrentArguments()[2];
-                assertEquals(Boolean.TRUE, props.get(GuardProxyCatalog.PROXY_SERVICE_KEY));
-
-                ServiceRegistration reg = EasyMock.createMock(ServiceRegistration.class);
-                ServiceReference sr = mockServiceReference(props);
-                EasyMock.expect(reg.getReference()).andReturn(sr).anyTimes();
-                reg.setProperties(EasyMock.isA(Dictionary.class));
-                EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
-                    @Override
-                    public Object answer() throws Throwable {
+                EasyMock.anyObject(Dictionary.class))).andAnswer((IAnswer) () -> {
+                    final Dictionary props = (Dictionary) EasyMock.getCurrentArguments()[2];
+                    assertEquals(Boolean.TRUE, props.get(GuardProxyCatalog.PROXY_SERVICE_KEY));
+
+                    ServiceRegistration reg = EasyMock.createMock(ServiceRegistration.class);
+                    ServiceReference sr = mockServiceReference(props);
+                    EasyMock.expect(reg.getReference()).andReturn(sr).anyTimes();
+                    reg.setProperties(EasyMock.isA(Dictionary.class));
+                    EasyMock.expectLastCall().andAnswer(() -> {
                         // Push the update into the service reference
                         ArrayList<String> oldKeys = Collections.list(props.keys());
                         for (String key : oldKeys) {
@@ -979,13 +906,11 @@ public class GuardProxyCatalogTest {
                             props.put(key, newProps.get(key));
                         }
                         return null;
-                    }
-                }).once();
-                EasyMock.replay(reg);
+                    }).once();
+                    EasyMock.replay(reg);
 
-                return reg;
-            }
-        }).anyTimes();
+                    return reg;
+                }).anyTimes();
 
         EasyMock.replay(providerBC);
 
@@ -1050,26 +975,19 @@ public class GuardProxyCatalogTest {
         EasyMock.expect(providerBC.registerService(
                 EasyMock.isA(String[].class),
                 EasyMock.anyObject(),
-                EasyMock.isA(Dictionary.class))).andAnswer(new IAnswer() {
-            @Override
-            public ServiceRegistration answer() throws Throwable {
-                Dictionary<String,Object> props = (Dictionary<String, Object>) EasyMock.getCurrentArguments()[2];
-                ServiceRegistration reg = EasyMock.createMock(ServiceRegistration.class);
-                ServiceReference sr = mockServiceReference(props);
-                EasyMock.expect(reg.getReference()).andReturn(sr).anyTimes();
-                EasyMock.replay(reg);
+                EasyMock.isA(Dictionary.class))).andAnswer((IAnswer) () -> {
+                    Dictionary<String,Object> props = (Dictionary<String, Object>) EasyMock.getCurrentArguments()[2];
+                    ServiceRegistration reg = EasyMock.createMock(ServiceRegistration.class);
+                    ServiceReference sr = mockServiceReference(props);
+                    EasyMock.expect(reg.getReference()).andReturn(sr).anyTimes();
+                    EasyMock.replay(reg);
 
-                serviceMap.put(sr, EasyMock.getCurrentArguments()[1]);
+                    serviceMap.put(sr, EasyMock.getCurrentArguments()[1]);
 
-                return reg;
-            }
-        }).once();
-        EasyMock.expect(providerBC.getService(EasyMock.isA(ServiceReference.class))).andAnswer(new IAnswer<Object>() {
-            @Override
-            public Object answer() throws Throwable {
-                return serviceMap.get(EasyMock.getCurrentArguments()[0]);
-            }
-        }).anyTimes();
+                    return reg;
+                }).once();
+        EasyMock.expect(providerBC.getService(EasyMock.isA(ServiceReference.class))).andAnswer(
+                () -> serviceMap.get(EasyMock.getCurrentArguments()[0])).anyTimes();
         EasyMock.replay(providerBC);
 
         // In some cases the proxy-creating code is looking for a classloader (e.g. when run through
@@ -1161,41 +1079,34 @@ public class GuardProxyCatalogTest {
         EasyMock.expect(providerBC.registerService(
                 EasyMock.isA(String[].class),
                 EasyMock.anyObject(),
-                EasyMock.isA(Dictionary.class))).andAnswer(new IAnswer() {
-            @Override
-            public ServiceRegistration answer() throws Throwable {
-                if (!runningUnderCoverage) {
-                    // Some of these checks don't work when running under coverage
-                    assertArrayEquals(new String [] {proxyRegClass.getName()},
-                            (String []) EasyMock.getCurrentArguments()[0]);
-
-                    Object svc = EasyMock.getCurrentArguments()[1];
-                    assertTrue(svc instanceof ServiceFactory);
-                }
+                EasyMock.isA(Dictionary.class))).andAnswer((IAnswer) () -> {
+                    if (!runningUnderCoverage) {
+                        // Some of these checks don't work when running under coverage
+                        assertArrayEquals(new String [] {proxyRegClass.getName()},
+                                (String []) EasyMock.getCurrentArguments()[0]);
+
+                        Object svc = EasyMock.getCurrentArguments()[1];
+                        assertTrue(svc instanceof ServiceFactory);
+                    }
 
-                Dictionary<String,Object> props = (Dictionary<String, Object>) EasyMock.getCurrentArguments()[2];
-                for (String key : expectedProxyProps.keySet()) {
-                    assertEquals(expectedProxyProps.get(key), props.get(key));
-                }
+                    Dictionary<String,Object> props = (Dictionary<String, Object>) EasyMock.getCurrentArguments()[2];
+                    for (String key : expectedProxyProps.keySet()) {
+                        assertEquals(expectedProxyProps.get(key), props.get(key));
+                    }
 
-                ServiceRegistration reg = EasyMock.createMock(ServiceRegistration.class);
-                ServiceReference sr = mockServiceReference(props);
-                EasyMock.expect(reg.getReference()).andReturn(sr).anyTimes();
-                reg.unregister();
-                EasyMock.expectLastCall().once();
-                EasyMock.replay(reg);
+                    ServiceRegistration reg = EasyMock.createMock(ServiceRegistration.class);
+                    ServiceReference sr = mockServiceReference(props);
+                    EasyMock.expect(reg.getReference()).andReturn(sr).anyTimes();
+                    reg.unregister();
+                    EasyMock.expectLastCall().once();
+                    EasyMock.replay(reg);
 
-                serviceMap.put(sr, EasyMock.getCurrentArguments()[1]);
+                    serviceMap.put(sr, EasyMock.getCurrentArguments()[1]);
 
-                return reg;
-            }
-        }).once();
-        EasyMock.expect(providerBC.getService(EasyMock.isA(ServiceReference.class))).andAnswer(new IAnswer<Object>() {
-            @Override
-            public Object answer() throws Throwable {
-                return serviceMap.get(EasyMock.getCurrentArguments()[0]);
-            }
-        }).anyTimes();
+                    return reg;
+                }).once();
+        EasyMock.expect(providerBC.getService(EasyMock.isA(ServiceReference.class))).andAnswer(
+                () -> serviceMap.get(EasyMock.getCurrentArguments()[0])).anyTimes();
         EasyMock.replay(providerBC);
 
         // In some cases the proxy-creating code is looking for a classloader (e.g. when run through
@@ -1305,46 +1216,39 @@ public class GuardProxyCatalogTest {
         EasyMock.expect(providerBC.registerService(
                 EasyMock.isA(String[].class),
                 EasyMock.anyObject(),
-                EasyMock.isA(Dictionary.class))).andAnswer(new IAnswer() {
-            @Override
-            public ServiceRegistration answer() throws Throwable {
-                if (!runningUnderCoverage) {
-                    // Some of these checks don't work when running under coverage
-                    assertArrayEquals(proxyRegClsMap.keySet().toArray(new String [] {}),
-                            (String []) EasyMock.getCurrentArguments()[0]);
-
-                    Object svc = EasyMock.getCurrentArguments()[1];
-                    assertTrue(svc instanceof ServiceFactory);
-                }
+                EasyMock.isA(Dictionary.class))).andAnswer((IAnswer) () -> {
+                    if (!runningUnderCoverage) {
+                        // Some of these checks don't work when running under coverage
+                        assertArrayEquals(proxyRegClsMap.keySet().toArray(new String [] {}),
+                                (String []) EasyMock.getCurrentArguments()[0]);
+
+                        Object svc = EasyMock.getCurrentArguments()[1];
+                        assertTrue(svc instanceof ServiceFactory);
+                    }
 
-                Dictionary<String,Object> props = (Dictionary<String, Object>) EasyMock.getCurrentArguments()[2];
-                for (String key : expectedProxyProps.keySet()) {
-                    if (GuardProxyCatalog.SERVICE_GUARD_ROLES_PROPERTY.equals(key)) {
-                        assertTrue("The roles property should have been overwritten",
-                                !Arrays.asList("everyone").equals(props.get(key)));
-                    } else {
-                        assertEquals(expectedProxyProps.get(key), props.get(key));
+                    Dictionary<String,Object> props = (Dictionary<String, Object>) EasyMock.getCurrentArguments()[2];
+                    for (String key : expectedProxyProps.keySet()) {
+                        if (GuardProxyCatalog.SERVICE_GUARD_ROLES_PROPERTY.equals(key)) {
+                            assertTrue("The roles property should have been overwritten",
+                                    !Arrays.asList("everyone").equals(props.get(key)));
+                        } else {
+                            assertEquals(expectedProxyProps.get(key), props.get(key));
+                        }
                     }
-                }
 
-                ServiceRegistration reg = EasyMock.createMock(ServiceRegistration.class);
-                ServiceReference sr = mockServiceReference(props);
-                EasyMock.expect(reg.getReference()).andReturn(sr).anyTimes();
-                reg.unregister();
-                EasyMock.expectLastCall().once();
-                EasyMock.replay(reg);
+                    ServiceRegistration reg = EasyMock.createMock(ServiceRegistration.class);
+                    ServiceReference sr = mockServiceReference(props);
+                    EasyMock.expect(reg.getReference()).andReturn(sr).anyTimes();
+                    reg.unregister();
+                    EasyMock.expectLastCall().once();
+                    EasyMock.replay(reg);
 
-                serviceMap.put(sr, EasyMock.getCurrentArguments()[1]);
+                    serviceMap.put(sr, EasyMock.getCurrentArguments()[1]);
 
-                return reg;
-            }
-        }).once();
-        EasyMock.expect(providerBC.getService(EasyMock.isA(ServiceReference.class))).andAnswer(new IAnswer<Object>() {
-            @Override
-            public Object answer() throws Throwable {
-                return serviceMap.get(EasyMock.getCurrentArguments()[0]);
-            }
-        }).anyTimes();
+                    return reg;
+                }).once();
+        EasyMock.expect(providerBC.getService(EasyMock.isA(ServiceReference.class))).andAnswer(
+                () -> serviceMap.get(EasyMock.getCurrentArguments()[0])).anyTimes();
         EasyMock.replay(providerBC);
 
         // In some cases the proxy-creating code is looking for a classloader (e.g. when run through
@@ -1370,12 +1274,8 @@ public class GuardProxyCatalogTest {
         Bundle clientBundle = EasyMock.createNiceMock(Bundle.class);
         EasyMock.expect(clientBundle.getBundleId()).andReturn(2999L).anyTimes();
         EasyMock.expect(clientBundle.getBundleContext()).andReturn(clientBC).anyTimes();
-        EasyMock.expect(clientBundle.loadClass(EasyMock.isA(String.class))).andAnswer(new IAnswer() {
-            @Override
-            public Class answer() throws Throwable {
-                return objClsMap.get(EasyMock.getCurrentArguments()[0]);
-            }
-        }).anyTimes();
+        EasyMock.expect(clientBundle.loadClass(EasyMock.isA(String.class))).andAnswer(
+                (IAnswer) () -> objClsMap.get(EasyMock.getCurrentArguments()[0])).anyTimes();
         EasyMock.replay(clientBundle);
 
         assertEquals("Precondition", 0, gpc.proxyMap.size());
@@ -1449,12 +1349,8 @@ public class GuardProxyCatalogTest {
         }
 
         BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
-        EasyMock.expect(bc.createFilter(EasyMock.isA(String.class))).andAnswer(new IAnswer<Filter>() {
-            @Override
-            public Filter answer() throws Throwable {
-                return FrameworkUtil.createFilter((String) EasyMock.getCurrentArguments()[0]);
-            }
-        }).anyTimes();
+        EasyMock.expect(bc.createFilter(EasyMock.isA(String.class))).andAnswer(
+                () -> FrameworkUtil.createFilter((String) EasyMock.getCurrentArguments()[0])).anyTimes();
         EasyMock.expect(bc.getBundle()).andReturn(b).anyTimes();
         EasyMock.replay(bc);
         return bc;
@@ -1462,12 +1358,8 @@ public class GuardProxyCatalogTest {
 
     private BundleContext openStrictMockBundleContext(Bundle b) throws InvalidSyntaxException {
         BundleContext bc = EasyMock.createMock(BundleContext.class);
-        EasyMock.expect(bc.createFilter(EasyMock.isA(String.class))).andAnswer(new IAnswer<Filter>() {
-            @Override
-            public Filter answer() throws Throwable {
-                return FrameworkUtil.createFilter((String) EasyMock.getCurrentArguments()[0]);
-            }
-        }).anyTimes();
+        EasyMock.expect(bc.createFilter(EasyMock.isA(String.class))).andAnswer(
+                () -> FrameworkUtil.createFilter((String) EasyMock.getCurrentArguments()[0])).anyTimes();
         if (b != null) {
             EasyMock.expect(bc.getBundle()).andReturn(b).anyTimes();
         }
@@ -1503,12 +1395,8 @@ public class GuardProxyCatalogTest {
 
         BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
         EasyMock.expect(bc.getBundle()).andReturn(b).anyTimes();
-        EasyMock.expect(bc.createFilter(EasyMock.isA(String.class))).andAnswer(new IAnswer<Filter>() {
-            @Override
-            public Filter answer() throws Throwable {
-                return FrameworkUtil.createFilter((String) EasyMock.getCurrentArguments()[0]);
-            }
-        }).anyTimes();
+        EasyMock.expect(bc.createFilter(EasyMock.isA(String.class))).andAnswer(
+                () -> FrameworkUtil.createFilter((String) EasyMock.getCurrentArguments()[0])).anyTimes();
         String cmFilter = "(&(objectClass=" + ConfigurationAdmin.class.getName() + ")"
                 + "(!(" + GuardProxyCatalog.PROXY_SERVICE_KEY + "=*)))";
         bc.addServiceListener(EasyMock.isA(ServiceListener.class), EasyMock.eq(cmFilter));
@@ -1534,18 +1422,10 @@ public class GuardProxyCatalogTest {
         ServiceReference<?> sr = EasyMock.createMock(ServiceReference.class);
 
         // Make sure the properties are 'live' in that if they change the reference changes too
-        EasyMock.expect(sr.getPropertyKeys()).andAnswer(new IAnswer<String[]>() {
-            @Override
-            public String[] answer() throws Throwable {
-                return Collections.list(serviceProps.keys()).toArray(new String [] {});
-            }
-        }).anyTimes();
-        EasyMock.expect(sr.getProperty(EasyMock.isA(String.class))).andAnswer(new IAnswer<Object>() {
-            @Override
-            public Object answer() throws Throwable {
-                return serviceProps.get(EasyMock.getCurrentArguments()[0]);
-            }
-        }).anyTimes();
+        EasyMock.expect(sr.getPropertyKeys()).andAnswer(
+                () -> Collections.list(serviceProps.keys()).toArray(new String [] {})).anyTimes();
+        EasyMock.expect(sr.getProperty(EasyMock.isA(String.class))).andAnswer(
+                () -> serviceProps.get(EasyMock.getCurrentArguments()[0])).anyTimes();
         if (providerBundle != null) {
             EasyMock.expect(sr.getBundle()).andReturn(providerBundle).anyTimes();
         }

http://git-wip-us.apache.org/repos/asf/karaf/blob/bf666631/service/guard/src/test/java/org/apache/karaf/service/guard/impl/GuardingEventHookTest.java
----------------------------------------------------------------------
diff --git a/service/guard/src/test/java/org/apache/karaf/service/guard/impl/GuardingEventHookTest.java b/service/guard/src/test/java/org/apache/karaf/service/guard/impl/GuardingEventHookTest.java
index f026cf6..2445a85 100644
--- a/service/guard/src/test/java/org/apache/karaf/service/guard/impl/GuardingEventHookTest.java
+++ b/service/guard/src/test/java/org/apache/karaf/service/guard/impl/GuardingEventHookTest.java
@@ -28,7 +28,6 @@ import java.util.Hashtable;
 import java.util.Map;
 
 import org.easymock.EasyMock;
-import org.easymock.IAnswer;
 import org.junit.Test;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
@@ -176,12 +175,8 @@ public class GuardingEventHookTest {
 
         BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
         EasyMock.expect(bc.getBundle()).andReturn(bundle).anyTimes();
-        EasyMock.expect(bc.createFilter(EasyMock.isA(String.class))).andAnswer(new IAnswer<Filter>() {
-            @Override
-            public Filter answer() throws Throwable {
-                return FrameworkUtil.createFilter((String) EasyMock.getCurrentArguments()[0]);
-            }
-        }).anyTimes();
+        EasyMock.expect(bc.createFilter(EasyMock.isA(String.class))).andAnswer(
+                () -> FrameworkUtil.createFilter((String) EasyMock.getCurrentArguments()[0])).anyTimes();
         EasyMock.replay(bc);
 
         EasyMock.expect(bundle.getBundleContext()).andReturn(bc).anyTimes();
@@ -222,12 +217,8 @@ public class GuardingEventHookTest {
         BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
         EasyMock.expect(bc.getBundle()).andReturn(b).anyTimes();
         EasyMock.expect(bc.getBundle(0L)).andReturn(sb).anyTimes();
-        EasyMock.expect(bc.createFilter(EasyMock.isA(String.class))).andAnswer(new IAnswer<Filter>() {
-            @Override
-            public Filter answer() throws Throwable {
-                return FrameworkUtil.createFilter((String) EasyMock.getCurrentArguments()[0]);
-            }
-        }).anyTimes();
+        EasyMock.expect(bc.createFilter(EasyMock.isA(String.class))).andAnswer(
+                () -> FrameworkUtil.createFilter((String) EasyMock.getCurrentArguments()[0])).anyTimes();
         String cmFilter = "(&(objectClass=" + ConfigurationAdmin.class.getName() + ")"
                 + "(!(" + GuardProxyCatalog.PROXY_SERVICE_KEY + "=*)))";
         bc.addServiceListener(EasyMock.isA(ServiceListener.class), EasyMock.eq(cmFilter));
@@ -243,18 +234,9 @@ public class GuardingEventHookTest {
         ServiceReference<?> sr = EasyMock.createMock(ServiceReference.class);
 
         // Make sure the properties are 'live' in that if they change the reference changes too
-        EasyMock.expect(sr.getPropertyKeys()).andAnswer(new IAnswer<String[]>() {
-            @Override
-            public String[] answer() throws Throwable {
-                return Collections.list(props.keys()).toArray(new String [] {});
-            }
-        }).anyTimes();
-        EasyMock.expect(sr.getProperty(EasyMock.isA(String.class))).andAnswer(new IAnswer<Object>() {
-            @Override
-            public Object answer() throws Throwable {
-                return props.get(EasyMock.getCurrentArguments()[0]);
-            }
-        }).anyTimes();
+        EasyMock.expect(sr.getPropertyKeys()).andAnswer(() -> Collections.list(props.keys()).toArray(new String [] {})).anyTimes();
+        EasyMock.expect(sr.getProperty(EasyMock.isA(String.class))).andAnswer(
+                () -> props.get(EasyMock.getCurrentArguments()[0])).anyTimes();
         EasyMock.replay(sr);
         return sr;
     }

http://git-wip-us.apache.org/repos/asf/karaf/blob/bf666631/service/guard/src/test/java/org/apache/karaf/service/guard/impl/GuardingFindHookTest.java
----------------------------------------------------------------------
diff --git a/service/guard/src/test/java/org/apache/karaf/service/guard/impl/GuardingFindHookTest.java b/service/guard/src/test/java/org/apache/karaf/service/guard/impl/GuardingFindHookTest.java
index a8fedf3..27422f6 100644
--- a/service/guard/src/test/java/org/apache/karaf/service/guard/impl/GuardingFindHookTest.java
+++ b/service/guard/src/test/java/org/apache/karaf/service/guard/impl/GuardingFindHookTest.java
@@ -26,7 +26,6 @@ import java.util.Dictionary;
 import java.util.Hashtable;
 
 import org.easymock.EasyMock;
-import org.easymock.IAnswer;
 import org.junit.Test;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
@@ -160,13 +159,8 @@ public class GuardingFindHookTest {
 
         BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
         EasyMock.expect(bc.getBundle()).andReturn(bundle).anyTimes();
-        EasyMock.expect(bc.createFilter(EasyMock.isA(String.class))).andAnswer(new IAnswer<Filter>() {
-            @Override
-            public Filter answer() throws Throwable {
-                Filter filter = FrameworkUtil.createFilter((String) EasyMock.getCurrentArguments()[0]);
-                return filter;
-            }
-        }).anyTimes();
+        EasyMock.expect(bc.createFilter(EasyMock.isA(String.class))).andAnswer(
+                () -> FrameworkUtil.createFilter((String) EasyMock.getCurrentArguments()[0])).anyTimes();
         EasyMock.replay(bc);
 
         EasyMock.expect(bundle.getBundleContext()).andReturn(bc).anyTimes();
@@ -201,12 +195,8 @@ public class GuardingFindHookTest {
 
         BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
         EasyMock.expect(bc.getBundle()).andReturn(b).anyTimes();
-        EasyMock.expect(bc.createFilter(EasyMock.isA(String.class))).andAnswer(new IAnswer<Filter>() {
-            @Override
-            public Filter answer() throws Throwable {
-                return FrameworkUtil.createFilter((String) EasyMock.getCurrentArguments()[0]);
-            }
-        }).anyTimes();
+        EasyMock.expect(bc.createFilter(EasyMock.isA(String.class))).andAnswer(
+                () -> FrameworkUtil.createFilter((String) EasyMock.getCurrentArguments()[0])).anyTimes();
         String cmFilter = "(&(objectClass=" + ConfigurationAdmin.class.getName() + ")"
                 + "(!(" + GuardProxyCatalog.PROXY_SERVICE_KEY + "=*)))";
         bc.addServiceListener(EasyMock.isA(ServiceListener.class), EasyMock.eq(cmFilter));
@@ -223,18 +213,10 @@ public class GuardingFindHookTest {
         ServiceReference<Object> sr = EasyMock.createMock(ServiceReference.class);
 
         // Make sure the properties are 'live' in that if they change the reference changes too
-        EasyMock.expect(sr.getPropertyKeys()).andAnswer(new IAnswer<String[]>() {
-            @Override
-            public String[] answer() throws Throwable {
-                return Collections.list(props.keys()).toArray(new String [] {});
-            }
-        }).anyTimes();
-        EasyMock.expect(sr.getProperty(EasyMock.isA(String.class))).andAnswer(new IAnswer<Object>() {
-            @Override
-            public Object answer() throws Throwable {
-                return props.get(EasyMock.getCurrentArguments()[0]);
-            }
-        }).anyTimes();
+        EasyMock.expect(sr.getPropertyKeys()).andAnswer(
+                () -> Collections.list(props.keys()).toArray(new String[] {})).anyTimes();
+        EasyMock.expect(sr.getProperty(EasyMock.isA(String.class))).andAnswer(
+                () -> props.get(EasyMock.getCurrentArguments()[0])).anyTimes();
         EasyMock.replay(sr);
         return sr;
     }

http://git-wip-us.apache.org/repos/asf/karaf/blob/bf666631/services/eventadmin/src/main/java/org/apache/felix/eventadmin/impl/Configuration.java
----------------------------------------------------------------------
diff --git a/services/eventadmin/src/main/java/org/apache/felix/eventadmin/impl/Configuration.java b/services/eventadmin/src/main/java/org/apache/felix/eventadmin/impl/Configuration.java
index c732ae7..86631dd 100644
--- a/services/eventadmin/src/main/java/org/apache/felix/eventadmin/impl/Configuration.java
+++ b/services/eventadmin/src/main/java/org/apache/felix/eventadmin/impl/Configuration.java
@@ -34,7 +34,6 @@ import org.apache.felix.eventadmin.impl.util.LogWrapper;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.cm.ConfigurationException;
 import org.osgi.service.cm.ManagedService;
 import org.osgi.service.event.EventAdmin;
 import org.osgi.service.metatype.MetaTypeProvider;
@@ -194,20 +193,13 @@ public class Configuration
     {
         // do this in the background as we don't want to stop
         // the config admin
-        new Thread()
-        {
-
-            @Override
-            public void run()
+        new Thread(() -> {
+            synchronized ( Configuration.this )
             {
-                synchronized ( Configuration.this )
-                {
-                    Configuration.this.configure( config );
-                    Configuration.this.startOrUpdate();
-                }
+                Configuration.this.configure( config );
+                Configuration.this.startOrUpdate();
             }
-
-        }.start();
+        }).start();
 
     }
 
@@ -485,14 +477,7 @@ public class Configuration
     {
         try
         {
-            return new ManagedService()
-            {
-                @Override
-                public void updated( Dictionary<String, ?> properties ) throws ConfigurationException
-                {
-                    updateFromConfigAdmin(properties);
-                }
-            };
+            return (ManagedService) this::updateFromConfigAdmin;
         }
         catch (Throwable t)
         {

http://git-wip-us.apache.org/repos/asf/karaf/blob/bf666631/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/InfoAction.java
----------------------------------------------------------------------
diff --git a/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/InfoAction.java b/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/InfoAction.java
index 18c5f73..3311bd9 100644
--- a/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/InfoAction.java
+++ b/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/InfoAction.java
@@ -144,11 +144,7 @@ public class InfoAction implements Action {
                 if (keys.size() > 0) {
                     System.out.println(section);
 
-                    Collections.sort(keys, new Comparator<Object>() {
-                        public int compare(Object o1, Object o2) {
-                            return String.valueOf(o1).compareTo(String.valueOf(o2));
-                        }
-                    });
+                    keys.sort(Comparator.comparing(String::valueOf));
 
                     for (Object key : keys) {
                         printValue(String.valueOf(key), maxNameLen, String.valueOf(properties.get(section).get(key)));