Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-2487

Strange behavior of category support

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.5
    • 1.5.8
    • groovy-jdk
    • None
    • Windows XP SP2

    Description

      static method in sub category class could not override that in super category class.

      More information to recreate the problem
      ****************************************************
      TestBaseCategory .java
      ****************************************************
      package zero.assemble.flow.util;
      public class TestBaseCategory {

      public static void test(Object str)

      { System.out.println("test() in TestBaseCategory"); }

      }

      ****************************************************
      TestCategory.java
      ****************************************************
      package zero.assemble.flow.util;
      public class TestCategory extends TestBaseCategory{
      public static void test(Object str)

      { System.out.println("test() in TestCategory"); }

      }

      ****************************************************
      test.groovy
      ****************************************************
      use (zero.assemble.flow.util.TestCategory) {
      "abc".test()
      }

      In the system console, it should show the "test() in TestCategory", but it show
      "test() in TestBaseCategory",
      When our debug the code, we found the
      org.codehaus.groovy.runtime.metaclass.NewMetaMethod#getDeclaringClass() could
      not return correct class.

      Attachments

        Activity

          People

            blackdrag Jochen Theodorou
            zhuke Ke Zhu
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: