Re: [sonar-dev] Re: About Java 7 support
Oliver Burn <[email protected]> Sat, 3 Sep 2011 21:18:40 +1000
| Newsgroups | gmane.comp.java.audit.checkstyle.user,gmane.comp.java.sonar.devel |
|---|---|
| Message-ID | <CAHZftdVHQ+JqdgM7X90E3zVMdz+eya0EvYcRdEXv51A38c98Xg@mail.gmail.com> |
--===============1768239818818328690== Content-Type: multipart/alternative; boundary=0015176f0c88d6988504ac07a321 --0015176f0c88d6988504ac07a321 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Thanks - I will look at the patch this week. On Fri, Sep 2, 2011 at 23:42, Dinesh Bolkensteyn < [email protected]> wrote: > Dear Olivier, > > The patch is provided here: > https://sourceforge.net/tracker/?func=3Ddetail&aid=3D3403265&group_id=3D2= 9721&atid=3D397080 > > Note that, because SourceForge does not preserve spaces in the comment, t= he > AST part is messed up, which is why I post the comment hereunder again. > > *** Original comment attached to the patch *** > > This patch adds the support for Java 7 to Checkstyle's ANTLR grammar. > It comes with 1 unit test for each new Java 7 language feature. > > This patch should be backwards-compatible: AST for files which do not use > Java 7 features should be left unchanged. > > Impact by Java 7 language feature: > > 1) String in switch: None, the grammar already supported this. > > 2) Simplified variable arguments: None, the grammar should not be impact= ed > by this feature. > > 3) Binary integer literals and underscores in numerical literals: The > tokens value in the AST will be identical as the one written in the sourc= e > code. > > 4) Diamond Generics: In presence of a diamond, the AST looks like: > > +--TYPE_ARGUMENTS > | > +--GENERIC_START > +--GENERIC_END > > 5) try-with-resources: In presence of a try-with-resources, the AST look= s > like: > > +--try > | > +--LPAREN (new node containing the "resource") > | > +--MODIFIERS > +--TYPE > | > ... > +--IDENT > +--ASSIGN > +--EXPR > | > ... > +--RPAREN > +--SLIST (list of statements of the try block, just like a try/catch) > | > ... > +--LITERAL_CATCH (optionnally, if there was a catch, just like a > try/catch) > +=85 (unchanged, just like a try/catch) > > 6) Multi-catch and more precise rethrow: In presence of a multi-catch, t= he > AST looks like: > > +--try > | > +--SLIST (list of statements of the try block) > | > ... > +--LITERAL_CATCH > | > +--LPAREN > +--PARAMETER_DEF > | > +--MODIFIERS > +--TYPE > | > +--IDENT (containing the first exception to catch, or a D= OT > node if it is a fully qualified type) > +--IDENT (containing the second exception to catch, or a > DOT node if it is a fully qualified type) > +--... > +--IDENT (name of the exception variable) > +--RPAREN > +--SLIST (list of statements of the catch block) > | > ... > > Kind regards, > Dinesh Bolkensteyn > > On Tue, Aug 16, 2011 at 10:07 AM, Freddy Mallet < > [email protected]> wrote: > >> Thanks for your answer Oliver ! So we'll start with the first baby step = to >> patch the current Antlr grammar. We should get back to you during the >> upcoming weeks. >> >> Kind regards, >> Freddy >> ---------------------------------------- >> Freddy Mallet >> www.SonarSource.org >> www.SonarSource.com >> ---------------------------------------- >> >> >> On Tue, Aug 16, 2011 at 4:34 AM, Oliver Burn <[email protected]>wrot= e: >> >>> Hi Freddy, >>> >>> Thanks for your kind offer. >>> >>> My preference for a new grammar is motivated by the following thoughts: >>> >>> - Upgrade from ANTLRv2 to ANTLRv3 - there a numerous benefits to not >>> being left behind, including newer features and the awesome ANTLRwor= ks >>> - The existing grammar has evolved along with the language - a fresh >>> implementation maybe cleaner >>> - Hoping to find a ANTLR grammar out there that somebody is >>> maintaining. Bare in mind that when Java 8 comes out, where will be = a series >>> of changes to the grammar required. >>> >>> That all said, it would be easier to patch the existing grammar. I woul= d >>> happily take a patch that does that. :-) >>> >>> Regards, >>> Oliver >>> >>> On Tue, Aug 16, 2011 at 01:57, Freddy Mallet <[email protected]>w= rote: >>> >>>> Hi Oliver, >>>> >>>> We would be happy to contribute to the support of java 7 [1]. Upgradin= g >>>> the current Antlr grammar should not be too complex (even if not simpl= e) in >>>> order to support new java language enhancements : >>>> >>>> - Strings in switch statements >>>> - try-with-resources statements >>>> - improved type inference for generic instance creation ("diamond") >>>> - better integral literals >>>> - and improved exception handling (multi-catch) >>>> >>>> In ticket 3328367 [1], you mention the option to fully rewrite the Ant= lr >>>> grammar instead of simply updating the existing one. In few words, cou= ld you >>>> explain what would be the advantages of this solution and why you seem= to >>>> prefer this second solution ? >>>> >>>> Thanks >>>> Freddy >>>> >>>> [1] - >>>> http://sourceforge.net/tracker/?func=3Ddetail&aid=3D3328367&group_id= =3D29721&atid=3D397078you seem to be >>>> ---------------------------------------- >>>> Freddy Mallet >>>> www.SonarSource.org >>>> www.SonarSource.com >>>> ---------------------------------------- >>>> >>>> >>>> ----------------------------------------------------------------------= -------- >>>> uberSVN's rich system and user administration capabilities and model >>>> configuration take the hassle out of deploying and managing Subversion >>>> and >>>> the tools developers use with it. Learn more about uberSVN and get a >>>> free >>>> download at: http://p.sf.net/sfu/wandisco-dev2dev >>>> >>>> _______________________________________________ >>>> Checkstyle-user mailing list >>>> [email protected] >>>> https://lists.sourceforge.net/lists/listinfo/checkstyle-user >>>> >>>> >>> >>> >>> -----------------------------------------------------------------------= ------- >>> uberSVN's rich system and user administration capabilities and model >>> configuration take the hassle out of deploying and managing Subversion >>> and >>> the tools developers use with it. Learn more about uberSVN and get a fr= ee >>> download at: http://p.sf.net/sfu/wandisco-dev2dev >>> >>> _______________________________________________ >>> Checkstyle-user mailing list >>> [email protected] >>> https://lists.sourceforge.net/lists/listinfo/checkstyle-user >>> >>> >> > > > -------------------------------------------------------------------------= ----- > Special Offer -- Download ArcSight Logger for FREE! > Finally, a world-class log management solution at an even better > price-free! And you'll get a free "Love Thy Logs" t-shirt when you > download Logger. Secure your free ArcSight Logger TODAY! > http://p.sf.net/sfu/arcsisghtdev2dev > _______________________________________________ > Checkstyle-user mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/checkstyle-user > > --0015176f0c88d6988504ac07a321 Content-Type: text/html; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Thanks - I will look at the patch this week.<br><br><div class=3D"gmail_quo= te">On Fri, Sep 2, 2011 at 23:42, Dinesh Bolkensteyn <span dir=3D"ltr"><= <a href=3D"mailto:[email protected]">dinesh.bolkensteyn@so= narsource.com</a>></span> wrote:<br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex;">Dear Olivier,<br><br>The patch is provided = here: <a href=3D"https://sourceforge.net/tracker/?func=3Ddetail&aid=3D3= 403265&group_id=3D29721&atid=3D397080" target=3D"_blank">https://so= urceforge.net/tracker/?func=3Ddetail&aid=3D3403265&group_id=3D29721= &atid=3D397080</a><br> <br>Note that, because SourceForge does not preserve spaces in the comment,= the AST part is messed up, which is why I post the comment hereunder again= .<br><br>*** Original comment attached to the patch ***<br><br>This patch a= dds the support for Java 7 to Checkstyle's ANTLR grammar.<br> It comes with 1 unit test for each new Java 7 language feature.<br><br>This= patch should be backwards-compatible: AST for files which do not use Java = 7 features should be left unchanged.<br><br>Impact by Java 7 language featu= re:<br> <br>=A01) String in switch: None, the grammar already supported this.<br><b= r>=A02) Simplified variable arguments: None, the grammar should not be impa= cted by this feature.<br>=A0<br>=A03) Binary integer literals and underscor= es in numerical literals: The tokens value in the AST will be identical as = the one written in the source code.<br> <br>=A04) Diamond Generics: In presence of a diamond, the AST looks like:<b= r><br>+--TYPE_ARGUMENTS<br>=A0=A0=A0 |<br>=A0=A0=A0 +--GENERIC_START<br>=A0= =A0=A0 +--GENERIC_END<br><br>=A05) try-with-resources: In presence of a try= -with-resources, the AST looks like: <br> <br>+--try<br>=A0=A0=A0 |<br>=A0=A0=A0 +--LPAREN (new node containing the &= quot;resource")<br>=A0=A0=A0=A0=A0=A0=A0 |<br>=A0=A0=A0=A0=A0=A0=A0 +-= -MODIFIERS<br>=A0=A0=A0=A0=A0=A0=A0 +--TYPE<br>=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0 |<br>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 ...<br>=A0=A0=A0=A0=A0=A0=A0 = +--IDENT<br>=A0=A0=A0=A0=A0=A0=A0 +--ASSIGN<br> =A0=A0=A0=A0=A0=A0=A0 +--EXPR<br> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 |<br>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 ..= .<br>=A0=A0=A0=A0=A0=A0=A0 +--RPAREN<br>=A0=A0=A0 +--SLIST (list of stateme= nts of the try block, just like a try/catch)<br>=A0=A0=A0=A0=A0=A0=A0 |<br>= =A0=A0=A0=A0=A0=A0=A0 ...<br>=A0=A0=A0 +--LITERAL_CATCH (optionnally, if th= ere was a catch, just like a try/catch)<br> =A0=A0=A0 +=85 (unchanged, just like a try/catch)<br><br>=A06) Multi-catch = and more precise rethrow: In presence of a multi-catch, the AST looks like:= <br>=A0<br>+--try<br>=A0=A0=A0 |<br>=A0=A0=A0 +--SLIST (list of statements = of the try block)<br> =A0=A0=A0=A0=A0=A0=A0 |<br>=A0=A0=A0=A0=A0=A0=A0 ...<br>=A0=A0=A0 +--LITERA= L_CATCH<br>=A0=A0=A0=A0=A0=A0=A0 |<br>=A0=A0=A0=A0=A0=A0=A0 +--LPAREN<br>= =A0=A0=A0=A0=A0=A0=A0 +--PARAMETER_DEF<br>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= |<br>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 +--MODIFIERS<br>=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0 +--TYPE<br>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 |<= br>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 +--IDENT (containing the f= irst exception to catch, or a DOT node if it is a fully qualified type)<br> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 +--IDENT (containing the seco= nd exception to catch, or a DOT node if it is a fully qualified type)<br>= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 +--...<br>=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0 +--IDENT (name of the exception variable)<br>=A0=A0=A0=A0= =A0=A0=A0 +--RPAREN<br> =A0=A0=A0=A0=A0=A0=A0 +--SLIST (list of statements of the catch block)<br>= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 |<br>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 ..= .<br><br>Kind regards,<br> =A0Dinesh Bolkensteyn<br><br><div class=3D"gmail_quote">On Tue, Aug 16, 201= 1 at 10:07 AM, Freddy Mallet <span dir=3D"ltr"><<a href=3D"mailto:freddy= [email protected]" target=3D"_blank">[email protected]</a= >></span> wrote:<br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"><div>Thanks for your answer Oliver ! So we&#= 39;ll start with the first baby step to patch the current Antlr grammar. We= should get back to you during the upcoming weeks.=A0</div> <div><br></div><div>Kind regards,</div><div>Freddy<br clear=3D"all"> ----------------------------------------<br>Freddy Mallet<br><a href=3D"htt= p://www.SonarSource.org" target=3D"_blank">www.SonarSource.org</a><br><a hr= ef=3D"http://www.SonarSource.com" target=3D"_blank">www.SonarSource.com</a>= <br> ----------------------------------------<br> <br><br><div class=3D"gmail_quote">On Tue, Aug 16, 2011 at 4:34 AM, Oliver = Burn <span dir=3D"ltr"><<a href=3D"mailto:[email protected]" target= =3D"_blank">[email protected]</a>></span> wrote:<br><blockquote clas= s=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;pad= ding-left:1ex"> Hi Freddy,<br><br>Thanks for your kind offer.<br><br>My preference for a ne= w grammar is motivated by the following thoughts:<br><ul><li>Upgrade from A= NTLRv2 to ANTLRv3 - there a numerous benefits to not being left behind, inc= luding newer features and the awesome ANTLRworks</li> <li>The existing grammar has evolved along with the language - a fresh impl= ementation maybe cleaner</li><li>Hoping to find a ANTLR grammar out there t= hat somebody is maintaining. Bare in mind that when Java 8 comes out, where= will be a series of changes to the grammar required.</li> </ul>That all said, it would be easier to patch the existing grammar. I wou= ld happily take a patch that does that. :-)<br><br>Regards,<br>Oliver<br><b= r><div class=3D"gmail_quote"><div><div></div><div>On Tue, Aug 16, 2011 at 0= 1:57, Freddy Mallet <span dir=3D"ltr"><<a href=3D"mailto:freddy.mallet@g= mail.com" target=3D"_blank">[email protected]</a>></span> wrote:<b= r> </div></div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;bo= rder-left:1px #ccc solid;padding-left:1ex"><div><div></div><div>Hi Oliver,<= div><br></div><div>We would be happy to contribute to the support of java 7= [1]. Upgrading the current Antlr grammar should not be too complex (even i= f not simple) in order to support new java language enhancements :=A0</div> <div><div><ul><li>Strings in switch statements</li><li>try-with-resources s= tatements</li><li>improved type inference for generic instance creation (&q= uot;diamond")</li><li>better integral literals</li><li>and improved ex= ception handling (multi-catch)</li> </ul></div></div><div>In ticket=A03328367 [1], you mention the option to fu= lly rewrite the Antlr grammar instead of simply updating the existing one. = In few words, could you explain what would be the advantages of this soluti= on and why you seem to prefer this second solution ?</div> <div><br></div><div>Thanks</div><div>Freddy</div><div><br></div><div>[1] - = <a href=3D"http://sourceforge.net/tracker/?func=3Ddetail&aid=3D3328367&= amp;group_id=3D29721&atid=3D397078" target=3D"_blank">http://sourceforg= e.net/tracker/?func=3Ddetail&aid=3D3328367&group_id=3D29721&ati= d=3D397078</a> you seem to be=A0<br clear=3D"all"> ----------------------------------------<br><font color=3D"#888888">Freddy = Mallet<br><a href=3D"http://www.SonarSource.org" target=3D"_blank">www.Sona= rSource.org</a><br><a href=3D"http://www.SonarSource.com" target=3D"_blank"= >www.SonarSource.com</a><br> ----------------------------------------<br> </font></div> <br></div></div>-----------------------------------------------------------= -------------------<br> uberSVN's rich system and user administration capabilities and model<br= > configuration take the hassle out of deploying and managing Subversion and<= br> the tools developers use with it. Learn more about uberSVN and get a free<b= r> download at: =A0<a href=3D"http://p.sf.net/sfu/wandisco-dev2dev" target=3D"= _blank">http://p.sf.net/sfu/wandisco-dev2dev</a><br> <br>_______________________________________________<br> Checkstyle-user mailing list<br> <a href=3D"mailto:[email protected]" target=3D"_blank">= [email protected]</a><br> <a href=3D"https://lists.sourceforge.net/lists/listinfo/checkstyle-user" ta= rget=3D"_blank">https://lists.sourceforge.net/lists/listinfo/checkstyle-use= r</a><br> <br></blockquote></div><br> <br>-----------------------------------------------------------------------= -------<br> uberSVN's rich system and user administration capabilities and model<br= > configuration take the hassle out of deploying and managing Subversion and<= br> the tools developers use with it. Learn more about uberSVN and get a free<b= r> download at: =A0<a href=3D"http://p.sf.net/sfu/wandisco-dev2dev" target=3D"= _blank">http://p.sf.net/sfu/wandisco-dev2dev</a><br> <br>_______________________________________________<br> Checkstyle-user mailing list<br> <a href=3D"mailto:[email protected]" target=3D"_blank">= [email protected]</a><br> <a href=3D"https://lists.sourceforge.net/lists/listinfo/checkstyle-user" ta= rget=3D"_blank">https://lists.sourceforge.net/lists/listinfo/checkstyle-use= r</a><br> <br></blockquote></div><br></div> </blockquote></div><br> <br>-----------------------------------------------------------------------= -------<br> Special Offer -- Download ArcSight Logger for FREE!<br> Finally, a world-class log management solution at an even better<br> price-free! And you'll get a free "Love Thy Logs" t-shirt whe= n you<br> download Logger. Secure your free ArcSight Logger TODAY!<br> <a href=3D"http://p.sf.net/sfu/arcsisghtdev2dev" target=3D"_blank">http://p= .sf.net/sfu/arcsisghtdev2dev</a><br>_______________________________________= ________<br> Checkstyle-user mailing list<br> <a href=3D"mailto:[email protected]">Checkstyle-user@li= sts.sourceforge.net</a><br> <a href=3D"https://lists.sourceforge.net/lists/listinfo/checkstyle-user" ta= rget=3D"_blank">https://lists.sourceforge.net/lists/listinfo/checkstyle-use= r</a><br> <br></blockquote></div><br> --0015176f0c88d6988504ac07a321-- --===============1768239818818328690== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------------ Special Offer -- Download ArcSight Logger for FREE! Finally, a world-class log management solution at an even better price-free! And you'll get a free "Love Thy Logs" t-shirt when you download Logger. Secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsisghtdev2dev --===============1768239818818328690== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Checkstyle-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/checkstyle-user --===============1768239818818328690==--