jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • groovy
  • GROOVY-3010 fix private field visibility
  • GROOVY-1809

non-static fields should not be treated as static properties

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Sub-task Sub-task
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: 1.0
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Testcase included:
    yes

Description

> java.awt.Font.getName() // ok
> java.awt.Font.name
> throws
> java.lang.IllegalArgumentException

the 'name' field on Font is treated as a static property while the field not static.

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Paul King added a comment - 09/Oct/07 6:21 PM

Hi Gents, I placed a try catch around the offending piece of code. This hides the problem rather than solving the root cause. I didn't have time to investigate any further. At least we have a workaround and test in place now and we can tighten the noose around the real bug (and avoid the expensive of the exception) when we find time.

Show
Paul King added a comment - 09/Oct/07 6:21 PM Hi Gents, I placed a try catch around the offending piece of code. This hides the problem rather than solving the root cause. I didn't have time to investigate any further. At least we have a workaround and test in place now and we can tighten the noose around the real bug (and avoid the expensive of the exception) when we find time.
Hide
Permalink
Alex Tkachman added a comment - 18/Nov/07 2:51 PM

I prefer to postpone this issue till 1.2 or even till we rewrite of meta class. Following code shows that many things goes differently than expected.

package org.codehaus.groovy.classgen

class StaticPropertyTest extends GroovyTestCase{

    void testStaticProperty () {
        // U.class.getName () call
        assertEquals "U", U.getName()

        // should fail because getU () is private
        assertEquals "U", new U ().u

        // should fail because getU () is private
        assertEquals "U", new U ().getU()

        // should call U.class.getName () because 'name' is private in U
        assertEquals "org.codehaus.groovy.classgen.U", U.name

        assertEquals "U", U.testPrivate()
    }
}

class U {
    private static def name = "U"

    static def testPrivate () {
        return U.name
    }

    private static def getName () {"U"}

    private def getU () {"U"}
}
Show
Alex Tkachman added a comment - 18/Nov/07 2:51 PM I prefer to postpone this issue till 1.2 or even till we rewrite of meta class. Following code shows that many things goes differently than expected.
package org.codehaus.groovy.classgen

class StaticPropertyTest extends GroovyTestCase{

    void testStaticProperty () {
        // U.class.getName () call
        assertEquals "U", U.getName()

        // should fail because getU () is private
        assertEquals "U", new U ().u

        // should fail because getU () is private
        assertEquals "U", new U ().getU()

        // should call U.class.getName () because 'name' is private in U
        assertEquals "org.codehaus.groovy.classgen.U", U.name

        assertEquals "U", U.testPrivate()
    }
}

class U {
    private static def name = "U"

    static def testPrivate () {
        return U.name
    }

    private static def getName () {"U"}

    private def getU () {"U"}
}

People

  • Assignee:
    Unassigned
    Reporter:
    Dierk Koenig
Vote (0)
Watch (3)

Dates

  • Created:
    30/Mar/07 2:53 AM
    Updated:
    03/Sep/08 5:56 PM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.