Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6571165

Minor doc bugs in JavaCompiler.java

    Details

    • Subcomponent:
    • Resolved In Build:
      b128
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Not verified

      Description

      Three minor doc bugs in JavaCompiler.java code example :

      The doc says :
      <DiagnosticCollector_example_code >
          Used to collect diagnostics in a list, for example:

                 Iterable<? extends JavaFileObject> compilationUnits = ...;
                 JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
                 DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<JavaFileObject>();
                 StandardJavaFileManager fileManager = compiler.getStandardFileManager(diagnostics, null, null);
                 compiler.getTask(null, fileManager, diagnostics, null, null, compilationUnits).call();

                 for (Diagnostic diagnostic : diagnostics.getDiagnostics())
                     System.out.format("Error on line %d in %d%n",
                                       diagnostic.getLineNumber()
                                       diagnostic.getSource().toUri());

                 fileManager.close();

      </DiagnosticCollector_example_code >

      1)for (Diagnostic diagnostic : diagnostics.getDiagnostics()) should be
      *for (Diagnostic<? extends JavaFileObject> diagnostic : diagnostics.getDiagnostics()) *
      since
      a) toUri() method is directly calling on dignostic.getSource() method
                 ***diagnostic.getSource().toUri()) ***
      b) diagnostics is already of type JavaFileObject

      2)System.out.format has both '%d's, it should be one %d and other %s since first one points to number but second one pointes to a String.
      System.out.format("Error on line %d in **%s**%n",

      3) ',' is missing between diagnostic.getLineNumber and diagnostic.getSource

        Attachments

          Activity

            People

            • Assignee:
              jjg Jonathan Gibbons
              Reporter:
              savadhansunw Seetharama Avadhanam (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: