home | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Groovy example source code file (MethodPointerBug.groovy)

This example Groovy source code file (MethodPointerBug.groovy) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Groovy tags/keywords

groovytestcase, groovytestcase, methodpointerbug, methodpointerbug

The Groovy MethodPointerBug.groovy source code

package groovy.bugs

 * @author Pilho Kim
 * @version $Revision: 2319 $
class MethodPointerBug extends GroovyTestCase {

    def void sayHello() { 
        println "hello" 

    def MethodPointerBug getThisObject() { 
        return this

    // Test a standard method pointer operator ".&".  For example, foo.&bar.
    void testMethodPointer() {
        def bug = new MethodPointerBug()
        def x = bug.&sayHello

    // Test a standard method pointer operator ".&" with this object.  For example, this.&bar.
    void testThisMethodPointer() {
        def y = this.&sayHello

    // Test a default method pointer operator "&" with this object.  For example, &bar.
    // This shows that the issue GROOVY-826 has been fixed in groovy-1.0-jar-02.
  todo - commented out due to groovy.g non-determinisms
    void testDefaultMethodPointer() {
        def z = &sayHello
    // Test a default method pointer operator ".&" with returned object.  For example, someMethod().&bar.
    void testMethodPointerWithReturn() {
        def u = getThisObject().&sayHello
        def v = thisObject.&sayHello

Other Groovy examples (source code examples)

Here is a short list of links related to this Groovy MethodPointerBug.groovy source code file:

new blog posts


Copyright 1998-2016 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.