Details
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
Activity
Paul King
made changes -
| Field | Original Value | New Value |
|---|---|---|
| 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 |
The following Groovy class with the {{UsePerson.java}} below works well:
{code} class Person { String firstName public Person(first) { firstName = first } } {code} Defining a class with @Immutable annotation seems to result in compilation error when used from Java. {code|title=Person.groovy} @Immutable class Person { String firstName } {code} {code|title=UsePerson.java} public class UsePerson { public static void main(String[] args) { Person person = new Person("Sam"); System.out.println(person.getFirstName()); } } {code} {noformat} >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 {noformat} |
Paul King
made changes -
| Description |
The following Groovy class with the {{UsePerson.java}} below works well:
{code} class Person { String firstName public Person(first) { firstName = first } } {code} Defining a class with @Immutable annotation seems to result in compilation error when used from Java. {code|title=Person.groovy} @Immutable class Person { String firstName } {code} {code|title=UsePerson.java} public class UsePerson { public static void main(String[] args) { Person person = new Person("Sam"); System.out.println(person.getFirstName()); } } {code} {noformat} >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 {noformat} |
The following Groovy class with the {{UsePerson.java}} below works well:
{code} class Person { String firstName public Person(first) { firstName = first } } {code} Defining a class with @Immutable annotation seems to result in compilation error when used from Java. {code:title=Person.groovy} @Immutable class Person { String firstName } {code} {code:title=UsePerson.java} public class UsePerson { public static void main(String[] args) { Person person = new Person("Sam"); System.out.println(person.getFirstName()); } } {code} {noformat} >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 {noformat} |
Paul King
made changes -
| Status | Open [ 1 ] | Resolved [ 5 ] |
| Assignee | Paul King [ paulk ] | |
| Fix Version/s | 1.7.11 [ 17244 ] | |
| Fix Version/s | 1.8.1 [ 17223 ] | |
| Resolution | Fixed [ 1 ] |
Paul King
made changes -
| Status | Resolved [ 5 ] | Closed [ 6 ] |
add code tags