This is an automated email from the ASF dual-hosted git repository.
emilles pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/GROOVY_3_0_X by this push:
new f235f3adaa GROOVY-11573: propagate parameters configuration to java
compiler
f235f3adaa is described below
commit f235f3adaa88f4127f88b6bbd8ce44cd8b0413dc
Author: Eric Milles <[email protected]>
AuthorDate: Sun Feb 23 14:52:40 2025 -0600
GROOVY-11573: propagate parameters configuration to java compiler
3_0_X backport
---
.../codehaus/groovy/tools/FileSystemCompiler.java | 18 ++-
.../org/codehaus/groovy/ant/GroovycTest.xml | 117 ++++++++----------
.../org/codehaus/groovy/ant/GroovycTest2.java | 15 +--
...oovycTest2.java => ParameterMetadataCheck.java} | 15 +--
.../ant/{GroovycTest2.java => params.groovy} | 20 +--
.../org/codehaus/groovy/ant/GroovycTest.java | 134 ++++++++++++---------
6 files changed, 149 insertions(+), 170 deletions(-)
diff --git a/src/main/java/org/codehaus/groovy/tools/FileSystemCompiler.java
b/src/main/java/org/codehaus/groovy/tools/FileSystemCompiler.java
index 44e77ebbf4..4d3a9a5354 100644
--- a/src/main/java/org/codehaus/groovy/tools/FileSystemCompiler.java
+++ b/src/main/java/org/codehaus/groovy/tools/FileSystemCompiler.java
@@ -23,6 +23,7 @@ import org.codehaus.groovy.control.CompilationUnit;
import org.codehaus.groovy.control.CompilerConfiguration;
import org.codehaus.groovy.control.ConfigurationException;
import org.codehaus.groovy.control.messages.WarningMessage;
+import org.codehaus.groovy.runtime.DefaultGroovyMethods;
import org.codehaus.groovy.runtime.DefaultGroovyStaticMethods;
import org.codehaus.groovy.runtime.StringGroovyMethods;
import org.codehaus.groovy.tools.javac.JavaAwareCompilationUnit;
@@ -325,7 +326,7 @@ public class FileSystemCompiler {
public String[] getVersion() {
return new String[]{
"Groovy compiler version " + GroovySystem.getVersion(),
- "Copyright 2003-2023 The Apache Software Foundation.
https://groovy-lang.org/",
+ "Copyright 2003-2025 The Apache Software Foundation.
https://groovy-lang.org/",
"",
};
}
@@ -427,7 +428,7 @@ public class FileSystemCompiler {
configuration.setClasspath(classpath);
}
- if (targetDir != null && targetDir.getName().length() > 0) {
+ if (targetDir != null && !targetDir.getName().isEmpty()) {
configuration.setTargetDirectory(targetDir);
}
@@ -457,7 +458,7 @@ public class FileSystemCompiler {
compilerOptions.put("stubDir", stubDirectory);
}
if (keepStubs) {
- compilerOptions.put("keepStubs", true);
+ compilerOptions.put("keepStubs", Boolean.TRUE);
}
configuration.setJointCompilationOptions(compilerOptions);
}
@@ -471,7 +472,7 @@ public class FileSystemCompiler {
configuration.getOptimizationOptions().put("parallelParse",
true);
}
- final List<String> transformations = new ArrayList<>();
+ List<String> transformations = new ArrayList<>();
if (compileStatic) {
transformations.add("ast(groovy.transform.CompileStatic)");
}
@@ -492,6 +493,15 @@ public class FileSystemCompiler {
scripts.addAll(StringGroovyMethods.tokenize(configScripts,
','));
}
processConfigScripts(scripts, configuration);
+ // GROOVY-11573: propagate parameters configuration
+ if (jointCompilation && configuration.getParameters()) {
+ Map<String, Object> options =
configuration.getJointCompilationOptions();
+ String[] flags = (String[]) options.getOrDefault("flags",
new String[0]);
+ if (!DefaultGroovyMethods.contains(flags, "parameters")) {
+ flags = DefaultGroovyMethods.plus(flags, "parameters");
+ options.put("flags", flags);
+ }
+ }
}
return configuration;
diff --git
a/subprojects/groovy-ant/src/test-resources/org/codehaus/groovy/ant/GroovycTest.xml
b/subprojects/groovy-ant/src/test-resources/org/codehaus/groovy/ant/GroovycTest.xml
index 73bb824edf..6488074ba2 100644
---
a/subprojects/groovy-ant/src/test-resources/org/codehaus/groovy/ant/GroovycTest.xml
+++
b/subprojects/groovy-ant/src/test-resources/org/codehaus/groovy/ant/GroovycTest.xml
@@ -20,12 +20,10 @@
-->
-<project name="Test Groovyc Task" default="test1">
+<project name="Test Groovyc Task">
- <property name="srcPath" value="."/>
- <property name="destPath" value="${user.dir}/target/classes/groovy/test"/>
-
- <property name="javaVersion" value="7"/>
+ <property name="srcPath" location="."/>
+ <property name="destPath"
location="${user.dir}/target/classes/groovy/test"/>
<path id="groovyMaterials">
<pathelement path="${java.class.path}"/>
@@ -33,187 +31,170 @@
<taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc"
classpathref="groovyMaterials"/>
+ <presetdef name="compile-plain">
+ <groovyc srcdir="${srcPath}" destdir="${destPath}" targetBytecode="7"/>
+ </presetdef>
+
+ <presetdef name="compile-joint">
+ <groovyc srcdir="${srcPath}" destdir="${destPath}" targetBytecode="8">
+ <javac debug="true" source="8" target="8"/>
+ </groovyc>
+ </presetdef>
+
+
<target name="GroovycTest1_NoFork_NoClasspath">
- <groovyc srcdir="${srcPath}" destdir="${destPath}"
includes="GroovycTest1.groovy"/>
+ <compile-plain includes="GroovycTest1.groovy"/>
<java classname="org.codehaus.groovy.ant.GroovycTest1"/>
</target>
<target name="GroovycTest1_NoFork_WithGroovyClasspath">
- <groovyc srcdir="${srcPath}" destdir="${destPath}"
includes="GroovycTest1.groovy"
- classpathref="groovyMaterials"/>
+ <compile-plain includes="GroovycTest1.groovy"
classpathref="groovyMaterials"/>
<java classname="org.codehaus.groovy.ant.GroovycTest1"/>
</target>
<target name="GroovycTest1_NoFork_WithJavaClasspath">
- <groovyc srcdir="${srcPath}" destdir="${destPath}"
includes="GroovycTest1.groovy"/>
+ <compile-plain includes="GroovycTest1.groovy"/>
<java classname="org.codehaus.groovy.ant.GroovycTest1"
classpathref="groovyMaterials"/>
</target>
<target name="GroovycTest1_NoFork_WithBothClasspath">
- <groovyc srcdir="${srcPath}" destdir="${destPath}"
includes="GroovycTest1.groovy"
- classpathref="groovyMaterials"/>
+ <compile-plain includes="GroovycTest1.groovy"
classpathref="groovyMaterials"/>
<java classname="org.codehaus.groovy.ant.GroovycTest1"
classpathref="groovyMaterials"/>
</target>
<target name="GroovycTest1_ForkGroovy_NoClasspath">
- <groovyc srcdir="${srcPath}" destdir="${destPath}"
includes="GroovycTest1.groovy" fork="true"/>
+ <compile-plain includes="GroovycTest1.groovy" fork="true"/>
<java classname="org.codehaus.groovy.ant.GroovycTest1"/>
</target>
<target name="GroovycTest1_ForkGroovy_WithGroovyClasspath">
- <groovyc srcdir="${srcPath}" destdir="${destPath}"
includes="GroovycTest1.groovy" classpathref="groovyMaterials"
- fork="true"/>
+ <compile-plain includes="GroovycTest1.groovy"
classpathref="groovyMaterials" fork="true"/>
<java classname="org.codehaus.groovy.ant.GroovycTest1"/>
</target>
<target name="GroovycTest1_ForkGroovy_WithJavaClasspath">
- <groovyc srcdir="${srcPath}" destdir="${destPath}"
includes="GroovycTest1.groovy" fork="true"/>
+ <compile-plain includes="GroovycTest1.groovy" fork="true"/>
<java classname="org.codehaus.groovy.ant.GroovycTest1"
classpathref="groovyMaterials"/>
</target>
<target name="GroovycTest1_ForkGroovy_WithBothClasspath">
- <groovyc srcdir="${srcPath}" destdir="${destPath}"
includes="GroovycTest1.groovy" classpathref="groovyMaterials"
- fork="true"/>
+ <compile-plain includes="GroovycTest1.groovy"
classpathref="groovyMaterials" fork="true"/>
<java classname="org.codehaus.groovy.ant.GroovycTest1"
classpathref="groovyMaterials"/>
</target>
<target name="GroovycTest1_Joint_NoFork_NoClasspath">
- <groovyc srcdir="${srcPath}" destdir="${destPath}"
includes="GroovycTest1.groovy,GroovyTest2.java">
- <javac source="${javaVersion}" target="${javaVersion}"
debug="true"/>
- </groovyc>
+ <compile-joint includes="GroovycTest1.groovy,GroovyTest2.java"/>
<java classname="org.codehaus.groovy.ant.GroovycTest1"/>
<java classname="org.codehaus.groovy.ant.GroovycTest2"/>
</target>
<target name="GroovycTest1_Joint_NoFork_WithGroovyClasspath">
- <groovyc srcdir="${srcPath}" destdir="${destPath}"
includes="GroovycTest1.groovy,GroovycTest2.java"
- classpathref="groovyMaterials">
- <javac source="${javaVersion}" target="${javaVersion}"
debug="true"/>
- </groovyc>
+ <compile-joint includes="GroovycTest1.groovy,GroovycTest2.java"
classpathref="groovyMaterials"/>
<java classname="org.codehaus.groovy.ant.GroovycTest1"/>
<java classname="org.codehaus.groovy.ant.GroovycTest2"/>
</target>
<target name="Groovyc_Joint_NoFork_NestedCompilerArg_WithGroovyClasspath">
- <groovyc srcdir="${srcPath}" destdir="${destPath}"
includes="IncorrectGenericsUsage.java"
- classpathref="groovyMaterials">
- <javac source="${javaVersion}" target="${javaVersion}"
debug="true">
+ <compile-joint includes="IncorrectGenericsUsage.java"
classpathref="groovyMaterials">
+ <javac>
<compilerarg value="-Xlint"/>
</javac>
- </groovyc>
+ </compile-joint>
</target>
<target name="GroovycTest1_Joint_NoFork_WithJavaClasspath">
- <groovyc srcdir="${srcPath}" destdir="${destPath}"
includes="GroovycTest1.groovy,GroovycTest2.java">
- <javac source="${javaVersion}" target="${javaVersion}"
debug="true"/>
- </groovyc>
+ <compile-joint includes="GroovycTest1.groovy,GroovycTest2.java"/>
<java classname="org.codehaus.groovy.ant.GroovycTest1"
classpathref="groovyMaterials"/>
<java classname="org.codehaus.groovy.ant.GroovycTest2"
classpathref="groovyMaterials"/>
</target>
<target name="GroovycTest1_Joint_NoFork_WithBothClasspath">
- <groovyc srcdir="${srcPath}" destdir="${destPath}"
includes="GroovycTest1.groovy,GroovycTest2.java"
- classpathref="groovyMaterials">
- <javac source="${javaVersion}" target="${javaVersion}"
debug="true"/>
- </groovyc>
+ <compile-joint includes="GroovycTest1.groovy,GroovycTest2.java"
classpathref="groovyMaterials"/>
<java classname="org.codehaus.groovy.ant.GroovycTest1"
classpathref="groovyMaterials"/>
<java classname="org.codehaus.groovy.ant.GroovycTest2"
classpathref="groovyMaterials"/>
</target>
<target name="GroovycTest1_Joint_ForkGroovy_NoClasspath">
- <groovyc srcdir="${srcPath}" destdir="${destPath}"
includes="GroovycTest1.groovy,GroovycTest2.java" fork="true">
- <javac source="${javaVersion}" target="${javaVersion}"
debug="true"/>
- </groovyc>
+ <compile-joint includes="GroovycTest1.groovy,GroovycTest2.java"
fork="true"/>
<java classname="org.codehaus.groovy.ant.GroovycTest1"/>
<java classname="org.codehaus.groovy.ant.GroovycTest2"/>
</target>
<target name="GroovycTest1_Joint_ForkGroovy_WithGroovyClasspath">
- <groovyc srcdir="${srcPath}" destdir="${destPath}"
includes="GroovycTest1.groovy,GroovycTest2.java" fork="true"
- classpathref="groovyMaterials">
- <javac source="${javaVersion}" target="${javaVersion}"
debug="true"/>
- </groovyc>
+ <compile-joint includes="GroovycTest1.groovy,GroovycTest2.java"
fork="true" classpathref="groovyMaterials"/>
<java classname="org.codehaus.groovy.ant.GroovycTest1"/>
<java classname="org.codehaus.groovy.ant.GroovycTest2"/>
</target>
<target name="GroovycTest1_Joint_ForkGroovy_WithJavaClasspath">
- <groovyc srcdir="${srcPath}" destdir="${destPath}"
includes="GroovycTest1.groovy,GroovycTest2.java" fork="true">
- <javac source="${javaVersion}" target="${javaVersion}"
debug="true"/>
- </groovyc>
+ <compile-joint includes="GroovycTest1.groovy,GroovycTest2.java"
fork="true"/>
<java classname="org.codehaus.groovy.ant.GroovycTest1"
classpathref="groovyMaterials"/>
<java classname="org.codehaus.groovy.ant.GroovycTest2"
classpathref="groovyMaterials"/>
</target>
<target name="GroovycTest1_Joint_ForkGroovy_WithBothClasspath">
- <groovyc srcdir="${srcPath}" destdir="${destPath}"
includes="GroovycTest1.groovy,GroovycTest2.java" fork="true"
- classpathref="groovyMaterials">
- <javac source="${javaVersion}" target="${javaVersion}"
debug="true"/>
- </groovyc>
+ <compile-joint includes="GroovycTest1.groovy,GroovycTest2.java"
fork="true" classpathref="groovyMaterials"/>
<java classname="org.codehaus.groovy.ant.GroovycTest1"
classpathref="groovyMaterials"/>
<java classname="org.codehaus.groovy.ant.GroovycTest2"
classpathref="groovyMaterials"/>
</target>
<target name="GroovycTest1_ForkGroovy_NoClasspath_WithJavaHome">
- <groovyc srcdir="${srcPath}" destdir="${destPath}"
includes="GroovycTest1.groovy" fork="true"
- javahome="${alt.java.home}"/>
+ <compile-plain includes="GroovycTest1.groovy" fork="true"
javahome="${alt.java.home}"/>
<java classname="org.codehaus.groovy.ant.GroovycTest1"/>
</target>
<target name="GroovycTest1_ForkGroovy_WithGroovyClasspath_WithJavaHome">
- <groovyc srcdir="${srcPath}" destdir="${destPath}"
includes="GroovycTest1.groovy" classpathref="groovyMaterials"
- fork="true" javahome="${alt.java.home}"/>
+ <compile-plain includes="GroovycTest1.groovy"
classpathref="groovyMaterials" fork="true" javahome="${alt.java.home}"/>
<java classname="org.codehaus.groovy.ant.GroovycTest1"/>
</target>
<target name="GroovycTest1_ForkGroovy_WithJavaClasspath_WithJavaHome">
- <groovyc srcdir="${srcPath}" destdir="${destPath}"
includes="GroovycTest1.groovy" fork="true"
- javahome="${alt.java.home}"/>
+ <compile-plain includes="GroovycTest1.groovy" fork="true"
javahome="${alt.java.home}"/>
<java classname="org.codehaus.groovy.ant.GroovycTest1"
classpathref="groovyMaterials"/>
</target>
<target name="GroovycTest1_ForkGroovy_WithBothClasspath_WithJavaHome">
- <groovyc srcdir="${srcPath}" destdir="${destPath}"
includes="GroovycTest1.groovy" classpathref="groovyMaterials"
- fork="true" javahome="${alt.java.home}"/>
+ <compile-plain includes="GroovycTest1.groovy"
classpathref="groovyMaterials" fork="true" javahome="${alt.java.home}"/>
<java classname="org.codehaus.groovy.ant.GroovycTest1"
classpathref="groovyMaterials"/>
</target>
<target name="GroovycTest1_ForkGroovy_NoClasspath_Fail">
- <groovyc srcdir="${srcPath}" destdir="${destPath}"
includes="GroovyTestBad1.groovy" fork="true"/>
- <java classname="org.codehaus.groovy.ant.GroovycTest1"/>
+ <compile-plain includes="GroovyTestBad1.groovy" fork="true"/>
</target>
<target name="noForkNoAntRuntime">
- <groovyc srcdir="${srcPath}" destdir="${destPath}"
includes="GroovycTest1.groovy" fork="false" includeAntRuntime="false"/>
+ <compile-plain includes="GroovycTest1.groovy" fork="false"
includeAntRuntime="false"/>
</target>
<!-- GROOVY-9197 -->
<target name="jointForkedCompilation_ExternalJarOnClasspath">
- <presetdef name="compile">
- <groovyc fork="true" includeantruntime="false">
- <javac debug="true" source="${javaVersion}"
target="${javaVersion}"/>
- </groovyc>
- </presetdef>
-
<path id="the.classpath">
<path refid="groovyMaterials"/>
<fileset file="commons-lang3-3.4.jar"/>
</path>
- <compile srcdir="${srcPath}" destdir="${destPath}"
includes="MakesExternalReference.java">
+ <compile-joint fork="true" includeantruntime="false"
includes="MakesExternalReference.java">
<classpath refid="the.classpath"/>
- </compile>
+ </compile-joint>
<java classname="org.codehaus.groovy.ant.MakesExternalReference"
classpathref="the.classpath"/>
</target>
+ <!-- GROOVY-11573 -->
+ <target name="jointForkedCompilation_ParameterMetadataCheck">
+ <compile-joint fork="true" configscript="params.groovy"
includes="ParameterMetadataCheck.java"/>
+ <java classname="org.codehaus.groovy.ant.ParameterMetadataCheck"/>
+ </target>
+
<target name="clean">
<delete quiet="true">
<fileset dir="${destPath}/org/codehaus/groovy/ant">
+ <include name="*_Result.txt"/>
<include name="GroovycTest1*.class"/>
<include name="GroovycTest2*.class"/>
<include name="IncorrectGenericsUsage.class"/>
<include name="MakesExternalReference.class"/>
+ <include name="ParameterMetadataCheck.class"/>
</fileset>
</delete>
</target>
diff --git
a/subprojects/groovy-ant/src/test-resources/org/codehaus/groovy/ant/GroovycTest2.java
b/subprojects/groovy-ant/src/test-resources/org/codehaus/groovy/ant/GroovycTest2.java
index ff990c2ad7..1ec6812fcc 100644
---
a/subprojects/groovy-ant/src/test-resources/org/codehaus/groovy/ant/GroovycTest2.java
+++
b/subprojects/groovy-ant/src/test-resources/org/codehaus/groovy/ant/GroovycTest2.java
@@ -22,17 +22,12 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
-class GroovycTest2 {
- static void main(String[] args) throws IOException {
- FileOutputStream fout = new FileOutputStream(
- new
File("target/classes/groovy/test/org/codehaus/groovy/ant/GroovycTest2_Result.txt"));
- try {
+public class GroovycTest2 {
+ public static void main(String[] args) throws IOException {
+ File file = new
File("target/classes/groovy/test/org/codehaus/groovy/ant/GroovycTest2_Result.txt");
+ file.createNewFile();
+ try (FileOutputStream fout = new FileOutputStream(file)) {
fout.write("OK.".getBytes());
- } finally {
- try {
- fout.close();
- } catch (IOException ignore) {
- }
}
}
}
diff --git
a/subprojects/groovy-ant/src/test-resources/org/codehaus/groovy/ant/GroovycTest2.java
b/subprojects/groovy-ant/src/test-resources/org/codehaus/groovy/ant/ParameterMetadataCheck.java
similarity index 72%
copy from
subprojects/groovy-ant/src/test-resources/org/codehaus/groovy/ant/GroovycTest2.java
copy to
subprojects/groovy-ant/src/test-resources/org/codehaus/groovy/ant/ParameterMetadataCheck.java
index ff990c2ad7..66a4966e24 100644
---
a/subprojects/groovy-ant/src/test-resources/org/codehaus/groovy/ant/GroovycTest2.java
+++
b/subprojects/groovy-ant/src/test-resources/org/codehaus/groovy/ant/ParameterMetadataCheck.java
@@ -22,17 +22,12 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
-class GroovycTest2 {
- static void main(String[] args) throws IOException {
- FileOutputStream fout = new FileOutputStream(
- new
File("target/classes/groovy/test/org/codehaus/groovy/ant/GroovycTest2_Result.txt"));
- try {
+public class ParameterMetadataCheck {
+ public static void main(String[] args) throws IOException {
+ File file = new
File("target/classes/groovy/test/org/codehaus/groovy/ant/ParameterMetadataCheck_Result.txt");
+ file.createNewFile();
+ try (FileOutputStream fout = new FileOutputStream(file)) {
fout.write("OK.".getBytes());
- } finally {
- try {
- fout.close();
- } catch (IOException ignore) {
- }
}
}
}
diff --git
a/subprojects/groovy-ant/src/test-resources/org/codehaus/groovy/ant/GroovycTest2.java
b/subprojects/groovy-ant/src/test-resources/org/codehaus/groovy/ant/params.groovy
similarity index 60%
copy from
subprojects/groovy-ant/src/test-resources/org/codehaus/groovy/ant/GroovycTest2.java
copy to
subprojects/groovy-ant/src/test-resources/org/codehaus/groovy/ant/params.groovy
index ff990c2ad7..d4e5cfeb5d 100644
---
a/subprojects/groovy-ant/src/test-resources/org/codehaus/groovy/ant/GroovycTest2.java
+++
b/subprojects/groovy-ant/src/test-resources/org/codehaus/groovy/ant/params.groovy
@@ -16,23 +16,5 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.codehaus.groovy.ant;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-
-class GroovycTest2 {
- static void main(String[] args) throws IOException {
- FileOutputStream fout = new FileOutputStream(
- new
File("target/classes/groovy/test/org/codehaus/groovy/ant/GroovycTest2_Result.txt"));
- try {
- fout.write("OK.".getBytes());
- } finally {
- try {
- fout.close();
- } catch (IOException ignore) {
- }
- }
- }
-}
+configuration.parameters=true
diff --git
a/subprojects/groovy-ant/src/test/groovy/org/codehaus/groovy/ant/GroovycTest.java
b/subprojects/groovy-ant/src/test/groovy/org/codehaus/groovy/ant/GroovycTest.java
index cec5dd691b..934cf80bef 100644
---
a/subprojects/groovy-ant/src/test/groovy/org/codehaus/groovy/ant/GroovycTest.java
+++
b/subprojects/groovy-ant/src/test/groovy/org/codehaus/groovy/ant/GroovycTest.java
@@ -30,6 +30,7 @@ import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintStream;
+import java.lang.reflect.Method;
import java.net.URISyntaxException;
import java.nio.file.Paths;
import java.util.regex.Pattern;
@@ -42,10 +43,12 @@ import java.util.regex.Pattern;
* matter as the tests remove all class files that should not pre-exist from
this directory at each step.
*/
public class GroovycTest extends GroovyTestCase {
+
private final File antFile = new
File("src/test-resources/org/codehaus/groovy/ant/GroovycTest.xml");
private Project project;
private static boolean warned = false;
+ @Override
protected void setUp() {
project = new Project();
project.init();
@@ -118,6 +121,70 @@ public class GroovycTest extends GroovyTestCase {
}
}
+ private void ensureExecutes(final String target) {
+ ensureNotPresent("GroovycTest1");
+ project.executeTarget(target);
+ ensureResultOK("GroovycTest1");
+ }
+
+ private void ensureExecutesWithJavaHome(final String target) {
+ if (project.getProperty("alt.java.home") != null) {
+ ensureExecutes(target);
+ } else {
+ if (!warned) {
+ System.err.println("Forked Java tests skipped, not a sun JDK
layout");
+ warned = true;
+ }
+ }
+ }
+
+ private void ensureFails(final String target) {
+ File badGroovy = new File(antFile.getParentFile(),
"GroovyTestBad1.groovy");
+ PrintStream ps = null;
+ try {
+ ps = new PrintStream(new FileOutputStream(badGroovy));
+ } catch (FileNotFoundException e) {
+ fail("Could not create test file:" + badGroovy.getAbsolutePath());
+ }
+ ps.println("class GroovyTest1Bad { Thi$ $hould Fail! (somehow)
};:??''+_|\\|");
+ ps.close();
+ ensureNotPresent("GroovycTestBad1");
+ try {
+ project.executeTarget(target);
+ fail("Ant script should have failed with execution exception");
+ } catch (BuildException be) {
+ be.printStackTrace();
+ ensureNotPresent("GroovycTestBad1");
+ } finally {
+ badGroovy.delete();
+ }
+ }
+
+ /**
+ * For the code:
+ * private ArrayList<String> x = new ArrayList<String>();
+ * x = (ArrayList)z ;
+ * Upto JDK6, 'javac -Xlint' produces the following output:
+ * found : java.util.ArrayList
+ * required: java.util.ArrayList<java.lang.String>
+ * But, OpenJDK seems to be producing the following output:
+ * required: ArrayList<String>
+ * found: ArrayList
+ * So, we first adjust the output a bit, so that difference in the output
brought in by OpenJDK javac
+ * does not impact the test adversely
+ */
+ private String adjustOutputToHandleOpenJDKJavacOutputDifference(String
antOutput) {
+ if (!antOutput.contains("java.util.ArrayList") &&
antOutput.contains("ArrayList")) {
+ antOutput = antOutput.replace("ArrayList", "java.util.ArrayList");
+ }
+ if (!antOutput.contains("java.lang.String") &&
antOutput.contains("String")) {
+ antOutput = antOutput.replace("String", "java.lang.String");
+ }
+ return antOutput;
+ }
+
+
//--------------------------------------------------------------------------
+
public void testGroovycTest1_NoFork_NoClasspath() {
ensureExecutes("GroovycTest1_NoFork_NoClasspath");
}
@@ -181,29 +248,6 @@ public class GroovycTest extends GroovyTestCase {
}
}
- /**
- * For the code:
- * private ArrayList<String> x = new ArrayList<String>();
- * x = (ArrayList)z ;
- * Upto JDK6, 'javac -Xlint' produces the following output:
- * found : java.util.ArrayList
- * required: java.util.ArrayList<java.lang.String>
- * But, OpenJDK seems to be producing the following output:
- * required: ArrayList<String>
- * found: ArrayList
- * So, we first adjust the output a bit, so that difference in the output
brought in by OpenJDK javac
- * does not impact the test adversely
- */
- private String adjustOutputToHandleOpenJDKJavacOutputDifference(String
antOutput) {
- if (!antOutput.contains("java.util.ArrayList") &&
antOutput.contains("ArrayList")) {
- antOutput = antOutput.replace("ArrayList", "java.util.ArrayList");
- }
- if (!antOutput.contains("java.lang.String") &&
antOutput.contains("String")) {
- antOutput = antOutput.replace("String", "java.lang.String");
- }
- return antOutput;
- }
-
public void testGroovycTest1_Joint_NoFork_WithJavaClasspath() {
ensureExecutes("GroovycTest1_Joint_NoFork_WithJavaClasspath");
}
@@ -259,42 +303,14 @@ public class GroovycTest extends GroovyTestCase {
ensureResultOK("MakesExternalReference");
}
- private void ensureExecutes(String target) {
- ensureNotPresent("GroovycTest1");
- project.executeTarget(target);
- ensureResultOK("GroovycTest1");
- }
-
- private void ensureExecutesWithJavaHome(String target) {
- if (project.getProperty("alt.java.home") != null) {
- ensureExecutes(target);
- } else {
- if (!warned) {
- System.err.println("Forked Java tests skipped, not a sun JDK
layout");
- warned = true;
- }
- }
- }
+ // GROOVY-11573
+ public void testJointCompilationPropagatesParameters() throws Exception {
+ ensureNotPresent("ParameterMetadataCheck");
+ project.executeTarget("jointForkedCompilation_ParameterMetadataCheck");
+ ensureResultOK("ParameterMetadataCheck");
- private void ensureFails(String target) {
- File badGroovy = new File(antFile.getParentFile(),
"GroovyTestBad1.groovy");
- PrintStream ps = null;
- try {
- ps = new PrintStream(new FileOutputStream(badGroovy));
- } catch (FileNotFoundException e) {
- fail("Could not create test file:" + badGroovy.getAbsolutePath());
- }
- ps.println("class GroovyTest1Bad { Thi$ $hould Fail! (somehow)
};:??''+_|\\|");
- ps.close();
- ensureNotPresent("GroovycTestBad1");
- try {
- project.executeTarget(target);
- fail("Ant script should have failed with execution exception");
- } catch (BuildException be) {
- be.printStackTrace();
- ensureNotPresent("GroovycTestBad1");
- } finally {
- badGroovy.delete();
- }
+ Class<?> c =
Class.forName("org.codehaus.groovy.ant.ParameterMetadataCheck");
+ Method m = c.getDeclaredMethod("main", String[].class);
+ assertEquals("args", m.getParameters()[0].getName());
}
}