test/langtools/tools/javac/parser/T4910483.java
changeset 48423 35cf3c947420
parent 47216 71c04702a3d5
equal deleted inserted replaced
48422:cafc0ddb8db3 48423:35cf3c947420
     1 /*
     1 /*
     2  * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    21  * questions.
    21  * questions.
    22  */
    22  */
    23 
    23 
    24 /*
    24 /*
    25  * @test
    25  * @test
    26  * @bug     4910483
    26  * @bug     4910483 8183961
    27  * @summary Javadoc renders the string ".*\\.pdf" as ".\*\.pdf"
    27  * @summary Javadoc renders the string ".*\\.pdf" as ".\*\.pdf"
    28  * @modules jdk.compiler/com.sun.tools.javac.file
    28  * @modules jdk.compiler/com.sun.tools.javac.file
    29  *          jdk.compiler/com.sun.tools.javac.main
    29  *          jdk.compiler/com.sun.tools.javac.main
    30  *          jdk.compiler/com.sun.tools.javac.tree
    30  *          jdk.compiler/com.sun.tools.javac.tree
    31  *          jdk.compiler/com.sun.tools.javac.util
    31  *          jdk.compiler/com.sun.tools.javac.util
    39 import com.sun.tools.javac.tree.JCTree;
    39 import com.sun.tools.javac.tree.JCTree;
    40 import com.sun.tools.javac.util.Context;
    40 import com.sun.tools.javac.util.Context;
    41 
    41 
    42 import javax.tools.JavaFileObject;
    42 import javax.tools.JavaFileObject;
    43 
    43 
    44 /**Test comment abc*\\def*/
    44 // Test the original issue ("\\") as well as other appearances of '\',
       
    45 // including a vanilla Unicode escape (U+0021, '!'), and a sequence
       
    46 // which is not a Unicode escape
       
    47 
       
    48 /**Test comment abc*\\def\
       
    49  *xyz\u0021\\u0021*/
    45 public class T4910483 {
    50 public class T4910483 {
    46     public static void main(String... args) {
    51     public static void main(String... args) {
    47         JavaCompiler compiler = JavaCompiler.instance(new Context());
    52         JavaCompiler compiler = JavaCompiler.instance(new Context());
    48         compiler.keepComments = true;
    53         compiler.keepComments = true;
    49 
    54 
    53 
    58 
    54         JCTree.JCCompilationUnit cu = compiler.parse(f);
    59         JCTree.JCCompilationUnit cu = compiler.parse(f);
    55         JCTree classDef = cu.getTypeDecls().head;
    60         JCTree classDef = cu.getTypeDecls().head;
    56         String commentText = cu.docComments.getCommentText(classDef);
    61         String commentText = cu.docComments.getCommentText(classDef);
    57 
    62 
    58         String expected = "Test comment abc*\\\\def"; // 4 '\' escapes to 2 in a string literal
    63         String expected = "Test comment abc*\\\\def\\\nxyz!\\\\u0021"; // 4 '\' escapes to 2 in a string literal
    59         if (!expected.equals(commentText)) {
    64         if (!expected.equals(commentText)) {
    60             throw new AssertionError("Incorrect comment text: [" + commentText + "], expected [" + expected + "]");
    65             throw new AssertionError("Incorrect comment text: [" + commentText + "], expected [" + expected + "]");
    61         }
    66         }
    62     }
    67     }
    63 }
    68 }