News for hackers. Stuff that matters.
Re:Code that is valid in both PHP and Java, and produces the... by danieldk on Thursday September 01, 2016 @02:43AM (#12403474)
But that's not really surprising, it's each character as a unicode escape (see section 3.2 of the Java spec). It's possible in any language that allows escaped code points.
Re:Code that is valid in both PHP and Java, and produces the... by ygra on Thursday September 01, 2016 @04:29AM (#12403755)
Most languages only tend to allow them in string literals, or identifiers. Java is fairly unique in that it has a pre-processor that replaces those throughout the source code before actually compiling. Which means that a lot of benign-looking source code can have fairly surprising behaviour, such as exhibited in the polyglot where

    //\u000Afoo
actually cancels the line comment.
Re:Code that is valid in both PHP and Java, and produces the... by 0xmohit on Thursday September 01, 2016 @03:04AM (#12403535)
Not surprising, yes.

But what is silly is that the Unicode sequences are also interpreted in comments.

  /* Comment region begins. \u002a\u002f
  String s = "Comment was closed in the previous statement";
Re:Code that is valid in both PHP and Java, and produces the... by flukus on Thursday September 01, 2016 @04:00AM (#12403685)
That's a recipe for pure evil.
Re:Code that is valid in both PHP and Java, and produces the... by 0xfeba on Thursday September 01, 2016 @01:51PM (#12407402)
Oh man, if I had known that at my last job I could have had great fun with some of coworkers via my commits.