test/langtools/tools/javac/6304921/TestLog.java
changeset 48721 ef3557eb4306
parent 47216 71c04702a3d5
child 53773 454d54d8af1c
equal deleted inserted replaced
48720:290b480df13e 48721:ef3557eb4306
     1 /*
     1 /*
     2  * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    27  * @summary unit test for Log
    27  * @summary unit test for Log
    28  * @modules jdk.compiler/com.sun.tools.javac.file
    28  * @modules jdk.compiler/com.sun.tools.javac.file
    29  *          jdk.compiler/com.sun.tools.javac.parser
    29  *          jdk.compiler/com.sun.tools.javac.parser
    30  *          jdk.compiler/com.sun.tools.javac.tree
    30  *          jdk.compiler/com.sun.tools.javac.tree
    31  *          jdk.compiler/com.sun.tools.javac.util:+open
    31  *          jdk.compiler/com.sun.tools.javac.util:+open
       
    32  *          jdk.compiler/com.sun.tools.javac.resources
    32  */
    33  */
    33 import java.lang.reflect.Field;
    34 import java.lang.reflect.Field;
    34 import java.io.InputStream;
    35 import java.io.InputStream;
    35 import java.io.OutputStream;
    36 import java.io.OutputStream;
    36 import java.net.URI;
    37 import java.net.URI;
    47 import com.sun.tools.javac.util.Log;
    48 import com.sun.tools.javac.util.Log;
    48 import com.sun.tools.javac.util.JCDiagnostic;
    49 import com.sun.tools.javac.util.JCDiagnostic;
    49 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag;
    50 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag;
    50 import com.sun.tools.javac.util.JCDiagnostic.Factory;
    51 import com.sun.tools.javac.util.JCDiagnostic.Factory;
    51 import com.sun.tools.javac.util.Options;
    52 import com.sun.tools.javac.util.Options;
       
    53 import com.sun.tools.javac.resources.CompilerProperties.Errors;
       
    54 import com.sun.tools.javac.resources.CompilerProperties.Warnings;
    52 
    55 
    53 public class TestLog
    56 public class TestLog
    54 {
    57 {
    55     public static void main(String... args) throws Exception {
    58     public static void main(String... args) throws Exception {
    56         test(false);
    59         test(false);
   120         }
   123         }
   121 
   124 
   122         public void visitIf(JCTree.JCIf tree) {
   125         public void visitIf(JCTree.JCIf tree) {
   123             JCDiagnostic.DiagnosticPosition nil = null;
   126             JCDiagnostic.DiagnosticPosition nil = null;
   124             // generate dummy messages to exercise the log API
   127             // generate dummy messages to exercise the log API
   125             log.error("not.stmt");
   128             log.error(Errors.NotStmt);
   126             log.error(tree.pos, "not.stmt");
   129             log.error(tree.pos, Errors.NotStmt);
   127             log.error(tree.pos(), "not.stmt");
   130             log.error(tree.pos(), Errors.NotStmt);
   128             log.error(nil, "not.stmt");
   131             log.error(nil, Errors.NotStmt);
   129 
   132 
   130             log.warning("div.zero");
   133             log.warning(Warnings.DivZero);
   131             log.warning(tree.pos, "div.zero");
   134             log.warning(tree.pos, Warnings.DivZero);
   132             log.warning(tree.pos(), "div.zero");
   135             log.warning(tree.pos(), Warnings.DivZero);
   133             log.warning(nil, "div.zero");
   136             log.warning(nil, Warnings.DivZero);
   134         }
   137         }
   135 
   138 
   136         private Log log;
   139         private Log log;
   137         private EndPosTable endPosTable;
   140         private EndPosTable endPosTable;
   138     }
   141     }