Description
The following Groovy class with the UsePerson.java below works well:
class Person { String firstName public Person(first) { firstName = first } }
Defining a class with @Immutable annotation seems to result in compilation error when used from Java.
Person.groovy
@Immutable class Person { String firstName }
UsePerson.java
public class UsePerson { public static void main(String[] args) { Person person = new Person("Sam"); System.out.println(person.getFirstName()); } }
>groovyc Person.groovy >ls Person.class Person.groovy UsePerson.java >javac UsePerson.java UsePerson.java:3: cannot access Person bad class file: ./Person.class undeclared type variable: K Please remove or make sure it appears in the correct subdirectory of the classpath. Person person = new Person("Sam"); ^ 1 error