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 2017/03/14 10:54:52 UTC

groovy git commit: GROOVY-6792: ClassFormatError if a method has dots within its name (enable only with system property for now)

Repository: groovy
Updated Branches:
  refs/heads/master b842d1bbd -> 73db9a7a7


GROOVY-6792: ClassFormatError if a method has dots within its name (enable only with system property for now)


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/73db9a7a
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/73db9a7a
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/73db9a7a

Branch: refs/heads/master
Commit: 73db9a7a75586e5cb17348c4d6108768798c2c7a
Parents: b842d1b
Author: paulk <pa...@asert.com.au>
Authored: Tue Mar 14 20:54:41 2017 +1000
Committer: paulk <pa...@asert.com.au>
Committed: Tue Mar 14 20:54:41 2017 +1000

----------------------------------------------------------------------
 .../codehaus/groovy/classgen/ClassCompletionVerifier.java    | 3 +++
 src/test/groovy/bugs/Groovy6792Bug.groovy                    | 8 ++++++++
 2 files changed, 11 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/73db9a7a/src/main/org/codehaus/groovy/classgen/ClassCompletionVerifier.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/classgen/ClassCompletionVerifier.java b/src/main/org/codehaus/groovy/classgen/ClassCompletionVerifier.java
index aba375a..c2da690 100644
--- a/src/main/org/codehaus/groovy/classgen/ClassCompletionVerifier.java
+++ b/src/main/org/codehaus/groovy/classgen/ClassCompletionVerifier.java
@@ -55,6 +55,8 @@ import static org.objectweb.asm.Opcodes.*;
  */
 public class ClassCompletionVerifier extends ClassCodeVisitorSupport {
     private static final String[] INVALID_NAME_CHARS = {".", ":", "/", ";", "[", "<", ">"};
+    // the groovy.compiler.strictNames system property is experimental and may change default value or be removed in a future version of Groovy
+    private final boolean strictNames = Boolean.parseBoolean(System.getProperty("groovy.compiler.strictNames", "false"));
     private ClassNode currentClass;
     private final SourceUnit source;
     private boolean inConstructor = false;
@@ -291,6 +293,7 @@ public class ClassCompletionVerifier extends ClassCodeVisitorSupport {
     }
 
     private void checkMethodsForIncorrectName(ClassNode cn) {
+        if (!strictNames) return;
         List<MethodNode> methods = cn.getAllDeclaredMethods();
         for (MethodNode mNode : methods) {
             String name = mNode.getName();

http://git-wip-us.apache.org/repos/asf/groovy/blob/73db9a7a/src/test/groovy/bugs/Groovy6792Bug.groovy
----------------------------------------------------------------------
diff --git a/src/test/groovy/bugs/Groovy6792Bug.groovy b/src/test/groovy/bugs/Groovy6792Bug.groovy
index 9223174..53bfd4e 100644
--- a/src/test/groovy/bugs/Groovy6792Bug.groovy
+++ b/src/test/groovy/bugs/Groovy6792Bug.groovy
@@ -31,6 +31,8 @@ class Groovy6792Bug extends CompilableTestSupport {
     }
 
     void testMethodWithInvalidName() {
+        // currently groovy.compiler.strictNames is experimental
+        System.setProperty('groovy.compiler.strictNames', 'true')
         def message = shouldNotCompile """
             class Foo {
                 def "bar.baz"(){}
@@ -38,4 +40,10 @@ class Groovy6792Bug extends CompilableTestSupport {
         """
         assert message.contains("You are not allowed to have '.' in a method name")
     }
+
+    @Override
+    protected void tearDown() throws Exception {
+        super.tearDown()
+        System.setProperty('groovy.compiler.strictNames', 'false')
+    }
 }