本文整理汇总了Java中com.sun.tools.sjavac.Log类的典型用法代码示例。如果您正苦于以下问题:Java Log类的具体用法?Java Log怎么用?Java Log使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Log类属于com.sun.tools.sjavac包,在下文中一共展示了Log类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: waitForValidValues
import com.sun.tools.sjavac.Log; //导入依赖的package包/类
/**
* Wait for the port file to contain values that look valid.
* Return true, if a-ok, false if the valid values did not materialize within 5 seconds.
*/
public synchronized boolean waitForValidValues() throws IOException, FileNotFoundException {
for (int tries = 0; tries < 50; tries++) {
lock();
getValues();
unlock();
if (containsPortInfo) {
Log.debug("Found valid values in port file after waiting "+(tries*100)+"ms");
return true;
}
try {
Thread.sleep(100);
} catch (InterruptedException e)
{}
}
Log.debug("Gave up waiting for valid values in port file");
return false;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:PortFile.java
示例2: tryConnect
import com.sun.tools.sjavac.Log; //导入依赖的package包/类
private Socket tryConnect() throws IOException, InterruptedException {
makeSureServerIsRunning(portFile);
int attempt = 0;
while (true) {
Log.debug("Trying to connect. Attempt " + (++attempt) + " of " + MAX_CONNECT_ATTEMPTS);
try {
return makeConnectionAttempt();
} catch (IOException ex) {
Log.error("Connection attempt failed: " + ex.getMessage());
if (attempt >= MAX_CONNECT_ATTEMPTS) {
Log.error("Giving up");
throw new IOException("Could not connect to server", ex);
}
}
Thread.sleep(WAIT_BETWEEN_CONNECT_ATTEMPTS);
}
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:SjavacClient.java
示例3: waitForValidValues
import com.sun.tools.sjavac.Log; //导入依赖的package包/类
/**
* Wait for the port file to contain values that look valid.
*/
public void waitForValidValues() throws IOException, InterruptedException {
final int MS_BETWEEN_ATTEMPTS = 500;
long startTime = System.currentTimeMillis();
long timeout = startTime + getServerStartupTimeoutSeconds() * 1000;
while (true) {
Log.debug("Looking for valid port file values...");
if (exists()) {
lock();
getValues();
unlock();
}
if (containsPortInfo) {
Log.debug("Valid port file values found after " + (System.currentTimeMillis() - startTime) + " ms");
return;
}
if (System.currentTimeMillis() > timeout) {
break;
}
Thread.sleep(MS_BETWEEN_ATTEMPTS);
}
throw new IOException("No port file values materialized. Giving up after " +
(System.currentTimeMillis() - startTime) + " ms");
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:PortFile.java
示例4: shutdown
import com.sun.tools.sjavac.Log; //导入依赖的package包/类
@Override
public void shutdown() {
Log.debug("Shutting down PooledSjavac");
pool.shutdown(); // Disable new tasks from being submitted
try {
// Wait a while for existing tasks to terminate
if (!pool.awaitTermination(60, TimeUnit.SECONDS)) {
pool.shutdownNow(); // Cancel currently executing tasks
// Wait a while for tasks to respond to being cancelled
if (!pool.awaitTermination(60, TimeUnit.SECONDS))
Log.error("ThreadPool did not terminate");
}
} catch (InterruptedException ie) {
// (Re-)Cancel if current thread also interrupted
pool.shutdownNow();
// Preserve interrupt status
Thread.currentThread().interrupt();
}
delegate.shutdown();
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:PooledSjavac.java
示例5: finished
import com.sun.tools.sjavac.Log; //导入依赖的package包/类
@Override
@DefinedBy(Api.COMPILER_TREE)
public void finished(TaskEvent e) {
switch (e.getKind()) {
case ANALYZE:
collectClassSymbols((JCCompilationUnit) e.getCompilationUnit());
break;
case COMPILATION:
Log.debug("Compilation finished");
Log.debug("Extracting pub APIs for the following symbols:");
for (ClassSymbol cs : classSymbols)
Log.debug(" " + cs.fullname);
extractPubApis();
// Save result for later retrieval. (Important that we do this
// before we return from this method, because we may not access
// symbols after compilation is finished.)
PubAPIs pa = PubAPIs.instance(context);
explicitPubApis = pa.getPubapis(explicitJFOs, true);
nonExplicitPubApis = pa.getPubapis(explicitJFOs, false);
Log.debug("done");
break;
}
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:PublicApiCollector.java
示例6: validateOptions
import com.sun.tools.sjavac.Log; //导入依赖的package包/类
private static boolean validateOptions(Options options) {
String err = null;
if (options.getDestDir() == null) {
err = "Please specify output directory.";
} else if (options.isJavaFilesAmongJavacArgs()) {
err = "Sjavac does not handle explicit compilation of single .java files.";
} else if (!options.getImplicitPolicy().equals("none")) {
err = "The only allowed setting for sjavac is -implicit:none";
} else if (options.getSources().isEmpty() && options.getStateDir() != null) {
err = "You have to specify -src when using --state-dir.";
} else if (options.getTranslationRules().size() > 1
&& options.getGenSrcDir() == null) {
err = "You have translators but no gensrc dir (-s) specified!";
}
if (err != null)
Log.error(err);
return err == null;
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:SjavacImpl.java
示例7: createIfMissing
import com.sun.tools.sjavac.Log; //导入依赖的package包/类
private static boolean createIfMissing(Path dir) {
if (Files.isDirectory(dir))
return true;
if (Files.exists(dir)) {
Log.error(dir + " is not a directory.");
return false;
}
try {
Files.createDirectories(dir);
} catch (IOException e) {
Log.error("Could not create directory: " + e.getMessage());
return false;
}
return true;
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:SjavacImpl.java
示例8: run
import com.sun.tools.sjavac.Log; //导入依赖的package包/类
public static int run(String[] args, Writer out, Writer err) {
Log.setLogForCurrentThread(new Log(out, err));
Options options;
try {
options = Options.parseArgs(args);
} catch (IllegalArgumentException e) {
Log.error(e.getMessage());
return Result.CMDERR.exitCode;
}
Log.setLogLevel(options.getLogLevel());
Log.debug("==========================================================");
Log.debug("Launching sjavac client with the following parameters:");
Log.debug(" " + options.getStateArgsString());
Log.debug("==========================================================");
// Prepare sjavac object
boolean useServer = options.getServerConf() != null;
Sjavac sjavac = useServer ? new SjavacClient(options) : new SjavacImpl();
// Perform compilation
Result result = sjavac.compile(args);
// If sjavac is running in the foreground we should shut it down at this point
if (!useServer) {
sjavac.shutdown();
}
return result.exitCode;
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:34,代码来源:ClientMain.java
示例9: makeConnectionAttempt
import com.sun.tools.sjavac.Log; //导入依赖的package包/类
private Socket makeConnectionAttempt() throws IOException {
Socket socket = new Socket();
InetAddress localhost = InetAddress.getByName(null);
InetSocketAddress address = new InetSocketAddress(localhost, portFile.getPort());
socket.connect(address, CONNECTION_TIMEOUT);
Log.debug("Connected");
return socket;
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:SjavacClient.java
示例10: write
import com.sun.tools.sjavac.Log; //导入依赖的package包/类
@Override
public void write(int b) throws IOException {
super.write(b);
buf.write(b);
if (buf.isLineComplete()) {
String line = new String(buf.toByteArray(), 0, buf.size() - LINE_SEP.length);
Log.log(level, linePrefix + line);
buf = new EolTrackingByteArrayOutputStream();
}
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:LoggingOutputStream.java
示例11: checkInternalErrorLog
import com.sun.tools.sjavac.Log; //导入依赖的package包/类
private void checkInternalErrorLog() {
Path errorLog = ServerMain.getErrorLog().getLogDestination();
if (errorLog != null) {
Log.error("Server has encountered an internal error. See " + errorLog.toAbsolutePath()
+ " for details.");
}
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:RequestHandler.java
示例12: close
import com.sun.tools.sjavac.Log; //导入依赖的package包/类
public void close() throws IOException {
if (closed) return;
closed = true;
String s = newContent.toString();
if (!oldContent.equals(s)) {
int p = file.getName().lastIndexOf(File.separatorChar);
try (Writer writer = file.openWriter()) {
writer.write(s);
}
Log.debug("Writing " + file.getName().substring(p + 1));
}
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:SmartWriter.java
示例13: compile
import com.sun.tools.sjavac.Log; //导入依赖的package包/类
@Override
public Result compile(String[] args) {
Log log = Log.get();
try {
return pool.submit(() -> {
Log.setLogForCurrentThread(log);
return delegate.compile(args);
}).get();
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("Error during compile", e);
}
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:PooledSjavac.java
示例14: srcDstOverlap
import com.sun.tools.sjavac.Log; //导入依赖的package包/类
private static boolean srcDstOverlap(List<SourceLocation> locs, Path dest) {
for (SourceLocation loc : locs) {
if (isOverlapping(loc.getPath(), dest)) {
Log.error("Source location " + loc.getPath() + " overlaps with destination " + dest);
return true;
}
}
return false;
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:SjavacImpl.java
示例15: logJavacInvocation
import com.sun.tools.sjavac.Log; //导入依赖的package包/类
private void logJavacInvocation(String[] args) {
Log.debug("Invoking javac with args");
Iterator<String> argIter = Arrays.asList(args).iterator();
while (argIter.hasNext()) {
String arg = argIter.next();
String line = " " + arg;
if (arg.matches("\\-(d|cp|classpath|sourcepath|source|target)")
&& argIter.hasNext()) {
line += " " + argIter.next();
}
Log.debug(line);
}
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:CompilationService.java
示例16: scheduleTimeout
import com.sun.tools.sjavac.Log; //导入依赖的package包/类
private void scheduleTimeout() {
if (idlenessTimerTask != null)
throw new IllegalStateException("Idle timeout already scheduled");
idlenessTimerTask = new TimerTask() {
public void run() {
Log.setLogForCurrentThread(ServerMain.getErrorLog());
toShutdown.shutdown("Server has been idle for " + (idleTimeout / 1000) + " seconds.");
}
};
idlenessTimer.schedule(idlenessTimerTask, idleTimeout);
}
开发者ID:campolake,项目名称:openjdk9,代码行数:12,代码来源:IdleResetSjavac.java
示例17: startServer
import com.sun.tools.sjavac.Log; //导入依赖的package包/类
/**
* Start a server using a settings string. Typically: "--startserver:portfile=/tmp/myserver,poolsize=3" and the string "portfile=/tmp/myserver,poolsize=3"
* is sent as the settings parameter. Returns 0 on success, -1 on failure.
*/
public int startServer() throws IOException, InterruptedException {
long serverStart = System.currentTimeMillis();
// The port file is locked and the server port and cookie is written into it.
portFile = getPortFile(portfilename);
synchronized (portFile) {
portFile.lock();
portFile.getValues();
if (portFile.containsPortInfo()) {
Log.debug("Javac server not started because portfile exists!");
portFile.unlock();
return Result.ERROR.exitCode;
}
// .-----------. .--------. .------.
// socket -->| IdleReset |-->| Pooled |-->| Impl |--> javac
// '-----------' '--------' '------'
sjavac = new SjavacImpl();
sjavac = new PooledSjavac(sjavac, poolsize);
sjavac = new IdleResetSjavac(sjavac,
this,
keepalive * 1000);
serverSocket = new ServerSocket();
InetAddress localhost = InetAddress.getByName(null);
serverSocket.bind(new InetSocketAddress(localhost, 0));
// At this point the server accepts connections, so it is now safe
// to publish the port / cookie information
portFile.setValues(getPort(), getCookie());
portFile.unlock();
}
portFileMonitor = new PortFileMonitor(portFile, this);
portFileMonitor.start();
Log.debug("Sjavac server started. Accepting connections...");
Log.debug(" port: " + getPort());
Log.debug(" time: " + new java.util.Date());
Log.debug(" poolsize: " + poolsize);
keepAcceptingRequests.set(true);
do {
try {
Socket socket = serverSocket.accept();
new RequestHandler(socket, sjavac).start();
} catch (SocketException se) {
// Caused by serverSocket.close() and indicates shutdown
}
} while (keepAcceptingRequests.get());
Log.debug("Shutting down.");
// No more connections accepted. If any client managed to connect after
// the accept() was interrupted but before the server socket is closed
// here, any attempt to read or write to the socket will result in an
// IOException on the client side.
long realTime = System.currentTimeMillis() - serverStart;
Log.debug("Total wall clock time " + realTime + "ms build time " + totalBuildTime + "ms");
// Shut down
sjavac.shutdown();
return Result.OK.exitCode;
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:73,代码来源:SjavacServer.java
示例18: LoggingOutputStream
import com.sun.tools.sjavac.Log; //导入依赖的package包/类
public LoggingOutputStream(OutputStream out, Log.Level level, String linePrefix) {
super(out);
this.level = level;
this.linePrefix = linePrefix;
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:LoggingOutputStream.java
示例19: run
import com.sun.tools.sjavac.Log; //导入依赖的package包/类
@Override
public void run() {
try (BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
PrintWriter out = new PrintWriter(socket.getOutputStream(), true)) {
// Set up logging for this thread. Stream back logging messages to
// client on the format format "level:msg".
Log.setLogForCurrentThread(new Log(out, out) {
@Override
protected boolean isLevelLogged(Level l) {
// Make sure it is up to the client to decide whether or
// not this message should be displayed.
return true;
}
@Override
protected void printLogMsg(Level msgLevel, String msg) {
// Follow sjavac server/client protocol: Send one line
// at a time and prefix with message with "level:".
Util.getLines(msg)
.map(line -> msgLevel + ":" + line)
.forEach(line -> super.printLogMsg(msgLevel, line));
}
});
// Read argument array
int n = Integer.parseInt(in.readLine());
String[] args = new String[n];
for (int i = 0; i < n; i++) {
args[i] = in.readLine();
}
// If there has been any internal errors, notify client
checkInternalErrorLog();
// Perform compilation
Main.Result rc = sjavac.compile(args);
// Send return code back to client
out.println(LINE_TYPE_RC + ":" + rc.name());
// Check for internal errors again.
checkInternalErrorLog();
} catch (Exception ex) {
// Not much to be done at this point. The client side request
// code will most likely throw an IOException and the
// compilation will fail.
Log.error(ex);
} finally {
Log.setLogForCurrentThread(null);
}
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:54,代码来源:RequestHandler.java
示例20: printRound
import com.sun.tools.sjavac.Log; //导入依赖的package包/类
private static void printRound(int round) {
Log.debug("****************************************");
Log.debug("* Round " + round + " *");
Log.debug("****************************************");
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:SjavacImpl.java
注:本文中的com.sun.tools.sjavac.Log类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论