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

          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