Thu, 20 Jun 2013 08:45:43 +0100
8016613: javac should avoid source 8 only analysis when compiling for source 7
Reviewed-by: jjg
Contributed-by: maurizio.cimadamore@oracle.com
ohrstrom@1504 | 1 | /* |
ohrstrom@1504 | 2 | * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
ohrstrom@1504 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
ohrstrom@1504 | 4 | * |
ohrstrom@1504 | 5 | * This code is free software; you can redistribute it and/or modify it |
ohrstrom@1504 | 6 | * under the terms of the GNU General Public License version 2 only, as |
ohrstrom@1504 | 7 | * published by the Free Software Foundation. Oracle designates this |
ohrstrom@1504 | 8 | * particular file as subject to the "Classpath" exception as provided |
ohrstrom@1504 | 9 | * by Oracle in the LICENSE file that accompanied this code. |
ohrstrom@1504 | 10 | * |
ohrstrom@1504 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
ohrstrom@1504 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
ohrstrom@1504 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
ohrstrom@1504 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
ohrstrom@1504 | 15 | * accompanied this code). |
ohrstrom@1504 | 16 | * |
ohrstrom@1504 | 17 | * You should have received a copy of the GNU General Public License version |
ohrstrom@1504 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
ohrstrom@1504 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
ohrstrom@1504 | 20 | * |
ohrstrom@1504 | 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ohrstrom@1504 | 22 | * or visit www.oracle.com if you need additional information or have any |
ohrstrom@1504 | 23 | * questions. |
ohrstrom@1504 | 24 | */ |
ohrstrom@1504 | 25 | |
ohrstrom@1504 | 26 | package com.sun.tools.sjavac; |
ohrstrom@1504 | 27 | |
ohrstrom@1504 | 28 | import java.io.PrintStream; |
ohrstrom@1504 | 29 | |
ohrstrom@1504 | 30 | /** |
ohrstrom@1504 | 31 | * Utility class only for sjavac logging. |
ohrstrom@1504 | 32 | * The log level can be set using for example --log=DEBUG on the sjavac command line. |
ohrstrom@1504 | 33 | * |
ohrstrom@1504 | 34 | * <p><b>This is NOT part of any supported API. |
ohrstrom@1504 | 35 | * If you write code that depends on this, you do so at your own |
ohrstrom@1504 | 36 | * risk. This code and its internal interfaces are subject to change |
ohrstrom@1504 | 37 | * or deletion without notice.</b></p> |
ohrstrom@1504 | 38 | */ |
ohrstrom@1504 | 39 | public class Log { |
ohrstrom@1504 | 40 | private static PrintStream out, err; |
ohrstrom@1504 | 41 | |
ohrstrom@1504 | 42 | public final static int WARN = 1; |
ohrstrom@1504 | 43 | public final static int INFO = 2; |
ohrstrom@1504 | 44 | public final static int DEBUG = 3; |
ohrstrom@1504 | 45 | public final static int TRACE = 4; |
ohrstrom@1504 | 46 | private static int level = WARN; |
ohrstrom@1504 | 47 | |
ohrstrom@1504 | 48 | static public void trace(String msg) { |
ohrstrom@1504 | 49 | if (level >= TRACE) { |
ohrstrom@1504 | 50 | out.println(msg); |
ohrstrom@1504 | 51 | } |
ohrstrom@1504 | 52 | } |
ohrstrom@1504 | 53 | |
ohrstrom@1504 | 54 | static public void debug(String msg) { |
ohrstrom@1504 | 55 | if (level >= DEBUG) { |
ohrstrom@1504 | 56 | out.println(msg); |
ohrstrom@1504 | 57 | } |
ohrstrom@1504 | 58 | } |
ohrstrom@1504 | 59 | |
ohrstrom@1504 | 60 | static public void info(String msg) { |
ohrstrom@1504 | 61 | if (level >= INFO) { |
ohrstrom@1504 | 62 | out.println(msg); |
ohrstrom@1504 | 63 | } |
ohrstrom@1504 | 64 | } |
ohrstrom@1504 | 65 | |
ohrstrom@1504 | 66 | static public void warn(String msg) { |
ohrstrom@1504 | 67 | err.println(msg); |
ohrstrom@1504 | 68 | } |
ohrstrom@1504 | 69 | |
ohrstrom@1504 | 70 | static public void error(String msg) { |
ohrstrom@1504 | 71 | err.println(msg); |
ohrstrom@1504 | 72 | } |
ohrstrom@1504 | 73 | |
ohrstrom@1504 | 74 | static public void setLogLevel(String l, PrintStream o, PrintStream e) |
ohrstrom@1504 | 75 | throws ProblemException { |
ohrstrom@1504 | 76 | out = o; |
ohrstrom@1504 | 77 | err = e; |
ohrstrom@1504 | 78 | if (l.equals("warn")) level = WARN; |
ohrstrom@1504 | 79 | else if (l.equals("info")) level = INFO; |
ohrstrom@1504 | 80 | else if (l.equals("debug")) level = DEBUG; |
ohrstrom@1504 | 81 | else if (l.equals("trace")) level = TRACE; |
ohrstrom@1504 | 82 | else throw new ProblemException("No such log level \""+l+"\""); |
ohrstrom@1504 | 83 | } |
ohrstrom@1504 | 84 | |
ohrstrom@1504 | 85 | static public boolean isTracing() { |
ohrstrom@1504 | 86 | return level >= TRACE; |
ohrstrom@1504 | 87 | } |
ohrstrom@1504 | 88 | |
ohrstrom@1504 | 89 | static public boolean isDebugging() { |
ohrstrom@1504 | 90 | return level >= DEBUG; |
ohrstrom@1504 | 91 | } |
ohrstrom@1504 | 92 | } |