jdk/test/java/lang/System/LoggerFinder/internal/LoggerFinderLoaderTest/LoggerFinderLoaderTest.java
equal
deleted
inserted
replaced
51 import java.util.Locale; |
51 import java.util.Locale; |
52 import java.util.ServiceConfigurationError; |
52 import java.util.ServiceConfigurationError; |
53 import java.util.ServiceLoader; |
53 import java.util.ServiceLoader; |
54 import java.util.concurrent.atomic.AtomicReference; |
54 import java.util.concurrent.atomic.AtomicReference; |
55 import jdk.internal.logger.SimpleConsoleLogger; |
55 import jdk.internal.logger.SimpleConsoleLogger; |
|
56 import java.lang.reflect.Module; |
56 |
57 |
57 /** |
58 /** |
58 * @test |
59 * @test |
59 * @bug 8140364 |
60 * @bug 8140364 |
60 * @summary JDK implementation specific unit test for LoggerFinderLoader. |
61 * @summary JDK implementation specific unit test for LoggerFinderLoader. |
164 logger.log(level, bundle, format, params); |
165 logger.log(level, bundle, format, params); |
165 } |
166 } |
166 |
167 |
167 } |
168 } |
168 |
169 |
169 public Logger getLogger(String name, Class<?> caller); |
170 public Logger getLogger(String name, Module caller); |
170 public Logger getLocalizedLogger(String name, ResourceBundle bundle, Class<?> caller); |
171 public Logger getLocalizedLogger(String name, ResourceBundle bundle, Module caller); |
171 } |
172 } |
172 |
173 |
173 public static class BaseLoggerFinder extends LoggerFinder implements TestLoggerFinder { |
174 public static class BaseLoggerFinder extends LoggerFinder implements TestLoggerFinder { |
174 |
175 |
175 static final RuntimePermission LOGGERFINDER_PERMISSION = |
176 static final RuntimePermission LOGGERFINDER_PERMISSION = |
185 return AccessController.doPrivileged(pa); |
186 return AccessController.doPrivileged(pa); |
186 } |
187 } |
187 |
188 |
188 |
189 |
189 @Override |
190 @Override |
190 public Logger getLogger(String name, Class<?> caller) { |
191 public Logger getLogger(String name, Module caller) { |
191 SecurityManager sm = System.getSecurityManager(); |
192 SecurityManager sm = System.getSecurityManager(); |
192 if (sm != null) { |
193 if (sm != null) { |
193 sm.checkPermission(LOGGERFINDER_PERMISSION); |
194 sm.checkPermission(LOGGERFINDER_PERMISSION); |
194 } |
195 } |
195 PrivilegedAction<ClassLoader> pa = () -> caller.getClassLoader(); |
196 PrivilegedAction<ClassLoader> pa = () -> caller.getClassLoader(); |
208 new RuntimePermission("loggerFinder"); |
209 new RuntimePermission("loggerFinder"); |
209 public BaseLoggerFinder2() { |
210 public BaseLoggerFinder2() { |
210 throw new ServiceConfigurationError("Should not come here"); |
211 throw new ServiceConfigurationError("Should not come here"); |
211 } |
212 } |
212 @Override |
213 @Override |
213 public Logger getLogger(String name, Class<?> caller) { |
214 public Logger getLogger(String name, Module caller) { |
214 throw new ServiceConfigurationError("Should not come here"); |
215 throw new ServiceConfigurationError("Should not come here"); |
215 } |
216 } |
216 } |
217 } |
217 |
218 |
218 public static class MyBundle extends ResourceBundle { |
219 public static class MyBundle extends ResourceBundle { |