Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/lang/System/Logger/default/AccessSystemLogger.java
41154 views
1
/*
2
* Copyright (c) 2015, 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.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
import java.io.IOException;
24
import java.lang.System.Logger;
25
import java.nio.file.Files;
26
import java.nio.file.Path;
27
import java.nio.file.Paths;
28
import java.nio.file.StandardCopyOption;
29
import java.util.ResourceBundle;
30
import java.util.logging.LogManager;
31
32
/**
33
*
34
* @author danielfuchs
35
*/
36
public final class AccessSystemLogger {
37
38
public AccessSystemLogger() {
39
this(check());
40
}
41
42
private AccessSystemLogger(Void unused) {
43
}
44
45
private static Void check() {
46
if (AccessSystemLogger.class.getClassLoader() != null) {
47
throw new RuntimeException("AccessSystemLogger should be loaded by the null classloader");
48
}
49
return null;
50
}
51
52
public Logger getLogger(String name) {
53
Logger logger = System.getLogger(name);
54
System.out.println("System.getLogger(\"" + name + "\"): " + logger);
55
return logger;
56
}
57
58
public Logger getLogger(String name, ResourceBundle bundle) {
59
Logger logger = System.getLogger(name, bundle);
60
System.out.println("System.getLogger(\"" + name + "\", bundle): " + logger);
61
return logger;
62
}
63
64
public java.util.logging.Logger demandSystemLogger(String name) {
65
return java.util.logging.Logger.getLogger(name);
66
}
67
68
// copy AccessSystemLogger.class to ./boot
69
public static void main(String[] args) throws IOException {
70
Path testDir = Paths.get(System.getProperty("user.dir", "."));
71
Path bootDir = Paths.get(testDir.toString(), "boot");
72
Path classes = Paths.get(System.getProperty("test.classes", "build/classes"));
73
Path thisClass = Paths.get(classes.toString(),
74
AccessSystemLogger.class.getSimpleName()+".class");
75
if (Files.notExists(bootDir)) {
76
Files.createDirectory(bootDir);
77
}
78
Path dest = Paths.get(bootDir.toString(),
79
AccessSystemLogger.class.getSimpleName()+".class");
80
Files.copy(thisClass, dest, StandardCopyOption.REPLACE_EXISTING);
81
}
82
83
}
84
85