Matthias F. Brandstetter | 1 Nov 00:34 2014
Picon

[groovy-user] Normal (dynamic) Groovy performance vs. CompileStatic

Hi all,

Today I ran some experiments to evaluate the performance of dynamic Groovy vs. statically compiled Groovy. So first I wrote a small quicksort class in Java as reference. For 100 iterations of 1.000.000 random numbers each I get an average of 83 ms in Java.

Then I took that Java code and made some minor (cosmetic) changes and compiled it with Groovy. I expected a quite longer runtime now. The same 100 iterations of 1.000.000 random numers took about 370 ms in dynamic Groovy. Not a big surprise here.

Then I added the <at> ComcpileStatic annotation to the quicksort class and ran the same test again. Big surprise: the static Groovy version took about 326 ms in average.

Now I understand that statically compiled Groovy cannot do any magic. But from what I have researched online and in particular also from my past experience with Groovy these results indeed came as a surprise to me. I would have expected a slightly longer runtime with statically compiled Groovy than with native Java. But my results are actually quite close to dynamic Groovy, far from Java performance.

I have attached my testing code to this mail.

My question: Do you think these results were to be expected, or is there some bug in my code?

Kind regards, Matthias
Attachment (QuicksortGroovyStatic.groovy): application/octet-stream, 2991 bytes

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Kazuki YAMAMOTO | 31 Oct 03:02 2014
Picon

[groovy-user] [ANN] Gaiden 1.0 released

Hi,

We are pleased to announce that Gaiden 1.0 has been released.


Gaiden is a tool that makes it easy to create documentation with Markdown. The Groovy language is the base of the tool.

The highlights of this release are:

 * New Look Default Theme
 * Numbering Support
 * Gaiden Wrapper

We welcome your feedback!

Regards,

--
Kazuki YAMAMOTO
<at> yamkazu
Steve Amerige | 30 Oct 19:47 2014
Picon

[groovy-user] Groovy Byte Code Fails when changing from Java 6 to Java 7: What to do?

Hi all,

When I searched the internet for "groovy runtime compile time incompatibility" I got some results such as:
In our discussions to date regarding Groovy and binary compatibility, we generally said that within a platform release (e.g., Groovy 2.x), binary compatibility is all but guaranteed.  That statement assumes we hold the JDK platform version constant.  Now, when changing the JDK platform from Java 6 to Java 7, the above links are evidence that binary compatibility breaks for Groovy.

So, from a release engineering point of view, does changing from Java 6 to Java 7 mean that for an application that uses many third-party jars that we need to re-obtain third-party jars that have been recompiled for Java 7?  Is this a big problem?  Is this a bigger problem than is found in Java code compiled with Java 6 and used with a Java 7 runtime?  How is it addressed?

Many thanks,
Steve Amerige
Principal Software Developer, Fraud and Compliance Solutions Development
SAS Institute, 940 NW Cary Pkwy #129, Cary, NC 27513-2792
Batman | 30 Oct 12:06 2014
Picon

[groovy-user] How to attach debugger for Static compilation?

I saw a JIRA over here:

https://jira.codehaus.org/browse/GROOVY-7106?jql=project%20%3D%20GROOVY%20AND%20resolution%20%3D%20Unresolved%20AND%20priority%20%3D%20Minor%20ORDER%20BY%20key%20DESC

Replacing the code here:

assert testIt() == "AnyValue"

 <at> groovy.transform.CompileStatic
def mapAccess(Map<String,Object> map) {
    map["AnyKey"]
}

 <at> groovy.transform.CompileStatic
def testIt() {
    return mapAccess([ AnyKey: "AnyValue", OtherKey: new Date() ])
}

I copied the code and attached the Debugger to testIt() method, just to
understand, where the StaticCompilation is failing. But when I start the
code in Debug mode, it fails with the message in first place:

Groovyc: [Static type checking] - Cannot find matching method
test#mapAccess(java.util.LinkedHashMap <java.lang.String,
java.io.Serializable>). Please check if the declared type is right and if
the method exists.

Looks like the code itself didnt start, due to the compilation failure. Can
anyone help me here?

How this AST author's debug their code?

--
View this message in context: http://groovy.329449.n5.nabble.com/How-to-attach-debugger-for-Static-compilation-tp5721599.html
Sent from the groovy - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

vetko | 30 Oct 11:55 2014
Picon

[groovy-user] Closures in scripts can't access fields annotated with <at> Field (Groovy 2.3.7)

We noticed a strange behaviour, that is somewhat blocking for us:

When writing a script that has fields annotated with the  <at> Field annotation,
the script itself and its methods can access the field variables properly.
Although when trying to access the same fields from within a closure in the
script, it is not accessible, it only operates on the binding of the script.

We believe this problem comes from the fact that the script does not look
onto its own variables when setting properties, so you may only set
variables on the binding. Here is the respective code fragment from
groovy.lang.Script.java:

    public void setProperty(String property, Object newValue) {
        if ("binding".equals(property))
            setBinding((Binding) newValue);
        else if("metaClass".equals(property))
            setMetaClass((MetaClass)newValue);
        else
            binding.setVariable(property, newValue);
    }

We think it needs the same mechanism delegating to the super class like in
the getProperty method: super.setProperty(property, newValue), and set into
the binding only if this fails. 

1) An example using plain scripts:
============================================

 <at> groovy.transform.Field def aField = "empty"

aField = "firstValue"
def closure = {aField = "secondValue"}
closure()

assert aField == "firstValue"   //true
assert aField == "secondValue"  //false

RUN RESULT:
============================================

Assertion failed: 

assert aField == "secondValue"  //false
       |      |
       |      false
       firstValue

	at Script1.run(Script1.groovy:9)
	
	
2) An example using class extending Script:
============================================	

class A extends Script {
    def aField = "empty"

    def run() {
        aField = "firstValue"

        def closure = {aField = "secondValue"}
        closure()

        assert aField == "firstValue"   //true
        assert aField == "secondValue"  //false		
    }
}

new A().run()

RUN RESULT:
============================================

Assertion failed: 

assert aField == "secondValue"  //false
       |      |
       |      false
       firstValue

	at A.run(Script1.groovy:12)
	at A$run.call(Unknown Source)
	at Script1.run(Script1.groovy:16)

	
	
The problem with this is that it is not consistent with the behaviour in
classes that are not extending scripts!

3) An example using a simple class NOT extending Script:
========================================================

class A {
    def aField = "empty"

    def run() {
        aField = "firstValue"

        def closure = {aField = "secondValue"}
        closure()

        assert aField == "secondValue"  //true
        assert aField == "firstValue"   //false
    }
}

new A().run()

RUN RESULT:
============================================

Assertion failed: 

assert aField == "firstValue"   //false
       |      |
       |      false
       secondValue

	at A.run(Script1.groovy:12)
	at A$run.call(Unknown Source)
	at Script1.run(Script1.groovy:16)
	
	
While the third example should be the correct behaviour for all cases, we do
not understand why this won't be fixed for scripts also, as seen on this
Jira link:
https://jira.codehaus.org/browse/GROOVY-5575

Thank You.

--
View this message in context: http://groovy.329449.n5.nabble.com/Closures-in-scripts-can-t-access-fields-annotated-with-Field-Groovy-2-3-7-tp5721598.html
Sent from the groovy - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

Blake McBride | 29 Oct 14:22 2014
Picon

[groovy-user] invokeMethod syntax

Greetings,

I understand that invoking a method with arguments is done as follows:

obj.invokeMethod("myMeth", [arg1, arg2, arg3] as Object[])

but what I would strongly prefer is utilizing Java's variable argument ability to allow this syntax instead:

obj.invokeMethodNew("myMeth", arg1, arg2, arg3)

Is something like this already there?  Is there a reason if not?

Thanks.

Blake McBride

Batman | 29 Oct 13:25 2014
Picon

[groovy-user] Reason behind using ASM.

Looking at the source code of Groovy, I can came across a different package
altogether called "asm".

It has loads of classes which does class manipulation. I wonder why? 

Why bytecode manipulation is needed? Can anyone say an example, where its
used?

--
View this message in context: http://groovy.329449.n5.nabble.com/Reason-behind-using-ASM-tp5721573.html
Sent from the groovy - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

Batman | 29 Oct 13:17 2014
Picon

[groovy-user] Highlight the current line in Swingbuilder

I have the groovy code like this:

swing = new SwingBuilder()
swing.edt {
    fileChooser = fileChooser()
    frame = frame( title: "RevisedGroovyFileViewer",
            defaultCloseOperation: JFrame.EXIT_ON_CLOSE,
            pack: true, visible: true, id: "frame" ) {
        borderLayout()
        menuBar () {
            menu(mnemonic: 'A', 'Action') {
                menuItem(action: paint)
            }
        }
        scrollPane( constraints: context.CENTER) {
            textArea( id: "textArea", editable:true, lineWrap: true)
        }
    }
    frame.size = [320,240]
}
which is working fine. I can able to type any text into the textarea etc.
But what I want to do is, when someone press ctrl shift l, highlight the
current line in the text area.

Is that possible to do so?

Thanks in advance.

--
View this message in context: http://groovy.329449.n5.nabble.com/Highlight-the-current-line-in-Swingbuilder-tp5721572.html
Sent from the groovy - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

Winnebeck, Jason | 28 Oct 19:38 2014

[groovy-user] Groovy equivalent extend

Is there a Groovy equivalent to the “extend” function common in many JavaScript libraries?

 

The extend function takes a source and destination object. For each property in the source, it sets the same property on the destination. For example:

 

assert [a:1, b:2].extend([a:2, c:3]) == [a:2, b:2, c:3]

 

Ideally the function can work with beans as well as maps (on either side).

 

I’ve looked in the past for bean-to-bean copy method, but haven’t found it, and have resorted in the past to a super-awkward and error-prone iteration of properties where I have to make sure I filter out the class and metaClass properties, and then it doesn’t work on Map. I know I can take the effort to write this, but I was hoping there was something already in the framework that I’ve missed.

 

Jason

This email message and any attachments are for the sole use of the intended recipient(s). Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message and any attachments.
Guillaume Laforge | 28 Oct 17:32 2014
Picon

[groovy-user] [ANN] Groovy Weekly #42

Hi all,

This might not necessarily the edition (42nd) where you'll learn the answer to life, the universe and everything, but at least, that's your weekly dose of Groovy related news!

http://glaforge.appspot.com/article/groovy-weekly-42

Keep on groovy-ing,

--
Guillaume Laforge
Groovy Project Manager
Pivotal, Inc.

Batman | 28 Oct 14:23 2014
Picon

[groovy-user] How JIRA is refered in the git commits?

Hi All, 

I'm trying to get involved in the groovy contribution. I thought of doing
this, go and see the "Resolved" bugs in the Groovy jira; Say for example the
following bug is been resolved:

https://jira.codehaus.org/browse/GROOVY-7063?jql=project%20%3D%20GROOVY%20AND%20status%20%3D%20Resolved%20ORDER%20BY%20priority%20DESC

But I want to know, what all files are been changed, with respect to this
bug fix.  Where I can get the git commit for the corresponding resolved bugs
in jira?

As it can help me, understand the files and other flows. 

--
View this message in context: http://groovy.329449.n5.nabble.com/How-JIRA-is-refered-in-the-git-commits-tp5721553.html
Sent from the groovy - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Gmane