51 static final String docletWarning = "warning from test doclet"; 52 53 /** Main doclet method. */ 54 public boolean run(DocletEnvironment root) { 55 reporter.print(javax.tools.Diagnostic.Kind.WARNING, docletWarning); 56 return true; 57 } 58 59 /** Main test method. */ 60 void run() throws Exception { 61 File javaHome = new File(System.getProperty("java.home")); 62 File javadoc = new File(new File(javaHome, "bin"), "javadoc"); 63 File testSrc = new File(System.getProperty("test.src")); 64 File testClasses = new File(System.getProperty("test.classes")); 65 66 // run javadoc in separate process to ensure doclet executed under 67 // normal user conditions w.r.t. classloader 68 String thisClassName = TestUserDoclet.class.getName(); 69 List<String> cmdArgs = new ArrayList<>(); 70 cmdArgs.add(javadoc.getPath()); 71 int i = 0; 72 String prop; 73 while ((prop = System.getProperty("jdk.launcher.patch." + (i++))) != null) { 74 cmdArgs.add("-J-Xpatch:" + prop); 75 } 76 cmdArgs.addAll(Arrays.asList( 77 "-doclet", thisClassName, 78 "-docletpath", testClasses.getPath(), 79 new File(testSrc, thisClassName + ".java").getPath() 80 )); 81 Process p = new ProcessBuilder() 82 .command(cmdArgs) 83 .redirectErrorStream(true) 84 .start(); 85 86 int actualDocletWarnCount = 0; 87 int reportedDocletWarnCount = 0; 88 BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream())); 89 try { 90 String line; 91 while ((line = in.readLine()) != null) { 92 System.err.println(line); 93 if (line.contains(docletWarning)) 94 actualDocletWarnCount++; 95 if (line.matches("[0-9]+ warning(s)?")) | 51 static final String docletWarning = "warning from test doclet"; 52 53 /** Main doclet method. */ 54 public boolean run(DocletEnvironment root) { 55 reporter.print(javax.tools.Diagnostic.Kind.WARNING, docletWarning); 56 return true; 57 } 58 59 /** Main test method. */ 60 void run() throws Exception { 61 File javaHome = new File(System.getProperty("java.home")); 62 File javadoc = new File(new File(javaHome, "bin"), "javadoc"); 63 File testSrc = new File(System.getProperty("test.src")); 64 File testClasses = new File(System.getProperty("test.classes")); 65 66 // run javadoc in separate process to ensure doclet executed under 67 // normal user conditions w.r.t. classloader 68 String thisClassName = TestUserDoclet.class.getName(); 69 List<String> cmdArgs = new ArrayList<>(); 70 cmdArgs.add(javadoc.getPath()); 71 cmdArgs.addAll(Arrays.asList( 72 "-doclet", thisClassName, 73 "-docletpath", testClasses.getPath(), 74 new File(testSrc, thisClassName + ".java").getPath() 75 )); 76 Process p = new ProcessBuilder() 77 .command(cmdArgs) 78 .redirectErrorStream(true) 79 .start(); 80 81 int actualDocletWarnCount = 0; 82 int reportedDocletWarnCount = 0; 83 BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream())); 84 try { 85 String line; 86 while ((line = in.readLine()) != null) { 87 System.err.println(line); 88 if (line.contains(docletWarning)) 89 actualDocletWarnCount++; 90 if (line.matches("[0-9]+ warning(s)?")) |