Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 4E275200D4B for ; Mon, 13 Nov 2017 03:50:53 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 4CD1F160BF1; Mon, 13 Nov 2017 02:50:53 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 9A7CF160C07 for ; Mon, 13 Nov 2017 03:50:52 +0100 (CET) Received: (qmail 7353 invoked by uid 500); 13 Nov 2017 02:50:51 -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 7264 invoked by uid 99); 13 Nov 2017 02:50:51 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 13 Nov 2017 02:50:51 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 41004DFE20; Mon, 13 Nov 2017 02:50:49 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: paulk@apache.org To: commits@groovy.apache.org Date: Mon, 13 Nov 2017 02:50:50 -0000 Message-Id: <4f112b26dac04745bf82f5c74bfcd46d@git.apache.org> In-Reply-To: <240c23f93a894dcea0b33c3783a7fe34@git.apache.org> References: <240c23f93a894dcea0b33c3783a7fe34@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [2/4] groovy git commit: GROOVY-8289: STC and default value in ctor is causing debugging error (closes #630) archived-at: Mon, 13 Nov 2017 02:50:53 -0000 GROOVY-8289: STC and default value in ctor is causing debugging error (closes #630) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/da310b6a Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/da310b6a Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/da310b6a Branch: refs/heads/GROOVY_2_4_X Commit: da310b6adbda3654cdbeacaa4fdbabaf723bd1f2 Parents: becb9ce Author: paulk Authored: Tue Nov 7 17:37:16 2017 +1000 Committer: paulk Committed: Mon Nov 13 12:48:45 2017 +1000 ---------------------------------------------------------------------- .../groovy/classgen/AsmClassGenerator.java | 6 +-- src/test/groovy/bugs/Groovy8289Bug.groovy | 43 ++++++++++++++++++++ 2 files changed, 46 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/groovy/blob/da310b6a/src/main/org/codehaus/groovy/classgen/AsmClassGenerator.java ---------------------------------------------------------------------- diff --git a/src/main/org/codehaus/groovy/classgen/AsmClassGenerator.java b/src/main/org/codehaus/groovy/classgen/AsmClassGenerator.java index f7e3527..a614c95 100644 --- a/src/main/org/codehaus/groovy/classgen/AsmClassGenerator.java +++ b/src/main/org/codehaus/groovy/classgen/AsmClassGenerator.java @@ -425,6 +425,9 @@ public class AsmClassGenerator extends ClassGenerator { } private void visitStdMethod(MethodNode node, boolean isConstructor, Parameter[] parameters, Statement code) { + controller.getCompileStack().init(node.getVariableScope(), parameters); + controller.getCallSiteWriter().makeSiteEntry(); + MethodVisitor mv = controller.getMethodVisitor(); final ClassNode superClass = controller.getClassNode().getSuperClass(); if (isConstructor && (code == null || !((ConstructorNode) node).firstStatementIsSpecialConstructorCall())) { @@ -454,9 +457,6 @@ public class AsmClassGenerator extends ClassGenerator { } } - controller.getCompileStack().init(node.getVariableScope(), parameters); - controller.getCallSiteWriter().makeSiteEntry(); - // handle body super.visitConstructorOrMethod(node, isConstructor); http://git-wip-us.apache.org/repos/asf/groovy/blob/da310b6a/src/test/groovy/bugs/Groovy8289Bug.groovy ---------------------------------------------------------------------- diff --git a/src/test/groovy/bugs/Groovy8289Bug.groovy b/src/test/groovy/bugs/Groovy8289Bug.groovy new file mode 100644 index 0000000..2091f66 --- /dev/null +++ b/src/test/groovy/bugs/Groovy8289Bug.groovy @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package groovy.bugs + +import org.codehaus.groovy.classgen.asm.AbstractBytecodeTestCase + +class Groovy8289Bug extends AbstractBytecodeTestCase { + void testConstructorLineIndex() { + def bytecode= compile(method:'', ''' + @groovy.transform.CompileStatic + class C { + String string + C(String s = null) { string = s } + static void main(args) { + def c = new C('') // put breakpoint on this line, run as Java app, and step + println c + } + } + ''') + + assert bytecode.hasStrictSequence([ + 'L0', + 'ALOAD 0', + 'INVOKESPECIAL java/lang/Object. ()V' + ]) + } +}