groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Remi Forax <fo...@univ-mlv.fr>
Subject Re: About the syntheticPublic property of member method node in class
Date Fri, 01 Apr 2016 19:08:18 GMT


----- Mail original -----
> De: "Jochen Theodorou" <blackdrag@gmx.org>
> À: dev@groovy.apache.org
> Envoyé: Vendredi 1 Avril 2016 18:02:18
> Objet: Re: About the syntheticPublic property of member method node in class
> 
> 
> On 01.04.2016 17:50, daniel_sun wrote:
> > Hi List,
> >
> >        The following code is copied from GinA2, which we use to test the
> >        new
> > parser for Groovy.
> >
> > class Book {
> >      private String title
> >      Book (String theTitle) {
> >          title = theTitle
> >      }
> >      String getTitle(){
> >          return title
> >      }
> > }
> >
> >        I have a question about the syntheticPublic of "getTitle" method
> >        node,
> > which has no visibility modifier(e.g. public, protected, private), so I
> > think its "public" should be synthetic and expect syntheticPublic  is true,
> > but the old parser of Groovy set syntheticPublic  as false.  (related issue
> > url: https://github.com/jespersm/groovy/issues/19).
> >
> >       Can you tell me the rationale about syntheticPublic and synthetic of
> > MethodNode?
> 
> If you set those bean property methods to synthetic, IDEs will not offer
> them anymore in auto-completion. I too was of the opinion synthetic
> means "added by the compiler", but I see it now more as a "internal
> method, not for the user".

What about, methods generated by the compiler because they are needed by the VM, they cary
no metadata for the compiler, that why they are ignored by the compiler.

There is no flag for method synthetized by the compiler but visible by the compiler (see [1]
for more info).

> So all those mop methods we have/had or
> rightfully synthetic, but bean methods like the setTitle one above does
> not fall in this second category. getTitle is a method added by the user
> and user-added methods should never be synthetic. And yes, no visibility
> modifier means public.
> 
> bye Jochen
> 

cheers,
Rémi

[1] http://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.8

Mime
View raw message