From commits-return-8437-archive-asf-public=cust-asf.ponee.io@groovy.apache.org Fri May 3 09:57:47 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 0386518064D for ; Fri, 3 May 2019 11:57:46 +0200 (CEST) Received: (qmail 9823 invoked by uid 500); 3 May 2019 09:57:46 -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 9809 invoked by uid 99); 3 May 2019 09:57:46 -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; Fri, 03 May 2019 09:57:46 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 1FE66871F3; Fri, 3 May 2019 09:57:46 +0000 (UTC) Date: Fri, 03 May 2019 09:57:46 +0000 To: "commits@groovy.apache.org" Subject: [groovy] branch master updated: GROOVY-9099: Throw a better exception when validating native method reference fails(closes #914) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <155687746600.4153.15995490313453140320@gitbox.apache.org> From: sunlan@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: groovy X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 1ee928b86b08864a2715ffed77ca62b39b69701a X-Git-Newrev: 9ef5c5bd0875f503bbb23b08b0f0bbbdd3b30fb9 X-Git-Rev: 9ef5c5bd0875f503bbb23b08b0f0bbbdd3b30fb9 X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated 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 The following commit(s) were added to refs/heads/master by this push: new 9ef5c5b GROOVY-9099: Throw a better exception when validating native method reference fails(closes #914) 9ef5c5b is described below commit 9ef5c5bd0875f503bbb23b08b0f0bbbdd3b30fb9 Author: Daniel Sun AuthorDate: Fri May 3 17:57:34 2019 +0800 GROOVY-9099: Throw a better exception when validating native method reference fails(closes #914) --- .../asm/sc/StaticTypesMethodReferenceExpressionWriter.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesMethodReferenceExpressionWriter.java b/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesMethodReferenceExpressionWriter.java index a635edb..1fe3772 100644 --- a/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesMethodReferenceExpressionWriter.java +++ b/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesMethodReferenceExpressionWriter.java @@ -18,7 +18,6 @@ */ package org.codehaus.groovy.classgen.asm.sc; -import groovy.lang.GroovyRuntimeException; import groovy.lang.Tuple; import groovy.lang.Tuple2; import org.codehaus.groovy.ast.ClassHelper; @@ -36,6 +35,7 @@ import org.codehaus.groovy.classgen.asm.BytecodeHelper; import org.codehaus.groovy.classgen.asm.MethodReferenceExpressionWriter; import org.codehaus.groovy.classgen.asm.WriterController; import org.codehaus.groovy.runtime.ArrayTypeUtils; +import org.codehaus.groovy.syntax.RuntimeParserException; import org.objectweb.asm.MethodVisitor; import org.objectweb.asm.Opcodes; @@ -100,15 +100,16 @@ public class StaticTypesMethodReferenceExpressionWriter extends MethodReferenceE addSyntheticMethodForConstructorReference(methodRefName, typeOrTargetRefType, parametersWithExactType); } + // TODO move the `findMethodRefMethod` and checking to `StaticTypeCheckingVisitor` MethodNode methodRefMethod = findMethodRefMethod(methodRefName, parametersWithExactType, typeOrTargetRef, isConstructorReference); if (null == methodRefMethod) { - throw new GroovyRuntimeException("Failed to find the expected method[" + throw new RuntimeParserException("Failed to find the expected method[" + methodRefName + "(" + Arrays.stream(parametersWithExactType) .map(e -> e.getType().getName()) .collect(Collectors.joining(",")) - + ")] in the type[" + typeOrTargetRefType.getName() + "]"); + + ")] in the type[" + typeOrTargetRefType.getName() + "]", methodReferenceExpression); } methodRefMethod.putNodeMetaData(ORIGINAL_PARAMETERS_WITH_EXACT_TYPE, parametersWithExactType); @@ -119,7 +120,7 @@ public class StaticTypesMethodReferenceExpressionWriter extends MethodReferenceE if (!isClassExpr) { if (isConstructorReference) { // TODO move the checking code to the Parrot parser - throw new GroovyRuntimeException("Constructor reference must be className::new"); + throw new RuntimeParserException("Constructor reference must be className::new", methodReferenceExpression); } if (methodRefMethod.isStatic()) {