(groovy) branch master updated: deprecated build usage

2024-04-21 Thread paulk
This is an automated email from the ASF dual-hosted git repository.

paulk 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 0f443141c6 deprecated build usage
0f443141c6 is described below

commit 0f443141c6719c51d5733713c9f0ffbcf031c800
Author: Paul King 
AuthorDate: Mon Apr 22 13:54:54 2024 +1000

deprecated build usage
---
 build-logic/src/main/groovy/org.apache.groovy-base.gradle | 4 ++--
 build.gradle  | 4 +++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/build-logic/src/main/groovy/org.apache.groovy-base.gradle 
b/build-logic/src/main/groovy/org.apache.groovy-base.gradle
index 4c33055503..99b1334e45 100644
--- a/build-logic/src/main/groovy/org.apache.groovy-base.gradle
+++ b/build-logic/src/main/groovy/org.apache.groovy-base.gradle
@@ -308,8 +308,8 @@ components.groovyLibrary {
 // By declaring a codehaus capability we can tell Gradle that the user has to
 // choose between "old" groovy and "new" groovy
 List capabilities = [
-
"org.codehaus.groovy:${archivesBaseName}:${sharedConfiguration.groovyVersion.get()}",
-
"org.apache.groovy:${archivesBaseName}:${sharedConfiguration.groovyVersion.get()}"
+
"org.codehaus.groovy:${base.archivesName.get()}:${sharedConfiguration.groovyVersion.get()}",
+
"org.apache.groovy:${base.archivesName.get()}:${sharedConfiguration.groovyVersion.get()}"
 ]
 int targetJvmVersion = 
Integer.valueOf(sharedConfiguration.targetJavaVersion.get())
 // First we create the "API" and "runtime" variants of Groovy for publication
diff --git a/build.gradle b/build.gradle
index 74a002bb35..f24ee350b3 100644
--- a/build.gradle
+++ b/build.gradle
@@ -33,7 +33,9 @@ buildScanRecipes {
 recipes 'git-status', 'gc-stats', 'teamcity', 'travis-ci'
 }
 
-archivesBaseName = 'groovy'
+base {
+archivesName = 'groovy'
+}
 
 groovyLibrary {
 registerOptionalFeature 'gpars'



(groovy) branch GROOVY_3_0_X updated: GROOVY-11362: classgen: catch parameter is `Exception` for `catch (e) {`

2024-04-21 Thread emilles
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/GROOVY_3_0_X by this push:
 new fbfdb6c69f GROOVY-11362: classgen: catch parameter is `Exception` for 
`catch (e) {`
fbfdb6c69f is described below

commit fbfdb6c69fa6deec2615741630b7d9c5280b601d
Author: Eric Milles 
AuthorDate: Sun Apr 21 14:18:36 2024 -0500

GROOVY-11362: classgen: catch parameter is `Exception` for `catch (e) {`

3_0_X backport
---
 .../groovy/classgen/asm/StatementWriter.java   | 21 +---
 src/test/groovy/bugs/Groovy11362.groovy| 39 ++
 2 files changed, 48 insertions(+), 12 deletions(-)

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 6ed2199d91..dee36013c7 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/StatementWriter.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/StatementWriter.java
@@ -21,7 +21,6 @@ package org.codehaus.groovy.classgen.asm;
 import org.codehaus.groovy.ast.ClassHelper;
 import org.codehaus.groovy.ast.ClassNode;
 import org.codehaus.groovy.ast.MethodNode;
-import org.codehaus.groovy.ast.Parameter;
 import org.codehaus.groovy.ast.expr.ArgumentListExpression;
 import org.codehaus.groovy.ast.expr.BooleanExpression;
 import org.codehaus.groovy.ast.expr.ClosureListExpression;
@@ -299,12 +298,11 @@ public class StatementWriter {
 controller.getAcg().onLineNumber(statement, "visitDoWhileLoop");
 writeStatementLabel(statement);
 
-MethodVisitor mv = controller.getMethodVisitor();
-
 controller.getCompileStack().pushLoop(statement.getStatementLabels());
 Label continueLabel = controller.getCompileStack().getContinueLabel();
 Label breakLabel = controller.getCompileStack().getBreakLabel();
 
+MethodVisitor mv = controller.getMethodVisitor();
 mv.visitLabel(continueLabel);
 
 statement.getLoopBlock().visit(controller.getAcg());
@@ -363,29 +361,26 @@ public class StatementWriter {
 Label tryEnd = new Label();
 mv.visitLabel(tryEnd);
 tryBlock.closeRange(tryEnd);
-// pop for "makeBlockRecorder(finallyStatement)"
-controller.getCompileStack().pop();
+// pop for BlockRecorder
+compileStack.pop();
 
 BlockRecorder catches = makeBlockRecorder(finallyStatement);
 for (CatchStatement catchStatement : statement.getCatchStatements()) {
-ClassNode exceptionType = catchStatement.getExceptionType();
-String exceptionTypeInternalName = 
BytecodeHelper.getClassInternalName(exceptionType);
-
 // start catch block, label needed for exception table
 Label catchStart = new Label();
 mv.visitLabel(catchStart);
 catches.startRange(catchStart);
 
 // create exception variable and store the exception
-Parameter exceptionVariable = catchStatement.getVariable();
 compileStack.pushState();
-compileStack.defineVariable(exceptionVariable, true);
+ClassNode type = catchStatement.getExceptionType();
+compileStack.defineVariable(catchStatement.getVariable(), type, 
true);
 // handle catch body
 catchStatement.visit(controller.getAcg());
 // place holder to avoid problems with empty catch blocks
 mv.visitInsn(NOP);
 // pop for the variable
-controller.getCompileStack().pop();
+compileStack.pop();
 
 // end of catch
 Label catchEnd = new Label();
@@ -394,7 +389,9 @@ public class StatementWriter {
 
 // goto finally start
 mv.visitJumpInsn(GOTO, finallyStart);
-compileStack.writeExceptionTable(tryBlock, catchStart, 
exceptionTypeInternalName);
+
+String typeName = BytecodeHelper.getClassInternalName(type);
+compileStack.writeExceptionTable(tryBlock, catchStart, typeName);
 }
 
 // used to handle exceptions in catches and regularly visited finals
diff --git a/src/test/groovy/bugs/Groovy11362.groovy 
b/src/test/groovy/bugs/Groovy11362.groovy
new file mode 100644
index 00..49600112c9
--- /dev/null
+++ b/src/test/groovy/bugs/Groovy11362.groovy
@@ -0,0 +1,39 @@
+/*
+ *  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/licens

(groovy) branch GROOVY_4_0_X updated: GROOVY-11362: classgen: catch parameter is `Exception` for `catch (e) {`

2024-04-21 Thread emilles
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/GROOVY_4_0_X by this push:
 new cb0e362374 GROOVY-11362: classgen: catch parameter is `Exception` for 
`catch (e) {`
cb0e362374 is described below

commit cb0e36237445c6b2d626ccdea212d4e64b98983c
Author: Eric Milles 
AuthorDate: Sun Apr 21 14:18:36 2024 -0500

GROOVY-11362: classgen: catch parameter is `Exception` for `catch (e) {`
---
 .../groovy/classgen/asm/StatementWriter.java   |  8 ++---
 src/test/groovy/bugs/Groovy11362.groovy| 39 ++
 2 files changed, 43 insertions(+), 4 deletions(-)

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 c33debbc95..d6f0bbde9e 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/StatementWriter.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/StatementWriter.java
@@ -350,8 +350,8 @@ public class StatementWriter {
 
 // create variable for the exception
 compileStack.pushState();
-// TODO: Is it okay that "catch (e)" makes variable type Object?
-compileStack.defineVariable(catchStatement.getVariable(), true);
+ClassNode type = catchStatement.getExceptionType();
+compileStack.defineVariable(catchStatement.getVariable(), type, 
true);
 // handle catch body
 catchStatement.visit(controller.getAcg());
 // placeholder to avoid problems with empty catch block
@@ -365,8 +365,8 @@ public class StatementWriter {
 mv.visitJumpInsn(GOTO, finallyStart);
 fallthroughFinally = true;
 }
-compileStack.writeExceptionTable(tryBlock, catchBlock,
-
BytecodeHelper.getClassInternalName(catchStatement.getExceptionType()));
+String typeName = BytecodeHelper.getClassInternalName(type);
+compileStack.writeExceptionTable(tryBlock, catchBlock, typeName);
 }
 
 // used to handle exceptions in catches and regularly visited finals
diff --git a/src/test/groovy/bugs/Groovy11362.groovy 
b/src/test/groovy/bugs/Groovy11362.groovy
new file mode 100644
index 00..d8c96a48da
--- /dev/null
+++ b/src/test/groovy/bugs/Groovy11362.groovy
@@ -0,0 +1,39 @@
+/*
+ *  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
+
+final class Groovy11362 extends AbstractBytecodeTestCase {
+
+void testCatchException() {
+def bytecode = compile method:'test', '''
+void test() {
+try {
+print 'f'
+} catch (e) {
+}
+}
+'''
+assert bytecode.hasSequence([
+'LOCALVARIABLE this Lscript; L0 L6 0',
+'LOCALVARIABLE e Ljava/lang/Exception; L5 L3 1' // not 
Ljava/lang/Object;
+])
+}
+}



(groovy) branch master updated: GROOVY-11362: classgen: catch parameter is `Exception` for `catch (e) {`

2024-04-21 Thread emilles
This is an automated email from the ASF dual-hosted git repository.

emilles 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 5bd57e9713 GROOVY-11362: classgen: catch parameter is `Exception` for 
`catch (e) {`
5bd57e9713 is described below

commit 5bd57e9713d6dc89dcefcba9fcd7e03f4d36f785
Author: Eric Milles 
AuthorDate: Sun Apr 21 14:18:36 2024 -0500

GROOVY-11362: classgen: catch parameter is `Exception` for `catch (e) {`
---
 .../groovy/classgen/asm/StatementWriter.java   |  8 ++---
 src/test/groovy/bugs/Groovy11362.groovy| 39 ++
 2 files changed, 43 insertions(+), 4 deletions(-)

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 c86b8272be..1e41fc9ac8 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/StatementWriter.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/StatementWriter.java
@@ -343,8 +343,8 @@ public class StatementWriter {
 
 // create variable for the exception
 compileStack.pushState();
-// TODO: Is it okay that "catch (e)" makes variable type Object?
-compileStack.defineVariable(catchStatement.getVariable(), true);
+ClassNode type = catchStatement.getExceptionType();
+compileStack.defineVariable(catchStatement.getVariable(), type, 
true);
 // handle catch body
 catchStatement.visit(controller.getAcg());
 // placeholder to avoid problems with empty catch block
@@ -358,8 +358,8 @@ public class StatementWriter {
 mv.visitJumpInsn(GOTO, finallyStart);
 fallthroughFinally = true;
 }
-compileStack.writeExceptionTable(tryBlock, catchBlock,
-
BytecodeHelper.getClassInternalName(catchStatement.getExceptionType()));
+String typeName = BytecodeHelper.getClassInternalName(type);
+compileStack.writeExceptionTable(tryBlock, catchBlock, typeName);
 }
 
 // used to handle exceptions in catches and regularly visited finals
diff --git a/src/test/groovy/bugs/Groovy11362.groovy 
b/src/test/groovy/bugs/Groovy11362.groovy
new file mode 100644
index 00..d8c96a48da
--- /dev/null
+++ b/src/test/groovy/bugs/Groovy11362.groovy
@@ -0,0 +1,39 @@
+/*
+ *  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
+
+final class Groovy11362 extends AbstractBytecodeTestCase {
+
+void testCatchException() {
+def bytecode = compile method:'test', '''
+void test() {
+try {
+print 'f'
+} catch (e) {
+}
+}
+'''
+assert bytecode.hasSequence([
+'LOCALVARIABLE this Lscript; L0 L6 0',
+'LOCALVARIABLE e Ljava/lang/Exception; L5 L3 1' // not 
Ljava/lang/Object;
+])
+}
+}