Replace concat String to append in StringBuilder parameters

Andrej Golovnin andrej.golovnin at gmail.com
Mon Aug 11 11:58:06 UTC 2014


Hi Otávio,

please ignore the previous diff. I'm sorry, there was a small mistake. I
have attached the corrected version.

Best regards,
Andrej Golovnin


On Mon, Aug 11, 2014 at 1:55 PM, Andrej Golovnin <andrej.golovnin at gmail.com>
wrote:

> Hi Otávio,
>
>  About the template in Parser.jjt, TokenMgrError.java, etc. I don't know
>> how can do that. Can anyone help me?
>>
>
> See attached diff for the changes in Parser.jjt and Parser.jj. For the
> TokenMgrError and ParserException you can just subscribe here:
>
> https://java.net/projects/javacc/lists
>
> on the dev or users mailing lists and send a message to JavaCC project.
> I'm sure the developers of JavaCC would help you.
>
> Best regards,
> Andrej Golovnin
>
>
>
>>  About readable of code I just renamed this class to sb instead of buf,
>> strbuf, etc. Because using StringBuilder beyond be more explicit I can use
>> char instead of a single String.
>>
>>
>> https://dl.dropboxusercontent.com/u/16109193/open_jdk/string_builder_concat_3.zip
>>
>>
>> On Mon, Aug 11, 2014 at 7:56 AM, Pavel Rappo <pavel.rappo at oracle.com>
>> wrote:
>>
>>> > In the class
>>> > src/share/classes/javax/management/openmbean/CompositeType.java you
>>> have
>>> > added the
>>> > annotation
>>> @SuppressWarnings("StringConcatenationInsideStringBufferAppend")
>>> > instead of fixing the concatenation inside the append method. Why?
>>>
>>> +1 Moreover, I wonder where this value comes from? I've never seen it
>>> before. Here are warnings that javac supports:
>>>
>>>
>>> all,auxiliaryclass,cast,classfile,deprecation,dep-ann,divzero,empty,fallthrough,finally,options,overloads,overrides,path,processing,rawtypes,serial,static,try,unchecked,varargs
>>>
>>> It doesn't look like one of Eclipse's warnings either.
>>>
>>> > And I would like to suggest to drop explicit usage of StringBuilder in
>>> some
>>> > methods at all to improve code readability.
>>>
>>> Agree.
>>>
>>> -Pavel
>>>
>>>
>>
>>
>> --
>> Otávio Gonçalves de Santana
>>
>> blog:     http://otaviosantana.blogspot.com.br/
>> twitter: http://twitter.com/otaviojava
>> site:     *http://about.me/otaviojava <http://about.me/otaviojava>*
>> 55 (11) 98255-3513
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/security-dev/attachments/20140811/4abc23d7/attachment.html>
-------------- next part --------------
diff --git a/src/share/classes/com/sun/jmx/snmp/IPAcl/Parser.jj b/src/share/classes/com/sun/jmx/snmp/IPAcl/Parser.jj
--- a/src/share/classes/com/sun/jmx/snmp/IPAcl/Parser.jj
+++ b/src/share/classes/com/sun/jmx/snmp/IPAcl/Parser.jj
@@ -420,7 +420,7 @@
   t=<IDENTIFIER> { jjtn000.name.append(t.image); }
 (
 "." t=<IDENTIFIER> 
-  {jjtn000.name.append( "." + t.image); }
+  {jjtn000.name.append('.').append(t.image); }
 )*/*@bgen(jjtree)*/
   } finally {
     if (jjtc000) {
@@ -447,7 +447,7 @@
   {jjtn000.address.append(t.image); }
 (
 "." t= <INTEGER_LITERAL> 
-  {jjtn000.address.append( "." + t.image); }
+  {jjtn000.address.append('.').append(t.image); }
 )*/*@bgen(jjtree)*/
 } finally {
   if (jjtc000) {
@@ -501,7 +501,7 @@
   {jjtn000.address.append(t.image); }
 (
 "!" t= <INTEGER_LITERAL> 
-  {jjtn000.address.append( "." + t.image); }
+  {jjtn000.address.append('.').append(t.image); }
 )*/*@bgen(jjtree)*/
 } finally {
   if (jjtc000) {
@@ -527,7 +527,7 @@
   {jjtn000.address.append(t.image); }
 (
 "." t= <INTEGER_LITERAL> 
-  {jjtn000.address.append( "." + t.image); }
+  {jjtn000.address.append('.').append(t.image); }
 )* "/" t= <INTEGER_LITERAL>/*@bgen(jjtree)*/
                             {
                               jjtree.closeNodeScope(jjtn000, true);
diff --git a/src/share/classes/com/sun/jmx/snmp/IPAcl/Parser.jjt b/src/share/classes/com/sun/jmx/snmp/IPAcl/Parser.jjt
--- a/src/share/classes/com/sun/jmx/snmp/IPAcl/Parser.jjt
+++ b/src/share/classes/com/sun/jmx/snmp/IPAcl/Parser.jjt
@@ -213,7 +213,7 @@
   t=<IDENTIFIER> { jjtThis.name.append(t.image); }
 (
 "." t=<IDENTIFIER> 
-  {jjtThis.name.append( "." + t.image); }
+  {jjtThis.name.append('.').append(t.image); }
 )*
 
 }
@@ -228,7 +228,7 @@
   {jjtThis.address.append(t.image); }
 (
 "." t= <INTEGER_LITERAL> 
-  {jjtThis.address.append( "." + t.image); }
+  {jjtThis.address.append('.').append(t.image); }
 )*
 
 }
@@ -253,7 +253,7 @@
   {jjtThis.address.append(t.image); }
 (
 "!" t= <INTEGER_LITERAL> 
-  {jjtThis.address.append( "." + t.image); }
+  {jjtThis.address.append('.').append(t.image); }
 )*
 }
 
@@ -267,7 +267,7 @@
   {jjtThis.address.append(t.image); }
 (
 "." t= <INTEGER_LITERAL> 
-  {jjtThis.address.append( "." + t.image); }
+  {jjtThis.address.append('.').append(t.image); }
 )* "/" t= <INTEGER_LITERAL> {jjtThis.mask = t.image; }
 }
 


More information about the security-dev mailing list