You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2019/11/03 13:39:06 UTC

[groovy] branch master updated (ea09b51 -> ebe9d61)

This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git.


    from ea09b51  Trivial refactoring: cleanup `CachedClass`
     new be7591e  Minor refactoring: Anonymous type can be replaced with lambda expression
     new caff79f  Minor refactoring: Anonymous type can be replaced with method reference
     new d852871  Minor refactoring: Lambda can be replaced with method reference
     new 746c05e  Trivial refactoring: Can be replaced with single 'Map.replaceAll' method call
     new 76e8280  Trivial refactoring: Can be replaced with single 'Map.computeIfAbsent' method call
     new ebe9d61  Trivial refactoring: remove unused imports

The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/main/java/groovy/grape/Grape.java              |  29 ++---
 src/main/java/groovy/lang/ExpandoMetaClass.java    | 135 ++++++++++-----------
 src/main/java/groovy/lang/GroovyClassLoader.java   |  71 +++++------
 src/main/java/groovy/lang/GroovyCodeSource.java    |  28 ++---
 src/main/java/groovy/lang/GroovyShell.java         |  36 +-----
 src/main/java/groovy/lang/ProxyMetaClass.java      |  24 +---
 .../java/groovy/util/FactoryBuilderSupport.java    |  18 +--
 src/main/java/groovy/util/GroovyScriptEngine.java  |  40 +++---
 src/main/java/groovy/util/ObjectGraphBuilder.java  |  70 ++++-------
 src/main/java/groovy/util/ProxyGenerator.java      |  14 +--
 .../internal/util/ReevaluatingReference.java       |  13 +-
 .../groovy/ast/decompiled/AsmDecompiler.java       |   5 +-
 .../groovy/ast/tools/WideningCategories.java       |  32 +++--
 .../org/codehaus/groovy/classgen/ReturnAdder.java  |  11 +-
 .../groovy/classgen/asm/InvocationWriter.java      |  14 +--
 .../groovy/classgen/asm/StatementWriter.java       |  20 ++-
 .../asm/sc/StaticCompilationMopWriter.java         |   7 +-
 .../org/codehaus/groovy/control/LabelVerifier.java |   1 -
 .../codehaus/groovy/control/ProcessingUnit.java    |  10 +-
 .../org/codehaus/groovy/control/SourceUnit.java    |   6 +-
 .../codehaus/groovy/reflection/SunClassLoader.java |  12 +-
 .../reflection/stdclasses/CachedSAMClass.java      |   3 +-
 .../groovy/runtime/DefaultGroovyMethods.java       |   7 +-
 .../groovy/runtime/ProcessGroovyMethods.java       |  52 ++++----
 .../groovy/runtime/ProxyGeneratorAdapter.java      |   6 +-
 .../groovy/runtime/SocketGroovyMethods.java        |   6 +-
 .../runtime/callsite/GroovySunClassLoader.java     |  16 ++-
 .../runtime/metaclass/MetaClassRegistryImpl.java   |  58 +++------
 .../runtime/powerassert/AssertionRenderer.java     |   1 -
 .../org/codehaus/groovy/tools/GroovyStarter.java   |   6 +-
 .../transform/MapConstructorASTTransformation.java |   1 -
 .../transform/SortableASTTransformation.java       |   6 +-
 .../transform/ToStringASTTransformation.java       |   6 +-
 .../TupleConstructorASTTransformation.java         |   6 +-
 .../stc/AbstractExtensionMethodCache.java          |   4 +-
 .../stc/GroovyTypeCheckingExtensionSupport.java    |   6 +-
 .../transform/stc/StaticTypeCheckingSupport.java   |   2 +-
 .../transform/stc/StaticTypeCheckingVisitor.java   |  12 +-
 .../codehaus/groovy/vmplugin/v7/IndyInterface.java |   8 +-
 .../org/codehaus/groovy/vmplugin/v7/Java7.java     |  18 +--
 40 files changed, 295 insertions(+), 525 deletions(-)


[groovy] 02/06: Minor refactoring: Anonymous type can be replaced with method reference

Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit caff79f40a4d92e3b08cb3a02ebd1d7ffc8528a0
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sun Nov 3 21:21:21 2019 +0800

    Minor refactoring: Anonymous type can be replaced with method reference
---
 .../org/codehaus/groovy/classgen/asm/sc/StaticCompilationMopWriter.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticCompilationMopWriter.java b/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticCompilationMopWriter.java
index 781ebe1..a509c8b 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticCompilationMopWriter.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticCompilationMopWriter.java
@@ -35,7 +35,7 @@ import java.util.LinkedList;
  */
 public class StaticCompilationMopWriter extends MopWriter {
 
-    public static final MopWriter.Factory FACTORY = controller -> new StaticCompilationMopWriter(controller);
+    public static final MopWriter.Factory FACTORY = StaticCompilationMopWriter::new;
 
     private final StaticTypesWriterController controller;
 


[groovy] 04/06: Trivial refactoring: Can be replaced with single 'Map.replaceAll' method call

Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 746c05e151764413b180087fc6a4db593c0685c8
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sun Nov 3 21:32:06 2019 +0800

    Trivial refactoring: Can be replaced with single 'Map.replaceAll' method call
---
 .../codehaus/groovy/transform/stc/AbstractExtensionMethodCache.java   | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/transform/stc/AbstractExtensionMethodCache.java b/src/main/java/org/codehaus/groovy/transform/stc/AbstractExtensionMethodCache.java
index bfb5c04..d65d9d4 100644
--- a/src/main/java/org/codehaus/groovy/transform/stc/AbstractExtensionMethodCache.java
+++ b/src/main/java/org/codehaus/groovy/transform/stc/AbstractExtensionMethodCache.java
@@ -100,9 +100,7 @@ public abstract class AbstractExtensionMethodCache {
     }
 
     private Map<String, List<MethodNode>> makeMethodsUnmodifiable(Map<String, List<MethodNode>> methods) {
-        for (Map.Entry<String, List<MethodNode>> entry : methods.entrySet()) {
-            methods.put(entry.getKey(), Collections.unmodifiableList(entry.getValue()));
-        }
+        methods.replaceAll((k, v) -> Collections.unmodifiableList(v));
 
         return Collections.unmodifiableMap(methods);
     }


[groovy] 01/06: Minor refactoring: Anonymous type can be replaced with lambda expression

Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit be7591e22c9605a9366129ef4c5a184264169922
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sun Nov 3 21:19:58 2019 +0800

    Minor refactoring: Anonymous type can be replaced with lambda expression
---
 src/main/java/groovy/grape/Grape.java              |  29 ++---
 src/main/java/groovy/lang/ExpandoMetaClass.java    | 135 ++++++++++-----------
 src/main/java/groovy/lang/GroovyClassLoader.java   |  71 +++++------
 src/main/java/groovy/lang/GroovyCodeSource.java    |  28 ++---
 src/main/java/groovy/lang/GroovyShell.java         |  36 +-----
 src/main/java/groovy/lang/ProxyMetaClass.java      |  24 +---
 .../java/groovy/util/FactoryBuilderSupport.java    |  12 +-
 src/main/java/groovy/util/GroovyScriptEngine.java  |  40 +++---
 src/main/java/groovy/util/ObjectGraphBuilder.java  |  70 ++++-------
 src/main/java/groovy/util/ProxyGenerator.java      |  14 +--
 .../internal/util/ReevaluatingReference.java       |  13 +-
 .../groovy/ast/tools/WideningCategories.java       |  32 +++--
 .../org/codehaus/groovy/classgen/ReturnAdder.java  |  11 +-
 .../groovy/classgen/asm/InvocationWriter.java      |  14 +--
 .../groovy/classgen/asm/StatementWriter.java       |  20 ++-
 .../asm/sc/StaticCompilationMopWriter.java         |   7 +-
 .../codehaus/groovy/control/ProcessingUnit.java    |  10 +-
 .../org/codehaus/groovy/control/SourceUnit.java    |   6 +-
 .../codehaus/groovy/reflection/SunClassLoader.java |  12 +-
 .../groovy/runtime/ProcessGroovyMethods.java       |  52 ++++----
 .../groovy/runtime/ProxyGeneratorAdapter.java      |   6 +-
 .../groovy/runtime/SocketGroovyMethods.java        |   6 +-
 .../runtime/callsite/GroovySunClassLoader.java     |  16 ++-
 .../runtime/metaclass/MetaClassRegistryImpl.java   |  34 +++---
 .../org/codehaus/groovy/tools/GroovyStarter.java   |   6 +-
 .../transform/SortableASTTransformation.java       |   6 +-
 .../transform/ToStringASTTransformation.java       |   6 +-
 .../TupleConstructorASTTransformation.java         |   6 +-
 .../codehaus/groovy/vmplugin/v7/IndyInterface.java |   8 +-
 .../org/codehaus/groovy/vmplugin/v7/Java7.java     |  18 +--
 30 files changed, 282 insertions(+), 466 deletions(-)

diff --git a/src/main/java/groovy/grape/Grape.java b/src/main/java/groovy/grape/Grape.java
index 7ab4328..dfe7a37 100644
--- a/src/main/java/groovy/grape/Grape.java
+++ b/src/main/java/groovy/grape/Grape.java
@@ -157,24 +157,21 @@ public class Grape {
 
     public static void grab(final Map<String, Object> args, final Map... dependencies) {
         if (enableGrapes) {
-            AccessController.doPrivileged(new PrivilegedAction<Void>() {
-                @Override
-                public Void run() {
-                    GrapeEngine instance = getInstance();
-                    if (instance != null) {
-                        if (!args.containsKey(AUTO_DOWNLOAD_SETTING)) {
-                            args.put(AUTO_DOWNLOAD_SETTING, enableAutoDownload);
-                        }
-                        if (!args.containsKey(DISABLE_CHECKSUMS_SETTING)) {
-                            args.put(DISABLE_CHECKSUMS_SETTING, disableChecksums);
-                        }
-                        if (!args.containsKey(GrapeEngine.CALLEE_DEPTH)) {
-                            args.put(GrapeEngine.CALLEE_DEPTH, GrapeEngine.DEFAULT_CALLEE_DEPTH + 2);
-                        }
-                        instance.grab(args, dependencies);
+            AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
+                GrapeEngine instance = getInstance();
+                if (instance != null) {
+                    if (!args.containsKey(AUTO_DOWNLOAD_SETTING)) {
+                        args.put(AUTO_DOWNLOAD_SETTING, enableAutoDownload);
                     }
-                    return null;
+                    if (!args.containsKey(DISABLE_CHECKSUMS_SETTING)) {
+                        args.put(DISABLE_CHECKSUMS_SETTING, disableChecksums);
+                    }
+                    if (!args.containsKey(GrapeEngine.CALLEE_DEPTH)) {
+                        args.put(GrapeEngine.CALLEE_DEPTH, GrapeEngine.DEFAULT_CALLEE_DEPTH + 2);
+                    }
+                    instance.grab(args, dependencies);
                 }
+                return null;
             });
         }
     }
diff --git a/src/main/java/groovy/lang/ExpandoMetaClass.java b/src/main/java/groovy/lang/ExpandoMetaClass.java
index 578fad1..42abd56 100644
--- a/src/main/java/groovy/lang/ExpandoMetaClass.java
+++ b/src/main/java/groovy/lang/ExpandoMetaClass.java
@@ -846,27 +846,24 @@ public class ExpandoMetaClass extends MetaClassImpl implements GroovyObject {
      * @param newValue The properties initial value
      */
     public void registerBeanProperty(final String property, final Object newValue) {
-        performOperationOnMetaClass(new Callable() {
-            public void call() {
-                Class type = newValue == null ? Object.class : newValue.getClass();
-
-                MetaBeanProperty mbp = newValue instanceof MetaBeanProperty ? (MetaBeanProperty) newValue : new ThreadManagedMetaBeanProperty(theClass, property, type, newValue);
+        performOperationOnMetaClass(() -> {
+            Class type = newValue == null ? Object.class : newValue.getClass();
 
-                final MetaMethod getter = mbp.getGetter();
-                final MethodKey getterKey = new DefaultCachedMethodKey(theClass, getter.getName(), CachedClass.EMPTY_ARRAY, false);
-                final MetaMethod setter = mbp.getSetter();
-                final MethodKey setterKey = new DefaultCachedMethodKey(theClass, setter.getName(), setter.getParameterTypes(), false);
-                addMetaMethod(getter);
-                addMetaMethod(setter);
+            MetaBeanProperty mbp = newValue instanceof MetaBeanProperty ? (MetaBeanProperty) newValue : new ThreadManagedMetaBeanProperty(theClass, property, type, newValue);
 
-                expandoMethods.put(setterKey, setter);
-                expandoMethods.put(getterKey, getter);
-                expandoProperties.put(mbp.getName(), mbp);
+            final MetaMethod getter = mbp.getGetter();
+            final MethodKey getterKey = new DefaultCachedMethodKey(theClass, getter.getName(), CachedClass.EMPTY_ARRAY, false);
+            final MetaMethod setter = mbp.getSetter();
+            final MethodKey setterKey = new DefaultCachedMethodKey(theClass, setter.getName(), setter.getParameterTypes(), false);
+            addMetaMethod(getter);
+            addMetaMethod(setter);
 
-                addMetaBeanProperty(mbp);
-                performRegistryCallbacks();
-            }
+            expandoMethods.put(setterKey, setter);
+            expandoMethods.put(getterKey, getter);
+            expandoProperties.put(mbp.getName(), mbp);
 
+            addMetaBeanProperty(mbp);
+            performRegistryCallbacks();
         });
     }
 
@@ -877,32 +874,29 @@ public class ExpandoMetaClass extends MetaClassImpl implements GroovyObject {
      */
     public void registerInstanceMethod(final MetaMethod metaMethod) {
         final boolean inited = this.initCalled;
-        performOperationOnMetaClass(new Callable() {
-            public void call() {
-                String methodName = metaMethod.getName();
-                checkIfGroovyObjectMethod(metaMethod);
-                MethodKey key = new DefaultCachedMethodKey(theClass, methodName, metaMethod.getParameterTypes(), false);
+        performOperationOnMetaClass(() -> {
+            String methodName = metaMethod.getName();
+            checkIfGroovyObjectMethod(metaMethod);
+            MethodKey key = new DefaultCachedMethodKey(theClass, methodName, metaMethod.getParameterTypes(), false);
 
-                if (isInitialized()) {
-                    throw new RuntimeException("Already initialized, cannot add new method: " + metaMethod);
-                }
-                // we always adds meta methods to class itself
-                addMetaMethodToIndex(metaMethod, metaMethodIndex.getHeader(theClass));
+            if (isInitialized()) {
+                throw new RuntimeException("Already initialized, cannot add new method: " + metaMethod);
+            }
+            // we always adds meta methods to class itself
+            addMetaMethodToIndex(metaMethod, metaMethodIndex.getHeader(theClass));
 
-                dropMethodCache(methodName);
-                expandoMethods.put(key, metaMethod);
+            dropMethodCache(methodName);
+            expandoMethods.put(key, metaMethod);
 
-                if (inited && isGetter(methodName, metaMethod.getParameterTypes())) {
-                    String propertyName = getPropertyForGetter(methodName);
-                    registerBeanPropertyForMethod(metaMethod, propertyName, true, false);
+            if (inited && isGetter(methodName, metaMethod.getParameterTypes())) {
+                String propertyName = getPropertyForGetter(methodName);
+                registerBeanPropertyForMethod(metaMethod, propertyName, true, false);
 
-                } else if (inited && isSetter(methodName, metaMethod.getParameterTypes())) {
-                    String propertyName = getPropertyForSetter(methodName);
-                    registerBeanPropertyForMethod(metaMethod, propertyName, false, false);
-                }
-                performRegistryCallbacks();
+            } else if (inited && isSetter(methodName, metaMethod.getParameterTypes())) {
+                String propertyName = getPropertyForSetter(methodName);
+                registerBeanPropertyForMethod(metaMethod, propertyName, false, false);
             }
-
+            performRegistryCallbacks();
         });
     }
 
@@ -1002,49 +996,46 @@ public class ExpandoMetaClass extends MetaClassImpl implements GroovyObject {
      * @param callable The callable Closure
      */
     protected void registerStaticMethod(final String name, final Closure callable, final Class[] paramTypes) {
-        performOperationOnMetaClass(new Callable() {
-            public void call() {
-                String methodName;
-                if (name.equals(METHOD_MISSING))
-                    methodName = STATIC_METHOD_MISSING;
-                else if (name.equals(PROPERTY_MISSING))
-                    methodName = STATIC_PROPERTY_MISSING;
-                else
-                    methodName = name;
+        performOperationOnMetaClass(() -> {
+            String methodName;
+            if (name.equals(METHOD_MISSING))
+                methodName = STATIC_METHOD_MISSING;
+            else if (name.equals(PROPERTY_MISSING))
+                methodName = STATIC_PROPERTY_MISSING;
+            else
+                methodName = name;
 
-                ClosureStaticMetaMethod metaMethod = null;
+            ClosureStaticMetaMethod metaMethod = null;
 
-                if (paramTypes != null) {
-                    metaMethod = new ClosureStaticMetaMethod(methodName, theClass, callable, paramTypes);
-                } else {
-                    metaMethod = new ClosureStaticMetaMethod(methodName, theClass, callable);
-                }
+            if (paramTypes != null) {
+                metaMethod = new ClosureStaticMetaMethod(methodName, theClass, callable, paramTypes);
+            } else {
+                metaMethod = new ClosureStaticMetaMethod(methodName, theClass, callable);
+            }
 
-                if (methodName.equals(INVOKE_METHOD_METHOD) && callable.getParameterTypes().length == 2) {
-                    invokeStaticMethodMethod = metaMethod;
-                } else {
-                    if (methodName.equals(METHOD_MISSING)) {
-                        methodName = STATIC_METHOD_MISSING;
-                    }
-                    MethodKey key = new DefaultCachedMethodKey(theClass, methodName, metaMethod.getParameterTypes(), false);
+            if (methodName.equals(INVOKE_METHOD_METHOD) && callable.getParameterTypes().length == 2) {
+                invokeStaticMethodMethod = metaMethod;
+            } else {
+                if (methodName.equals(METHOD_MISSING)) {
+                    methodName = STATIC_METHOD_MISSING;
+                }
+                MethodKey key = new DefaultCachedMethodKey(theClass, methodName, metaMethod.getParameterTypes(), false);
 
-                    addMetaMethod(metaMethod);
-                    dropStaticMethodCache(methodName);
+                addMetaMethod(metaMethod);
+                dropStaticMethodCache(methodName);
 //                    cacheStaticMethod(key,metaMethod);
 
-                    if (isGetter(methodName, metaMethod.getParameterTypes())) {
-                        String propertyName = getPropertyForGetter(methodName);
-                        registerBeanPropertyForMethod(metaMethod, propertyName, true, true);
+                if (isGetter(methodName, metaMethod.getParameterTypes())) {
+                    String propertyName = getPropertyForGetter(methodName);
+                    registerBeanPropertyForMethod(metaMethod, propertyName, true, true);
 
-                    } else if (isSetter(methodName, metaMethod.getParameterTypes())) {
-                        String propertyName = getPropertyForSetter(methodName);
-                        registerBeanPropertyForMethod(metaMethod, propertyName, false, true);
-                    }
-                    performRegistryCallbacks();
-                    expandoMethods.put(key, metaMethod);
+                } else if (isSetter(methodName, metaMethod.getParameterTypes())) {
+                    String propertyName = getPropertyForSetter(methodName);
+                    registerBeanPropertyForMethod(metaMethod, propertyName, false, true);
                 }
+                performRegistryCallbacks();
+                expandoMethods.put(key, metaMethod);
             }
-
         });
     }
 
diff --git a/src/main/java/groovy/lang/GroovyClassLoader.java b/src/main/java/groovy/lang/GroovyClassLoader.java
index 59741fb..afc52ff 100644
--- a/src/main/java/groovy/lang/GroovyClassLoader.java
+++ b/src/main/java/groovy/lang/GroovyClassLoader.java
@@ -325,12 +325,7 @@ public class GroovyClassLoader extends URLClassLoader {
 
         return sourceCache.getAndPut(
                 cacheKey,
-                new EvictableCache.ValueProvider<String, Class>() {
-                    @Override
-                    public Class provide(String key) {
-                        return doParseClass(codeSource);
-                    }
-                },
+                key -> doParseClass(codeSource),
                 shouldCacheSource
         );
     }
@@ -666,11 +661,7 @@ public class GroovyClassLoader extends URLClassLoader {
      * @return the ClassCollector
      */
     protected ClassCollector createCollector(CompilationUnit unit, SourceUnit su) {
-        InnerLoader loader = AccessController.doPrivileged(new PrivilegedAction<InnerLoader>() {
-            public InnerLoader run() {
-                return new InnerLoader(GroovyClassLoader.this);
-            }
-        });
+        InnerLoader loader = AccessController.doPrivileged((PrivilegedAction<InnerLoader>) () -> new InnerLoader(GroovyClassLoader.this));
         return new ClassCollector(loader, unit, su);
     }
 
@@ -1098,42 +1089,40 @@ public class GroovyClassLoader extends URLClassLoader {
      * @see #addURL(URL)
      */
     public void addClasspath(final String path) {
-        AccessController.doPrivileged(new PrivilegedAction<Void>() {
-            public Void run() {
+        AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
 
-                URI newURI;
-                try {
-                    newURI = new URI(path);
-                    // check if we can create a URL from that URI
-                    newURI.toURL();
-                } catch (URISyntaxException | IllegalArgumentException | MalformedURLException e) {
-                    // the URI has a false format, so lets try it with files ...
-                    newURI=new File(path).toURI();
-                }
+            URI newURI;
+            try {
+                newURI = new URI(path);
+                // check if we can create a URL from that URI
+                newURI.toURL();
+            } catch (URISyntaxException | IllegalArgumentException | MalformedURLException e) {
+                // the URI has a false format, so lets try it with files ...
+                newURI=new File(path).toURI();
+            }
 
-                URL[] urls = getURLs();
-                for (URL url : urls) {
-                    // Do not use URL.equals.  It uses the network to resolve names and compares ip addresses!
-                    // That is a violation of RFC and just plain evil.
-                    // http://michaelscharf.blogspot.com/2006/11/javaneturlequals-and-hashcode-make.html
-                    // http://docs.oracle.com/javase/7/docs/api/java/net/URL.html#equals(java.lang.Object)
-                    // "Since hosts comparison requires name resolution, this operation is a blocking operation.
-                    // Note: The defined behavior for equals is known to be inconsistent with virtual hosting in HTTP."
-                    try {
-                        if (newURI.equals(url.toURI())) return null;
-                    } catch (URISyntaxException e) {
-                        // fail fast! if we got a malformed URI the Classloader has to tell it
-                        throw new RuntimeException( e );
-                    }
-                }
+            URL[] urls = getURLs();
+            for (URL url : urls) {
+                // Do not use URL.equals.  It uses the network to resolve names and compares ip addresses!
+                // That is a violation of RFC and just plain evil.
+                // http://michaelscharf.blogspot.com/2006/11/javaneturlequals-and-hashcode-make.html
+                // http://docs.oracle.com/javase/7/docs/api/java/net/URL.html#equals(java.lang.Object)
+                // "Since hosts comparison requires name resolution, this operation is a blocking operation.
+                // Note: The defined behavior for equals is known to be inconsistent with virtual hosting in HTTP."
                 try {
-                    addURL(newURI.toURL());
-                } catch (MalformedURLException e) {
-                    // fail fast! if we got a malformed URL the Classloader has to tell it
+                    if (newURI.equals(url.toURI())) return null;
+                } catch (URISyntaxException e) {
+                    // fail fast! if we got a malformed URI the Classloader has to tell it
                     throw new RuntimeException( e );
                 }
-                return null;
             }
+            try {
+                addURL(newURI.toURL());
+            } catch (MalformedURLException e) {
+                // fail fast! if we got a malformed URL the Classloader has to tell it
+                throw new RuntimeException( e );
+            }
+            return null;
         });
     }
 
diff --git a/src/main/java/groovy/lang/GroovyCodeSource.java b/src/main/java/groovy/lang/GroovyCodeSource.java
index 6acd292..2cd6fa2 100644
--- a/src/main/java/groovy/lang/GroovyCodeSource.java
+++ b/src/main/java/groovy/lang/GroovyCodeSource.java
@@ -123,22 +123,20 @@ public class GroovyCodeSource {
         //The calls below require access to user.dir - allow here since getName() and getCodeSource() are
         //package private and used only by the GroovyClassLoader.
         try {
-            Object[] info = AccessController.doPrivileged(new PrivilegedExceptionAction<Object[]>() {
-                public Object[] run() throws IOException {
-                    // retrieve the content of the file using the provided encoding
-                    if (encoding != null) {
-                        scriptText = ResourceGroovyMethods.getText(infile, encoding);
-                    } else {
-                        scriptText = ResourceGroovyMethods.getText(infile);
-                    }
-
-                    Object[] info = new Object[2];
-                    URL url = file.toURI().toURL();
-                    info[0] = url.toExternalForm();
-                    //toURI().toURL() will encode, but toURL() will not.
-                    info[1] = new CodeSource(url, (Certificate[]) null);
-                    return info;
+            Object[] info = AccessController.doPrivileged((PrivilegedExceptionAction<Object[]>) () -> {
+                // retrieve the content of the file using the provided encoding
+                if (encoding != null) {
+                    scriptText = ResourceGroovyMethods.getText(infile, encoding);
+                } else {
+                    scriptText = ResourceGroovyMethods.getText(infile);
                 }
+
+                Object[] info1 = new Object[2];
+                URL url = file.toURI().toURL();
+                info1[0] = url.toExternalForm();
+                //toURI().toURL() will encode, but toURL() will not.
+                info1[1] = new CodeSource(url, (Certificate[]) null);
+                return info1;
             });
 
             this.name = (String) info[0];
diff --git a/src/main/java/groovy/lang/GroovyShell.java b/src/main/java/groovy/lang/GroovyShell.java
index 6f32a3c..3255fa1 100644
--- a/src/main/java/groovy/lang/GroovyShell.java
+++ b/src/main/java/groovy/lang/GroovyShell.java
@@ -100,11 +100,7 @@ public class GroovyShell extends GroovyObjectSupport {
             && ((GroovyClassLoader) parentLoader).hasCompatibleConfiguration(config)) {
           this.loader = (GroovyClassLoader) parentLoader;
         } else {
-          this.loader = AccessController.doPrivileged(new PrivilegedAction<GroovyClassLoader>() {
-              public GroovyClassLoader run() {
-                  return new GroovyClassLoader(parentLoader,config);
-              }
-          });
+          this.loader = AccessController.doPrivileged((PrivilegedAction<GroovyClassLoader>) () -> new GroovyClassLoader(parentLoader,config));
         }
         this.context = binding;
         this.config = config;
@@ -212,11 +208,7 @@ public class GroovyShell extends GroovyObjectSupport {
         // if you are compiling the script because the JVM isn't executing the main method.
         Class scriptClass;
         try {
-            scriptClass = AccessController.doPrivileged(new PrivilegedExceptionAction<Class>() {
-                public Class run() throws CompilationFailedException, IOException {
-                    return loader.parseClass(scriptFile);
-                }
-            });
+            scriptClass = AccessController.doPrivileged((PrivilegedExceptionAction<Class>) () -> loader.parseClass(scriptFile));
         } catch (PrivilegedActionException pae) {
             Exception e = pae.getException();
             if (e instanceof CompilationFailedException) {
@@ -347,11 +339,7 @@ public class GroovyShell extends GroovyObjectSupport {
      * @param args       the command line arguments to pass in
      */
     public Object run(final String scriptText, final String fileName, String[] args) throws CompilationFailedException {
-        GroovyCodeSource gcs = AccessController.doPrivileged(new PrivilegedAction<GroovyCodeSource>() {
-            public GroovyCodeSource run() {
-                return new GroovyCodeSource(scriptText, fileName, DEFAULT_CODE_BASE);
-            }
-        });
+        GroovyCodeSource gcs = AccessController.doPrivileged((PrivilegedAction<GroovyCodeSource>) () -> new GroovyCodeSource(scriptText, fileName, DEFAULT_CODE_BASE));
         return run(gcs, args);
     }
 
@@ -415,11 +403,7 @@ public class GroovyShell extends GroovyObjectSupport {
      * @param args     the command line arguments to pass in
      */
     public Object run(final Reader in, final String fileName, String[] args) throws CompilationFailedException {
-        GroovyCodeSource gcs = AccessController.doPrivileged(new PrivilegedAction<GroovyCodeSource>() {
-                    public GroovyCodeSource run() {
-                        return new GroovyCodeSource(in, fileName, DEFAULT_CODE_BASE);
-                    }
-        });
+        GroovyCodeSource gcs = AccessController.doPrivileged((PrivilegedAction<GroovyCodeSource>) () -> new GroovyCodeSource(in, fileName, DEFAULT_CODE_BASE));
         Class scriptClass = parseClass(gcs);
         return runScriptOrMainOrTestOrRunnable(scriptClass, args);
     }
@@ -476,11 +460,7 @@ public class GroovyShell extends GroovyObjectSupport {
             sm.checkPermission(new GroovyCodeSourcePermission(codeBase));
         }
 
-        GroovyCodeSource gcs = AccessController.doPrivileged(new PrivilegedAction<GroovyCodeSource>() {
-            public GroovyCodeSource run() {
-                return new GroovyCodeSource(scriptText, fileName, codeBase);
-            }
-        });
+        GroovyCodeSource gcs = AccessController.doPrivileged((PrivilegedAction<GroovyCodeSource>) () -> new GroovyCodeSource(scriptText, fileName, codeBase));
 
         return evaluate(gcs);
     }
@@ -590,11 +570,7 @@ public class GroovyShell extends GroovyObjectSupport {
     }
 
     public Script parse(final String scriptText, final String fileName) throws CompilationFailedException {
-        GroovyCodeSource gcs = AccessController.doPrivileged(new PrivilegedAction<GroovyCodeSource>() {
-            public GroovyCodeSource run() {
-                return new GroovyCodeSource(scriptText, fileName, DEFAULT_CODE_BASE);
-            }
-        });
+        GroovyCodeSource gcs = AccessController.doPrivileged((PrivilegedAction<GroovyCodeSource>) () -> new GroovyCodeSource(scriptText, fileName, DEFAULT_CODE_BASE));
         return parse(gcs);
     }
 
diff --git a/src/main/java/groovy/lang/ProxyMetaClass.java b/src/main/java/groovy/lang/ProxyMetaClass.java
index 06c8d96..ed1d8dd 100644
--- a/src/main/java/groovy/lang/ProxyMetaClass.java
+++ b/src/main/java/groovy/lang/ProxyMetaClass.java
@@ -115,11 +115,7 @@ public class ProxyMetaClass extends MetaClassImpl implements AdaptingMetaClass {
      * See Interceptor for details.
      */
     public Object invokeMethod(final Object object, final String methodName, final Object[] arguments) {
-        return doCall(object, methodName, arguments, interceptor, new Callable() {
-            public Object call() {
-                return adaptee.invokeMethod(object, methodName, arguments);
-            }
-        });
+        return doCall(object, methodName, arguments, interceptor, () -> adaptee.invokeMethod(object, methodName, arguments));
     }
 
     /**
@@ -130,11 +126,7 @@ public class ProxyMetaClass extends MetaClassImpl implements AdaptingMetaClass {
      */
     @Override
     public Object invokeMethod(final Class sender, final Object object, final String methodName, final Object[] arguments, final boolean isCallToSuper, final boolean fromInsideClass) {
-        return doCall(object, methodName, arguments, interceptor, new Callable() {
-            public Object call() {
-                return adaptee.invokeMethod(sender, object, methodName, arguments, isCallToSuper, fromInsideClass);
-            }
-        });
+        return doCall(object, methodName, arguments, interceptor, () -> adaptee.invokeMethod(sender, object, methodName, arguments, isCallToSuper, fromInsideClass));
     }
 
     /**
@@ -144,11 +136,7 @@ public class ProxyMetaClass extends MetaClassImpl implements AdaptingMetaClass {
      * See Interceptor for details.
      */
     public Object invokeStaticMethod(final Object object, final String methodName, final Object[] arguments) {
-        return doCall(object, methodName, arguments, interceptor, new Callable() {
-            public Object call() {
-                return adaptee.invokeStaticMethod(object, methodName, arguments);
-            }
-        });
+        return doCall(object, methodName, arguments, interceptor, () -> adaptee.invokeStaticMethod(object, methodName, arguments));
     }
 
     /**
@@ -158,11 +146,7 @@ public class ProxyMetaClass extends MetaClassImpl implements AdaptingMetaClass {
      * See Interceptor for details.
      */
     public Object invokeConstructor(final Object[] arguments) {
-        return doCall(theClass, "ctor", arguments, interceptor, new Callable() {
-            public Object call() {
-                return adaptee.invokeConstructor(arguments);
-            }
-        });
+        return doCall(theClass, "ctor", arguments, interceptor, () -> adaptee.invokeConstructor(arguments));
     }
 
     /**
diff --git a/src/main/java/groovy/util/FactoryBuilderSupport.java b/src/main/java/groovy/util/FactoryBuilderSupport.java
index 7316433..aeffa68 100644
--- a/src/main/java/groovy/util/FactoryBuilderSupport.java
+++ b/src/main/java/groovy/util/FactoryBuilderSupport.java
@@ -71,13 +71,11 @@ public abstract class FactoryBuilderSupport extends Binding {
     public static final String CHILD_BUILDER = "_CHILD_BUILDER_";
     public static final String SCRIPT_CLASS_NAME = "_SCRIPT_CLASS_NAME_";
     private static final Logger LOG = Logger.getLogger(FactoryBuilderSupport.class.getName());
-    private static final Comparator<Method> METHOD_COMPARATOR = new Comparator<Method>() {
-        public int compare(final Method o1, final Method o2) {
-            int cmp = o1.getName().compareTo(o2.getName());
-            if (cmp != 0) return cmp;
-            cmp = o1.getParameterTypes().length - o2.getParameterTypes().length;
-            return cmp;
-        }
+    private static final Comparator<Method> METHOD_COMPARATOR = (o1, o2) -> {
+        int cmp = o1.getName().compareTo(o2.getName());
+        if (cmp != 0) return cmp;
+        cmp = o1.getParameterTypes().length - o2.getParameterTypes().length;
+        return cmp;
     };
 
     /**
diff --git a/src/main/java/groovy/util/GroovyScriptEngine.java b/src/main/java/groovy/util/GroovyScriptEngine.java
index eede5cb..fa813a6 100644
--- a/src/main/java/groovy/util/GroovyScriptEngine.java
+++ b/src/main/java/groovy/util/GroovyScriptEngine.java
@@ -61,11 +61,7 @@ import java.util.concurrent.ConcurrentHashMap;
  * with dependent scripts.
  */
 public class GroovyScriptEngine implements ResourceConnector {
-    private static final ClassLoader CL_STUB = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
-        public ClassLoader run() {
-            return new ClassLoader() {};
-        }
-    });
+    private static final ClassLoader CL_STUB = AccessController.doPrivileged((PrivilegedAction<ClassLoader>) () -> new ClassLoader() {});
 
     private static final URL[] EMPTY_URL_ARRAY = new URL[0];
 
@@ -133,20 +129,18 @@ public class GroovyScriptEngine implements ResourceConnector {
 
         private void setResLoader() {
             final GroovyResourceLoader rl = getResourceLoader();
-            setResourceLoader(new GroovyResourceLoader() {
-                public URL loadGroovySource(String className) throws MalformedURLException {
-                    String filename;
-                    for (String extension : getConfig().getScriptExtensions()) {
-                        filename = className.replace('.', File.separatorChar) + "." + extension;
-                        try {
-                            URLConnection dependentScriptConn = rc.getResourceConnection(filename);
-                            return dependentScriptConn.getURL();
-                        } catch (ResourceException e) {
-                            //TODO: maybe do something here?
-                        }
+            setResourceLoader(className -> {
+                String filename;
+                for (String extension : getConfig().getScriptExtensions()) {
+                    filename = className.replace('.', File.separatorChar) + "." + extension;
+                    try {
+                        URLConnection dependentScriptConn = rc.getResourceConnection(filename);
+                        return dependentScriptConn.getURL();
+                    } catch (ResourceException e) {
+                        //TODO: maybe do something here?
                     }
-                    return rl.loadGroovySource(className);
                 }
+                return rl.loadGroovySource(className);
             });
         }
 
@@ -349,13 +343,11 @@ public class GroovyScriptEngine implements ResourceConnector {
      */
     private GroovyClassLoader initGroovyLoader() {
         GroovyClassLoader groovyClassLoader =
-                AccessController.doPrivileged(new PrivilegedAction<ScriptClassLoader>() {
-                    public ScriptClassLoader run() {
-                        if (parentLoader instanceof GroovyClassLoader) {
-                            return new ScriptClassLoader((GroovyClassLoader) parentLoader);
-                        } else {
-                            return new ScriptClassLoader(parentLoader, config);
-                        }
+                AccessController.doPrivileged((PrivilegedAction<ScriptClassLoader>) () -> {
+                    if (parentLoader instanceof GroovyClassLoader) {
+                        return new ScriptClassLoader((GroovyClassLoader) parentLoader);
+                    } else {
+                        return new ScriptClassLoader(parentLoader, config);
                     }
                 });
         for (URL root : roots) groovyClassLoader.addURL(root);
diff --git a/src/main/java/groovy/util/ObjectGraphBuilder.java b/src/main/java/groovy/util/ObjectGraphBuilder.java
index b6b6b48..5a10b26 100644
--- a/src/main/java/groovy/util/ObjectGraphBuilder.java
+++ b/src/main/java/groovy/util/ObjectGraphBuilder.java
@@ -152,13 +152,10 @@ public class ObjectGraphBuilder extends FactoryBuilderSupport {
             this.childPropertySetter = (ChildPropertySetter) childPropertySetter;
         } else if (childPropertySetter instanceof Closure) {
             final ObjectGraphBuilder self = this;
-            this.childPropertySetter = new ChildPropertySetter() {
-                public void setChild(Object parent, Object child, String parentName,
-                                     String propertyName) {
-                    Closure cls = (Closure) childPropertySetter;
-                    cls.setDelegate(self);
-                    cls.call(parent, child, parentName, propertyName);
-                }
+            this.childPropertySetter = (parent, child, parentName, propertyName) -> {
+                Closure cls = (Closure) childPropertySetter;
+                cls.setDelegate(self);
+                cls.call(parent, child, parentName, propertyName);
             };
         } else {
             this.childPropertySetter = new DefaultChildPropertySetter();
@@ -181,19 +178,13 @@ public class ObjectGraphBuilder extends FactoryBuilderSupport {
         if (classNameResolver instanceof ClassNameResolver) {
             this.classNameResolver = (ClassNameResolver) classNameResolver;
         } else if (classNameResolver instanceof String) {
-            this.classNameResolver = new ClassNameResolver() {
-                public String resolveClassname(String classname) {
-                    return makeClassName((String) classNameResolver, classname);
-                }
-            };
+            this.classNameResolver = classname -> makeClassName((String) classNameResolver, classname);
         } else if (classNameResolver instanceof Closure) {
             final ObjectGraphBuilder self = this;
-            this.classNameResolver = new ClassNameResolver() {
-                public String resolveClassname(String classname) {
-                    Closure cls = (Closure) classNameResolver;
-                    cls.setDelegate(self);
-                    return (String) cls.call(new Object[]{classname});
-                }
+            this.classNameResolver = classname -> {
+                Closure cls = (Closure) classNameResolver;
+                cls.setDelegate(self);
+                return (String) cls.call(new Object[]{classname});
             };
         } else if (classNameResolver instanceof Map) {
             Map classNameResolverOptions = (Map) classNameResolver;
@@ -229,19 +220,13 @@ public class ObjectGraphBuilder extends FactoryBuilderSupport {
         if (identifierResolver instanceof IdentifierResolver) {
             this.identifierResolver = (IdentifierResolver) identifierResolver;
         } else if (identifierResolver instanceof String) {
-            this.identifierResolver = new IdentifierResolver() {
-                public String getIdentifierFor(String nodeName) {
-                    return (String) identifierResolver;
-                }
-            };
+            this.identifierResolver = nodeName -> (String) identifierResolver;
         } else if (identifierResolver instanceof Closure) {
             final ObjectGraphBuilder self = this;
-            this.identifierResolver = new IdentifierResolver() {
-                public String getIdentifierFor(String nodeName) {
-                    Closure cls = (Closure) identifierResolver;
-                    cls.setDelegate(self);
-                    return (String) cls.call(new Object[]{nodeName});
-                }
+            this.identifierResolver = nodeName -> {
+                Closure cls = (Closure) identifierResolver;
+                cls.setDelegate(self);
+                return (String) cls.call(new Object[]{nodeName});
             };
         } else {
             this.identifierResolver = new DefaultIdentifierResolver();
@@ -265,13 +250,10 @@ public class ObjectGraphBuilder extends FactoryBuilderSupport {
             this.newInstanceResolver = (NewInstanceResolver) newInstanceResolver;
         } else if (newInstanceResolver instanceof Closure) {
             final ObjectGraphBuilder self = this;
-            this.newInstanceResolver = new NewInstanceResolver() {
-                public Object newInstance(Class klass, Map attributes)
-                        throws InstantiationException, IllegalAccessException {
-                    Closure cls = (Closure) newInstanceResolver;
-                    cls.setDelegate(self);
-                    return cls.call(klass, attributes);
-                }
+            this.newInstanceResolver = (klass, attributes) -> {
+                Closure cls = (Closure) newInstanceResolver;
+                cls.setDelegate(self);
+                return cls.call(klass, attributes);
             };
         } else {
             this.newInstanceResolver = new DefaultNewInstanceResolver();
@@ -287,19 +269,13 @@ public class ObjectGraphBuilder extends FactoryBuilderSupport {
         if (referenceResolver instanceof ReferenceResolver) {
             this.referenceResolver = (ReferenceResolver) referenceResolver;
         } else if (referenceResolver instanceof String) {
-            this.referenceResolver = new ReferenceResolver() {
-                public String getReferenceFor(String nodeName) {
-                    return (String) referenceResolver;
-                }
-            };
+            this.referenceResolver = nodeName -> (String) referenceResolver;
         } else if (referenceResolver instanceof Closure) {
             final ObjectGraphBuilder self = this;
-            this.referenceResolver = new ReferenceResolver() {
-                public String getReferenceFor(String nodeName) {
-                    Closure cls = (Closure) referenceResolver;
-                    cls.setDelegate(self);
-                    return (String) cls.call(new Object[]{nodeName});
-                }
+            this.referenceResolver = nodeName -> {
+                Closure cls = (Closure) referenceResolver;
+                cls.setDelegate(self);
+                return (String) cls.call(new Object[]{nodeName});
             };
         } else {
             this.referenceResolver = new DefaultReferenceResolver();
diff --git a/src/main/java/groovy/util/ProxyGenerator.java b/src/main/java/groovy/util/ProxyGenerator.java
index 3fd5ff2..06d6a2a 100644
--- a/src/main/java/groovy/util/ProxyGenerator.java
+++ b/src/main/java/groovy/util/ProxyGenerator.java
@@ -247,14 +247,12 @@ public class ProxyGenerator {
     }
     
     private static final class CacheKey {
-        private static final Comparator<Class> INTERFACE_COMPARATOR = new Comparator<Class>() {
-            public int compare(final Class o1, final Class o2) {
-                // Traits order *must* be preserved
-                // See GROOVY-7285
-                if (Traits.isTrait(o1)) return -1;
-                if (Traits.isTrait(o2)) return 1;
-                return o1.getName().compareTo(o2.getName());
-            }
+        private static final Comparator<Class> INTERFACE_COMPARATOR = (o1, o2) -> {
+            // Traits order *must* be preserved
+            // See GROOVY-7285
+            if (Traits.isTrait(o1)) return -1;
+            if (Traits.isTrait(o2)) return 1;
+            return o1.getName().compareTo(o2.getName());
         };
         private final boolean emptyMethods;
         private final boolean useDelegate;
diff --git a/src/main/java/org/apache/groovy/internal/util/ReevaluatingReference.java b/src/main/java/org/apache/groovy/internal/util/ReevaluatingReference.java
index feeeea8..255e97b 100644
--- a/src/main/java/org/apache/groovy/internal/util/ReevaluatingReference.java
+++ b/src/main/java/org/apache/groovy/internal/util/ReevaluatingReference.java
@@ -41,15 +41,10 @@ public class ReevaluatingReference<T> {
     static {
         try {
             //TODO Jochen: move the findSpecial to a central place together with others to easy security configuration
-            FALLBACK_HANDLE = AccessController.doPrivileged(new PrivilegedExceptionAction<MethodHandle>() {
-                @Override
-                public MethodHandle run() throws Exception {
-                    return  MethodHandles.lookup().findSpecial(
-                            ReevaluatingReference.class, "replacePayLoad",
-                            MethodType.methodType(Object.class),
-                            ReevaluatingReference.class);
-                }
-            });
+            FALLBACK_HANDLE = AccessController.doPrivileged((PrivilegedExceptionAction<MethodHandle>) () -> MethodHandles.lookup().findSpecial(
+                    ReevaluatingReference.class, "replacePayLoad",
+                    MethodType.methodType(Object.class),
+                    ReevaluatingReference.class));
         } catch (PrivilegedActionException e) {
             throw new GroovyBugError(e);
         }
diff --git a/src/main/java/org/codehaus/groovy/ast/tools/WideningCategories.java b/src/main/java/org/codehaus/groovy/ast/tools/WideningCategories.java
index 374239c..85cdd76 100644
--- a/src/main/java/org/codehaus/groovy/ast/tools/WideningCategories.java
+++ b/src/main/java/org/codehaus/groovy/ast/tools/WideningCategories.java
@@ -89,18 +89,16 @@ public class WideningCategories {
      * since a concrete implementation should be used at compile time, we must ensure that interfaces are
      * always sorted. It is not important what sort is used, as long as the result is constant.
      */
-    private static final Comparator<ClassNode> INTERFACE_CLASSNODE_COMPARATOR = new Comparator<ClassNode>() {
-        public int compare(final ClassNode o1, final ClassNode o2) {
-            int interfaceCountForO1 = o1.getInterfaces().length;
-            int interfaceCountForO2 = o2.getInterfaces().length;
-            if (interfaceCountForO1 > interfaceCountForO2) return -1;
-            if (interfaceCountForO1 < interfaceCountForO2) return 1;
-            int methodCountForO1 = o1.getMethods().size();
-            int methodCountForO2 = o2.getMethods().size();
-            if (methodCountForO1 > methodCountForO2) return -1;
-            if (methodCountForO1 < methodCountForO2) return 1;
-            return o1.getName().compareTo(o2.getName());
-        }
+    private static final Comparator<ClassNode> INTERFACE_CLASSNODE_COMPARATOR = (o1, o2) -> {
+        int interfaceCountForO1 = o1.getInterfaces().length;
+        int interfaceCountForO2 = o2.getInterfaces().length;
+        if (interfaceCountForO1 > interfaceCountForO2) return -1;
+        if (interfaceCountForO1 < interfaceCountForO2) return 1;
+        int methodCountForO1 = o1.getMethods().size();
+        int methodCountForO2 = o2.getMethods().size();
+        if (methodCountForO1 > methodCountForO2) return -1;
+        if (methodCountForO1 < methodCountForO2) return 1;
+        return o1.getName().compareTo(o2.getName());
     };
 
     /**
@@ -592,12 +590,10 @@ public class WideningCategories {
      *
      */
     public static class LowestUpperBoundClassNode extends ClassNode {
-        private static final Comparator<ClassNode> CLASS_NODE_COMPARATOR = new Comparator<ClassNode>() {
-            public int compare(final ClassNode o1, final ClassNode o2) {
-                String n1 = o1 instanceof LowestUpperBoundClassNode?((LowestUpperBoundClassNode)o1).name:o1.getName();
-                String n2 = o2 instanceof LowestUpperBoundClassNode?((LowestUpperBoundClassNode)o2).name:o2.getName();
-                return n1.compareTo(n2);
-            }
+        private static final Comparator<ClassNode> CLASS_NODE_COMPARATOR = (o1, o2) -> {
+            String n1 = o1 instanceof LowestUpperBoundClassNode?((LowestUpperBoundClassNode)o1).name:o1.getName();
+            String n2 = o2 instanceof LowestUpperBoundClassNode?((LowestUpperBoundClassNode)o2).name:o2.getName();
+            return n1.compareTo(n2);
         };
         private final ClassNode compileTimeClassNode;
         private final String name;
diff --git a/src/main/java/org/codehaus/groovy/classgen/ReturnAdder.java b/src/main/java/org/codehaus/groovy/classgen/ReturnAdder.java
index 22f3059..110cb99 100644
--- a/src/main/java/org/codehaus/groovy/classgen/ReturnAdder.java
+++ b/src/main/java/org/codehaus/groovy/classgen/ReturnAdder.java
@@ -46,9 +46,7 @@ import java.util.List;
  */
 public class ReturnAdder {
 
-    private static final ReturnStatementListener DEFAULT_LISTENER = new ReturnStatementListener() {
-        public void returnStatementAdded(final ReturnStatement returnStatement) {
-        }
+    private static final ReturnStatementListener DEFAULT_LISTENER = returnStatement -> {
     };
 
     /**
@@ -165,12 +163,7 @@ public class ReturnAdder {
         if (statement instanceof TryCatchStatement) {
             TryCatchStatement trys = (TryCatchStatement) statement;
             final boolean[] missesReturn = new boolean[1];
-            new ReturnAdder(new ReturnStatementListener() {
-                @Override
-                public void returnStatementAdded(ReturnStatement returnStatement) {
-                    missesReturn[0] = true;
-                }
-            }).addReturnsIfNeeded(trys.getFinallyStatement(), scope);
+            new ReturnAdder(returnStatement -> missesReturn[0] = true).addReturnsIfNeeded(trys.getFinallyStatement(), scope);
             boolean hasFinally = !(trys.getFinallyStatement() instanceof EmptyStatement);
 
             // if there is no missing return in the finally block and the block exists
diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/InvocationWriter.java b/src/main/java/org/codehaus/groovy/classgen/asm/InvocationWriter.java
index 3287481..c4a40ad 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/InvocationWriter.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/InvocationWriter.java
@@ -718,14 +718,12 @@ public class InvocationWriter {
     private static List<ConstructorNode> sortConstructors(ConstructorCallExpression call, ClassNode callNode) {
         // sort in a new list to prevent side effects
         List<ConstructorNode> constructors = new ArrayList<ConstructorNode>(callNode.getDeclaredConstructors());
-        Comparator comp = new Comparator() {
-            public int compare(Object arg0, Object arg1) {
-                ConstructorNode c0 = (ConstructorNode) arg0;
-                ConstructorNode c1 = (ConstructorNode) arg1;
-                String descriptor0 = BytecodeHelper.getMethodDescriptor(ClassHelper.VOID_TYPE, c0.getParameters());
-                String descriptor1 = BytecodeHelper.getMethodDescriptor(ClassHelper.VOID_TYPE, c1.getParameters());
-                return descriptor0.compareTo(descriptor1);
-            }
+        Comparator comp = (arg0, arg1) -> {
+            ConstructorNode c0 = (ConstructorNode) arg0;
+            ConstructorNode c1 = (ConstructorNode) arg1;
+            String descriptor0 = BytecodeHelper.getMethodDescriptor(ClassHelper.VOID_TYPE, c0.getParameters());
+            String descriptor1 = BytecodeHelper.getMethodDescriptor(ClassHelper.VOID_TYPE, c1.getParameters());
+            return descriptor0.compareTo(descriptor1);
         };
         Collections.sort(constructors, comp);
         return constructors;
diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/StatementWriter.java b/src/main/java/org/codehaus/groovy/classgen/asm/StatementWriter.java
index 3a1f712..ad37efb 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/StatementWriter.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/StatementWriter.java
@@ -437,13 +437,10 @@ public class StatementWriter {
 
     private BlockRecorder makeBlockRecorder(Statement finallyStatement) {
         final BlockRecorder block = new BlockRecorder();
-        block.excludedStatement = new Runnable() {
-            @Override
-            public void run() {
-                controller.getCompileStack().pushBlockRecorderVisit(block);
-                finallyStatement.visit(controller.getAcg());
-                controller.getCompileStack().popBlockRecorderVisit(block);
-            }
+        block.excludedStatement = () -> {
+            controller.getCompileStack().pushBlockRecorderVisit(block);
+            finallyStatement.visit(controller.getAcg());
+            controller.getCompileStack().popBlockRecorderVisit(block);
         };
         controller.getCompileStack().pushBlockRecorder(block);
         return block;
@@ -553,12 +550,9 @@ public class StatementWriter {
         // if there is only a break/continue.
         mv.visitInsn(NOP);
 
-        Runnable finallyPart = new Runnable() {
-            @Override
-            public void run() {
-                mv.visitVarInsn(ALOAD, index);
-                mv.visitInsn(MONITOREXIT);
-            }
+        Runnable finallyPart = () -> {
+            mv.visitVarInsn(ALOAD, index);
+            mv.visitInsn(MONITOREXIT);
         };
         BlockRecorder fb = new BlockRecorder(finallyPart);
         fb.startRange(synchronizedStart);
diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticCompilationMopWriter.java b/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticCompilationMopWriter.java
index c30040d..781ebe1 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticCompilationMopWriter.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticCompilationMopWriter.java
@@ -35,12 +35,7 @@ import java.util.LinkedList;
  */
 public class StaticCompilationMopWriter extends MopWriter {
 
-    public static final MopWriter.Factory FACTORY = new MopWriter.Factory() {
-        @Override
-        public MopWriter create(final WriterController controller) {
-            return new StaticCompilationMopWriter(controller);
-        }
-    };
+    public static final MopWriter.Factory FACTORY = controller -> new StaticCompilationMopWriter(controller);
 
     private final StaticTypesWriterController controller;
 
diff --git a/src/main/java/org/codehaus/groovy/control/ProcessingUnit.java b/src/main/java/org/codehaus/groovy/control/ProcessingUnit.java
index a16c826..83146cf 100644
--- a/src/main/java/org/codehaus/groovy/control/ProcessingUnit.java
+++ b/src/main/java/org/codehaus/groovy/control/ProcessingUnit.java
@@ -98,12 +98,10 @@ public abstract class ProcessingUnit {
     public void setClassLoader(final GroovyClassLoader loader) {
         // ClassLoaders should only be created inside a doPrivileged block in case
         // this method is invoked by code that does not have security permissions.
-        this.classLoader = loader != null ? loader : AccessController.doPrivileged(new PrivilegedAction<GroovyClassLoader>() {
-            public GroovyClassLoader run() {
-                ClassLoader parent = Thread.currentThread().getContextClassLoader();
-                if (parent == null) parent = ProcessingUnit.class.getClassLoader();
-                return new GroovyClassLoader(parent, getConfiguration());
-            }
+        this.classLoader = loader != null ? loader : AccessController.doPrivileged((PrivilegedAction<GroovyClassLoader>) () -> {
+            ClassLoader parent = Thread.currentThread().getContextClassLoader();
+            if (parent == null) parent = ProcessingUnit.class.getClassLoader();
+            return new GroovyClassLoader(parent, getConfiguration());
         });
     }
 
diff --git a/src/main/java/org/codehaus/groovy/control/SourceUnit.java b/src/main/java/org/codehaus/groovy/control/SourceUnit.java
index 5188611..561f42d 100644
--- a/src/main/java/org/codehaus/groovy/control/SourceUnit.java
+++ b/src/main/java/org/codehaus/groovy/control/SourceUnit.java
@@ -256,11 +256,7 @@ public class SourceUnit extends ProcessingUnit {
             getErrorCollector().addError(new SyntaxErrorMessage(e, this));
         }
 
-        String property = (String) AccessController.doPrivileged(new PrivilegedAction() {
-            public Object run() {
-                return System.getProperty("groovy.ast");
-            }
-        });
+        String property = (String) AccessController.doPrivileged((PrivilegedAction) () -> System.getProperty("groovy.ast"));
 
         if ("xml".equals(property)) {
             saveAsXML(name, ast);
diff --git a/src/main/java/org/codehaus/groovy/reflection/SunClassLoader.java b/src/main/java/org/codehaus/groovy/reflection/SunClassLoader.java
index 0a6a082..6914585 100644
--- a/src/main/java/org/codehaus/groovy/reflection/SunClassLoader.java
+++ b/src/main/java/org/codehaus/groovy/reflection/SunClassLoader.java
@@ -41,13 +41,11 @@ public class SunClassLoader extends ClassLoader implements Opcodes {
     static {
         SunClassLoader res;
         try {
-            res = AccessController.doPrivileged(new PrivilegedAction<SunClassLoader>() {
-                public SunClassLoader run() {
-                    try {
-                        return new SunClassLoader();
-                    } catch (Throwable e) {
-                        return null;
-                    }
+            res = AccessController.doPrivileged((PrivilegedAction<SunClassLoader>) () -> {
+                try {
+                    return new SunClassLoader();
+                } catch (Throwable e) {
+                    return null;
                 }
             });
         }
diff --git a/src/main/java/org/codehaus/groovy/runtime/ProcessGroovyMethods.java b/src/main/java/org/codehaus/groovy/runtime/ProcessGroovyMethods.java
index 7348d3f..fc82dc9 100644
--- a/src/main/java/org/codehaus/groovy/runtime/ProcessGroovyMethods.java
+++ b/src/main/java/org/codehaus/groovy/runtime/ProcessGroovyMethods.java
@@ -348,13 +348,11 @@ public class ProcessGroovyMethods extends DefaultGroovyMethodsSupport {
      * @since 1.5.2
      */
     public static void withWriter(final Process self, final Closure closure) {
-        new Thread(new Runnable() {
-            public void run() {
-                try {
-                    IOGroovyMethods.withWriter(new BufferedOutputStream(getOut(self)), closure);
-                } catch (IOException e) {
-                    throw new GroovyRuntimeException("exception while reading process stream", e);
-                }
+        new Thread(() -> {
+            try {
+                IOGroovyMethods.withWriter(new BufferedOutputStream(getOut(self)), closure);
+            } catch (IOException e) {
+                throw new GroovyRuntimeException("exception while reading process stream", e);
             }
         }).start();
     }
@@ -370,13 +368,11 @@ public class ProcessGroovyMethods extends DefaultGroovyMethodsSupport {
      * @since 1.5.2
      */
     public static void withOutputStream(final Process self, final Closure closure) {
-        new Thread(new Runnable() {
-            public void run() {
-                try {
-                    IOGroovyMethods.withStream(new BufferedOutputStream(getOut(self)), closure);
-                } catch (IOException e) {
-                    throw new GroovyRuntimeException("exception while reading process stream", e);
-                }
+        new Thread(() -> {
+            try {
+                IOGroovyMethods.withStream(new BufferedOutputStream(getOut(self)), closure);
+            } catch (IOException e) {
+                throw new GroovyRuntimeException("exception while reading process stream", e);
             }
         }).start();
     }
@@ -391,22 +387,20 @@ public class ProcessGroovyMethods extends DefaultGroovyMethodsSupport {
      * @since 1.5.2
      */
     public static Process pipeTo(final Process left, final Process right) throws IOException {
-        new Thread(new Runnable() {
-            public void run() {
-                InputStream in = new BufferedInputStream(getIn(left));
-                OutputStream out = new BufferedOutputStream(getOut(right));
-                byte[] buf = new byte[8192];
-                int next;
-                try {
-                    while ((next = in.read(buf)) != -1) {
-                        out.write(buf, 0, next);
-                    }
-                } catch (IOException e) {
-                    throw new GroovyRuntimeException("exception while reading process stream", e);
-                } finally {
-                    closeWithWarning(out);
-                    closeWithWarning(in);
+        new Thread(() -> {
+            InputStream in = new BufferedInputStream(getIn(left));
+            OutputStream out = new BufferedOutputStream(getOut(right));
+            byte[] buf = new byte[8192];
+            int next;
+            try {
+                while ((next = in.read(buf)) != -1) {
+                    out.write(buf, 0, next);
                 }
+            } catch (IOException e) {
+                throw new GroovyRuntimeException("exception while reading process stream", e);
+            } finally {
+                closeWithWarning(out);
+                closeWithWarning(in);
             }
         }).start();
         return right;
diff --git a/src/main/java/org/codehaus/groovy/runtime/ProxyGeneratorAdapter.java b/src/main/java/org/codehaus/groovy/runtime/ProxyGeneratorAdapter.java
index 8f688cb..23c4017 100644
--- a/src/main/java/org/codehaus/groovy/runtime/ProxyGeneratorAdapter.java
+++ b/src/main/java/org/codehaus/groovy/runtime/ProxyGeneratorAdapter.java
@@ -252,11 +252,7 @@ public class ProxyGeneratorAdapter extends ClassVisitor implements Opcodes {
     }
 
     private static InnerLoader createInnerLoader(final ClassLoader parent, final Class[] interfaces) {
-        return AccessController.doPrivileged(new PrivilegedAction<InnerLoader>() {
-            public InnerLoader run() {
-                return new InnerLoader(parent, interfaces);
-            }
-        });
+        return AccessController.doPrivileged((PrivilegedAction<InnerLoader>) () -> new InnerLoader(parent, interfaces));
     }
 
     private InnerLoader findClassLoader(Class clazz, Class[] interfaces) {
diff --git a/src/main/java/org/codehaus/groovy/runtime/SocketGroovyMethods.java b/src/main/java/org/codehaus/groovy/runtime/SocketGroovyMethods.java
index ded99e5..38a9053 100644
--- a/src/main/java/org/codehaus/groovy/runtime/SocketGroovyMethods.java
+++ b/src/main/java/org/codehaus/groovy/runtime/SocketGroovyMethods.java
@@ -178,11 +178,7 @@ public class SocketGroovyMethods extends DefaultGroovyMethodsSupport {
                                 @ClosureParams(value=SimpleType.class, options="java.net.Socket") final Closure closure) throws IOException {
         final Socket socket = serverSocket.accept();
         if (runInANewThread) {
-            new Thread(new Runnable() {
-                public void run() {
-                    invokeClosureWithSocket(socket, closure);
-                }
-            }).start();
+            new Thread(() -> invokeClosureWithSocket(socket, closure)).start();
         } else {
             invokeClosureWithSocket(socket, closure);
         }
diff --git a/src/main/java/org/codehaus/groovy/runtime/callsite/GroovySunClassLoader.java b/src/main/java/org/codehaus/groovy/runtime/callsite/GroovySunClassLoader.java
index 71fd21e..1462825 100644
--- a/src/main/java/org/codehaus/groovy/runtime/callsite/GroovySunClassLoader.java
+++ b/src/main/java/org/codehaus/groovy/runtime/callsite/GroovySunClassLoader.java
@@ -33,17 +33,15 @@ public class GroovySunClassLoader extends SunClassLoader {
     public static final SunClassLoader sunVM;
 
     static {
-            sunVM = AccessController.doPrivileged(new PrivilegedAction<SunClassLoader>() {
-                public SunClassLoader run() {
-                    try {
-                        if (SunClassLoader.sunVM != null) {
-                            return new GroovySunClassLoader();
-                        }
+            sunVM = AccessController.doPrivileged((PrivilegedAction<SunClassLoader>) () -> {
+                try {
+                    if (SunClassLoader.sunVM != null) {
+                        return new GroovySunClassLoader();
                     }
-                    catch (Throwable t) {//
-                    }
-                    return null;
                 }
+                catch (Throwable t) {//
+                }
+                return null;
             });
     }
 
diff --git a/src/main/java/org/codehaus/groovy/runtime/metaclass/MetaClassRegistryImpl.java b/src/main/java/org/codehaus/groovy/runtime/metaclass/MetaClassRegistryImpl.java
index 5495b9a..ec9fe1b 100644
--- a/src/main/java/org/codehaus/groovy/runtime/metaclass/MetaClassRegistryImpl.java
+++ b/src/main/java/org/codehaus/groovy/runtime/metaclass/MetaClassRegistryImpl.java
@@ -135,25 +135,23 @@ public class MetaClassRegistryImpl implements MetaClassRegistry{
         ClassInfo.getClassInfo(ExpandoMetaClass.class).setStrongMetaClass(emcMetaClass);
 
 
-        addNonRemovableMetaClassRegistryChangeEventListener(new MetaClassRegistryChangeEventListener(){
-            public void updateConstantMetaClass(MetaClassRegistryChangeEvent cmcu) {
-                // The calls to DefaultMetaClassInfo.setPrimitiveMeta and sdyn.setBoolean need to be
-                // ordered. Even though metaClassInfo is thread-safe, it is included in the block
-                // so the meta classes are added to the queue in the same order.
-                synchronized (metaClassInfo) {
-                   metaClassInfo.add(cmcu.getNewMetaClass());
-                   DefaultMetaClassInfo.getNewConstantMetaClassVersioning();
-                   Class c = cmcu.getClassToUpdate();
-                   DefaultMetaClassInfo.setPrimitiveMeta(c, cmcu.getNewMetaClass()==null);
-                   Field sdyn;
-                   try {
-                       sdyn = c.getDeclaredField(Verifier.STATIC_METACLASS_BOOL);
-                       sdyn.setBoolean(null, cmcu.getNewMetaClass()!=null);
-                   } catch (Throwable e) {
-                       //DO NOTHING
-                   }
+        addNonRemovableMetaClassRegistryChangeEventListener(cmcu -> {
+            // The calls to DefaultMetaClassInfo.setPrimitiveMeta and sdyn.setBoolean need to be
+            // ordered. Even though metaClassInfo is thread-safe, it is included in the block
+            // so the meta classes are added to the queue in the same order.
+            synchronized (metaClassInfo) {
+               metaClassInfo.add(cmcu.getNewMetaClass());
+               DefaultMetaClassInfo.getNewConstantMetaClassVersioning();
+               Class c = cmcu.getClassToUpdate();
+               DefaultMetaClassInfo.setPrimitiveMeta(c, cmcu.getNewMetaClass()==null);
+               Field sdyn;
+               try {
+                   sdyn = c.getDeclaredField(Verifier.STATIC_METACLASS_BOOL);
+                   sdyn.setBoolean(null, cmcu.getNewMetaClass()!=null);
+               } catch (Throwable e) {
+                   //DO NOTHING
+               }
 
-                }
             }
         });
    }
diff --git a/src/main/java/org/codehaus/groovy/tools/GroovyStarter.java b/src/main/java/org/codehaus/groovy/tools/GroovyStarter.java
index 08f8f1c..c745510 100644
--- a/src/main/java/org/codehaus/groovy/tools/GroovyStarter.java
+++ b/src/main/java/org/codehaus/groovy/tools/GroovyStarter.java
@@ -94,11 +94,7 @@ public class GroovyStarter {
             }
         }
         // create loader and execute main class
-        ClassLoader loader = AccessController.doPrivileged(new PrivilegedAction<RootLoader>() {
-            public RootLoader run() {
-                return new RootLoader(lc);
-            }
-        });
+        ClassLoader loader = AccessController.doPrivileged((PrivilegedAction<RootLoader>) () -> new RootLoader(lc));
         Method m=null;
         try {
             Class c = loader.loadClass(lc.getMainClass());
diff --git a/src/main/java/org/codehaus/groovy/transform/SortableASTTransformation.java b/src/main/java/org/codehaus/groovy/transform/SortableASTTransformation.java
index e45772c..7acd487 100644
--- a/src/main/java/org/codehaus/groovy/transform/SortableASTTransformation.java
+++ b/src/main/java/org/codehaus/groovy/transform/SortableASTTransformation.java
@@ -236,11 +236,7 @@ public class SortableASTTransformation extends AbstractASTTransformation {
             checkComparable(pNode);
         }
         if (includes != null) {
-            Comparator<PropertyNode> includeComparator = new Comparator<PropertyNode>() {
-                public int compare(PropertyNode o1, PropertyNode o2) {
-                    return Integer.compare(includes.indexOf(o1.getName()), includes.indexOf(o2.getName()));
-                }
-            };
+            Comparator<PropertyNode> includeComparator = (o1, o2) -> Integer.compare(includes.indexOf(o1.getName()), includes.indexOf(o2.getName()));
             Collections.sort(properties, includeComparator);
         }
         return properties;
diff --git a/src/main/java/org/codehaus/groovy/transform/ToStringASTTransformation.java b/src/main/java/org/codehaus/groovy/transform/ToStringASTTransformation.java
index eff7aa6..7de6e13 100644
--- a/src/main/java/org/codehaus/groovy/transform/ToStringASTTransformation.java
+++ b/src/main/java/org/codehaus/groovy/transform/ToStringASTTransformation.java
@@ -218,11 +218,7 @@ public class ToStringASTTransformation extends AbstractASTTransformation {
         }
 
         if (includes != null) {
-            Comparator<ToStringElement> includeComparator = new Comparator<ToStringElement>() {
-                public int compare(ToStringElement tse1, ToStringElement tse2) {
-                    return Integer.compare(includes.indexOf(tse1.name), includes.indexOf(tse2.name));
-                }
-            };
+            Comparator<ToStringElement> includeComparator = (tse1, tse2) -> Integer.compare(includes.indexOf(tse1.name), includes.indexOf(tse2.name));
             Collections.sort(elements, includeComparator);
         }
 
diff --git a/src/main/java/org/codehaus/groovy/transform/TupleConstructorASTTransformation.java b/src/main/java/org/codehaus/groovy/transform/TupleConstructorASTTransformation.java
index 65cd26d..def9095 100644
--- a/src/main/java/org/codehaus/groovy/transform/TupleConstructorASTTransformation.java
+++ b/src/main/java/org/codehaus/groovy/transform/TupleConstructorASTTransformation.java
@@ -248,11 +248,7 @@ public class TupleConstructorASTTransformation extends AbstractASTTransformation
         }
 
         if (includes != null) {
-            Comparator<Parameter> includeComparator = new Comparator<Parameter>() {
-                public int compare(Parameter p1, Parameter p2) {
-                    return Integer.compare(includes.indexOf(p1.getName()), includes.indexOf(p2.getName()));
-                }
-            };
+            Comparator<Parameter> includeComparator = (p1, p2) -> Integer.compare(includes.indexOf(p1.getName()), includes.indexOf(p2.getName()));
             Collections.sort(params, includeComparator);
         }
 
diff --git a/src/main/java/org/codehaus/groovy/vmplugin/v7/IndyInterface.java b/src/main/java/org/codehaus/groovy/vmplugin/v7/IndyInterface.java
index 6057476..3cbfad3 100644
--- a/src/main/java/org/codehaus/groovy/vmplugin/v7/IndyInterface.java
+++ b/src/main/java/org/codehaus/groovy/vmplugin/v7/IndyInterface.java
@@ -19,8 +19,6 @@
 package org.codehaus.groovy.vmplugin.v7;
 
 import groovy.lang.GroovySystem;
-import groovy.lang.MetaClassRegistryChangeEvent;
-import groovy.lang.MetaClassRegistryChangeEventListener;
 import org.codehaus.groovy.GroovyBugError;
 
 import java.lang.invoke.CallSite;
@@ -104,11 +102,7 @@ public class IndyInterface {
 
         protected static SwitchPoint switchPoint = new SwitchPoint();
         static {
-            GroovySystem.getMetaClassRegistry().addMetaClassRegistryChangeEventListener(new MetaClassRegistryChangeEventListener() {
-                public void updateConstantMetaClass(MetaClassRegistryChangeEvent cmcu) {
-                	invalidateSwitchPoints();
-                }
-            });
+            GroovySystem.getMetaClassRegistry().addMetaClassRegistryChangeEventListener(cmcu -> invalidateSwitchPoints());
         }
 
         /**
diff --git a/src/main/java/org/codehaus/groovy/vmplugin/v7/Java7.java b/src/main/java/org/codehaus/groovy/vmplugin/v7/Java7.java
index 071e71e..bc93bbd 100644
--- a/src/main/java/org/codehaus/groovy/vmplugin/v7/Java7.java
+++ b/src/main/java/org/codehaus/groovy/vmplugin/v7/Java7.java
@@ -47,12 +47,9 @@ public class Java7 extends Java6 {
             try {
                 if (!con.isAccessible()) {
                     final Constructor tmp = con;
-                    AccessController.doPrivileged(new PrivilegedAction<Object>() {
-                        @Override
-                        public Object run() {
-                            ReflectionUtils.trySetAccessible(tmp);
-                            return null;
-                        }
+                    AccessController.doPrivileged((PrivilegedAction<Object>) () -> {
+                        ReflectionUtils.trySetAccessible(tmp);
+                        return null;
                     });
                 }
             } catch (SecurityException se) {
@@ -86,12 +83,9 @@ public class Java7 extends Java6 {
             return super.getInvokeSpecialHandle(method, receiver);
         }
         if (!method.isAccessible()) {
-            AccessController.doPrivileged(new PrivilegedAction<Object>() {
-                @Override
-                public Object run() {
-                    ReflectionUtils.trySetAccessible(method);
-                    return null;
-                }
+            AccessController.doPrivileged((PrivilegedAction<Object>) () -> {
+                ReflectionUtils.trySetAccessible(method);
+                return null;
             });
         }
         Class declaringClass = method.getDeclaringClass();


[groovy] 06/06: Trivial refactoring: remove unused imports

Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit ebe9d61a42f3a5d4571c31a7b3d54a1cc6e1b060
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sun Nov 3 21:37:10 2019 +0800

    Trivial refactoring: remove unused imports
---
 src/main/java/org/codehaus/groovy/control/LabelVerifier.java             | 1 -
 .../java/org/codehaus/groovy/runtime/powerassert/AssertionRenderer.java  | 1 -
 .../org/codehaus/groovy/transform/MapConstructorASTTransformation.java   | 1 -
 3 files changed, 3 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/control/LabelVerifier.java b/src/main/java/org/codehaus/groovy/control/LabelVerifier.java
index 65bb6b5..0708db8 100644
--- a/src/main/java/org/codehaus/groovy/control/LabelVerifier.java
+++ b/src/main/java/org/codehaus/groovy/control/LabelVerifier.java
@@ -27,7 +27,6 @@ import org.codehaus.groovy.ast.stmt.Statement;
 import org.codehaus.groovy.ast.stmt.SwitchStatement;
 import org.codehaus.groovy.ast.stmt.WhileStatement;
 
-import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 
diff --git a/src/main/java/org/codehaus/groovy/runtime/powerassert/AssertionRenderer.java b/src/main/java/org/codehaus/groovy/runtime/powerassert/AssertionRenderer.java
index 5644bec..e911e6c 100644
--- a/src/main/java/org/codehaus/groovy/runtime/powerassert/AssertionRenderer.java
+++ b/src/main/java/org/codehaus/groovy/runtime/powerassert/AssertionRenderer.java
@@ -22,7 +22,6 @@ import org.codehaus.groovy.runtime.InvokerHelper;
 
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Comparator;
 import java.util.List;
 
 /**
diff --git a/src/main/java/org/codehaus/groovy/transform/MapConstructorASTTransformation.java b/src/main/java/org/codehaus/groovy/transform/MapConstructorASTTransformation.java
index 8888960..5939c83 100644
--- a/src/main/java/org/codehaus/groovy/transform/MapConstructorASTTransformation.java
+++ b/src/main/java/org/codehaus/groovy/transform/MapConstructorASTTransformation.java
@@ -45,7 +45,6 @@ import org.codehaus.groovy.control.SourceUnit;
 
 import java.util.ArrayList;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;


[groovy] 03/06: Minor refactoring: Lambda can be replaced with method reference

Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit d852871dc12cb72716f2cbb0d2a0e2160cc11aac
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sun Nov 3 21:29:25 2019 +0800

    Minor refactoring: Lambda can be replaced with method reference
---
 .../java/org/codehaus/groovy/reflection/stdclasses/CachedSAMClass.java | 3 +--
 .../org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java   | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/reflection/stdclasses/CachedSAMClass.java b/src/main/java/org/codehaus/groovy/reflection/stdclasses/CachedSAMClass.java
index 9ab08c2..227eba4 100644
--- a/src/main/java/org/codehaus/groovy/reflection/stdclasses/CachedSAMClass.java
+++ b/src/main/java/org/codehaus/groovy/reflection/stdclasses/CachedSAMClass.java
@@ -37,7 +37,6 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
-import java.util.ListIterator;
 import java.util.Map;
 
 public class CachedSAMClass extends CachedClass {
@@ -103,7 +102,7 @@ public class CachedSAMClass extends CachedClass {
 
     private static Method[] getDeclaredMethods(final Class c) {
         try {
-            Method[] methods = AccessController.doPrivileged((PrivilegedAction<Method[]>) () -> c.getDeclaredMethods());
+            Method[] methods = AccessController.doPrivileged((PrivilegedAction<Method[]>) c::getDeclaredMethods);
             if (methods!=null) return methods;
         } catch (java.security.AccessControlException ace) {
             // swallow and do as if no method is available
diff --git a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
index 84728cd..dd74327 100644
--- a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
+++ b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
@@ -1191,7 +1191,7 @@ public abstract class StaticTypeCheckingSupport {
         return Arrays.stream(params).map(param -> {
             String name = param.getType().getUnresolvedName();
             Optional<GenericsType> value = genericsPlaceholderAndTypeMap.entrySet().stream()
-                .filter(e -> e.getKey().getName().equals(name)).findFirst().map(e -> e.getValue());
+                .filter(e -> e.getKey().getName().equals(name)).findFirst().map(Entry::getValue);
             ClassNode type = value.map(GenericsType::getType).orElseGet(() -> makeRawType(param.getType()));
 
             return new Parameter(type, param.getName());


[groovy] 05/06: Trivial refactoring: Can be replaced with single 'Map.computeIfAbsent' method call

Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 76e82806c46366bfbd0cdecc631a91c4d6597387
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sun Nov 3 21:34:26 2019 +0800

    Trivial refactoring: Can be replaced with single 'Map.computeIfAbsent' method call
---
 .../java/groovy/util/FactoryBuilderSupport.java    |  6 +-----
 .../groovy/ast/decompiled/AsmDecompiler.java       |  5 +----
 .../groovy/runtime/DefaultGroovyMethods.java       |  7 +------
 .../runtime/metaclass/MetaClassRegistryImpl.java   | 24 ++++------------------
 .../stc/GroovyTypeCheckingExtensionSupport.java    |  6 +-----
 .../transform/stc/StaticTypeCheckingVisitor.java   | 12 ++---------
 6 files changed, 10 insertions(+), 50 deletions(-)

diff --git a/src/main/java/groovy/util/FactoryBuilderSupport.java b/src/main/java/groovy/util/FactoryBuilderSupport.java
index aeffa68..be85429 100644
--- a/src/main/java/groovy/util/FactoryBuilderSupport.java
+++ b/src/main/java/groovy/util/FactoryBuilderSupport.java
@@ -169,11 +169,7 @@ public abstract class FactoryBuilderSupport extends Binding {
     }
 
     private Set<String> getRegistrationGroup(String name) {
-        Set<String> group = registrationGroup.get(name);
-        if (group == null ) {
-            group = new TreeSet<String>();
-            registrationGroup.put(name, group);
-        }
+        Set<String> group = registrationGroup.computeIfAbsent(name, k -> new TreeSet<String>());
         return group;
     }
 
diff --git a/src/main/java/org/codehaus/groovy/ast/decompiled/AsmDecompiler.java b/src/main/java/org/codehaus/groovy/ast/decompiled/AsmDecompiler.java
index 4e0f922..bee97c0 100644
--- a/src/main/java/org/codehaus/groovy/ast/decompiled/AsmDecompiler.java
+++ b/src/main/java/org/codehaus/groovy/ast/decompiled/AsmDecompiler.java
@@ -140,10 +140,7 @@ public abstract class AsmDecompiler {
                     @Override
                     public AnnotationVisitor visitParameterAnnotation(int parameter, String desc, boolean visible) {
                         if (stub.parameterAnnotations == null) stub.parameterAnnotations = new HashMap<Integer, List<AnnotationStub>>(1);
-                        List<AnnotationStub> list = stub.parameterAnnotations.get(parameter);
-                        if (list == null) {
-                            stub.parameterAnnotations.put(parameter, list = new ArrayList<AnnotationStub>());
-                        }
+                        List<AnnotationStub> list = stub.parameterAnnotations.computeIfAbsent(parameter, k -> new ArrayList<AnnotationStub>());
                         AnnotationStub annotationStub = new AnnotationStub(desc);
                         list.add(annotationStub);
                         return readAnnotationMembers(annotationStub);
diff --git a/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java b/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
index 64b3603..3811036 100644
--- a/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
+++ b/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
@@ -5917,12 +5917,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport {
      * @since 1.5.0
      */
     protected static <K, T> void groupAnswer(final Map<K, List<T>> answer, T element, K value) {
-        List<T> groupedElements = answer.get(value);
-
-        if (null == groupedElements) {
-            groupedElements = new ArrayList<T>();
-            answer.put(value, groupedElements);
-        }
+        List<T> groupedElements = answer.computeIfAbsent(value, k -> new ArrayList<T>());
 
         groupedElements.add(element);
     }
diff --git a/src/main/java/org/codehaus/groovy/runtime/metaclass/MetaClassRegistryImpl.java b/src/main/java/org/codehaus/groovy/runtime/metaclass/MetaClassRegistryImpl.java
index ec9fe1b..5edca84 100644
--- a/src/main/java/org/codehaus/groovy/runtime/metaclass/MetaClassRegistryImpl.java
+++ b/src/main/java/org/codehaus/groovy/runtime/metaclass/MetaClassRegistryImpl.java
@@ -210,11 +210,7 @@ public class MetaClassRegistryImpl implements MetaClassRegistry{
                             newParams
                     );
                     final CachedClass declClass = method.getDeclaringClass();
-                    List<MetaMethod> arr = map.get(declClass);
-                    if (arr == null) {
-                        arr = new ArrayList<MetaMethod>(4);
-                        map.put(declClass, arr);
-                    }
+                    List<MetaMethod> arr = map.computeIfAbsent(declClass, k -> new ArrayList<MetaMethod>(4));
                     arr.add(method);
                     instanceMethods.add(method);
                 }
@@ -231,11 +227,7 @@ public class MetaClassRegistryImpl implements MetaClassRegistry{
                 if (Modifier.isStatic(mod) && Modifier.isPublic(mod) && method.getAnnotation(Deprecated.class) == null) {
                     CachedClass[] paramTypes = method.getParameterTypes();
                     if (paramTypes.length > 0) {
-                        List<MetaMethod> arr = map.get(paramTypes[0]);
-                        if (arr == null) {
-                            arr = new ArrayList<MetaMethod>(4);
-                            map.put(paramTypes[0], arr);
-                        }
+                        List<MetaMethod> arr = map.computeIfAbsent(paramTypes[0], k -> new ArrayList<MetaMethod>(4));
                         if (useInstanceMethods) {
                             final NewInstanceMetaMethod metaMethod = new NewInstanceMetaMethod(method);
                             arr.add(metaMethod);
@@ -255,11 +247,7 @@ public class MetaClassRegistryImpl implements MetaClassRegistry{
         try {
             MetaMethod method = (MetaMethod) aClass.getDeclaredConstructor().newInstance();
             final CachedClass declClass = method.getDeclaringClass();
-            List<MetaMethod> arr = map.get(declClass);
-            if (arr == null) {
-                arr = new ArrayList<MetaMethod>(4);
-                map.put(declClass, arr);
-            }
+            List<MetaMethod> arr = map.computeIfAbsent(declClass, k -> new ArrayList<MetaMethod>(4));
             arr.add(method);
             instanceMethods.add(method);
         } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { /* ignore */
@@ -527,11 +515,7 @@ public class MetaClassRegistryImpl implements MetaClassRegistry{
             List<MetaMethod> metaMethods = module.getMetaMethods();
             for (MetaMethod metaMethod : metaMethods) {
                 CachedClass cachedClass = metaMethod.getDeclaringClass();
-                List<MetaMethod> methods = map.get(cachedClass);
-                if (methods == null) {
-                    methods = new ArrayList<MetaMethod>(4);
-                    map.put(cachedClass, methods);
-                }
+                List<MetaMethod> methods = map.computeIfAbsent(cachedClass, k -> new ArrayList<MetaMethod>(4));
                 methods.add(metaMethod);
                 if (metaMethod.isStatic()) {
                     staticMethods.add(metaMethod);
diff --git a/src/main/java/org/codehaus/groovy/transform/stc/GroovyTypeCheckingExtensionSupport.java b/src/main/java/org/codehaus/groovy/transform/stc/GroovyTypeCheckingExtensionSupport.java
index d456331..0852cf3 100644
--- a/src/main/java/org/codehaus/groovy/transform/stc/GroovyTypeCheckingExtensionSupport.java
+++ b/src/main/java/org/codehaus/groovy/transform/stc/GroovyTypeCheckingExtensionSupport.java
@@ -441,11 +441,7 @@ public class GroovyTypeCheckingExtensionSupport extends AbstractTypeCheckingExte
                 if (methodName == null) {
                     return InvokerHelper.invokeMethod(extension, name, args);
                 }
-                List<Closure> closures = extension.eventHandlers.get(methodName);
-                if (closures == null) {
-                    closures = new LinkedList<Closure>();
-                    extension.eventHandlers.put(methodName, closures);
-                }
+                List<Closure> closures = extension.eventHandlers.computeIfAbsent(methodName, k -> new LinkedList<Closure>());
                 closures.add((Closure) argsArray[0]);
                 return null;
             } else {
diff --git a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
index 226064a..37abc13 100644
--- a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
+++ b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
@@ -1145,11 +1145,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
     protected void pushInstanceOfTypeInfo(final Expression objectOfInstanceOf, final Expression typeExpression) {
         final Map<Object, List<ClassNode>> tempo = typeCheckingContext.temporaryIfBranchTypeInformation.peek();
         Object key = extractTemporaryTypeInfoKey(objectOfInstanceOf);
-        List<ClassNode> potentialTypes = tempo.get(key);
-        if (potentialTypes == null) {
-            potentialTypes = new LinkedList<ClassNode>();
-            tempo.put(key, potentialTypes);
-        }
+        List<ClassNode> potentialTypes = tempo.computeIfAbsent(key, k -> new LinkedList<ClassNode>());
         potentialTypes.add(typeExpression.getType());
     }
 
@@ -4225,11 +4221,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
                 ((Parameter) accessedVariable).putNodeMetaData(INFERRED_TYPE, cn);
             }
             if (var.isClosureSharedVariable() && cn != null) {
-                List<ClassNode> assignedTypes = typeCheckingContext.closureSharedVariablesAssignmentTypes.get(var);
-                if (assignedTypes == null) {
-                    assignedTypes = new LinkedList<ClassNode>();
-                    typeCheckingContext.closureSharedVariablesAssignmentTypes.put(var, assignedTypes);
-                }
+                List<ClassNode> assignedTypes = typeCheckingContext.closureSharedVariablesAssignmentTypes.computeIfAbsent(var, k -> new LinkedList<ClassNode>());
                 assignedTypes.add(cn);
             }
             if (!typeCheckingContext.temporaryIfBranchTypeInformation.empty()) {