[jira] [Resolved] (GROOVY-6537) Support getParsedOptionValue() in OptionAccessor.getProperty()
[ https://issues.apache.org/jira/browse/GROOVY-6537?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Paul King resolved GROOVY-6537. --- Resolution: Fixed Assignee: Paul King Fix Version/s: 2.5.0-beta-1 I am going to close this. There is now some minimal CLI type support in the upcoming 2.5 beta. Any further work, if required, should be re-cast as an enhancement to what is currently provided. > Support getParsedOptionValue() in OptionAccessor.getProperty() > -- > > Key: GROOVY-6537 > URL: https://issues.apache.org/jira/browse/GROOVY-6537 > Project: Groovy > Issue Type: Improvement > Components: command line processing >Affects Versions: 2.2.1 >Reporter: Björn Kautler >Assignee: Paul King > Labels: CliBuilder > Fix For: 2.5.0-beta-1 > > > It would be nice if OptionAccessor.getProperty() would also use the > getParsedOptionValue() before falling back to getOptionValue() > Currently to use a parsed option value you have to do something like > {code} > def cliBuilder = new CliBuilder() > cliBuilder.d longOpt: 'directory', args: 1, type: File, 'd option' > def arguments = cliBuilder.parse args > if (!arguments) { > System.exit 1 > } > def directory > if (arguments.directory) { >directory = arguments.getParsedOptionValue 'directory' > } else { >directory = System.properties.'user.dir' as File > } > {code} > if would be nicer to instead just do > {code} > def cliBuilder = new CliBuilder() > cliBuilder.d longOpt: 'directory', args: 1, type: File, 'd option' > def arguments = cliBuilder.parse args > if (!arguments) { > System.exit 1 > } > def directory > if (arguments.directory) { >directory = arguments.directory > } else { >directory = System.properties.'user.dir' as File > } > {code} > I think something along the lines of changing > {code} > def getProperty(String name) { > def methodname = 'getOptionValue' > if (name.size() > 1 && name.endsWith('s')) { > def singularName = name[0..-2] > if (hasOption(singularName)) { > name = singularName > methodname += 's' > } > } > if (name.size() == 1) name = name as char > def result = InvokerHelper.getMetaClass(inner).invokeMethod(inner, > methodname, name) > if (null == result) result = inner.hasOption(name) > if (result instanceof String[]) result = result.toList() > return result > } > {code} > to > {code} > def getProperty(String name) { > def methodname = 'getOptionValue' > if (name.size() > 1 && name.endsWith('s')) { > def singularName = name[0..-2] > if (hasOption(singularName)) { > name = singularName > methodname += 's' > } > } > if (name.size() == 1) name = name as char > def result = inner.getParsedOptionValue(name) > if (null == result) result = > InvokerHelper.getMetaClass(inner).invokeMethod(inner, methodname, name) > if (null == result) result = inner.hasOption(name) > if (result instanceof String[]) result = result.toList() > return result > } > {code} > should do what I mean, as getParsedOptionValue() returns null if no type is > set or the type is unknown to the TypeHandler. -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Resolved] (GROOVY-6538) Support default value for OptionAccessor.getProperty()
[ https://issues.apache.org/jira/browse/GROOVY-6538?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Paul King resolved GROOVY-6538. --- Resolution: Fixed Assignee: Paul King Fix Version/s: 2.5.0-beta-1 I am going to close this. There is now some minimal CLI default value support in the upcoming 2.5 beta. Perhaps it isn't exactly as envisaged by this issue but I think any further work if needed should be re-cast as an enhancement to the currently provided feature. > Support default value for OptionAccessor.getProperty() > -- > > Key: GROOVY-6538 > URL: https://issues.apache.org/jira/browse/GROOVY-6538 > Project: Groovy > Issue Type: Improvement > Components: command line processing >Affects Versions: 2.2.1 >Reporter: Björn Kautler >Assignee: Paul King > Labels: CliBuilder > Fix For: 2.5.0-beta-1 > > > When retrieving an argument from the OptionAccessor, it would be nice to be > able to give a default value that is returned if hasValue() in > OptionAccessor.getProperty() returned false > Currently to you have to do something like > {code} > def cliBuilder = new CliBuilder() > cliBuilder.d longOpt: 'directory', args: 1, 'd option' > def arguments = cliBuilder.parse args > if (!arguments) { > System.exit 1 > } > def directory > if (arguments.directory) { >directory = arguments.directory > } else { >directory = System.properties.'user.dir' > } > {code} > if would be nicer to instead just do > {code} > def cliBuilder = new CliBuilder() > cliBuilder.d longOpt: 'directory', args: 1, 'd option' > def arguments = cliBuilder.parse args > if (!arguments) { > System.exit 1 > } > def directory = arguments.directory System.properties.'user.dir' > {code} > I think something along the lines of changing > {code} > if (null == result) result = inner.hasOption(name) > if (result instanceof String[]) result = result.toList() > return result > {code} > to > {code} > if (null == result) result = inner.hasOption(name) > if (!result) result = defaultValue > if (result instanceof String[]) result = result.toList() > return result > {code} > should do what I mean. -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Closed] (GROOVY-6624) Create groovy-cli subproject for CLI-oriented stuff
[ https://issues.apache.org/jira/browse/GROOVY-6624?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Paul King closed GROOVY-6624. - Resolution: Won't Fix I am going to close this. There is now some minimal CLI annotation support in the upcoming 2.5 beta. I know not as fancy or feature complete as some of the options considered earlier but at least a minimal step forward. Given the unique package requirement for jigsaw, I think we'd need to re-look at what we want from a groovy-cli project in any case. > Create groovy-cli subproject for CLI-oriented stuff > --- > > Key: GROOVY-6624 > URL: https://issues.apache.org/jira/browse/GROOVY-6624 > Project: Groovy > Issue Type: Improvement > Components: command line processing >Reporter: James P. White > > Put the CLI stuff into its own subproject as another step in the Groovy > reorganization into core + modules. -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Resolved] (GROOVY-7823) Bump Ant version to 1.9.7
[ https://issues.apache.org/jira/browse/GROOVY-7823?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Paul King resolved GROOVY-7823. --- Resolution: Fixed Fix Version/s: 2.5.0-beta-1 > Bump Ant version to 1.9.7 > - > > Key: GROOVY-7823 > URL: https://issues.apache.org/jira/browse/GROOVY-7823 > Project: Groovy > Issue Type: Task >Reporter: Paul King >Assignee: Paul King >Priority: Minor > Fix For: 2.5.0-beta-1 > > -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Created] (GROOVY-7823) Bump Ant version to 1.9.7
Paul King created GROOVY-7823: - Summary: Bump Ant version to 1.9.7 Key: GROOVY-7823 URL: https://issues.apache.org/jira/browse/GROOVY-7823 Project: Groovy Issue Type: Task Reporter: Paul King Assignee: Paul King Priority: Minor -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (GROOVY-7820) CachedMethod.compareToCachedMethod throws "Should never happen"
[ https://issues.apache.org/jira/browse/GROOVY-7820?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15251263#comment-15251263 ] ASF GitHub Bot commented on GROOVY-7820: GitHub user paulk-asert opened a pull request: https://github.com/apache/groovy/pull/315 GROOVY-7820: CachedMethod.compareToCachedMethod throws "Should never … …happen" You can merge this pull request into a Git repository by running: $ git pull https://github.com/paulk-asert/groovy groovy7820 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/groovy/pull/315.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #315 commit f61d0329295ff1be1f6f0f683c27c9c0bddae95a Author: paulk Date: 2016-04-21T04:50:50Z GROOVY-7820: CachedMethod.compareToCachedMethod throws "Should never happen" > CachedMethod.compareToCachedMethod throws "Should never happen" > --- > > Key: GROOVY-7820 > URL: https://issues.apache.org/jira/browse/GROOVY-7820 > Project: Groovy > Issue Type: Bug > Components: groovy-jdk, groovy-runtime >Affects Versions: 2.4.6 > Environment: Groovy Version: 2.4.6 JVM: 1.8.0_72 Vendor: Oracle > Corporation OS: Linux >Reporter: Felipe Mamud > > When running the code below: > {code:java} > String.metaClass.methods.unique() > {code} > The exception occurs: > {noformat} > Exception in thread "main" java.lang.RuntimeException: Should never happen > at > org.codehaus.groovy.reflection.CachedMethod.compareToCachedMethod(CachedMethod.java:171) > at > org.codehaus.groovy.reflection.CachedMethod.compareTo(CachedMethod.java:140) > at > org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.compareToWithEqualityCheck(DefaultTypeTransformation.java:588) > at > org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.compareTo(DefaultTypeTransformation.java:543) > at > org.codehaus.groovy.runtime.NumberAwareComparator.compare(NumberAwareComparator.java:34) > at > org.codehaus.groovy.runtime.DefaultGroovyMethods.numberAwareCompareTo(DefaultGroovyMethods.java:1119) > at > org.codehaus.groovy.runtime.DefaultGroovyMethods.coercedEquals(DefaultGroovyMethods.java:11493) > at > org.codehaus.groovy.runtime.DefaultGroovyMethods.unique(DefaultGroovyMethods.java:1071) > at > org.codehaus.groovy.runtime.DefaultGroovyMethods.unique(DefaultGroovyMethods.java:1044) > at org.codehaus.groovy.runtime.dgm$739.invoke(Unknown Source) > at > org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:274) > at > org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56) > at > org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) > at > org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) > at > org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117) > at com.study.Main.run(Main.groovy:3) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.lang.reflect.Method.invoke(Method.java:498) > at > org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93) > at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325) > at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1212) > at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1021) > at > org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:923) > at > org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:906) > at > org.codehaus.groovy.runtime.InvokerHelper.runScript(InvokerHelper.java:410) > at org.codehaus.groovy.runtime.InvokerHelper$runScript.call(Unknown > Source) > at > org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) > at > org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) > at > org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133) > at com.study.Main.main(Main.groovy) > {noformat} > It is seen that is being compared to the same cached method with distinct > instances. It should be treated as a cached method? > {code:java} > self.toString() > (Java.lang.String) public boolean java.lang.String.equals (java.lan
[GitHub] groovy pull request: GROOVY-7820: CachedMethod.compareToCachedMeth...
GitHub user paulk-asert opened a pull request: https://github.com/apache/groovy/pull/315 GROOVY-7820: CachedMethod.compareToCachedMethod throws "Should never ⦠â¦happen" You can merge this pull request into a Git repository by running: $ git pull https://github.com/paulk-asert/groovy groovy7820 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/groovy/pull/315.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #315 commit f61d0329295ff1be1f6f0f683c27c9c0bddae95a Author: paulk Date: 2016-04-21T04:50:50Z GROOVY-7820: CachedMethod.compareToCachedMethod throws "Should never happen" --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[jira] [Resolved] (GROOVY-7783) Redundant computation in ObservableList
[ https://issues.apache.org/jira/browse/GROOVY-7783?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] John Wagenleitner resolved GROOVY-7783. --- Resolution: Fixed Assignee: John Wagenleitner Fix Version/s: 2.4.7 Thanks for providing the patch, a slightly modified version was applied to both the removeAll and retainAll methods. I have cloned this to create an issue for fixing ObservableSet as well. > Redundant computation in ObservableList > --- > > Key: GROOVY-7783 > URL: https://issues.apache.org/jira/browse/GROOVY-7783 > Project: Groovy > Issue Type: Bug > Components: groovy-runtime >Affects Versions: 2.4.6 >Reporter: Monika Dhok >Assignee: John Wagenleitner > Fix For: 2.4.7 > > Attachments: ObservableList.patch, Test.java > > > There appears to be redundant computaions in "ObservableList.retainAll" > methods in version 2.4.6. I have attached a test and proposed a small > patch which ensures that "contains" method is called on hashset of > input collection. This patch gives 1739X speed up on my > machine for the provided test. > Also, one more possibility to fix the issue is by using TreeSet as suggested > in > https://issues.apache.org/jira/browse/GROOVY-5739 as well. > Similar patches can be applied for three other methods, > ObservableList.removeAll, ObservableSet.retainAll, ObservableSet.removeAll. -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Created] (GROOVY-7822) CLONE - Redundant computation in ObservableSet
John Wagenleitner created GROOVY-7822: - Summary: CLONE - Redundant computation in ObservableSet Key: GROOVY-7822 URL: https://issues.apache.org/jira/browse/GROOVY-7822 Project: Groovy Issue Type: Bug Components: groovy-runtime Affects Versions: 2.4.6 Reporter: John Wagenleitner There appears to be redundant computaions in "ObservableList.retainAll" methods in version 2.4.6. I have attached a test and proposed a small patch which ensures that "contains" method is called on hashset of input collection. This patch gives 1739X speed up on my machine for the provided test. Also, one more possibility to fix the issue is by using TreeSet as suggested in https://issues.apache.org/jira/browse/GROOVY-5739 as well. Similar patches can be applied for three other methods, ObservableList.removeAll, ObservableSet.retainAll, ObservableSet.removeAll. -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (GROOVY-7783) Redundant computation in ObservableList
[ https://issues.apache.org/jira/browse/GROOVY-7783?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15251118#comment-15251118 ] ASF GitHub Bot commented on GROOVY-7783: Github user asfgit closed the pull request at: https://github.com/apache/groovy/pull/314 > Redundant computation in ObservableList > --- > > Key: GROOVY-7783 > URL: https://issues.apache.org/jira/browse/GROOVY-7783 > Project: Groovy > Issue Type: Bug > Components: groovy-runtime >Affects Versions: 2.4.6 >Reporter: Monika Dhok > Attachments: ObservableList.patch, Test.java > > > There appears to be redundant computaions in "ObservableList.retainAll" > methods in version 2.4.6. I have attached a test and proposed a small > patch which ensures that "contains" method is called on hashset of > input collection. This patch gives 1739X speed up on my > machine for the provided test. > Also, one more possibility to fix the issue is by using TreeSet as suggested > in > https://issues.apache.org/jira/browse/GROOVY-5739 as well. > Similar patches can be applied for three other methods, > ObservableList.removeAll, ObservableSet.retainAll, ObservableSet.removeAll. -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[GitHub] groovy pull request: GROOVY-7783 - Redundant computation in Observ...
Github user asfgit closed the pull request at: https://github.com/apache/groovy/pull/314 --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[jira] [Created] (GROOVY-7821) @CompileStatic and exception list throws ClassCastException
Brendon Anderson created GROOVY-7821: Summary: @CompileStatic and exception list throws ClassCastException Key: GROOVY-7821 URL: https://issues.apache.org/jira/browse/GROOVY-7821 Project: Groovy Issue Type: Bug Affects Versions: 2.4.6 Environment: OSX, java version "1.8.0_40" Reporter: Brendon Anderson Priority: Minor {code:title=Bar.java|borderStyle=solid} @Slf4j @CompileStatic class TestException { static void main(String[] args) { try { throw new NullPointerException('ahh!') } catch (NullPointerException | IOException e) { log.error('error {}', e.message) } } } {code} This throws a ClassCastException: {noformat} Exception in thread "main" java.lang.ClassCastException: java.lang.NullPointerException cannot be cast to java.io.IOException {noformat} -- This message was sent by Atlassian JIRA (v6.3.4#6332)