Skip to content

Commit 2312578

Browse files
committed
8315696: SignedLoggerFinderTest.java test failed
Backport-of: e409d07ae84c693b656c02befb636593f9293635
1 parent 51d738b commit 2312578

File tree

7 files changed

+26
-16
lines changed

7 files changed

+26
-16
lines changed

test/jdk/java/lang/System/LoggerFinder/RecursiveLoading/PlatformRecursiveLoadingTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,12 @@
2626
* @bug 8314263
2727
* @summary Creating a logger while loading the Logger finder
2828
* triggers recursion and StackOverflowError
29-
* @modules java.base/sun.util.logging
30-
* @library /test/lib
29+
* @modules java.base/sun.util.logging java.base/jdk.internal.logger:+open
30+
* @library ../lib
3131
* @compile RecursiveLoadingTest.java SimpleLoggerFinder.java
3232
* @run main/othervm PlatformRecursiveLoadingTest
3333
*/
3434

35-
3635
import java.time.Instant;
3736
import java.util.Arrays;
3837
import java.util.List;
@@ -50,6 +49,8 @@ public class PlatformRecursiveLoadingTest {
5049
*/
5150
public static void main(String[] args) throws Throwable {
5251
PlatformLogger.getLogger("main").info("in main");
52+
// allow time to let bootstrap logger flush data
53+
BootstrapLoggerUtils.awaitPending();
5354
List<Object> logs = loggerfinder.SimpleLoggerFinder.LOGS;
5455
logs.stream().map(SimpleLogRecord::of).forEach(System.out::println);
5556
logs.stream().map(SimpleLogRecord::of).forEach(SimpleLogRecord::check);

test/jdk/java/lang/System/LoggerFinder/RecursiveLoading/RecursiveLoadingTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
* @bug 8314263
2727
* @summary Creating a logger while loading the Logger finder
2828
* triggers recursion and StackOverflowError
29+
* @modules java.base/jdk.internal.logger:+open
30+
* @library ../lib
2931
* @compile RecursiveLoadingTest.java SimpleLoggerFinder.java
3032
* @run main/othervm RecursiveLoadingTest
3133
*/
@@ -45,6 +47,8 @@ public class RecursiveLoadingTest {
4547
*/
4648
public static void main(String[] args) throws Throwable {
4749
System.getLogger("main").log(System.Logger.Level.INFO, "in main");
50+
// allow time to let bootstrap logger flush data
51+
BootstrapLoggerUtils.awaitPending();
4852
List<Object> logs = loggerfinder.SimpleLoggerFinder.LOGS;
4953
logs.stream().map(SimpleLogRecord::of).forEach(System.out::println);
5054
logs.stream().map(SimpleLogRecord::of).forEach(SimpleLogRecord::check);

test/jdk/java/lang/System/LoggerFinder/SignedLoggerFinderTest/SignedLoggerFinderTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
* @test
2626
* @bug 8314263
2727
* @summary Signed jars triggering Logger finder recursion and StackOverflowError
28-
* @library /test/lib
28+
* @modules java.base/jdk.internal.logger:+open
29+
* @library /test/lib ../lib
2930
* @build jdk.test.lib.compiler.CompilerUtils
3031
* jdk.test.lib.process.*
3132
* jdk.test.lib.util.JarUtils
@@ -146,6 +147,8 @@ public static void main(String[] args) throws Throwable {
146147

147148
// LoggerFinder should be initialized, trigger a simple log call
148149
Security.setProperty("test_2", "test");
150+
// allow time to let bootstrap logger flush data
151+
BootstrapLoggerUtils.awaitPending();
149152
}
150153
}
151154

@@ -165,6 +168,8 @@ private static void launchTest(boolean multiThreadLoad, boolean withCustomLogger
165168
System.getProperty("test.classes")));
166169
}
167170
cmds.addAll(List.of(
171+
// allow test to access internal bootstrap logger functionality
172+
"--add-opens=java.base/jdk.internal.logger=ALL-UNNAMED",
168173
// following debug property seems useful to tickle the issue
169174
"-Dsun.misc.URLClassPath.debug=true",
170175
// console logger level to capture event output

test/jdk/java/lang/System/LoggerFinder/internal/BootstrapLogger/BootstrapLoggerAPIsTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -29,7 +29,7 @@
2929
import java.util.Enumeration;
3030
import java.util.List;
3131
import java.util.ResourceBundle;
32-
import java.util.Set;
32+
3333
import jdk.internal.logger.BootstrapLogger;
3434
import jdk.internal.logger.LazyLoggers;
3535

@@ -38,9 +38,10 @@
3838
* @bug 8144460 8144214
3939
* @summary Cover the logXX and LogEvent.valueOf APIs of BootstrapLogger
4040
* and logXX APIs of SimpleConsoleLogger.
41+
* @library ../../lib
4142
* @modules java.base/jdk.internal.logger:+open
4243
* java.base/sun.util.logging
43-
* @build BootstrapLoggerUtils LogStream
44+
* @build LogStream
4445
* @run main/othervm BootstrapLoggerAPIsTest
4546
*/
4647

test/jdk/java/lang/System/LoggerFinder/internal/BootstrapLogger/BootstrapLoggerTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -53,9 +53,10 @@
5353
* @summary JDK implementation specific unit test for JDK internal artifacts.
5454
Tests the behavior of bootstrap loggers (and SimpleConsoleLoggers
5555
* too).
56+
* @library ../../lib
5657
* @modules java.base/jdk.internal.logger:+open
5758
* java.logging
58-
* @build BootstrapLoggerUtils LogStream
59+
* @build LogStream
5960
* @run main/othervm BootstrapLoggerTest NO_SECURITY
6061
* @run main/othervm -Djava.security.manager=allow BootstrapLoggerTest SECURE
6162
* @run main/othervm/timeout=120 -Djava.security.manager=allow BootstrapLoggerTest SECURE_AND_WAIT

test/jdk/java/lang/System/LoggerFinder/internal/BootstrapLogger/LogStream.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -25,8 +25,6 @@
2525
import java.io.OutputStream;
2626
import java.io.PrintStream;
2727

28-
import jdk.internal.logger.BootstrapLogger;
29-
3028
/**
3129
* We use an instance of this class to check what the logging system has printed
3230
* on System.err.
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -28,7 +28,7 @@
2828

2929
import jdk.internal.logger.BootstrapLogger;
3030

31-
class BootstrapLoggerUtils {
31+
public final class BootstrapLoggerUtils {
3232

3333
private static final Field IS_BOOTED;
3434
private static final Method AWAIT_PENDING;
@@ -46,11 +46,11 @@ class BootstrapLoggerUtils {
4646
}
4747
}
4848

49-
static void setBootedHook(BooleanSupplier supplier) throws IllegalAccessException {
49+
public static void setBootedHook(BooleanSupplier supplier) throws IllegalAccessException {
5050
IS_BOOTED.set(null, supplier);
5151
}
5252

53-
static void awaitPending() {
53+
public static void awaitPending() {
5454
try {
5555
AWAIT_PENDING.invoke(null);
5656
} catch (IllegalAccessException | IllegalArgumentException

0 commit comments

Comments
 (0)