[2/2] groovy git commit: Closing the GroovyClassLoader is now realized by try-with-resources. (closes #595)

2017-09-13 Thread sunlan
Closing the GroovyClassLoader is now realized by
try-with-resources. (closes #595)

Old Methode makeCompileUnit is added for API compatibility and marked as 
deprecated.

(cherry picked from commit abfde7e)


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

Branch: refs/heads/GROOVY_2_6_X
Commit: 2072339556a44dbf042f9c826b0aca565172c80e
Parents: 58f35e7
Author: Marcus Berndt 
Authored: Fri Aug 25 14:17:49 2017 +0800
Committer: sunlan 
Committed: Thu Sep 14 08:25:14 2017 +0800

--
 .../java/org/codehaus/groovy/ant/Groovyc.java   | 59 ++--
 1 file changed, 28 insertions(+), 31 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/groovy/blob/20723395/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java
--
diff --git 
a/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java 
b/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java
index 4d4ffb2..d69dcb4 100644
--- a/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java
+++ b/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java
@@ -291,7 +291,7 @@ public class Groovyc extends MatchingTask {
  * @param version the bytecode compatibility mode
  */
 public void setTargetBytecode(String version) {
-
+
 for (String allowedJdk : CompilerConfiguration.ALLOWED_JDKS) {
 if (allowedJdk.equals(version)) {
 this.targetBytecode = version;
@@ -304,8 +304,8 @@ public class Groovyc extends MatchingTask {
  * Retrieves the compiler bytecode compatibility mode.
  *
  * @return bytecode compatibility mode. Can be one of the values
- * 1.8, 1.7, 1.6, 1.5 or
- * 1.4.
+ * 1.8, 1.7, 1.6, 1.5 or
+ * 1.4.
  */
 public String getTargetBytecode() {
 return this.targetBytecode;
@@ -666,7 +666,7 @@ public class Groovyc extends MatchingTask {
  * Get the result of the groovyc task (success or failure).
  *
  * @return true if compilation succeeded, or
- * was not necessary, false if the compilation failed.
+ * was not necessary, false if the compilation failed.
  */
 public boolean getTaskSuccess() {
 return taskSuccess;
@@ -786,7 +786,7 @@ public class Groovyc extends MatchingTask {
 
 /**
  * Set the forceLookupUnnamedFiles flag. Defaults to false.
- *
+ * 
  * The Groovyc Ant task is frequently used in the context of a build system
  * that knows the complete list of source files to be compiled. In such a
  * context, it is wasteful for the Groovy compiler to go searching the
@@ -1195,13 +1195,9 @@ public class Groovyc extends MatchingTask {
 }
 
 if (!fileNameErrors) {
-  GroovyClassLoader loader = buildClassLoaderFor();
-  try {
-FileSystemCompiler.doCompilation(configuration, 
makeCompileUnit(loader), filenames, forceLookupUnnamedFiles);
-  } finally {
-if (loader != null)
-  loader.close();
-  }
+try (GroovyClassLoader loader = buildClassLoaderFor()) {
+FileSystemCompiler.doCompilation(configuration, 
makeCompileUnit(loader), filenames, forceLookupUnnamedFiles);
+}
 }
 
 } catch (Exception re) {
@@ -1265,6 +1261,14 @@ public class Groovyc extends MatchingTask {
 }
 }
 
+/**
+ * @deprecated This method is not in use anymore. Use {@link 
Groovyc#makeCompileUnit(GroovyClassLoader)} instead.
+ */
+@Deprecated
+protected CompilationUnit makeCompileUnit() {
+return makeCompileUnit(buildClassLoaderFor());
+}
+
 protected CompilationUnit makeCompileUnit(GroovyClassLoader loader) {
 Map options = 
configuration.getJointCompilationOptions();
 if (options != null) {
@@ -1319,12 +1323,11 @@ public class Groovyc extends MatchingTask {
  * may not exist in the classpath yet
  */
 if (!found && new File(cpEntry).exists()) {
-   try {
-   antLoader.addPathElement(cpEntry);
-   }
-   catch(BuildException e) {
-   log.warn("The classpath entry " + cpEntry + " 
is not a valid Java resource");
-   }
+try {
+antLoader.addPathElement(cpEntry);
+ 

[2/2] groovy git commit: Closing the GroovyClassLoader is now realized by try-with-resources. (closes #595)

2017-09-13 Thread sunlan
Closing the GroovyClassLoader is now realized by
try-with-resources. (closes #595)

Old Methode makeCompileUnit is added for API compatibility and marked as 
deprecated.


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

Branch: refs/heads/master
Commit: abfde7ef53d5d2185a53e5d43c16214691f0266e
Parents: 4e3ee3c
Author: Marcus Berndt 
Authored: Fri Aug 25 08:17:49 2017 +0200
Committer: sunlan 
Committed: Thu Sep 14 08:13:44 2017 +0800

--
 .../java/org/codehaus/groovy/ant/Groovyc.java   | 59 ++--
 1 file changed, 28 insertions(+), 31 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/groovy/blob/abfde7ef/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java
--
diff --git 
a/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java 
b/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java
index 4d4ffb2..d69dcb4 100644
--- a/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java
+++ b/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java
@@ -291,7 +291,7 @@ public class Groovyc extends MatchingTask {
  * @param version the bytecode compatibility mode
  */
 public void setTargetBytecode(String version) {
-
+
 for (String allowedJdk : CompilerConfiguration.ALLOWED_JDKS) {
 if (allowedJdk.equals(version)) {
 this.targetBytecode = version;
@@ -304,8 +304,8 @@ public class Groovyc extends MatchingTask {
  * Retrieves the compiler bytecode compatibility mode.
  *
  * @return bytecode compatibility mode. Can be one of the values
- * 1.8, 1.7, 1.6, 1.5 or
- * 1.4.
+ * 1.8, 1.7, 1.6, 1.5 or
+ * 1.4.
  */
 public String getTargetBytecode() {
 return this.targetBytecode;
@@ -666,7 +666,7 @@ public class Groovyc extends MatchingTask {
  * Get the result of the groovyc task (success or failure).
  *
  * @return true if compilation succeeded, or
- * was not necessary, false if the compilation failed.
+ * was not necessary, false if the compilation failed.
  */
 public boolean getTaskSuccess() {
 return taskSuccess;
@@ -786,7 +786,7 @@ public class Groovyc extends MatchingTask {
 
 /**
  * Set the forceLookupUnnamedFiles flag. Defaults to false.
- *
+ * 
  * The Groovyc Ant task is frequently used in the context of a build system
  * that knows the complete list of source files to be compiled. In such a
  * context, it is wasteful for the Groovy compiler to go searching the
@@ -1195,13 +1195,9 @@ public class Groovyc extends MatchingTask {
 }
 
 if (!fileNameErrors) {
-  GroovyClassLoader loader = buildClassLoaderFor();
-  try {
-FileSystemCompiler.doCompilation(configuration, 
makeCompileUnit(loader), filenames, forceLookupUnnamedFiles);
-  } finally {
-if (loader != null)
-  loader.close();
-  }
+try (GroovyClassLoader loader = buildClassLoaderFor()) {
+FileSystemCompiler.doCompilation(configuration, 
makeCompileUnit(loader), filenames, forceLookupUnnamedFiles);
+}
 }
 
 } catch (Exception re) {
@@ -1265,6 +1261,14 @@ public class Groovyc extends MatchingTask {
 }
 }
 
+/**
+ * @deprecated This method is not in use anymore. Use {@link 
Groovyc#makeCompileUnit(GroovyClassLoader)} instead.
+ */
+@Deprecated
+protected CompilationUnit makeCompileUnit() {
+return makeCompileUnit(buildClassLoaderFor());
+}
+
 protected CompilationUnit makeCompileUnit(GroovyClassLoader loader) {
 Map options = 
configuration.getJointCompilationOptions();
 if (options != null) {
@@ -1319,12 +1323,11 @@ public class Groovyc extends MatchingTask {
  * may not exist in the classpath yet
  */
 if (!found && new File(cpEntry).exists()) {
-   try {
-   antLoader.addPathElement(cpEntry);
-   }
-   catch(BuildException e) {
-   log.warn("The classpath entry " + cpEntry + " 
is not a valid Java resource");
-   }
+try {
+antLoader.addPathElement(cpEntry);
+} catch (BuildException e) {
+