groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwagenleit...@apache.org
Subject [2/2] groovy git commit: Remove outdated parser loading logic. (closes #415)
Date Sun, 11 Sep 2016 02:19:51 GMT
Remove outdated parser loading logic. (closes #415)

It looks like a long time ago there were two Groovy parsers, a “Classic”
and Antlr.  The Antlr one was loaded using reflection, while the classic
one was simply instantiated.  The reflection logic was kept after
definitely switching to Antlr (cf. ebeff74), although it is still
normally instantiated if reflection fails.

This commit simply removes all the reflection stuff.


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

Branch: refs/heads/GROOVY_2_4_X
Commit: 5bae714d27665762a1b89d251dd8870167c06b30
Parents: 49d5dd1
Author: Sébastien Le Callonnec <sebastien@weblogism.com>
Authored: Tue Sep 6 20:14:56 2016 +0100
Committer: John Wagenleitner <jwagenleitner@apache.org>
Committed: Sat Sep 10 19:19:09 2016 -0700

----------------------------------------------------------------------
 .../groovy/control/CompilerConfiguration.java   |  2 +-
 .../groovy/control/ParserPluginFactory.java     | 50 +++++++-------------
 .../control/CompilerConfigurationTest.java      |  2 +-
 3 files changed, 20 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/5bae714d/src/main/org/codehaus/groovy/control/CompilerConfiguration.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/control/CompilerConfiguration.java b/src/main/org/codehaus/groovy/control/CompilerConfiguration.java
index 00370f4..8c567ef 100644
--- a/src/main/org/codehaus/groovy/control/CompilerConfiguration.java
+++ b/src/main/org/codehaus/groovy/control/CompilerConfiguration.java
@@ -666,7 +666,7 @@ public class CompilerConfiguration {
 
     public ParserPluginFactory getPluginFactory() {
         if (pluginFactory == null) {
-            pluginFactory = ParserPluginFactory.newInstance(true);
+            pluginFactory = ParserPluginFactory.newInstance();
         }
         return pluginFactory;
     }

http://git-wip-us.apache.org/repos/asf/groovy/blob/5bae714d/src/main/org/codehaus/groovy/control/ParserPluginFactory.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/control/ParserPluginFactory.java b/src/main/org/codehaus/groovy/control/ParserPluginFactory.java
index 20cb9e4..d043a7f 100644
--- a/src/main/org/codehaus/groovy/control/ParserPluginFactory.java
+++ b/src/main/org/codehaus/groovy/control/ParserPluginFactory.java
@@ -25,40 +25,26 @@ import org.codehaus.groovy.antlr.AntlrParserPluginFactory;
  *
  */
 public abstract class ParserPluginFactory {
+
+    /**
+     * Creates a new instance of {@link ParserPluginFactory}.
+     *
+     * <p>The <code>useNewParser</code> parameter is not used, and this
method
+     * is kept for backward compatibility.
+     *
+     * @param useNewParser unused.
+     * @return the new parser factory.
+     */
     public static ParserPluginFactory newInstance(boolean useNewParser) {
-        if (useNewParser) {
-            Class type = null;
-            String name = "org.codehaus.groovy.antlr.AntlrParserPluginFactory";
-            try {
-                type = Class.forName(name);
-            }
-            catch (ClassNotFoundException e) {
-                try {
-                    type = ParserPluginFactory.class.getClassLoader().loadClass(name);
-                }
-                catch (ClassNotFoundException e1) {
-                    ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
-                    if (contextClassLoader != null) {
-                        try {
-                            type = contextClassLoader.loadClass(name);
-                        }
-                        catch (ClassNotFoundException e2) {
-                            // ignore
-                        }
-                    }
-                }
-            }
+        return newInstance();
+    }
 
-            if (type != null) {
-                try {
-                    return (ParserPluginFactory) type.newInstance();
-                }
-                catch (Exception e) {
-                    throw new RuntimeException("Could not create AntlrParserPluginFactory:
" + e, e);
-                }
-            }
-            // can't find Antlr parser, so lets use the Classic one
-        }
+    /**
+     * Creates a new instance of {@link ParserPluginFactory}.
+     *
+     * @return the new parser factory.
+     */
+    public static ParserPluginFactory newInstance() {
         return new AntlrParserPluginFactory();
     }
 

http://git-wip-us.apache.org/repos/asf/groovy/blob/5bae714d/src/test/org/codehaus/groovy/control/CompilerConfigurationTest.java
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/control/CompilerConfigurationTest.java b/src/test/org/codehaus/groovy/control/CompilerConfigurationTest.java
index b3569ae..06cec24 100644
--- a/src/test/org/codehaus/groovy/control/CompilerConfigurationTest.java
+++ b/src/test/org/codehaus/groovy/control/CompilerConfigurationTest.java
@@ -129,7 +129,7 @@ public class CompilerConfigurationTest extends GroovyTestCase {
         initJoint.put("somekey", "somevalue");
         init.setJointCompilationOptions(initJoint);
 
-        final ParserPluginFactory initPPF = ParserPluginFactory.newInstance(true);
+        final ParserPluginFactory initPPF = ParserPluginFactory.newInstance();
         init.setPluginFactory(initPPF);
 
         assertEquals(WarningMessage.POSSIBLE_ERRORS, init.getWarningLevel());


Mime
View raw message