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 2019/05/17 02:45:09 UTC

[groovy] branch master updated (d250f8a -> 60c102a)

This is an automated email from the ASF dual-hosted git repository.

paulk pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git.


    from d250f8a  GROOVY-8647: Split package renaming (groovy-xml)
     new 9f66b48  fix memStub javadoc typo
     new 1fd7f04  minor refactor: formatting and style
     new 50fd92d  GROOVY-9122: code smell in ProcessingUnit
     new d0b8e91  minor refactor: remove dead code
     new 60c102a  GROOVY-9121: Default compiler configuration is modified by GroovyMain

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/main/groovy/groovy/ui/GroovyMain.java          |  2 +-
 .../codehaus/groovy/control/CompilationUnit.java   | 11 ----
 .../groovy/control/CompilerConfiguration.java      |  2 +-
 .../codehaus/groovy/control/ProcessingUnit.java    | 66 +++++++++++-----------
 4 files changed, 35 insertions(+), 46 deletions(-)


[groovy] 02/05: minor refactor: formatting and style

Posted by pa...@apache.org.
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

commit 1fd7f048226384f10a2635f8129c02b8937e57f3
Author: Paul King <pa...@asert.com.au>
AuthorDate: Fri May 17 11:03:01 2019 +1000

    minor refactor: formatting and style
---
 .../codehaus/groovy/control/ProcessingUnit.java    | 53 ++++++++++------------
 1 file changed, 23 insertions(+), 30 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/control/ProcessingUnit.java b/src/main/java/org/codehaus/groovy/control/ProcessingUnit.java
index 34c9439..f4509cd 100644
--- a/src/main/java/org/codehaus/groovy/control/ProcessingUnit.java
+++ b/src/main/java/org/codehaus/groovy/control/ProcessingUnit.java
@@ -32,10 +32,10 @@ public abstract class ProcessingUnit {
     /**
      * The current phase
      */
-    protected int phase;
+    protected int phase = Phases.INITIALIZATION;
 
     /**
-     * Set true if phase is finished
+     * True if phase is finished
      */
     protected boolean phaseComplete;
 
@@ -55,10 +55,9 @@ public abstract class ProcessingUnit {
     protected ErrorCollector errorCollector;
 
     /**
-     * Initialize the ProcessingUnit to the empty state.
+     * Initializes the ProcessingUnit to the empty state.
      */
     public ProcessingUnit(final CompilerConfiguration configuration, final GroovyClassLoader classLoader, final ErrorCollector errorCollector) {
-        this.phase = Phases.INITIALIZATION;
         setClassLoader(classLoader);
         configure(configuration != null ? configuration : CompilerConfiguration.DEFAULT);
         this.errorCollector = errorCollector != null ? errorCollector : new ErrorCollector(getConfiguration());
@@ -90,47 +89,44 @@ public abstract class ProcessingUnit {
      * Sets the class loader for use by this ProcessingUnit.
      */
     public void setClassLoader(final GroovyClassLoader loader) {
-        // Classloaders should only be created inside a doPrivileged block in case
-        // this method is invoked by code that does not have security permissions
+        // ClassLoaders should only be created inside a doPrivileged block in case
+        // this method is invoked by code that does not have security permissions.
         this.classLoader = loader != null ? loader : AccessController.doPrivileged(new PrivilegedAction<GroovyClassLoader>() {
             public GroovyClassLoader run() {
                 ClassLoader parent = Thread.currentThread().getContextClassLoader();
                 if (parent == null) parent = ProcessingUnit.class.getClassLoader();
-                return new GroovyClassLoader(parent, configuration);
+                return new GroovyClassLoader(parent, getConfiguration());
             }
         });
     }
 
     /**
+     * Errors found during the compilation should be reported through the ErrorCollector.
+     */
+    public ErrorCollector getErrorCollector() {
+        return errorCollector;
+    }
+
+    /**
      * Returns the current phase.
      */
     public int getPhase() {
-        return this.phase;
+        return phase;
     }
 
     /**
      * Returns the description for the current phase.
      */
     public String getPhaseDescription() {
-        return Phases.getDescription(this.phase);
+        return Phases.getDescription(phase);
     }
 
-    /**
-     * Errors found during the compilation should be reported through the ErrorCollector.
-     *
-     * @return the ErrorCollector for this ProcessingUnit
-     */
-    public ErrorCollector getErrorCollector() {
-        return errorCollector;
+    public boolean isPhaseComplete() {
+        return phaseComplete;
     }
 
-    //---------------------------------------------------------------------------
-    // PROCESSING
-
-
     /**
-     * Marks the current phase complete and processes any
-     * errors.
+     * Marks the current phase complete and processes any errors.
      */
     public void completePhase() throws CompilationFailedException {
         errorCollector.failIfErrors();
@@ -138,23 +134,20 @@ public abstract class ProcessingUnit {
     }
 
     /**
-     * A synonym for <code>gotoPhase( phase + 1 )</code>.
+     * A synonym for <code>gotoPhase(getPhase() + 1)</code>.
      */
     public void nextPhase() throws CompilationFailedException {
-        gotoPhase(this.phase + 1);
+        gotoPhase(phase + 1);
     }
 
     /**
-     * Wraps up any pending operations for the current phase
-     * and switches to the next phase.
+     * Wraps up any pending operations for the current phase and switches to the given phase.
      */
     public void gotoPhase(int phase) throws CompilationFailedException {
-        if (!this.phaseComplete) {
+        if (!phaseComplete) {
             completePhase();
         }
-
         this.phase = phase;
-        this.phaseComplete = false;
+        phaseComplete = false;
     }
-
 }


[groovy] 05/05: GROOVY-9121: Default compiler configuration is modified by GroovyMain

Posted by pa...@apache.org.
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

commit 60c102a2c8c93794cecde4cee7a8b43e510ba538
Author: Paul King <pa...@asert.com.au>
AuthorDate: Fri May 17 12:44:55 2019 +1000

    GROOVY-9121: Default compiler configuration is modified by GroovyMain
---
 src/main/groovy/groovy/ui/GroovyMain.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/groovy/groovy/ui/GroovyMain.java b/src/main/groovy/groovy/ui/GroovyMain.java
index e6702e4..d227357 100644
--- a/src/main/groovy/groovy/ui/GroovyMain.java
+++ b/src/main/groovy/groovy/ui/GroovyMain.java
@@ -281,7 +281,7 @@ public class GroovyMain {
             }
 
             if (indy) {
-                CompilerConfiguration.DEFAULT.getOptimizationOptions().put("indy", true);
+                System.setProperty("groovy.target.indy", "true");
                 main.conf.getOptimizationOptions().put("indy", true);
             }
 


[groovy] 01/05: fix memStub javadoc typo

Posted by pa...@apache.org.
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

commit 9f66b48bae509a8de4007f9f9446ac9b73a23d9c
Author: Paul King <pa...@asert.com.au>
AuthorDate: Fri May 17 08:45:50 2019 +1000

    fix memStub javadoc typo
---
 src/main/java/org/codehaus/groovy/control/CompilerConfiguration.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/codehaus/groovy/control/CompilerConfiguration.java b/src/main/java/org/codehaus/groovy/control/CompilerConfiguration.java
index 44f8bdb..7bc3cbe 100644
--- a/src/main/java/org/codehaus/groovy/control/CompilerConfiguration.java
+++ b/src/main/java/org/codehaus/groovy/control/CompilerConfiguration.java
@@ -55,7 +55,7 @@ public class CompilerConfiguration {
     /** This (<code>"runtimeGroovydoc"</code>) is the Optimization Option value for enabling attaching {@link groovy.lang.Groovydoc} annotation*/
     public static final String RUNTIME_GROOVYDOC = "runtimeGroovydoc";
 
-    /** This (<code>"memStub"</code>) is the Optimization Option value for enabling generating stubs in memory*/
+    /** This (<code>"memStub"</code>) is the Joint Compilation Option value for enabling generating stubs in memory*/
     public static final String MEM_STUB = "memStub";
 
     /** This (<code>"1.4"</code>) is the value for targetBytecode to compile for a JDK 1.4. **/


[groovy] 03/05: GROOVY-9122: code smell in ProcessingUnit

Posted by pa...@apache.org.
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

commit 50fd92dc30cdfb89d83054e8cc8f5294d807f943
Author: Paul King <pa...@asert.com.au>
AuthorDate: Fri May 17 11:50:39 2019 +1000

    GROOVY-9122: code smell in ProcessingUnit
---
 .../java/org/codehaus/groovy/control/ProcessingUnit.java    | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/control/ProcessingUnit.java b/src/main/java/org/codehaus/groovy/control/ProcessingUnit.java
index f4509cd..a16c826 100644
--- a/src/main/java/org/codehaus/groovy/control/ProcessingUnit.java
+++ b/src/main/java/org/codehaus/groovy/control/ProcessingUnit.java
@@ -58,23 +58,30 @@ public abstract class ProcessingUnit {
      * Initializes the ProcessingUnit to the empty state.
      */
     public ProcessingUnit(final CompilerConfiguration configuration, final GroovyClassLoader classLoader, final ErrorCollector errorCollector) {
+        setConfiguration(configuration != null ? configuration : CompilerConfiguration.DEFAULT);
         setClassLoader(classLoader);
-        configure(configuration != null ? configuration : CompilerConfiguration.DEFAULT);
         this.errorCollector = errorCollector != null ? errorCollector : new ErrorCollector(getConfiguration());
+        configure(getConfiguration());
     }
 
     /**
      * Reconfigures the ProcessingUnit.
      */
     public void configure(CompilerConfiguration configuration) {
-        this.configuration = configuration;
+        setConfiguration(configuration);
     }
 
+    /**
+     * Get the CompilerConfiguration for this ProcessingUnit.
+     */
     public CompilerConfiguration getConfiguration() {
         return configuration;
     }
 
-    public void setConfiguration(CompilerConfiguration configuration) {
+    /**
+     * Sets the CompilerConfiguration for this ProcessingUnit.
+     */
+    public final void setConfiguration(CompilerConfiguration configuration) {
         this.configuration = configuration;
     }
 


[groovy] 04/05: minor refactor: remove dead code

Posted by pa...@apache.org.
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

commit d0b8e9178e3690c64f841dfcd6da89c69def7803
Author: Paul King <pa...@asert.com.au>
AuthorDate: Fri May 17 11:57:14 2019 +1000

    minor refactor: remove dead code
---
 .../java/org/codehaus/groovy/control/CompilationUnit.java     | 11 -----------
 1 file changed, 11 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/control/CompilationUnit.java b/src/main/java/org/codehaus/groovy/control/CompilationUnit.java
index b9dbaec..205431c 100644
--- a/src/main/java/org/codehaus/groovy/control/CompilationUnit.java
+++ b/src/main/java/org/codehaus/groovy/control/CompilationUnit.java
@@ -342,20 +342,9 @@ public class CompilationUnit extends ProcessingUnit {
     public void configure(CompilerConfiguration configuration) {
         super.configure(configuration);
         this.debug = configuration.getDebug();
-
-        if (!this.configured && this.classLoader instanceof GroovyClassLoader) {
-            appendCompilerConfigurationClasspathToClassLoader(configuration, (GroovyClassLoader) this.classLoader);
-        }
-
         this.configured = true;
     }
 
-    private void appendCompilerConfigurationClasspathToClassLoader(CompilerConfiguration configuration, GroovyClassLoader classLoader) {
-        /*for (Iterator iterator = configuration.getClasspath().iterator(); iterator.hasNext(); ) {
-            classLoader.addClasspath((String) iterator.next());
-        }*/
-    }
-
     /**
      * Returns the CompileUnit that roots our AST.
      */