You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2020/10/09 00:15:06 UTC
[groovy] branch master updated: GROOVY-9770: Groovy 3 generated
lambda classes are marked as synthetic (closes #1396)
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 08a88d8 GROOVY-9770: Groovy 3 generated lambda classes are marked as synthetic (closes #1396)
08a88d8 is described below
commit 08a88d80059e5ece00ddc2619f518fd177336a4f
Author: Paul King <pa...@asert.com.au>
AuthorDate: Tue Oct 6 20:42:39 2020 +1000
GROOVY-9770: Groovy 3 generated lambda classes are marked as synthetic (closes #1396)
---
.../classgen/asm/sc/StaticTypesLambdaWriter.java | 2 +-
src/test/groovy/bugs/Groovy9770.groovy | 38 ++++++++++++++++++++++
2 files changed, 39 insertions(+), 1 deletion(-)
diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesLambdaWriter.java b/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesLambdaWriter.java
index fc96361..fd178f7 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesLambdaWriter.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesLambdaWriter.java
@@ -116,7 +116,7 @@ public class StaticTypesLambdaWriter extends LambdaWriter implements AbstractFun
}
ClassNode enclosingClass = controller.getClassNode();
- int modifiers = ACC_FINAL | ACC_PUBLIC | ACC_SYNTHETIC;
+ int modifiers = ACC_FINAL | ACC_PUBLIC;
if (enclosingClass.isInterface()) modifiers |= ACC_STATIC;
ClassNode lambdaClass = getOrAddLambdaClass(expression, modifiers, abstractMethod);
MethodNode lambdaMethod = lambdaClass.getMethods("doCall").get(0);
diff --git a/src/test/groovy/bugs/Groovy9770.groovy b/src/test/groovy/bugs/Groovy9770.groovy
new file mode 100644
index 0000000..557c93f
--- /dev/null
+++ b/src/test/groovy/bugs/Groovy9770.groovy
@@ -0,0 +1,38 @@
+/*
+ * 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 groovy.test.GroovyTestCase
+
+class Groovy9770 extends GroovyTestCase {
+ void testLambdaClassModifiers() {
+ assertScript '''
+ @groovy.transform.CompileStatic
+ class Foo {
+ def bar(String arg) {
+ java.util.function.Function<String, String> up = (String s) -> { s.toUpperCase() }
+ up(arg)
+ }
+ }
+
+ assert new Foo().bar('hello') == 'HELLO'
+ assert getClass().classLoader.loadClass('Foo$_bar_lambda1').modifiers == 17 // PUBLIC | FINAL
+ '''
+ }
+}