Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
8245153: Unicode encoded double-quoted empty string does not compile
Fixed parsing of Unicode encoded double-quoted empty strings in c.s.t.j.p.JavaTokenizer::scanString

Reviewed-by: jlaskey
  • Loading branch information
Adam Sotona committed May 29, 2020
1 parent 4d10ebb commit 5a57b9f8ec83b401342f525ebf6035c7fd977467
Showing with 42 additions and 4 deletions.
  1. +2 −4 src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java
  2. +40 −0 test/langtools/tools/javac/8245153/T8245153.java
@@ -427,10 +427,8 @@ private void scanString(int pos) {
case 1: // Starting a string literal.
break;
case 2: // Starting an empty string literal.
// Start again but only consume one quote.
reader.reset(pos);
openCount = countChar('\"', 1);
break;
tk = Tokens.TokenKind.STRINGLITERAL;
return;
case 3: // Starting a text block.
// Check if preview feature is enabled for text blocks.
checkSourceLevel(pos, Feature.TEXT_BLOCKS);
@@ -0,0 +1,40 @@

/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

/*
* @test
* @bug 8245153
* @summary Unicode encoded double-quoted empty string does not compile
* @compile T8245153.java
*/

public class T8245153 {

String s0 = "";
String s1 = \u0022\u0022;
String s2 = "\u0022;
String s3 = \u0022";
String s4 = \u0022\\u0022\u0022;

}

0 comments on commit 5a57b9f

Please sign in to comment.