< prev index next >

src/java.base/share/classes/java/lang/System.java

Print this page


   1 /*
   2  * Copyright (c) 1994, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


1402         }
1403 
1404         private LoggerFinder(Void unused) {
1405             // nothing to do.
1406         }
1407 
1408         private static Void checkPermission() {
1409             final SecurityManager sm = System.getSecurityManager();
1410             if (sm != null) {
1411                 sm.checkPermission(LOGGERFINDER_PERMISSION);
1412             }
1413             return null;
1414         }
1415 
1416         /**
1417          * Returns an instance of {@link Logger Logger}
1418          * for the given {@code caller}.
1419          *
1420          * @param name the name of the logger.
1421          * @param caller the class for which the logger is being requested;
1422          *               can be {@code null}.
1423          *
1424          * @return a {@link Logger logger} suitable for the given caller's
1425          *         use.
1426          * @throws NullPointerException if {@code name} is {@code null} or
1427          *        {@code caller} is {@code null}.
1428          * @throws SecurityException if a security manager is present and its
1429          *         {@code checkPermission} method doesn't allow the
1430          *         {@code RuntimePermission("loggerFinder")}.
1431          */
1432         public abstract Logger getLogger(String name, /* Module */ Class<?> caller);
1433 
1434         /**
1435          * Returns a localizable instance of {@link Logger Logger}
1436          * for the given {@code caller}.
1437          * The returned logger will use the provided resource bundle for
1438          * message localization.
1439          *
1440          * @implSpec By default, this method calls {@link
1441          * #getLogger(java.lang.String, java.lang.Class)
1442          * this.getLogger(name, caller)} to obtain a logger, then wraps that


   1 /*
   2  * Copyright (c) 1994, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


1402         }
1403 
1404         private LoggerFinder(Void unused) {
1405             // nothing to do.
1406         }
1407 
1408         private static Void checkPermission() {
1409             final SecurityManager sm = System.getSecurityManager();
1410             if (sm != null) {
1411                 sm.checkPermission(LOGGERFINDER_PERMISSION);
1412             }
1413             return null;
1414         }
1415 
1416         /**
1417          * Returns an instance of {@link Logger Logger}
1418          * for the given {@code caller}.
1419          *
1420          * @param name the name of the logger.
1421          * @param caller the class for which the logger is being requested;

1422          *
1423          * @return a {@link Logger logger} suitable for the given caller's
1424          *         use.
1425          * @throws NullPointerException if {@code name} is {@code null} or
1426          *        {@code caller} is {@code null}.
1427          * @throws SecurityException if a security manager is present and its
1428          *         {@code checkPermission} method doesn't allow the
1429          *         {@code RuntimePermission("loggerFinder")}.
1430          */
1431         public abstract Logger getLogger(String name, /* Module */ Class<?> caller);
1432 
1433         /**
1434          * Returns a localizable instance of {@link Logger Logger}
1435          * for the given {@code caller}.
1436          * The returned logger will use the provided resource bundle for
1437          * message localization.
1438          *
1439          * @implSpec By default, this method calls {@link
1440          * #getLogger(java.lang.String, java.lang.Class)
1441          * this.getLogger(name, caller)} to obtain a logger, then wraps that


< prev index next >