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

Cannot intercept constructors

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.6
    • 1.6.1, 1.7-beta-1
    • None
    • None

    Description

      public class ClassProxyMetaClass extends ProxyMetaClass {
      ClassProxyMetaClass(MetaClassRegistry metaClassRegistry, Class aClass, MetaClass adaptee)

      { super(metaClassRegistry, aClass, adaptee) }

      public Object invokeConstructor(final Object[] arguments)

      { 'constructor' }

      }

      class NewString {
      static get()

      { new String() }

      }

      assert '' == new String()
      assert '' == NewString.get()

      MetaClassRegistry registry = GroovySystem.metaClassRegistry
      def mc = new ClassProxyMetaClass(registry, String, registry.getMetaClass(String))
      registry.setMetaClass(String, mc)

      assert 'constructor' == new String()
      assert 'constructor' == NewString.get() // failed here

      Attachments

        1. Groovy3424_1.patch
          9 kB
          Johnny Jian

        Activity

          People

            blackdrag Jochen Theodorou
            johnnyjian Johnny Jian
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: