jaxb-codemodel icon indicating copy to clipboard operation
jaxb-codemodel copied to clipboard

Forced unicode character escape in com.sun.codemodel.JExpr#quotify

Open Hubbitus opened this issue 6 years ago • 2 comments

com.sun.codemodel.JExpr#quotify have ancient comment and force unicode characters escape:

                // technically Unicode escape shouldn't be done here,
                // for it's a lexical level handling.
                // 
                // However, various tools are so broken around this area,
                // so just to be on the safe side, it's better to do
                // the escaping here (regardless of the actual file encoding)
                //
                // see bug 
                if( c<0x20 || 0x7E<c ) {
                    // not printable. use Unicode escape
                    sb.append("\\u");
                    String hex = Integer.toHexString(((int)c)&0xFFFF);
                    for( int k=hex.length(); k<4; k++ )
                        sb.append('0');
sb.append(hex);

I want my annotation values became unescaped in generated sources by JCB. I think in now days most compilers do not have any issues with it. So could you please just remove such block? Or at least provide option to disable.

Hubbitus avatar Jan 23 '19 16:01 Hubbitus

If you are willing I could make PR for that.

Hubbitus avatar Jan 24 '19 10:01 Hubbitus

Just spent a few hours today looking for an answer why the jsonscheme2pojo library, which uses the codemodel for generating java clasess, escapes characters in Jackson annotations.
image image image

antonovdmitriy avatar Oct 26 '20 23:10 antonovdmitriy