T4910483.java revision 3155:30e288cb2d22
1169689Skan/* 2169689Skan * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. 3169689Skan * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4169689Skan * 5169689Skan * This code is free software; you can redistribute it and/or modify it 6169689Skan * under the terms of the GNU General Public License version 2 only, as 7169689Skan * published by the Free Software Foundation. 8169689Skan * 9169689Skan * This code is distributed in the hope that it will be useful, but WITHOUT 10169689Skan * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11169689Skan * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12169689Skan * version 2 for more details (a copy is included in the LICENSE file that 13169689Skan * accompanied this code). 14169689Skan * 15169689Skan * You should have received a copy of the GNU General Public License version 16169689Skan * 2 along with this work; if not, write to the Free Software Foundation, 17169689Skan * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18169689Skan * 19169689Skan * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20169689Skan * or visit www.oracle.com if you need additional information or have any 21169689Skan * questions. 22169689Skan */ 23169689Skan 24169689Skan/* 25169689Skan * @test 26169689Skan * @bug 4910483 27169689Skan * @summary Javadoc renders the string ".*\\.pdf" as ".\*\.pdf" 28169689Skan * @modules jdk.compiler/com.sun.tools.javac.file 29169689Skan * jdk.compiler/com.sun.tools.javac.main 30169689Skan * jdk.compiler/com.sun.tools.javac.tree 31169689Skan * jdk.compiler/com.sun.tools.javac.util 32169689Skan * @run main T4910483 33169689Skan */ 34169689Skan 35169689Skanimport java.io.File; 36169689Skan 37169689Skanimport com.sun.tools.javac.main.JavaCompiler; 38169689Skanimport com.sun.tools.javac.file.JavacFileManager; 39169689Skanimport com.sun.tools.javac.tree.JCTree; 40169689Skanimport com.sun.tools.javac.util.Context; 41169689Skan 42169689Skanimport javax.tools.JavaFileObject; 43169689Skan 44169689Skan/**Test comment abc*\\def*/ 45169689Skanpublic class T4910483 { 46169689Skan public static void main(String... args) { 47169689Skan JavaCompiler compiler = JavaCompiler.instance(new Context()); 48169689Skan compiler.keepComments = true; 49169689Skan 50169689Skan String testSrc = System.getProperty("test.src"); 51169689Skan JavacFileManager fm = new JavacFileManager(new Context(), false, null); 52169689Skan JavaFileObject f = fm.getJavaFileObject(testSrc + File.separatorChar + "T4910483.java"); 53169689Skan 54169689Skan JCTree.JCCompilationUnit cu = compiler.parse(f); 55169689Skan JCTree classDef = cu.getTypeDecls().head; 56169689Skan String commentText = cu.docComments.getCommentText(classDef); 57169689Skan 58169689Skan String expected = "Test comment abc*\\\\def"; // 4 '\' escapes to 2 in a string literal 59169689Skan if (!expected.equals(commentText)) { 60169689Skan throw new AssertionError("Incorrect comment text: [" + commentText + "], expected [" + expected + "]"); 61169689Skan } 62169689Skan } 63169689Skan} 64169689Skan