8147571: Information about written .h files is printed on the wrong logging level
Changed how SmartWriter outputs log messages. Reviewed-by: jlahoda
This commit is contained in:
parent
49850dd82f
commit
889b3cc5eb
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -95,11 +95,8 @@ public class CompilationService {
|
||||
for (JavaFileObject jfo : fm.getJavaFileObjectsFromFiles(sourcesToCompileFiles))
|
||||
explicitJFOs.append(SmartFileManager.locWrap(jfo, StandardLocation.SOURCE_PATH));
|
||||
|
||||
// Create a new logger
|
||||
StringWriter stdoutLog = new StringWriter();
|
||||
// Create a log to capture compiler output
|
||||
StringWriter stderrLog = new StringWriter();
|
||||
PrintWriter stdout = new PrintWriter(stdoutLog);
|
||||
PrintWriter stderr = new PrintWriter(stderrLog);
|
||||
com.sun.tools.javac.main.Main.Result rc = com.sun.tools.javac.main.Main.Result.OK;
|
||||
PublicApiCollector pubApiCollector = new PublicApiCollector(context, explicitJFOs);
|
||||
PathAndPackageVerifier papVerifier = new PathAndPackageVerifier();
|
||||
@ -108,11 +105,10 @@ public class CompilationService {
|
||||
if (explicitJFOs.size() > 0) {
|
||||
sfm.setVisibleSources(visibleSources);
|
||||
sfm.cleanArtifacts();
|
||||
sfm.setLog(stdout);
|
||||
|
||||
// Do the compilation!
|
||||
JavacTaskImpl task =
|
||||
(JavacTaskImpl) compiler.getTask(stderr,
|
||||
(JavacTaskImpl) compiler.getTask(new PrintWriter(stderrLog),
|
||||
sfm,
|
||||
null,
|
||||
Arrays.asList(args),
|
||||
@ -144,7 +140,6 @@ public class CompilationService {
|
||||
|
||||
compilationResult.packagePubapis = pubApiCollector.getPubApis(true);
|
||||
compilationResult.dependencyPubapis = pubApiCollector.getPubApis(false);
|
||||
compilationResult.stdout = stdoutLog.toString();
|
||||
compilationResult.stderr = stderrLog.toString();
|
||||
compilationResult.returnCode = rc.exitCode;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -63,8 +63,6 @@ public class SmartFileManager extends ForwardingJavaFileManager<JavaFileManager>
|
||||
Set<URI> visibleSources = new HashSet<>();
|
||||
// Map from modulename:packagename to artifacts.
|
||||
Map<String,Set<URI>> packageArtifacts = new HashMap<>();
|
||||
// Where to print informational messages.
|
||||
PrintWriter stdout;
|
||||
|
||||
public SmartFileManager(JavaFileManager fileManager) {
|
||||
super(fileManager);
|
||||
@ -78,10 +76,6 @@ public class SmartFileManager extends ForwardingJavaFileManager<JavaFileManager>
|
||||
packageArtifacts = new HashMap<>();
|
||||
}
|
||||
|
||||
public void setLog(PrintWriter pw) {
|
||||
stdout = pw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether or not to use ct.sym as an alternate to rt.jar.
|
||||
*/
|
||||
@ -188,7 +182,7 @@ public class SmartFileManager extends ForwardingJavaFileManager<JavaFileManager>
|
||||
if (file == null) return file;
|
||||
|
||||
if (location.equals(StandardLocation.NATIVE_HEADER_OUTPUT) && superFile instanceof JavaFileObject) {
|
||||
file = new SmartFileObject((JavaFileObject) file, stdout);
|
||||
file = new SmartFileObject((JavaFileObject) file);
|
||||
packageName = ":" + packageNameFromFileName(relativeName);
|
||||
}
|
||||
if (packageName.equals("")) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -49,11 +49,9 @@ import com.sun.tools.javac.util.DefinedBy.Api;
|
||||
public class SmartFileObject implements JavaFileObject {
|
||||
|
||||
JavaFileObject file;
|
||||
PrintWriter stdout;
|
||||
|
||||
public SmartFileObject(JavaFileObject r, PrintWriter pw) {
|
||||
public SmartFileObject(JavaFileObject r) {
|
||||
file = r;
|
||||
stdout = pw;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -113,7 +111,7 @@ public class SmartFileObject implements JavaFileObject {
|
||||
} catch (FileNotFoundException | NoSuchFileException e) {
|
||||
// Perfectly ok.
|
||||
}
|
||||
return new SmartWriter(file, s.toString(), file.getName(), stdout);
|
||||
return new SmartWriter(file, s.toString(), file.getName());
|
||||
}
|
||||
|
||||
@DefinedBy(Api.COMPILER)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,6 +25,8 @@
|
||||
|
||||
package com.sun.tools.sjavac.comp;
|
||||
|
||||
import com.sun.tools.sjavac.Log;
|
||||
|
||||
import java.io.*;
|
||||
import javax.tools.JavaFileObject;
|
||||
|
||||
@ -45,19 +47,17 @@ public class SmartWriter extends Writer {
|
||||
JavaFileObject file;
|
||||
String oldContent;
|
||||
StringWriter newContent = new StringWriter();
|
||||
PrintWriter stdout;
|
||||
boolean closed;
|
||||
public SmartWriter(JavaFileObject f, String s, String n, PrintWriter pw) {
|
||||
|
||||
public SmartWriter(JavaFileObject f, String s, String n) {
|
||||
name = n;
|
||||
file = f;
|
||||
oldContent = s;
|
||||
newContent = new StringWriter();
|
||||
stdout = pw;
|
||||
closed = false;
|
||||
}
|
||||
|
||||
public void write(char[] chars, int i, int i1)
|
||||
{
|
||||
public void write(char[] chars, int i, int i1) {
|
||||
newContent.write(chars, i, i1);
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ public class SmartWriter extends Writer {
|
||||
try (Writer writer = file.openWriter()) {
|
||||
writer.write(s);
|
||||
}
|
||||
stdout.println("Writing "+file.getName().substring(p+1));
|
||||
Log.debug("Writing " + file.getName().substring(p + 1));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user