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 2018/09/15 03:05:27 UTC
[1/4] groovy git commit: GROOVY-8497: Can't call getProperty() from
Java
Repository: groovy
Updated Branches:
refs/heads/GROOVY_2_5_X b2bf677e3 -> 6d2de6716
GROOVY-8497: Can't call getProperty() from Java
Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/079e349c
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/079e349c
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/079e349c
Branch: refs/heads/GROOVY_2_5_X
Commit: 079e349c014e0bffa3cd3265f78bf17631d83b1a
Parents: 99691fa
Author: Paul King <pa...@asert.com.au>
Authored: Sat Sep 15 00:12:31 2018 +1000
Committer: Paul King <pa...@asert.com.au>
Committed: Sat Sep 15 13:05:13 2018 +1000
----------------------------------------------------------------------
.../groovy/groovy/ant/Groovy8497Test.groovy | 53 ++++++++++++++++++++
1 file changed, 53 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/groovy/blob/079e349c/subprojects/groovy-ant/src/test/groovy/groovy/ant/Groovy8497Test.groovy
----------------------------------------------------------------------
diff --git a/subprojects/groovy-ant/src/test/groovy/groovy/ant/Groovy8497Test.groovy b/subprojects/groovy-ant/src/test/groovy/groovy/ant/Groovy8497Test.groovy
new file mode 100644
index 0000000..1991c2d
--- /dev/null
+++ b/subprojects/groovy-ant/src/test/groovy/groovy/ant/Groovy8497Test.groovy
@@ -0,0 +1,53 @@
+/*
+ * 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.ant
+
+class Groovy8497Test extends AntTestCase {
+ void testGetProperty() {
+// def debugLogger = new org.apache.tools.ant.DefaultLogger()
+// debugLogger.setMessageOutputLevel(4)
+// debugLogger.setOutputPrintStream(System.out)
+// debugLogger.setErrorPrintStream(System.err)
+
+ doInTmpDir { ant, baseDir ->
+ baseDir.src {
+ 'GroovyClass8497.groovy'('''
+ class GroovyClass8497 {
+ String getFoo() { 'FOO!' }
+ }
+ ''')
+ 'AccessGetProperty.java'('''
+ public class AccessGetProperty {
+ public static void main(String[] args) {
+ System.out.println(new GroovyClass8497().getProperty("foo"));
+ }
+ }
+ ''')
+ }
+// ant.project.addBuildListener(debugLogger)
+ ant.mkdir(dir: 'build')
+ def cp = System.getProperty('java.class.path') + ':build'
+ ant.taskdef(name: 'groovyc', classname: 'org.codehaus.groovy.ant.Groovyc')
+ ant.groovyc(srcdir: 'src', destdir: 'build')
+ ant.javac(classpath: cp, destdir: 'build', srcdir: 'src', includeantruntime: 'false', fork: 'true')
+ ant.java(classpath: cp, outputproperty: 'result', classname: 'AccessGetProperty')
+ assert ant.project.properties.result == 'FOO!'
+ }
+ }
+}
[4/4] groovy git commit: GROOVY-7362: Can't compile Java class
extending Groovy abstract class with explicit GroovyObject interface (already
fixed - add test case)
Posted by pa...@apache.org.
GROOVY-7362: Can't compile Java class extending Groovy abstract class with explicit GroovyObject interface (already fixed - add test case)
Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/6d2de671
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/6d2de671
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/6d2de671
Branch: refs/heads/GROOVY_2_5_X
Commit: 6d2de67162cb8bd78b457a4a598ef030c2e2e452
Parents: 079e349
Author: Paul King <pa...@asert.com.au>
Authored: Sat Sep 15 13:03:04 2018 +1000
Committer: Paul King <pa...@asert.com.au>
Committed: Sat Sep 15 13:05:14 2018 +1000
----------------------------------------------------------------------
.../groovy/groovy/ant/Groovy7362Test.groovy | 48 ++++++++++++++++++++
1 file changed, 48 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/groovy/blob/6d2de671/subprojects/groovy-ant/src/test/groovy/groovy/ant/Groovy7362Test.groovy
----------------------------------------------------------------------
diff --git a/subprojects/groovy-ant/src/test/groovy/groovy/ant/Groovy7362Test.groovy b/subprojects/groovy-ant/src/test/groovy/groovy/ant/Groovy7362Test.groovy
new file mode 100644
index 0000000..6a3b33f
--- /dev/null
+++ b/subprojects/groovy-ant/src/test/groovy/groovy/ant/Groovy7362Test.groovy
@@ -0,0 +1,48 @@
+/*
+ * 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.ant
+
+class Groovy7362Test extends AntTestCase {
+ void testCompileJavaClassExtendingAbstractGroovyClass() {
+// def debugLogger = new org.apache.tools.ant.DefaultLogger()
+// debugLogger.setMessageOutputLevel(4)
+// debugLogger.setOutputPrintStream(System.out)
+// debugLogger.setErrorPrintStream(System.err)
+
+ doInTmpDir { ant, baseDir ->
+ baseDir.src {
+ 'ConcreteClass.groovy'('''
+ class ConcreteClass { }
+ ''')
+ 'AbstractClass.groovy'('''
+ abstract class AbstractClass extends ConcreteClass implements GroovyObject { }
+ ''')
+ 'JavaClass.java'('''
+ public class JavaClass extends AbstractClass { }
+ ''')
+ }
+// ant.project.addBuildListener(debugLogger)
+ ant.mkdir(dir: 'build')
+ def cp = System.getProperty('java.class.path') + ':build'
+ ant.taskdef(name: 'groovyc', classname: 'org.codehaus.groovy.ant.Groovyc')
+ ant.groovyc(srcdir: 'src', destdir: 'build')
+ ant.javac(classpath: cp, destdir: 'build', srcdir: 'src', includeantruntime: 'false', fork: 'true')
+ }
+ }
+}
[3/4] groovy git commit: GROOVY-8495: GroovyObject method
implementations are marked with ACC_SYNTHETIC
Posted by pa...@apache.org.
GROOVY-8495: GroovyObject method implementations are marked with ACC_SYNTHETIC
Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/103a1090
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/103a1090
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/103a1090
Branch: refs/heads/GROOVY_2_5_X
Commit: 103a109026e37f4822a67d6b9382e1f79f725c71
Parents: b2bf677
Author: Paul King <pa...@asert.com.au>
Authored: Fri Sep 14 22:40:57 2018 +1000
Committer: Paul King <pa...@asert.com.au>
Committed: Sat Sep 15 13:05:13 2018 +1000
----------------------------------------------------------------------
src/main/java/org/codehaus/groovy/classgen/Verifier.java | 10 +++++-----
.../org/codehaus/groovy/reflection/MixinInMetaClass.java | 4 ++++
.../groovy/runtime/callsite/AbstractCallSite.java | 3 ++-
.../java/org/codehaus/groovy/vmplugin/v7/Selector.java | 3 ++-
src/test/groovy/bugs/Groovy3175_Bug.groovy | 10 +++++++---
5 files changed, 20 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/groovy/blob/103a1090/src/main/java/org/codehaus/groovy/classgen/Verifier.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/classgen/Verifier.java b/src/main/java/org/codehaus/groovy/classgen/Verifier.java
index 5010807..d39df18 100644
--- a/src/main/java/org/codehaus/groovy/classgen/Verifier.java
+++ b/src/main/java/org/codehaus/groovy/classgen/Verifier.java
@@ -408,7 +408,7 @@ public class Verifier implements GroovyClassVisitor, Opcodes {
if (!node.hasMethod("getMetaClass", Parameter.EMPTY_ARRAY)) {
metaClassField = setMetaClassFieldIfNotExists(node, metaClassField);
- MethodNode methodNode = addMethod(node, !isAbstract(node.getModifiers()),
+ MethodNode methodNode = addMethod(node, !shouldAnnotate,
"getMetaClass",
ACC_PUBLIC,
ClassHelper.METACLASS_TYPE,
@@ -476,7 +476,7 @@ public class Verifier implements GroovyClassVisitor, Opcodes {
setMetaClassCode = new BytecodeSequence(list);
}
- MethodNode methodNode = addMethod(node, !isAbstract(node.getModifiers()),
+ MethodNode methodNode = addMethod(node, !shouldAnnotate,
"setMetaClass",
ACC_PUBLIC, ClassHelper.VOID_TYPE,
SET_METACLASS_PARAMS, ClassNode.EMPTY_ARRAY,
@@ -492,7 +492,7 @@ public class Verifier implements GroovyClassVisitor, Opcodes {
blockScope.putReferencedLocalVariable(vMethods);
blockScope.putReferencedLocalVariable(vArguments);
- MethodNode methodNode = addMethod(node, !isAbstract(node.getModifiers()),
+ MethodNode methodNode = addMethod(node, !shouldAnnotate,
"invokeMethod",
ACC_PUBLIC,
ClassHelper.OBJECT_TYPE, INVOKE_METHOD_PARAMS,
@@ -513,7 +513,7 @@ public class Verifier implements GroovyClassVisitor, Opcodes {
}
if (!node.hasMethod("getProperty", GET_PROPERTY_PARAMS)) {
- MethodNode methodNode = addMethod(node, !isAbstract(node.getModifiers()),
+ MethodNode methodNode = addMethod(node, !shouldAnnotate,
"getProperty",
ACC_PUBLIC,
ClassHelper.OBJECT_TYPE,
@@ -534,7 +534,7 @@ public class Verifier implements GroovyClassVisitor, Opcodes {
}
if (!node.hasMethod("setProperty", SET_PROPERTY_PARAMS)) {
- MethodNode methodNode = addMethod(node, !isAbstract(node.getModifiers()),
+ MethodNode methodNode = addMethod(node, !shouldAnnotate,
"setProperty",
ACC_PUBLIC,
ClassHelper.VOID_TYPE,
http://git-wip-us.apache.org/repos/asf/groovy/blob/103a1090/src/main/java/org/codehaus/groovy/reflection/MixinInMetaClass.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/reflection/MixinInMetaClass.java b/src/main/java/org/codehaus/groovy/reflection/MixinInMetaClass.java
index 4dfa083..727cb89 100644
--- a/src/main/java/org/codehaus/groovy/reflection/MixinInMetaClass.java
+++ b/src/main/java/org/codehaus/groovy/reflection/MixinInMetaClass.java
@@ -25,6 +25,7 @@ import groovy.lang.GroovySystem;
import groovy.lang.MetaClass;
import groovy.lang.MetaMethod;
import groovy.lang.MetaProperty;
+import groovy.transform.Generated;
import org.codehaus.groovy.runtime.HandleMetaClass;
import org.codehaus.groovy.runtime.MetaClassHelper;
import org.codehaus.groovy.runtime.metaclass.MixedInMetaClass;
@@ -137,6 +138,9 @@ public class MixinInMetaClass extends ManagedConcurrentMap {
if (method instanceof CachedMethod && ((CachedMethod) method).getCachedMethod().isSynthetic())
continue;
+ if (method instanceof CachedMethod && ((CachedMethod) method).getCachedMethod().getAnnotation(Generated.class) != null)
+ continue;
+
if (Modifier.isStatic(mod)) {
if (method instanceof CachedMethod)
staticMethod(self, arr, (CachedMethod) method);
http://git-wip-us.apache.org/repos/asf/groovy/blob/103a1090/src/main/java/org/codehaus/groovy/runtime/callsite/AbstractCallSite.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/runtime/callsite/AbstractCallSite.java b/src/main/java/org/codehaus/groovy/runtime/callsite/AbstractCallSite.java
index d85e445..758f880 100644
--- a/src/main/java/org/codehaus/groovy/runtime/callsite/AbstractCallSite.java
+++ b/src/main/java/org/codehaus/groovy/runtime/callsite/AbstractCallSite.java
@@ -23,6 +23,7 @@ import groovy.lang.GroovyRuntimeException;
import groovy.lang.MetaClass;
import groovy.lang.MetaClassImpl;
import groovy.lang.MetaProperty;
+import groovy.transform.Generated;
import org.codehaus.groovy.reflection.CachedClass;
import org.codehaus.groovy.reflection.CachedField;
import org.codehaus.groovy.reflection.ParameterTypes;
@@ -334,7 +335,7 @@ public class AbstractCallSite implements CallSite {
Class aClass = receiver.getClass();
try {
final Method method = aClass.getMethod("getProperty", String.class);
- if (method != null && method.isSynthetic() && ((GroovyObject) receiver).getMetaClass() instanceof MetaClassImpl)
+ if (method != null && (method.isSynthetic() || method.getAnnotation(Generated.class) != null) && ((GroovyObject) receiver).getMetaClass() instanceof MetaClassImpl)
return createPogoMetaClassGetPropertySite((GroovyObject) receiver);
} catch (NoSuchMethodException e) {
// fall threw
http://git-wip-us.apache.org/repos/asf/groovy/blob/103a1090/src/main/java/org/codehaus/groovy/vmplugin/v7/Selector.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/vmplugin/v7/Selector.java b/src/main/java/org/codehaus/groovy/vmplugin/v7/Selector.java
index 4e1eb8b..1b93b71 100644
--- a/src/main/java/org/codehaus/groovy/vmplugin/v7/Selector.java
+++ b/src/main/java/org/codehaus/groovy/vmplugin/v7/Selector.java
@@ -31,6 +31,7 @@ import groovy.lang.MetaClassImpl.MetaConstructor;
import groovy.lang.MetaMethod;
import groovy.lang.MetaProperty;
import groovy.lang.MissingMethodException;
+import groovy.transform.Generated;
import org.codehaus.groovy.GroovyBugError;
import org.codehaus.groovy.reflection.CachedField;
import org.codehaus.groovy.reflection.CachedMethod;
@@ -300,7 +301,7 @@ public abstract class Selector {
Method reflectionMethod = null;
try {
reflectionMethod = aClass.getMethod("getProperty", String.class);
- if (!reflectionMethod.isSynthetic()) {
+ if (!reflectionMethod.isSynthetic() && reflectionMethod.getAnnotation(Generated.class) == null) {
handle = MethodHandles.insertArguments(GROOVY_OBJECT_GET_PROPERTY, 1, name);
return;
}
http://git-wip-us.apache.org/repos/asf/groovy/blob/103a1090/src/test/groovy/bugs/Groovy3175_Bug.groovy
----------------------------------------------------------------------
diff --git a/src/test/groovy/bugs/Groovy3175_Bug.groovy b/src/test/groovy/bugs/Groovy3175_Bug.groovy
index a2b309b..257b7e8 100644
--- a/src/test/groovy/bugs/Groovy3175_Bug.groovy
+++ b/src/test/groovy/bugs/Groovy3175_Bug.groovy
@@ -18,10 +18,12 @@
*/
package groovy.bugs
-public class Groovy3175_Bug extends GroovyTestCase {
+class Groovy3175_Bug extends GroovyTestCase {
void testSyntheticModifier() {
assertScript """
+ import groovy.transform.Generated
+
class MyService {
private fio
def thing
@@ -29,9 +31,11 @@ public class Groovy3175_Bug extends GroovyTestCase {
def anotherSomething() { assert true }
}
def fields = MyService.getDeclaredFields().grep { !it.synthetic }
- assert fields.size() == 2
+ assert fields.size() == 2
def methods = MyService.getDeclaredMethods().grep { !it.synthetic }
- assert methods.size() == 4
+ assert methods.size() == 9
+ methods = methods.grep { !it.getAnnotation(Generated) }
+ assert methods.size() == 4
"""
}
}
[2/4] groovy git commit: GROOVY-8496: Can't call default
getProperty() implementation from Java subclass
Posted by pa...@apache.org.
GROOVY-8496: Can't call default getProperty() implementation from Java subclass
Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/99691fa3
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/99691fa3
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/99691fa3
Branch: refs/heads/GROOVY_2_5_X
Commit: 99691fa39382ca97bada7c05d69a36e4476c65a8
Parents: 103a109
Author: Paul King <pa...@asert.com.au>
Authored: Sat Sep 15 00:11:46 2018 +1000
Committer: Paul King <pa...@asert.com.au>
Committed: Sat Sep 15 13:05:13 2018 +1000
----------------------------------------------------------------------
.../groovy/groovy/ant/Groovy8496Test.groovy | 57 ++++++++++++++++++++
1 file changed, 57 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/groovy/blob/99691fa3/subprojects/groovy-ant/src/test/groovy/groovy/ant/Groovy8496Test.groovy
----------------------------------------------------------------------
diff --git a/subprojects/groovy-ant/src/test/groovy/groovy/ant/Groovy8496Test.groovy b/subprojects/groovy-ant/src/test/groovy/groovy/ant/Groovy8496Test.groovy
new file mode 100644
index 0000000..981c0a0
--- /dev/null
+++ b/subprojects/groovy-ant/src/test/groovy/groovy/ant/Groovy8496Test.groovy
@@ -0,0 +1,57 @@
+/*
+ * 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.ant
+
+class Groovy8496Test extends AntTestCase {
+ void testGetProperty() {
+// def debugLogger = new org.apache.tools.ant.DefaultLogger()
+// debugLogger.setMessageOutputLevel(4)
+// debugLogger.setOutputPrintStream(System.out)
+// debugLogger.setErrorPrintStream(System.err)
+
+ doInTmpDir { ant, baseDir ->
+ baseDir.src {
+ 'GroovyClass8496.groovy'('''
+ class GroovyClass8496 {
+ String getBar() { 'BAR!' }
+ }
+ ''')
+ 'OverrideGetProperty.java'('''
+ public class OverrideGetProperty extends GroovyClass8496 {
+ @Override
+ public Object getProperty(String propertyName) {
+ return super.getProperty(propertyName).toString().toLowerCase();
+ }
+ public static void main(String[] args) {
+ System.out.println(new OverrideGetProperty().getProperty("bar"));
+ }
+ }
+ ''')
+ }
+// ant.project.addBuildListener(debugLogger)
+ ant.mkdir(dir: 'build')
+ def cp = System.getProperty('java.class.path') + ':build'
+ ant.taskdef(name: 'groovyc', classname: 'org.codehaus.groovy.ant.Groovyc')
+ ant.groovyc(srcdir: 'src', destdir: 'build')
+ ant.javac(classpath: cp, destdir: 'build', srcdir: 'src', includeantruntime: 'false', fork: 'true')
+ ant.java(classpath: cp, outputproperty: 'result', classname: 'OverrideGetProperty')
+ assert ant.project.properties.result == 'bar!'
+ }
+ }
+}