Class<?> docletClass,
Iterable<String> options,
Iterable<? extends JavaFileObject> compilationUnits,
Context context) {
try {
ClientCodeWrapper ccw = ClientCodeWrapper.instance(context);
if (options != null) {
for (String option : options)
option.getClass(); // null check
}
if (compilationUnits != null) {
compilationUnits = ccw.wrapJavaFileObjects(compilationUnits); // implicit null check
for (JavaFileObject cu : compilationUnits) {
if (cu.getKind() != JavaFileObject.Kind.SOURCE) {
final String kindMsg = "All compilation units must be of SOURCE kind";
throw new IllegalArgumentException(kindMsg);
}
}
}
if (diagnosticListener != null)
context.put(DiagnosticListener.class, ccw.wrap(diagnosticListener));
if (out == null)
context.put(Log.outKey, new PrintWriter(System.err, true));
else if (out instanceof PrintWriter)
context.put(Log.outKey, ((PrintWriter) out));
else
context.put(Log.outKey, new PrintWriter(out, true));
if (fileManager == null)
fileManager = getStandardFileManager(diagnosticListener, null, null);
fileManager = ccw.wrap(fileManager);
context.put(JavaFileManager.class, fileManager);
return new JavadocTaskImpl(context, docletClass, options, compilationUnits);
} catch (ClientCodeException ex) {
throw new RuntimeException(ex.getCause());