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

SwingBuilder edt breaks with anonymous subclassing

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.7.10
    • None
    • Swing
    • None

    Description

      When within SwingBuilder.edt, the instantiation of anonymous inner classes to appears to be broken.

      Example code:

      import groovy.swing.SwingBuilder
      import javax.swing.SwingWorker;
      import javax.swing.JFrame
      import java.awt.BorderLayout
      
      class TestEDT {
          public static void main( String[] args )
          {
              def myLabel
              def swing = new SwingBuilder()
              swing.edt {
                  frame(pack:true, show:true, defaultCloseOperation:JFrame.EXIT_ON_CLOSE){
                      borderLayout()
                      myLabel = label("Hello", constraints:BorderLayout.CENTER)
                  }
      
                  def sw = new SwingWorker() {
                      protected Object doInBackground() throws Exception
                      {
                          return 10
                      }
                      protected void done()
                      {
                          myLabel.text = get()
                      }
                  }.execute();
              }
          }
      }
      

      This throws:

      Exception in thread "main" groovy.lang.GroovyRuntimeException: Could not find matching constructor for: TestEDT$1(java.lang.Class, groovy.lang.Reference)
      	at groovy.lang.MetaClassImpl.invokeConstructor(MetaClassImpl.java:1481)
      	at groovy.lang.MetaClassImpl.invokeConstructor(MetaClassImpl.java:1397)
      	at org.codehaus.groovy.runtime.callsite.MetaClassConstructorSite.callConstructor(MetaClassConstructorSite.java:46)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:52)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:190)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:202)
      	at TestEDT$_main_closure1.doCall(TestEDT.groovy:17)
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            gubespam GubeSpam
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: