33 import java.io.IOException; |
33 import java.io.IOException; |
34 import java.io.InputStream; |
34 import java.io.InputStream; |
35 import java.io.PrintStream; |
35 import java.io.PrintStream; |
36 import java.io.UnsupportedEncodingException; |
36 import java.io.UnsupportedEncodingException; |
37 import java.lang.annotation.Annotation; |
37 import java.lang.annotation.Annotation; |
|
38 import java.lang.module.ModuleDescriptor; |
38 import java.lang.reflect.Constructor; |
39 import java.lang.reflect.Constructor; |
39 import java.lang.reflect.Executable; |
40 import java.lang.reflect.Executable; |
40 import java.lang.reflect.Layer; |
|
41 import java.lang.reflect.Method; |
41 import java.lang.reflect.Method; |
42 import java.lang.reflect.Modifier; |
42 import java.lang.reflect.Modifier; |
43 import java.lang.reflect.Module; |
43 import java.net.URI; |
44 import java.net.URL; |
44 import java.net.URL; |
45 import java.security.AccessControlContext; |
45 import java.security.AccessControlContext; |
46 import java.security.ProtectionDomain; |
46 import java.security.ProtectionDomain; |
47 import java.util.Properties; |
|
48 import java.util.PropertyPermission; |
|
49 import java.util.Map; |
|
50 import java.security.AccessController; |
47 import java.security.AccessController; |
51 import java.security.PrivilegedAction; |
48 import java.security.PrivilegedAction; |
52 import java.nio.channels.Channel; |
49 import java.nio.channels.Channel; |
53 import java.nio.channels.spi.SelectorProvider; |
50 import java.nio.channels.spi.SelectorProvider; |
|
51 import java.util.Map; |
|
52 import java.util.Objects; |
|
53 import java.util.Properties; |
|
54 import java.util.PropertyPermission; |
|
55 import java.util.ResourceBundle; |
|
56 import java.util.function.Supplier; |
54 import java.util.concurrent.ConcurrentHashMap; |
57 import java.util.concurrent.ConcurrentHashMap; |
55 import java.util.stream.Stream; |
58 import java.util.stream.Stream; |
56 |
59 |
57 import java.util.Objects; |
60 import jdk.internal.module.ModuleBootstrap; |
58 import java.util.ResourceBundle; |
61 import jdk.internal.module.ServicesCatalog; |
59 import java.util.function.Supplier; |
|
60 import sun.nio.ch.Interruptible; |
|
61 import jdk.internal.reflect.CallerSensitive; |
62 import jdk.internal.reflect.CallerSensitive; |
62 import jdk.internal.reflect.Reflection; |
63 import jdk.internal.reflect.Reflection; |
63 import sun.security.util.SecurityConstants; |
|
64 import sun.reflect.annotation.AnnotationType; |
|
65 import jdk.internal.HotSpotIntrinsicCandidate; |
64 import jdk.internal.HotSpotIntrinsicCandidate; |
66 import jdk.internal.misc.JavaLangAccess;; |
65 import jdk.internal.misc.JavaLangAccess;; |
67 import jdk.internal.misc.SharedSecrets;; |
66 import jdk.internal.misc.SharedSecrets;; |
68 import jdk.internal.misc.VM; |
67 import jdk.internal.misc.VM; |
69 import jdk.internal.logger.LoggerFinderLoader; |
68 import jdk.internal.logger.LoggerFinderLoader; |
70 import jdk.internal.logger.LazyLoggers; |
69 import jdk.internal.logger.LazyLoggers; |
71 import jdk.internal.logger.LocalizedLoggerWrapper; |
70 import jdk.internal.logger.LocalizedLoggerWrapper; |
72 |
71 import sun.reflect.annotation.AnnotationType; |
73 import jdk.internal.module.ModuleBootstrap; |
72 import sun.nio.ch.Interruptible; |
|
73 import sun.security.util.SecurityConstants; |
74 |
74 |
75 /** |
75 /** |
76 * The <code>System</code> class contains several useful class fields |
76 * The <code>System</code> class contains several useful class fields |
77 * and methods. It cannot be instantiated. |
77 * and methods. It cannot be instantiated. |
78 * |
78 * |
1158 * |
1158 * |
1159 * @param level the log message level. |
1159 * @param level the log message level. |
1160 * @param msg the string message (or a key in the message catalog, if |
1160 * @param msg the string message (or a key in the message catalog, if |
1161 * this logger is a {@link |
1161 * this logger is a {@link |
1162 * LoggerFinder#getLocalizedLogger(java.lang.String, |
1162 * LoggerFinder#getLocalizedLogger(java.lang.String, |
1163 * java.util.ResourceBundle, java.lang.reflect.Module) localized logger}); |
1163 * java.util.ResourceBundle, java.lang.Module) localized logger}); |
1164 * can be {@code null}. |
1164 * can be {@code null}. |
1165 * |
1165 * |
1166 * @throws NullPointerException if {@code level} is {@code null}. |
1166 * @throws NullPointerException if {@code level} is {@code null}. |
1167 */ |
1167 */ |
1168 public default void log(Level level, String msg) { |
1168 public default void log(Level level, String msg) { |
1226 * |
1226 * |
1227 * @param level the log message level. |
1227 * @param level the log message level. |
1228 * @param msg the string message (or a key in the message catalog, if |
1228 * @param msg the string message (or a key in the message catalog, if |
1229 * this logger is a {@link |
1229 * this logger is a {@link |
1230 * LoggerFinder#getLocalizedLogger(java.lang.String, |
1230 * LoggerFinder#getLocalizedLogger(java.lang.String, |
1231 * java.util.ResourceBundle, java.lang.reflect.Module) localized logger}); |
1231 * java.util.ResourceBundle, java.lang.Module) localized logger}); |
1232 * can be {@code null}. |
1232 * can be {@code null}. |
1233 * @param thrown a {@code Throwable} associated with the log message; |
1233 * @param thrown a {@code Throwable} associated with the log message; |
1234 * can be {@code null}. |
1234 * can be {@code null}. |
1235 * |
1235 * |
1236 * @throws NullPointerException if {@code level} is {@code null}. |
1236 * @throws NullPointerException if {@code level} is {@code null}. |
1275 * @param level one of the log message level identifiers. |
1275 * @param level one of the log message level identifiers. |
1276 * @param format the string message format in {@link |
1276 * @param format the string message format in {@link |
1277 * java.text.MessageFormat} format, (or a key in the message |
1277 * java.text.MessageFormat} format, (or a key in the message |
1278 * catalog, if this logger is a {@link |
1278 * catalog, if this logger is a {@link |
1279 * LoggerFinder#getLocalizedLogger(java.lang.String, |
1279 * LoggerFinder#getLocalizedLogger(java.lang.String, |
1280 * java.util.ResourceBundle, java.lang.reflect.Module) localized logger}); |
1280 * java.util.ResourceBundle, java.lang.Module) localized logger}); |
1281 * can be {@code null}. |
1281 * can be {@code null}. |
1282 * @param params an optional list of parameters to the message (may be |
1282 * @param params an optional list of parameters to the message (may be |
1283 * none). |
1283 * none). |
1284 * |
1284 * |
1285 * @throws NullPointerException if {@code level} is {@code null}. |
1285 * @throws NullPointerException if {@code level} is {@code null}. |
1480 * for the given {@code module}. |
1480 * for the given {@code module}. |
1481 * The returned logger will use the provided resource bundle for |
1481 * The returned logger will use the provided resource bundle for |
1482 * message localization. |
1482 * message localization. |
1483 * |
1483 * |
1484 * @implSpec By default, this method calls {@link |
1484 * @implSpec By default, this method calls {@link |
1485 * #getLogger(java.lang.String, java.lang.reflect.Module) |
1485 * #getLogger(java.lang.String, java.lang.Module) |
1486 * this.getLogger(name, module)} to obtain a logger, then wraps that |
1486 * this.getLogger(name, module)} to obtain a logger, then wraps that |
1487 * logger in a {@link Logger} instance where all methods that do not |
1487 * logger in a {@link Logger} instance where all methods that do not |
1488 * take a {@link ResourceBundle} as parameter are redirected to one |
1488 * take a {@link ResourceBundle} as parameter are redirected to one |
1489 * which does - passing the given {@code bundle} for |
1489 * which does - passing the given {@code bundle} for |
1490 * localization. So for instance, a call to {@link |
1490 * localization. So for instance, a call to {@link |
1564 * use. |
1564 * use. |
1565 * |
1565 * |
1566 * @implSpec |
1566 * @implSpec |
1567 * Instances returned by this method route messages to loggers |
1567 * Instances returned by this method route messages to loggers |
1568 * obtained by calling {@link LoggerFinder#getLogger(java.lang.String, |
1568 * obtained by calling {@link LoggerFinder#getLogger(java.lang.String, |
1569 * java.lang.reflect.Module) LoggerFinder.getLogger(name, module)}, where |
1569 * java.lang.Module) LoggerFinder.getLogger(name, module)}, where |
1570 * {@code module} is the caller's module. |
1570 * {@code module} is the caller's module. |
1571 * In cases where {@code System.getLogger} is called from a context where |
1571 * In cases where {@code System.getLogger} is called from a context where |
1572 * there is no caller frame on the stack (e.g when called directly |
1572 * there is no caller frame on the stack (e.g when called directly |
1573 * from a JNI attached thread), {@code IllegalCallerException} is thrown. |
1573 * from a JNI attached thread), {@code IllegalCallerException} is thrown. |
1574 * To obtain a logger in such a context, use an auxiliary class that will |
1574 * To obtain a logger in such a context, use an auxiliary class that will |
1577 * Note that doing the latter may eagerly initialize the underlying |
1577 * Note that doing the latter may eagerly initialize the underlying |
1578 * logging system. |
1578 * logging system. |
1579 * |
1579 * |
1580 * @apiNote |
1580 * @apiNote |
1581 * This method may defer calling the {@link |
1581 * This method may defer calling the {@link |
1582 * LoggerFinder#getLogger(java.lang.String, java.lang.reflect.Module) |
1582 * LoggerFinder#getLogger(java.lang.String, java.lang.Module) |
1583 * LoggerFinder.getLogger} method to create an actual logger supplied by |
1583 * LoggerFinder.getLogger} method to create an actual logger supplied by |
1584 * the logging backend, for instance, to allow loggers to be obtained during |
1584 * the logging backend, for instance, to allow loggers to be obtained during |
1585 * the system initialization time. |
1585 * the system initialization time. |
1586 * |
1586 * |
1587 * @param name the name of the logger. |
1587 * @param name the name of the logger. |
1610 * localization. |
1610 * localization. |
1611 * |
1611 * |
1612 * @implSpec |
1612 * @implSpec |
1613 * The returned logger will perform message localization as specified |
1613 * The returned logger will perform message localization as specified |
1614 * by {@link LoggerFinder#getLocalizedLogger(java.lang.String, |
1614 * by {@link LoggerFinder#getLocalizedLogger(java.lang.String, |
1615 * java.util.ResourceBundle, java.lang.reflect.Module) |
1615 * java.util.ResourceBundle, java.lang.Module) |
1616 * LoggerFinder.getLocalizedLogger(name, bundle, module)}, where |
1616 * LoggerFinder.getLocalizedLogger(name, bundle, module)}, where |
1617 * {@code module} is the caller's module. |
1617 * {@code module} is the caller's module. |
1618 * In cases where {@code System.getLogger} is called from a context where |
1618 * In cases where {@code System.getLogger} is called from a context where |
1619 * there is no caller frame on the stack (e.g when called directly |
1619 * there is no caller frame on the stack (e.g when called directly |
1620 * from a JNI attached thread), {@code IllegalCallerException} is thrown. |
1620 * from a JNI attached thread), {@code IllegalCallerException} is thrown. |
2098 return new Thread(target, acc); |
2098 return new Thread(target, acc); |
2099 } |
2099 } |
2100 public void invokeFinalize(Object o) throws Throwable { |
2100 public void invokeFinalize(Object o) throws Throwable { |
2101 o.finalize(); |
2101 o.finalize(); |
2102 } |
2102 } |
2103 public Layer getBootLayer() { |
|
2104 return bootLayer; |
|
2105 } |
|
2106 public ConcurrentHashMap<?, ?> createOrGetClassLoaderValueMap(ClassLoader cl) { |
2103 public ConcurrentHashMap<?, ?> createOrGetClassLoaderValueMap(ClassLoader cl) { |
2107 return cl.createOrGetClassLoaderValueMap(); |
2104 return cl.createOrGetClassLoaderValueMap(); |
2108 } |
2105 } |
2109 public Class<?> defineClass(ClassLoader loader, String name, byte[] b, ProtectionDomain pd, String source) { |
2106 public Class<?> defineClass(ClassLoader loader, String name, byte[] b, ProtectionDomain pd, String source) { |
2110 return ClassLoader.defineClass1(loader, name, b, 0, b.length, pd, source); |
2107 return ClassLoader.defineClass1(loader, name, b, 0, b.length, pd, source); |
2125 return Long.fastUUID(lsb, msb); |
2122 return Long.fastUUID(lsb, msb); |
2126 } |
2123 } |
2127 public void invalidatePackageAccessCache() { |
2124 public void invalidatePackageAccessCache() { |
2128 SecurityManager.invalidatePackageAccessCache(); |
2125 SecurityManager.invalidatePackageAccessCache(); |
2129 } |
2126 } |
|
2127 public Module defineModule(ClassLoader loader, |
|
2128 ModuleDescriptor descriptor, |
|
2129 URI uri) { |
|
2130 return new Module(null, loader, descriptor, uri); |
|
2131 } |
|
2132 public Module defineUnnamedModule(ClassLoader loader) { |
|
2133 return new Module(loader); |
|
2134 } |
|
2135 public void addReads(Module m1, Module m2) { |
|
2136 m1.implAddReads(m2); |
|
2137 } |
|
2138 public void addReadsAllUnnamed(Module m) { |
|
2139 m.implAddReadsAllUnnamed(); |
|
2140 } |
|
2141 public void addExports(Module m, String pn, Module other) { |
|
2142 m.implAddExports(pn, other); |
|
2143 } |
|
2144 public void addExportsToAllUnnamed(Module m, String pn) { |
|
2145 m.implAddExportsToAllUnnamed(pn); |
|
2146 } |
|
2147 public void addOpens(Module m, String pn, Module other) { |
|
2148 m.implAddOpens(pn, other); |
|
2149 } |
|
2150 public void addOpensToAllUnnamed(Module m, String pn) { |
|
2151 m.implAddOpensToAllUnnamed(pn); |
|
2152 } |
|
2153 public void addUses(Module m, Class<?> service) { |
|
2154 m.implAddUses(service); |
|
2155 } |
|
2156 public ServicesCatalog getServicesCatalog(ModuleLayer layer) { |
|
2157 return layer.getServicesCatalog(); |
|
2158 } |
|
2159 public Stream<ModuleLayer> layers(ModuleLayer layer) { |
|
2160 return layer.layers(); |
|
2161 } |
|
2162 public Stream<ModuleLayer> layers(ClassLoader loader) { |
|
2163 return ModuleLayer.layers(loader); |
|
2164 } |
2130 }); |
2165 }); |
2131 } |
2166 } |
2132 } |
2167 } |