You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by nickgrealy <gi...@git.apache.org> on 2015/05/13 13:11:32 UTC

[GitHub] incubator-groovy pull request: Access to Method parameter names at...

GitHub user nickgrealy opened a pull request:

    https://github.com/apache/incubator-groovy/pull/15

    Access to Method parameter names at runtime

    Given that JDK8 now supports [accessing parameter names at runtime](http://openjdk.java.net/jeps/118), I've incorporated this behaviour
    into the Groovy code base (configurable).
    
    Configuration is similar to the javac ```-parameters``` parameter...
    
    It can be enabled by passing ```-pa``` or ```--parameters``` to the ```groovy``` or ```groovyc``` executables, or alternatively, you can set the ```-Dparameters``` system property.
    
    Happy to have feedback on changes/suggestions. Thanks to Jochen Theodorou for showing me where to get started!
    
    Reference: [mail-archives](http://mail-archives.apache.org/mod_mbox/incubator-groovy-dev/201505.mbox/%3CCAK%2BHH6c1Z0FwWPY709uVccWe919viTw%3DRMS5%2BeN9P%2B16Qp7g8Q%40mail.gmail.com%3E)

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/nickgrealy/incubator-groovy master

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-groovy/pull/15.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 #15
    
----
commit 1984a6414a9e4c6597499af2d9770c891e46e850
Author: Nick Grealy <ni...@gmail.com>
Date:   2015-05-13T09:19:17Z

    Added JEP118 to groovyc

commit 69148f99811cb79371d24181c5003dec4ab77bc9
Author: Nick Grealy <ni...@gmail.com>
Date:   2015-05-13T09:34:31Z

    Added JEP118 to groovy
    
    Changed 'p' cli option to 'pa', so as not to clash with existing
    bin\groovy param.

commit 3bcf47b5683507d21c00b57520c7cf222391450d
Author: Nick Grealy <ni...@gmail.com>
Date:   2015-05-13T10:53:30Z

    Added opt JEP118 configuration via System property.

----


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-groovy pull request: Access to Method parameter names at...

Posted by paulk-asert <gi...@git.apache.org>.
Github user paulk-asert commented on a diff in the pull request:

    https://github.com/apache/incubator-groovy/pull/15#discussion_r30281069
  
    --- Diff: src/main/groovy/ui/GroovyMain.java ---
    @@ -305,6 +310,7 @@ private static boolean process(CommandLine line) throws ParseException, IOExcept
             main.isScriptFile = !line.hasOption('e');
             main.debug = line.hasOption('d');
             main.conf.setDebug(main.debug);
    +        main.conf.setParameters(line.hasOption("pa") || System.getProperty("parameters") != null);
    --- End diff --
    
    We wouldn't normally check system properties here but rather in CompilerConfiguration#configure. We'd also normally prefix properties e.g. like "groovy.parameters" unless Java is already using something without a java prefix in which case we might use directly what Java uses.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-groovy pull request: Access to Method parameter names at...

Posted by roranade <gi...@git.apache.org>.
Github user roranade commented on a diff in the pull request:

    https://github.com/apache/incubator-groovy/pull/15#discussion_r30250819
  
    --- Diff: src/main/org/codehaus/groovy/classgen/AsmClassGenerator.java ---
    @@ -375,6 +375,13 @@ protected void visitConstructorOrMethod(MethodNode node, boolean isConstructor)
                 visitParameterAnnotations(parameters[i], i, mv);
             }
     
    +        // Add parameter names to the MethodVisitor (jdk8+ only)
    +        if (getCompileUnit().getConfig().getParameters()){
    --- End diff --
    
    A very minor nit - there should be a space between `...getParameters())` and `{`


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-groovy pull request: Access to Method parameter names at...

Posted by nickgrealy <gi...@git.apache.org>.
Github user nickgrealy closed the pull request at:

    https://github.com/apache/incubator-groovy/pull/15


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---