From commits-return-9601-archive-asf-public=cust-asf.ponee.io@groovy.apache.org Sat Nov 2 21:47:00 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 540C9180661 for ; Sat, 2 Nov 2019 22:46:59 +0100 (CET) Received: (qmail 32222 invoked by uid 500); 2 Nov 2019 21:46:58 -0000 Mailing-List: contact commits-help@groovy.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@groovy.apache.org Delivered-To: mailing list commits@groovy.apache.org Received: (qmail 31885 invoked by uid 99); 2 Nov 2019 21:46:58 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 02 Nov 2019 21:46:58 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id E3D2F805F6; Sat, 2 Nov 2019 21:46:57 +0000 (UTC) Date: Sat, 02 Nov 2019 21:47:04 +0000 To: "commits@groovy.apache.org" Subject: [groovy] 07/08: Java 8 refactor MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit From: sunlan@apache.org In-Reply-To: <157273121755.1217.6410754759374014273@gitbox.apache.org> References: <157273121755.1217.6410754759374014273@gitbox.apache.org> X-Git-Host: gitbox.apache.org X-Git-Repo: groovy X-Git-Refname: refs/heads/GROOVY_3_0_X X-Git-Reftype: branch X-Git-Rev: 0fdf71e23e812ed161d13bb28181ca966d4228e0 X-Git-NotificationType: diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated Message-Id: <20191102214657.E3D2F805F6@gitbox.apache.org> This is an automated email from the ASF dual-hosted git repository. sunlan pushed a commit to branch GROOVY_3_0_X in repository https://gitbox.apache.org/repos/asf/groovy.git commit 0fdf71e23e812ed161d13bb28181ca966d4228e0 Author: Daniel Sun AuthorDate: Sun Nov 3 04:28:53 2019 +0800 Java 8 refactor (cherry picked from commit 2042f6c2cc38114acf7e27d7dfda3b34389d5903) --- src/main/java/groovy/lang/MetaClassImpl.java | 45 +++++++++------------------- 1 file changed, 14 insertions(+), 31 deletions(-) diff --git a/src/main/java/groovy/lang/MetaClassImpl.java b/src/main/java/groovy/lang/MetaClassImpl.java index e1b00eb..8cee0f2 100644 --- a/src/main/java/groovy/lang/MetaClassImpl.java +++ b/src/main/java/groovy/lang/MetaClassImpl.java @@ -82,7 +82,6 @@ import org.codehaus.groovy.vmplugin.VMPluginFactory; import javax.annotation.Nullable; import java.beans.BeanInfo; import java.beans.EventSetDescriptor; -import java.beans.IntrospectionException; import java.beans.Introspector; import java.beans.PropertyDescriptor; import java.lang.reflect.Array; @@ -1626,14 +1625,12 @@ public class MetaClassImpl implements MetaClass, MutableMetaClass { CachedConstructor constructor = createCachedConstructor(arguments); List l = new ArrayList(constructors.toList()); - Comparator comp = new Comparator() { - public int compare(Object arg0, Object arg1) { - CachedConstructor c0 = (CachedConstructor) arg0; - CachedConstructor c1 = (CachedConstructor) arg1; - String descriptor0 = BytecodeHelper.getMethodDescriptor(Void.TYPE, c0.getNativeParameterTypes()); - String descriptor1 = BytecodeHelper.getMethodDescriptor(Void.TYPE, c1.getNativeParameterTypes()); - return descriptor0.compareTo(descriptor1); - } + Comparator comp = (arg0, arg1) -> { + CachedConstructor c0 = (CachedConstructor) arg0; + CachedConstructor c1 = (CachedConstructor) arg1; + String descriptor0 = BytecodeHelper.getMethodDescriptor(Void.TYPE, c0.getNativeParameterTypes()); + String descriptor1 = BytecodeHelper.getMethodDescriptor(Void.TYPE, c1.getNativeParameterTypes()); + return descriptor0.compareTo(descriptor1); }; Collections.sort(l, comp); int found = -1; @@ -3404,17 +3401,9 @@ public class MetaClassImpl implements MetaClass, MutableMetaClass { // introspect try { if (isBeanDerivative(theClass)) { - info = (BeanInfo) AccessController.doPrivileged(new PrivilegedExceptionAction() { - public Object run() throws IntrospectionException { - return Introspector.getBeanInfo(theClass, Introspector.IGNORE_ALL_BEANINFO); - } - }); + info = (BeanInfo) AccessController.doPrivileged((PrivilegedExceptionAction) () -> Introspector.getBeanInfo(theClass, Introspector.IGNORE_ALL_BEANINFO)); } else { - info = (BeanInfo) AccessController.doPrivileged(new PrivilegedExceptionAction() { - public Object run() throws IntrospectionException { - return Introspector.getBeanInfo(theClass); - } - }); + info = (BeanInfo) AccessController.doPrivileged((PrivilegedExceptionAction) () -> Introspector.getBeanInfo(theClass)); } } catch (PrivilegedActionException pae) { throw new GroovyRuntimeException("exception during bean introspection", pae.getException()); @@ -3914,21 +3903,15 @@ public class MetaClassImpl implements MetaClass, MutableMetaClass { metaMethodIndex.clearCaches(); } - private static final SingleKeyHashMap.Copier NAME_INDEX_COPIER = new SingleKeyHashMap.Copier() { - public Object copy(Object value) { - if (value instanceof FastArray) { - return ((FastArray) value).copy(); - } else { - return value; - } + private static final SingleKeyHashMap.Copier NAME_INDEX_COPIER = value -> { + if (value instanceof FastArray) { + return ((FastArray) value).copy(); + } else { + return value; } }; - private static final SingleKeyHashMap.Copier METHOD_INDEX_COPIER = new SingleKeyHashMap.Copier() { - public Object copy(Object value) { - return SingleKeyHashMap.copy(new SingleKeyHashMap(false), (SingleKeyHashMap) value, NAME_INDEX_COPIER); - } - }; + private static final SingleKeyHashMap.Copier METHOD_INDEX_COPIER = value -> SingleKeyHashMap.copy(new SingleKeyHashMap(false), (SingleKeyHashMap) value, NAME_INDEX_COPIER); static class MethodIndex extends Index { public MethodIndex(boolean b) {