Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Cannot Reproduce
-
3.0.8
-
None
Description
I am having difficulty reducing this to a minimal example, but it seems (1) reliably reproducible with groovyc and (2) intermittent with GRECLIPSE.
Method references (with .&) to getters are inconsistently producing errors of the form
Cannot find matching method com.example.IdentityRecord#getEmail.
The property in question is defined simply as String email, and javap produces the entirely mundane
public java.lang.String getEmail(); Code: 0: aload_0 1: getfield #94 // Field email:Ljava/lang/String; 4: areturn
What is baffling me is that this does not occur on all properties. The properties on which it appears are ones where I have JSR-303 annotations (i.e., markers but nothing that triggers an ASTT), but the error persists even after commenting the annotation and its import, both in groovyc and GRECLIPSE. Identical properties without annotations never trigger the error.
It appears that the error only appears when both the POGO and the class trying to define a method reference on it are in the compilation unit; in Eclipse only, explicitly compiling the record class and then triggering a recompile by saving the service class works, but doing a project clean and rebuild produces the error.
I believe that this may be able to reproduce:
import javax.validation.constraints.Email @CompileStatic class Record { @Email String email } @CompileStatic class Service { List<String> emails(List<Record> records) { records.collect(Record.&getEmail) } }