This is an automated email from the ASF dual-hosted git repository. sunlan pushed a commit to branch GROOVY_3_0_X in repository https://gitbox.apache.org/repos/asf/groovy.git
commit 6b55d3eef0645262d6859dc415b5e0f65edea4a9 Author: Daniel Sun <[email protected]> AuthorDate: Sat Mar 14 19:46:06 2020 +0800 Trivial refactoring: Use safer parameter type with generics As the generics will be erased, no binary compatibility issue was introduced here (cherry picked from commit 6cd16721972247c401947386fdd6310ce170adb4) --- src/main/java/groovy/lang/GroovyShell.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/main/java/groovy/lang/GroovyShell.java b/src/main/java/groovy/lang/GroovyShell.java index 3255fa1..0bce524 100644 --- a/src/main/java/groovy/lang/GroovyShell.java +++ b/src/main/java/groovy/lang/GroovyShell.java @@ -145,18 +145,14 @@ public class GroovyShell extends GroovyObjectSupport { } } - // - // FIXME: Use List<String> here, current version is not safe - // - /** * A helper method which runs the given script file with the given command line arguments * * @param scriptFile the file of the script to run * @param list the command line arguments to pass in */ - public Object run(File scriptFile, List list) throws CompilationFailedException, IOException { - return run(scriptFile, (String[]) list.toArray(EMPTY_STRING_ARRAY)); + public Object run(File scriptFile, List<String> list) throws CompilationFailedException, IOException { + return run(scriptFile, list.toArray(EMPTY_STRING_ARRAY)); } /** @@ -166,8 +162,8 @@ public class GroovyShell extends GroovyObjectSupport { * @param fileName is the logical file name of the script (which is used to create the class name of the script) * @param list the command line arguments to pass in */ - public Object run(String scriptText, String fileName, List list) throws CompilationFailedException { - return run(scriptText, fileName, (String[]) list.toArray(EMPTY_STRING_ARRAY)); + public Object run(String scriptText, String fileName, List<String> list) throws CompilationFailedException { + return run(scriptText, fileName, list.toArray(EMPTY_STRING_ARRAY)); } /**
