Andres Soolo I think that could only be a problem if you are using some other language that compiles to Java as an intermediate representation. I otherwise can’t think of a way unicode literals in the the source code could cause a problem at runtime apart from the obvious problem of obfuscating pieces of the program from the developers.
That cannot work, surely?
(I did try and fire up Java to test, but my eyes started to bleed when I had to build all the guff around a main() function just to run it)
LikeLike
The rules say, Unicode escapes are parsed before lexical scanning: <https://docs.oracle.com/javase/specs/jls/se7/html/jls-3.html>
docs.oracle.com – Chapter 3. Lexical Structure
LikeLike
I just tried it, it works. It would be useful for driving colleagues crazy.
LikeLike
Ramin Honary : Just imagine a strategically placed u0022 or u005C in the middle of a string literal.
LikeLike
Andres Soolo I think that could only be a problem if you are using some other language that compiles to Java as an intermediate representation. I otherwise can’t think of a way unicode literals in the the source code could cause a problem at runtime apart from the obvious problem of obfuscating pieces of the program from the developers.
LikeLike
C can do similarly crazed things with trigraphs. 🙂
LikeLike