Groovy
  1. Groovy
  2. GROOVY-3680

Cannot use Groovy class with @Bindable or @Vetoable in Java code: cannot find symbol for addPropertyChangeListener

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.6.4, 1.7-beta-1
    • Fix Version/s: 2.4.0-beta-2
    • Component/s: groovy-jdk
    • Labels:
      None
    • Environment:
      Windows XP, Java 1.6

      Description

      I compile GroovyBean with @Bindable and/or @Vetoable annotations to Java bytecode. I want to use this class in a Java application. But when I compile the Java class I get the following error:

      CarApp.java:11: cannot find symbol
      symbol  : method addPropertyChangeListener(<anonymous java.beans.PropertyChangeListener>)
      location: class CarBean
                      car.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
                         ^
      

      The strange thing is that when I look with javap in the generated Groovy class I see the method is available.

      Groovy class:

      import groovy.beans.*
      
      class Car {
         	int numberOfDoors
      	@Vetoable String model
      	@Vetoable String brand
      	boolean automatic
      	@Bindable double price
      	
      	String toString() {
      	    "[Car details =&gt; brand: '${brand}', model: '${model}', #doors: '${numberOfDoors}', automatic: '${automatic}', price: '${price}']"
      	}
      }
      

      Java class:

      import java.beans.*;
      
      public class CarApp {
        public static void main(String[] args) throws Exception {
          Car car = new Car();
          car.setNumberOfDoors(3);
          car.setModel("A3");
          car.setBrand("AUDI");
          car.setPrice(32010);
      		
          car.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
      	public void propertyChange(java.beans.PropertyChangeEvent evt) {
      		System.out.println(evt);
      	}
          });
        }
      }
      

        Activity

        Hubert Klein Ikkink created issue -
        Paul King made changes -
        Field Original Value New Value
        Description I compile GroovyBean with @Bindable and/or @Vetoable annotations to Java bytecode. I want to use this class in a Java application. But when I compile the Java class I get the following error:
        CarApp.java:11: cannot find symbol
        symbol : method addPropertyChangeListener(<anonymous java.beans.PropertyChangeListener>)
        location: class CarBean
                        car.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
                           ^

        The strange thing is that when I look with javap in the generated Groovy class I see the method is available.

        Groovy class:

        import groovy.beans.*

        class Car {
            int numberOfDoors
        @Vetoable String model
        @Vetoable String brand
        boolean automatic
        @Bindable double price

        String toString() {
        "[Car details =&gt; brand: '${brand}', model: '${model}', #doors: '${numberOfDoors}', automatic: '${automatic}', price: '${price}']"
        }
        }

        Java class:

        import java.beans.*;

        public class CarApp {
        public static void main(String[] args) throws Exception {
          Car car = new Car();
          car.setNumberOfDoors(3);
          car.setModel("A3");
          car.setBrand("AUDI");
          car.setPrice(32010);

          car.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
        public void propertyChange(java.beans.PropertyChangeEvent evt) {
        System.out.println(evt);
        }
          });
        }
        }
        I compile GroovyBean with @Bindable and/or @Vetoable annotations to Java bytecode. I want to use this class in a Java application. But when I compile the Java class I get the following error:
        {noformat}
        CarApp.java:11: cannot find symbol
        symbol : method addPropertyChangeListener(<anonymous java.beans.PropertyChangeListener>)
        location: class CarBean
                        car.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
                           ^
        {noformat}

        The strange thing is that when I look with javap in the generated Groovy class I see the method is available.

        Groovy class:

        {code}
        import groovy.beans.*

        class Car {
            int numberOfDoors
        @Vetoable String model
        @Vetoable String brand
        boolean automatic
        @Bindable double price

        String toString() {
        "[Car details =&gt; brand: '${brand}', model: '${model}', #doors: '${numberOfDoors}', automatic: '${automatic}', price: '${price}']"
        }
        }
        {code}

        Java class:

        {code}
        import java.beans.*;

        public class CarApp {
          public static void main(String[] args) throws Exception {
            Car car = new Car();
            car.setNumberOfDoors(3);
            car.setModel("A3");
            car.setBrand("AUDI");
            car.setPrice(32010);

            car.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
        public void propertyChange(java.beans.PropertyChangeEvent evt) {
        System.out.println(evt);
        }
            });
          }
        }
        {code}
        Paul King made changes -
        Assignee Paul King [ paulk ]
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Fix Version/s 2.4.0-beta-2 [ 20433 ]
        Paul King made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Mark Thomas made changes -
        Project Import Sun Apr 05 13:32:57 UTC 2015 [ 1428240777691 ]
        Mark Thomas made changes -
        Workflow jira [ 12732664 ] Default workflow, editable Closed status [ 12744511 ]
        Mark Thomas made changes -
        Project Import Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ]
        Mark Thomas made changes -
        Workflow jira [ 12970977 ] Default workflow, editable Closed status [ 12978753 ]

          People

          • Assignee:
            Paul King
            Reporter:
            Hubert Klein Ikkink
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development