# HG changeset patch # User jjg # Date 1514938067 28800 # Node ID 35cf3c94742031c47ab8767b31d93e1b26df5f55 # Parent cafc0ddb8db37debc1702bbb0a2b6a834827a899 8183964: Bad lexing of javadoc comments (change in parsing/rendering of backslashes in javadoc) Reviewed-by: vromero, cushon diff -r cafc0ddb8db3 -r 35cf3c947420 src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavadocTokenizer.java --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavadocTokenizer.java Tue Jan 02 09:56:53 2018 -0800 +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavadocTokenizer.java Tue Jan 02 16:07:47 2018 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2018, 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 @@ -394,6 +394,7 @@ comment_reader.putChar('\\', false); } comment_reader.scanCommentChar(); + break; case ' ': case '\t': comment_reader.putChar(comment_reader.ch, false); diff -r cafc0ddb8db3 -r 35cf3c947420 test/langtools/tools/javac/parser/T4910483.java --- a/test/langtools/tools/javac/parser/T4910483.java Tue Jan 02 09:56:53 2018 -0800 +++ b/test/langtools/tools/javac/parser/T4910483.java Tue Jan 02 16:07:47 2018 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2018, 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 @@ -23,7 +23,7 @@ /* * @test - * @bug 4910483 + * @bug 4910483 8183961 * @summary Javadoc renders the string ".*\\.pdf" as ".\*\.pdf" * @modules jdk.compiler/com.sun.tools.javac.file * jdk.compiler/com.sun.tools.javac.main @@ -41,7 +41,12 @@ import javax.tools.JavaFileObject; -/**Test comment abc*\\def*/ +// Test the original issue ("\\") as well as other appearances of '\', +// including a vanilla Unicode escape (U+0021, '!'), and a sequence +// which is not a Unicode escape + +/**Test comment abc*\\def\ + *xyz\u0021\\u0021*/ public class T4910483 { public static void main(String... args) { JavaCompiler compiler = JavaCompiler.instance(new Context()); @@ -55,7 +60,7 @@ JCTree classDef = cu.getTypeDecls().head; String commentText = cu.docComments.getCommentText(classDef); - String expected = "Test comment abc*\\\\def"; // 4 '\' escapes to 2 in a string literal + String expected = "Test comment abc*\\\\def\\\nxyz!\\\\u0021"; // 4 '\' escapes to 2 in a string literal if (!expected.equals(commentText)) { throw new AssertionError("Incorrect comment text: [" + commentText + "], expected [" + expected + "]"); }