You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Matthias Fuchs (Jira)" <ji...@apache.org> on 2019/12/14 18:13:00 UTC
[jira] [Created] (GROOVY-9339) Compile-time-safe reflection access
to field
Matthias Fuchs created GROOVY-9339:
--------------------------------------
Summary: Compile-time-safe reflection access to field
Key: GROOVY-9339
URL: https://issues.apache.org/jira/browse/GROOVY-9339
Project: Groovy
Issue Type: Wish
Reporter: Matthias Fuchs
With groovy 3 we can get a reference to method like this:
{code:java}
var valueOf = String::valueOf
println(valueOf("a"))
{code}
It would be nice to have such a compile-time-safe reflective access to fields as well:
{code:java}
class Data {
private String field
}
def field = Data::field // 1
def value = field.get(){code}
This way the compiler would ensure that "field" is actually a real field and not cause *NoSuchFieldException*.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)