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 03:34:12 UTC

[groovy] branch GROOVY_2_5_X updated (0ff47b0 -> 6902f2b)

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

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


    from 0ff47b0  port for 2_5_X
     new d36a1be  minor refactor: formatting and style
     new 746e104  GROOVY-9122: code smell in ProcessingUnit
     new f306f9f  minor refactor: remove dead code
     new 1a65ef7  GROOVY-9121: Default compiler configuration is modified by GroovyMain
     new 6902f2b  Merge remote-tracking branch 'origin/GROOVY_2_5_X' into GROOVY_2_5_X

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 ----
 .../codehaus/groovy/control/ProcessingUnit.java    | 71 +++++++++++-----------
 3 files changed, 36 insertions(+), 48 deletions(-)


[groovy] 01/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 GROOVY_2_5_X
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit d36a1be78af53e7c0c3a9218ac7ce73cde4aa0b1
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    | 57 ++++++++++------------
 1 file changed, 25 insertions(+), 32 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/control/ProcessingUnit.java b/src/main/java/org/codehaus/groovy/control/ProcessingUnit.java
index 1621535..b37793e 100644
--- a/src/main/java/org/codehaus/groovy/control/ProcessingUnit.java
+++ b/src/main/java/org/codehaus/groovy/control/ProcessingUnit.java
@@ -32,9 +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 +56,9 @@ public abstract class ProcessingUnit {
 
 
     /**
-     * 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());
@@ -95,25 +95,31 @@ public abstract class ProcessingUnit {
      */
 
     public void setClassLoader(final GroovyClassLoader loader) {
-        // Classloaders should only be created inside doPrivileged block
-        // This code creates a classloader, which needs permission if a security manage is installed.
-        // If this code might be invoked by code that does not have security permissions, then the classloader creation needs to occur inside a doPrivileged block.
-        this.classLoader = AccessController.doPrivileged(new PrivilegedAction<GroovyClassLoader>() {
+        // 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 loader == null ? new GroovyClassLoader(parent, configuration) : loader;
+                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;
     }
 
 
@@ -122,25 +128,15 @@ public abstract class ProcessingUnit {
      */
 
     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 {
@@ -150,24 +146,21 @@ 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: Merge remote-tracking branch 'origin/GROOVY_2_5_X' into GROOVY_2_5_X

Posted by pa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 6902f2b8670d9d096d4a0cb5780e2b09d4448d40
Merge: 1a65ef7 0ff47b0
Author: Paul King <pa...@asert.com.au>
AuthorDate: Fri May 17 13:20:42 2019 +1000

    Merge remote-tracking branch 'origin/GROOVY_2_5_X' into GROOVY_2_5_X

 src/main/java/org/codehaus/groovy/control/CompilerConfiguration.java | 5 -----
 1 file changed, 5 deletions(-)


[groovy] 04/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 GROOVY_2_5_X
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 1a65ef74a6ffa43df8d02b551d397169c2ff5511
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 b1ea153..699e5c0 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] 03/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 GROOVY_2_5_X
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit f306f9f0e818ae9aaf48d94acc9a40d127c5f7b1
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 26e58bf..0aa7372 100644
--- a/src/main/java/org/codehaus/groovy/control/CompilationUnit.java
+++ b/src/main/java/org/codehaus/groovy/control/CompilationUnit.java
@@ -336,20 +336,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.
      */


[groovy] 02/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 GROOVY_2_5_X
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 746e104ee592031c82bfc494e98f9e79e3b67313
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   | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/control/ProcessingUnit.java b/src/main/java/org/codehaus/groovy/control/ProcessingUnit.java
index b37793e..c279363 100644
--- a/src/main/java/org/codehaus/groovy/control/ProcessingUnit.java
+++ b/src/main/java/org/codehaus/groovy/control/ProcessingUnit.java
@@ -59,9 +59,10 @@ 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());
     }
 
 
@@ -69,15 +70,20 @@ public abstract class ProcessingUnit {
      * 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;
     }