From 38dbe05e004a018c810e3acaae4660c69dd982da Mon Sep 17 00:00:00 2001 From: Bradford Wetmore Date: Wed, 16 Jun 2021 16:59:02 +0000 Subject: [PATCH 001/258] 8268901: JDK-8268768 missed removing two files Reviewed-by: mcimadamore --- make/ide/idea/jdk/template/module.iml | 13 ------------- make/ide/idea/jdk/template/test.iml | 10 ---------- 2 files changed, 23 deletions(-) delete mode 100644 make/ide/idea/jdk/template/module.iml delete mode 100644 make/ide/idea/jdk/template/test.iml diff --git a/make/ide/idea/jdk/template/module.iml b/make/ide/idea/jdk/template/module.iml deleted file mode 100644 index 446d055f240..00000000000 --- a/make/ide/idea/jdk/template/module.iml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - ###SOURCE_DIRS### - - - ###DEPENDENCIES### - - - - diff --git a/make/ide/idea/jdk/template/test.iml b/make/ide/idea/jdk/template/test.iml deleted file mode 100644 index f684c675afe..00000000000 --- a/make/ide/idea/jdk/template/test.iml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - ###TEST_MODULE_DEPENDENCIES### - - - From 8ea0606aba15911f5bfe2c81a83b42288d97095f Mon Sep 17 00:00:00 2001 From: Daniel Fuchs Date: Wed, 16 Jun 2021 17:24:06 +0000 Subject: [PATCH 002/258] 8268714: [macos-aarch64] 7 java/net/httpclient/websocket tests failed Reviewed-by: chegar, michaelm --- .../java/net/httpclient/ISO_8859_1_Test.java | 1 + .../websocket/DummyWebSocketServer.java | 8 ++- .../websocket/PendingBinaryPingClose.java | 2 + .../websocket/PendingBinaryPongClose.java | 2 + .../websocket/PendingPingBinaryClose.java | 2 + .../websocket/PendingPingTextClose.java | 2 + .../websocket/PendingPongBinaryClose.java | 2 + .../websocket/PendingPongTextClose.java | 2 + .../websocket/PendingTextPongClose.java | 2 + .../net/httpclient/websocket/Support.java | 50 ++++++++++++++++++- .../websocket/WSHandshakeExceptionTest.java | 25 ++++++++-- .../websocket/WebSocketProxyTest.java | 2 + 12 files changed, 93 insertions(+), 7 deletions(-) diff --git a/test/jdk/java/net/httpclient/ISO_8859_1_Test.java b/test/jdk/java/net/httpclient/ISO_8859_1_Test.java index e4585b22383..f947d886dbc 100644 --- a/test/jdk/java/net/httpclient/ISO_8859_1_Test.java +++ b/test/jdk/java/net/httpclient/ISO_8859_1_Test.java @@ -278,6 +278,7 @@ private static final Exception completionCause(CompletionException x) { @Test(dataProvider = "variants") public void test(String uri, boolean sameClient) throws Exception { + checkSkip(); System.out.println("Request to " + uri); HttpClient client = newHttpClient(sameClient); diff --git a/test/jdk/java/net/httpclient/websocket/DummyWebSocketServer.java b/test/jdk/java/net/httpclient/websocket/DummyWebSocketServer.java index 84c98198686..176634d6907 100644 --- a/test/jdk/java/net/httpclient/websocket/DummyWebSocketServer.java +++ b/test/jdk/java/net/httpclient/websocket/DummyWebSocketServer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -150,7 +150,7 @@ public DummyWebSocketServer(BiFunction,Credentials,List> ma err.println("Error in connection: " + channel + ", " + e); } finally { err.println("Closed: " + channel); - close(channel); + closeChannel(channel); readReady.countDown(); } } @@ -184,6 +184,10 @@ protected void read(SocketChannel ch) throws IOException { } } + protected void closeChannel(SocketChannel channel) { + close(channel); + } + protected void write(SocketChannel ch) throws IOException { } protected final void serve(SocketChannel channel) diff --git a/test/jdk/java/net/httpclient/websocket/PendingBinaryPingClose.java b/test/jdk/java/net/httpclient/websocket/PendingBinaryPingClose.java index 782380cfbac..446f8253d1b 100644 --- a/test/jdk/java/net/httpclient/websocket/PendingBinaryPingClose.java +++ b/test/jdk/java/net/httpclient/websocket/PendingBinaryPingClose.java @@ -25,6 +25,7 @@ * @test * @build DummyWebSocketServer * @run testng/othervm + * -Djdk.httpclient.sendBufferSize=8192 * -Djdk.internal.httpclient.debug=true * -Djdk.internal.httpclient.websocket.debug=true * PendingBinaryPingClose @@ -48,6 +49,7 @@ public class PendingBinaryPingClose extends PendingOperations { public void pendingBinaryPingClose(boolean last) throws Exception { repeatable(() -> { server = Support.notReadingServer(); + server.setReceiveBufferSize(1024); server.open(); webSocket = httpClient().newWebSocketBuilder() .buildAsync(server.getURI(), new WebSocket.Listener() { }) diff --git a/test/jdk/java/net/httpclient/websocket/PendingBinaryPongClose.java b/test/jdk/java/net/httpclient/websocket/PendingBinaryPongClose.java index ef75b0f1c0d..7592743a030 100644 --- a/test/jdk/java/net/httpclient/websocket/PendingBinaryPongClose.java +++ b/test/jdk/java/net/httpclient/websocket/PendingBinaryPongClose.java @@ -25,6 +25,7 @@ * @test * @build DummyWebSocketServer * @run testng/othervm + * -Djdk.httpclient.sendBufferSize=8192 * -Djdk.internal.httpclient.debug=true * -Djdk.internal.httpclient.websocket.debug=true * PendingBinaryPongClose @@ -50,6 +51,7 @@ public class PendingBinaryPongClose extends PendingOperations { public void pendingBinaryPongClose(boolean last) throws Exception { repeatable(() -> { server = Support.notReadingServer(); + server.setReceiveBufferSize(1024); server.open(); webSocket = httpClient().newWebSocketBuilder() .buildAsync(server.getURI(), new WebSocket.Listener() { }) diff --git a/test/jdk/java/net/httpclient/websocket/PendingPingBinaryClose.java b/test/jdk/java/net/httpclient/websocket/PendingPingBinaryClose.java index 1cb1fe74175..7f3a530e81e 100644 --- a/test/jdk/java/net/httpclient/websocket/PendingPingBinaryClose.java +++ b/test/jdk/java/net/httpclient/websocket/PendingPingBinaryClose.java @@ -25,6 +25,7 @@ * @test * @build DummyWebSocketServer * @run testng/othervm + * -Djdk.httpclient.sendBufferSize=8192 * PendingPingBinaryClose */ @@ -50,6 +51,7 @@ public class PendingPingBinaryClose extends PendingOperations { public void pendingPingBinaryClose(boolean last) throws Exception { repeatable( () -> { server = Support.notReadingServer(); + server.setReceiveBufferSize(1024); server.open(); webSocket = httpClient().newWebSocketBuilder() .buildAsync(server.getURI(), new WebSocket.Listener() { }) diff --git a/test/jdk/java/net/httpclient/websocket/PendingPingTextClose.java b/test/jdk/java/net/httpclient/websocket/PendingPingTextClose.java index b40a27c6891..e6110c5d464 100644 --- a/test/jdk/java/net/httpclient/websocket/PendingPingTextClose.java +++ b/test/jdk/java/net/httpclient/websocket/PendingPingTextClose.java @@ -25,6 +25,7 @@ * @test * @build DummyWebSocketServer * @run testng/othervm + * -Djdk.httpclient.sendBufferSize=8192 * PendingPingTextClose */ @@ -52,6 +53,7 @@ public void pendingPingTextClose(boolean last) throws Exception { try { repeatable(() -> { server = Support.notReadingServer(); + server.setReceiveBufferSize(1024); server.open(); webSocket = httpClient().newWebSocketBuilder() .buildAsync(server.getURI(), new WebSocket.Listener() { }) diff --git a/test/jdk/java/net/httpclient/websocket/PendingPongBinaryClose.java b/test/jdk/java/net/httpclient/websocket/PendingPongBinaryClose.java index 069abaef4a9..b1f405ff326 100644 --- a/test/jdk/java/net/httpclient/websocket/PendingPongBinaryClose.java +++ b/test/jdk/java/net/httpclient/websocket/PendingPongBinaryClose.java @@ -25,6 +25,7 @@ * @test * @build DummyWebSocketServer * @run testng/othervm + * -Djdk.httpclient.sendBufferSize=8192 * PendingPongBinaryClose */ @@ -50,6 +51,7 @@ public class PendingPongBinaryClose extends PendingOperations { public void pendingPongBinaryClose(boolean last) throws Exception { repeatable( () -> { server = Support.notReadingServer(); + server.setReceiveBufferSize(1024); server.open(); webSocket = httpClient().newWebSocketBuilder() .buildAsync(server.getURI(), new WebSocket.Listener() { }) diff --git a/test/jdk/java/net/httpclient/websocket/PendingPongTextClose.java b/test/jdk/java/net/httpclient/websocket/PendingPongTextClose.java index 19e7c70f1a8..6772f49b2f7 100644 --- a/test/jdk/java/net/httpclient/websocket/PendingPongTextClose.java +++ b/test/jdk/java/net/httpclient/websocket/PendingPongTextClose.java @@ -25,6 +25,7 @@ * @test * @build DummyWebSocketServer * @run testng/othervm + * -Djdk.httpclient.sendBufferSize=8192 * PendingPongTextClose */ @@ -50,6 +51,7 @@ public class PendingPongTextClose extends PendingOperations { public void pendingPongTextClose(boolean last) throws Exception { repeatable( () -> { server = Support.notReadingServer(); + server.setReceiveBufferSize(1024); server.open(); webSocket = httpClient().newWebSocketBuilder() .buildAsync(server.getURI(), new WebSocket.Listener() { }) diff --git a/test/jdk/java/net/httpclient/websocket/PendingTextPongClose.java b/test/jdk/java/net/httpclient/websocket/PendingTextPongClose.java index b9a0c88b020..a8125615e35 100644 --- a/test/jdk/java/net/httpclient/websocket/PendingTextPongClose.java +++ b/test/jdk/java/net/httpclient/websocket/PendingTextPongClose.java @@ -27,6 +27,7 @@ * @run testng/othervm * -Djdk.internal.httpclient.debug=true * -Djdk.internal.httpclient.websocket.debug=true + * -Djdk.httpclient.sendBufferSize=8192 * PendingTextPongClose */ @@ -49,6 +50,7 @@ public class PendingTextPongClose extends PendingOperations { public void pendingTextPongClose(boolean last) throws Exception { repeatable(() -> { server = Support.notReadingServer(); + server.setReceiveBufferSize(1024); server.open(); webSocket = httpClient().newWebSocketBuilder() .buildAsync(server.getURI(), new WebSocket.Listener() { }) diff --git a/test/jdk/java/net/httpclient/websocket/Support.java b/test/jdk/java/net/httpclient/websocket/Support.java index 9f7f5c43578..1323ae35105 100644 --- a/test/jdk/java/net/httpclient/websocket/Support.java +++ b/test/jdk/java/net/httpclient/websocket/Support.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -136,17 +136,65 @@ protected void write(SocketChannel ch) throws IOException { */ public static DummyWebSocketServer notReadingServer() { return new DummyWebSocketServer() { + volatile Thread reader; @Override protected void read(SocketChannel ch) throws IOException { + reader = Thread.currentThread(); try { + System.out.println("Not reading server waiting"); Thread.sleep(Long.MAX_VALUE); } catch (InterruptedException e) { throw new IOException(e); } } + + @Override + protected void closeChannel(SocketChannel channel) { + try { + long read = drain(channel); + System.out.printf("Not reading server drained %s bytes%n", read); + } catch (IOException io) { + System.out.println("Not reading server failed to drain channel: " + io); + } + super.closeChannel(channel); + } + + @Override + public void close() { + super.close(); + Thread thread = reader; + if (thread != null && thread.isAlive() && thread != Thread.currentThread()) { + try { + thread.join(); + System.out.println("Not reading server: closed"); + } catch (InterruptedException x) { + System.out.println("Not reading server: close interrupted: " + x); + } + } + } }; } + static long drain(SocketChannel channel) throws IOException { + System.out.println("Not reading server: draining socket"); + var blocking = channel.isBlocking(); + if (blocking) channel.configureBlocking(false); + long count = 0; + try { + ByteBuffer buffer = ByteBuffer.allocateDirect(8 * 1024); + int read; + while ((read = channel.read(buffer)) > 0) { + count += read; + buffer.clear(); + } + return count; + } finally { + if (blocking != channel.isBlocking()) { + channel.configureBlocking(blocking); + } + } + } + public static DummyWebSocketServer writingServer(int... data) { byte[] copy = new byte[data.length]; for (int i = 0; i < data.length; i++) { diff --git a/test/jdk/java/net/httpclient/websocket/WSHandshakeExceptionTest.java b/test/jdk/java/net/httpclient/websocket/WSHandshakeExceptionTest.java index 44620f63ff4..a3ca4e2b439 100644 --- a/test/jdk/java/net/httpclient/websocket/WSHandshakeExceptionTest.java +++ b/test/jdk/java/net/httpclient/websocket/WSHandshakeExceptionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -76,8 +76,9 @@ public class WSHandshakeExceptionTest { String httpsURI; String httpNonUtf8URI; String httpsNonUtf8URI; + HttpClient sharedClient; - static final int ITERATION_COUNT = 10; + static final int ITERATION_COUNT = 4; // a shared executor helps reduce the amount of threads created by the test static final ExecutorService executor = Executors.newCachedThreadPool(); @@ -106,11 +107,16 @@ HttpClient newHttpClient() { @Test(dataProvider = "variants") public void test(String uri, boolean sameClient) { - HttpClient client = null; + HttpClient client = sharedClient; + boolean pause; for (int i = 0; i < ITERATION_COUNT; i++) { System.out.printf("iteration %s%n", i); - if (!sameClient || client == null) + if (!sameClient || client == null) { + pause = client != null; client = newHttpClient(); + if (pause) gc(10); // give some time to gc + } + if (sharedClient == null) sharedClient = client; try { client.newWebSocketBuilder() @@ -143,6 +149,15 @@ public void test(String uri, boolean sameClient) { } } + static void gc(long ms) { + System.gc(); + try { + Thread.sleep(ms); + } catch (InterruptedException x) { + // OK + } + } + @BeforeTest public void setup() throws Exception { sslContext = new SimpleSSLContext().get(); @@ -168,6 +183,8 @@ public void setup() throws Exception { @AfterTest public void teardown() { + sharedClient = null; + gc(100); httpTestServer.stop(0); httpsTestServer.stop(0); executor.shutdownNow(); diff --git a/test/jdk/java/net/httpclient/websocket/WebSocketProxyTest.java b/test/jdk/java/net/httpclient/websocket/WebSocketProxyTest.java index edc97636feb..405edd270a4 100644 --- a/test/jdk/java/net/httpclient/websocket/WebSocketProxyTest.java +++ b/test/jdk/java/net/httpclient/websocket/WebSocketProxyTest.java @@ -404,6 +404,8 @@ public void failBadCredentials() throws IOException { @BeforeMethod public void breakBetweenTests() { + System.gc(); + try {Thread.sleep(100); } catch (InterruptedException x) { /* OK */ } System.out.println("\n-------\n"); } } From 2c7e47e12b8a772bcebcdf0b15d6a4d3f92e2267 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Wed, 16 Jun 2021 18:03:48 +0000 Subject: [PATCH 003/258] 8268774: Residual logging output written to STDOUT, not STDERR Reviewed-by: prappo, hannesw --- .../jdk/javadoc/internal/tool/Start.java | 3 +- .../internal/tool/ToolEnvironment.java | 4 +- .../jdk/javadoc/tool/ToolProviderTest.java | 4 +- .../testLocaleOption/TestLocaleOption.java | 10 +- .../tool/testToolStreams/TestToolStreams.java | 122 ++++++++++++++++++ 5 files changed, 133 insertions(+), 10 deletions(-) create mode 100644 test/langtools/jdk/javadoc/tool/testToolStreams/TestToolStreams.java diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java index 4b2899969e8..307c5d6517e 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java @@ -560,7 +560,8 @@ private Result parseAndExecute(List argList, Iterable new Object[]{Path.of(m.getName())}); + } + + ToolBox tb = new ToolBox(); + + TestToolStreams() throws IOException { + tb.writeJavaFiles(Path.of("src"), + """ + package p1; + /** Comment 1. */ + public class C1 { }""", + """ + package p2; + /** Comment 2. */ + public class C2 { }"""); + } + + /** + * Tests the entry point used by the DocumentationTool API and JavadocTester, in which + * all output is written to a single specified writer. + */ + @Test + public void testSingleStream(Path base) { + test(base, false, Output.OUT, Output.OUT); + } + + /** + * Tests the entry point used by the launcher, in which output is written to + * writers that wrap {@code System.out} and {@code System.err}. + */ + @Test + public void testStandardStreams(Path base) { + test(base, true, Output.STDOUT, Output.STDERR); + } + + void test(Path base, boolean useStdStreams, Output stdOut, Output stdErr) { + setOutputDirectoryCheck(DirectoryCheck.NONE); + setUseStandardStreams(useStdStreams); + + javadoc("--help"); + checkExit(Exit.OK); + + if (stdOut != stdErr) { + checkIsEmpty(stdErr); + } + + checkOutput(stdOut, true, + "Usage:"); + + javadoc("-d", base.resolve("out").toString(), + "-sourcepath", "src", + "-verbose", // Note: triggers lots of javac messages as well as the javadoc time-taken message + "p1", + Path.of("src").resolve("p2").resolve("C2.java").toString()); + checkExit(Exit.OK); + + if (stdOut != stdErr) { + checkIsEmpty(stdOut); + } + + checkOutput(stdErr, true, + "Loading source file src/p2/C2.java...".replace("/", FS), + "Loading source files for package p1...", + "Constructing Javadoc information", + "[done in ", " ms]" + ); + } + + void checkIsEmpty(Output out) { + checking("no output to " + out); + String s = getOutput(out); + if (s.isEmpty()) { + passed("no output written to " + out); + } else { + failed(out + " is not empty"); + } + } +} \ No newline at end of file From 54f5ffeaad9da7cc77d9b6c0339758340c42ea2e Mon Sep 17 00:00:00 2001 From: Rajan Halade Date: Wed, 16 Jun 2021 18:53:37 +0000 Subject: [PATCH 004/258] 8259338: Add expiry exception for identrustdstx3 alias to VerifyCACerts.java test Backport-of: b836b83b2aefbc87b0cf26990ddbab4479c42b71 --- test/jdk/sun/security/lib/cacerts/VerifyCACerts.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java b/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java index 1e2368f7d3a..5cdf81f4aa4 100644 --- a/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java +++ b/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java @@ -268,6 +268,8 @@ public class VerifyCACerts { add("luxtrustglobalrootca [jdk]"); // Valid until: Wed Mar 17 11:33:33 PDT 2021 add("quovadisrootca [jdk]"); + // Valid until: Thu Sep 30 14:01:15 GMT 2021 + add("identrustdstx3 [jdk]"); } }; From f0f2178876813cca070db01ce37ea7a04b712923 Mon Sep 17 00:00:00 2001 From: "Daniel D. Daugherty" Date: Wed, 16 Jun 2021 19:19:00 +0000 Subject: [PATCH 005/258] 8268909: ProblemList jdk/jfr/api/consumer/streaming/TestLatestEvent.java on win-x64 Reviewed-by: mikael, dfuchs --- test/jdk/ProblemList.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index aae79cfabed..cf70e93d253 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -823,6 +823,7 @@ jdk/jfr/event/os/TestThreadContextSwitches.java 8247776 windows- jdk/jfr/startupargs/TestStartName.java 8214685 windows-x64 jdk/jfr/startupargs/TestStartDuration.java 8214685 windows-x64 jdk/jfr/event/gc/detailed/TestEvacuationFailedEvent.java 8263461 linux-x64 +jdk/jfr/api/consumer/streaming/TestLatestEvent.java 8268297 windows-x64 ############################################################################ From ee03bc6d0aad4b0d07bbe792c8cc77f986c617e1 Mon Sep 17 00:00:00 2001 From: Yasumasa Suenaga Date: Wed, 16 Jun 2021 23:21:51 +0000 Subject: [PATCH 006/258] 8268863: ProblemList serviceability/sa/TestJmapCoreMetaspace.java on linux-x64 with ZGC Reviewed-by: dcubed --- test/hotspot/jtreg/ProblemList-zgc.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/hotspot/jtreg/ProblemList-zgc.txt b/test/hotspot/jtreg/ProblemList-zgc.txt index d98da36e886..7c6cf795bcf 100644 --- a/test/hotspot/jtreg/ProblemList-zgc.txt +++ b/test/hotspot/jtreg/ProblemList-zgc.txt @@ -39,7 +39,7 @@ serviceability/sa/ClhsdbFindPC.java#id3 8268722 macosx-x serviceability/sa/ClhsdbPmap.java#id1 8268722 macosx-x64 serviceability/sa/ClhsdbPstack.java#id1 8268722 macosx-x64 serviceability/sa/TestJmapCore.java 8268722,8268283 macosx-x64,linux-aarch64 -serviceability/sa/TestJmapCoreMetaspace.java 8268722 macosx-x64 +serviceability/sa/TestJmapCoreMetaspace.java 8268722,8268636 macosx-x64,linux-x64 serviceability/dcmd/framework/HelpTest.java 8268433 windows-x64 serviceability/dcmd/framework/InvalidCommandTest.java 8268433 windows-x64 From 9f7851b5f5220132fce8556269851e33ac06ef31 Mon Sep 17 00:00:00 2001 From: David Holmes Date: Wed, 16 Jun 2021 23:58:24 +0000 Subject: [PATCH 007/258] 8260194: Update the documentation for -Xcheck:jni Reviewed-by: coleenp, hseigel --- src/java.base/share/man/java.1 | 68 +++++++++++++++++++++++++++++++--- 1 file changed, 62 insertions(+), 6 deletions(-) diff --git a/src/java.base/share/man/java.1 b/src/java.base/share/man/java.1 index 279068014ae..6c4d06f5222 100644 --- a/src/java.base/share/man/java.1 +++ b/src/java.base/share/man/java.1 @@ -794,13 +794,69 @@ list. .TP .B \f[CB]\-Xcheck:jni\f[R] Performs additional checks for Java Native Interface (JNI) functions. -Specifically, it validates the parameters passed to the JNI function and -the runtime environment data before processing the JNI request. -It also checks for pending exceptions between JNI calls. -Any invalid data encountered indicates a problem in the native code, and -the JVM terminates with an irrecoverable error in such cases. -Expect a performance degradation when this option is used. .RS +.PP +The following checks are considered indicative of significant problems +with the native code, and the JVM terminates with an irrecoverable error +in such cases: +.IP \[bu] 2 +The thread doing the call is not attached to the JVM. +.IP \[bu] 2 +The thread doing the call is using the \f[CB]JNIEnv\f[R] belonging to +another thread. +.IP \[bu] 2 +A parameter validation check fails: +.RS 2 +.IP \[bu] 2 +A \f[CB]jfieldID\f[R], or \f[CB]jmethodID\f[R], is detected as being +invalid. +For example: +.RS 2 +.IP \[bu] 2 +Of the wrong type +.IP \[bu] 2 +Associated with the wrong class +.RE +.IP \[bu] 2 +A parameter of the wrong type is detected. +.IP \[bu] 2 +An invalid parameter value is detected. +For example: +.RS 2 +.IP \[bu] 2 +NULL where not permitted +.IP \[bu] 2 +An out\-of\-bounds array index, or frame capacity +.IP \[bu] 2 +A non\-UTF\-8 string +.IP \[bu] 2 +An invalid JNI reference +.IP \[bu] 2 +An attempt to use a \f[CB]ReleaseXXX\f[R] function on a parameter not +produced by the corresponding \f[CB]GetXXX\f[R] function +.RE +.RE +.PP +The following checks only result in warnings being printed: +.IP \[bu] 2 +A JNI call was made without checking for a pending exception from a +previous JNI call, and the current call is not safe when an exception +may be pending. +.IP \[bu] 2 +The number of JNI local references existing when a JNI function +terminates exceeds the number guaranteed to be available. +See the \f[CB]EnsureLocalcapacity\f[R] function. +.IP \[bu] 2 +A class descriptor is in decorated format (\f[CB]Lname;\f[R]) when it +should not be. +.IP \[bu] 2 +A \f[CB]NULL\f[R] parameter is allowed, but its use is questionable. +.IP \[bu] 2 +Calling other JNI functions in the scope of +\f[CB]Get/ReleasePrimitiveArrayCritical\f[R] or +\f[CB]Get/ReleaseStringCritical\f[R] +.PP +Expect a performance degradation when this option is used. .RE .TP .B \f[CB]\-Xdebug\f[R] From 112ddb7633d8794d5c85e1b2cf0369ee2e0e349a Mon Sep 17 00:00:00 2001 From: Jie Fu Date: Thu, 17 Jun 2021 02:10:52 +0000 Subject: [PATCH 008/258] 8268641: [foreign] assert(allocates2(pc)) failed: not in CodeBuffer memory with ShenandoahGC Reviewed-by: rbackman, kvn --- src/hotspot/cpu/x86/universalUpcallHandler_x86_64.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hotspot/cpu/x86/universalUpcallHandler_x86_64.cpp b/src/hotspot/cpu/x86/universalUpcallHandler_x86_64.cpp index bbfaa87bcb8..30072e91aa9 100644 --- a/src/hotspot/cpu/x86/universalUpcallHandler_x86_64.cpp +++ b/src/hotspot/cpu/x86/universalUpcallHandler_x86_64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -585,7 +585,7 @@ address ProgrammableUpcallHandler::generate_optimized_upcall_stub(jobject receiv const ABIDescriptor abi = ForeignGlobals::parse_abi_descriptor(jabi); const CallRegs conv = ForeignGlobals::parse_call_regs(jconv); assert(conv._rets_length <= 1, "no multi reg returns"); - CodeBuffer buffer("upcall_stub_linkToNative", /* code_size = */ 1024, /* locs_size = */ 1024); + CodeBuffer buffer("upcall_stub_linkToNative", /* code_size = */ 2048, /* locs_size = */ 1024); int register_size = sizeof(uintptr_t); int buffer_alignment = xmm_reg_size; From 4c9aefdb6193f754bfac3ae022f08a76b0cae718 Mon Sep 17 00:00:00 2001 From: Eric Liu Date: Thu, 17 Jun 2021 02:47:00 +0000 Subject: [PATCH 009/258] 8268739: AArch64: Build failure after JDK-8267663 Reviewed-by: aph, dholmes --- .../cpu/aarch64/c2_MacroAssembler_aarch64.cpp | 45 ++++++++++++++++++- .../cpu/aarch64/c2_MacroAssembler_aarch64.hpp | 6 ++- .../cpu/aarch64/macroAssembler_aarch64.cpp | 43 ------------------ .../cpu/aarch64/macroAssembler_aarch64.hpp | 2 - 4 files changed, 49 insertions(+), 47 deletions(-) diff --git a/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp index fab8ff669b1..9da93c99680 100644 --- a/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,7 @@ #include "asm/assembler.inline.hpp" #include "opto/c2_MacroAssembler.hpp" #include "opto/intrinsicnode.hpp" +#include "opto/subnode.hpp" #include "runtime/stubRoutines.hpp" #ifdef PRODUCT @@ -832,3 +833,45 @@ void C2_MacroAssembler::string_compare(Register str1, Register str2, BLOCK_COMMENT("} string_compare"); } + +void C2_MacroAssembler::neon_compare(FloatRegister dst, BasicType bt, FloatRegister src1, + FloatRegister src2, int cond, bool isQ) { + SIMD_Arrangement size = esize2arrangement(type2aelembytes(bt), isQ); + if (bt == T_FLOAT || bt == T_DOUBLE) { + switch (cond) { + case BoolTest::eq: fcmeq(dst, size, src1, src2); break; + case BoolTest::ne: { + fcmeq(dst, size, src1, src2); + notr(dst, T16B, dst); + break; + } + case BoolTest::ge: fcmge(dst, size, src1, src2); break; + case BoolTest::gt: fcmgt(dst, size, src1, src2); break; + case BoolTest::le: fcmge(dst, size, src2, src1); break; + case BoolTest::lt: fcmgt(dst, size, src2, src1); break; + default: + assert(false, "unsupported"); + ShouldNotReachHere(); + } + } else { + switch (cond) { + case BoolTest::eq: cmeq(dst, size, src1, src2); break; + case BoolTest::ne: { + cmeq(dst, size, src1, src2); + notr(dst, T16B, dst); + break; + } + case BoolTest::ge: cmge(dst, size, src1, src2); break; + case BoolTest::gt: cmgt(dst, size, src1, src2); break; + case BoolTest::le: cmge(dst, size, src2, src1); break; + case BoolTest::lt: cmgt(dst, size, src2, src1); break; + case BoolTest::uge: cmhs(dst, size, src1, src2); break; + case BoolTest::ugt: cmhi(dst, size, src1, src2); break; + case BoolTest::ult: cmhi(dst, size, src2, src1); break; + case BoolTest::ule: cmhs(dst, size, src2, src1); break; + default: + assert(false, "unsupported"); + ShouldNotReachHere(); + } + } +} diff --git a/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.hpp b/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.hpp index b2f6226bf9e..d7d381116b2 100644 --- a/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.hpp +++ b/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -49,4 +49,8 @@ Register ch, Register result, Register tmp1, Register tmp2, Register tmp3); + // SIMD&FP comparison + void neon_compare(FloatRegister dst, BasicType bt, FloatRegister src1, + FloatRegister src2, int cond, bool isQ); + #endif // CPU_AARCH64_C2_MACROASSEMBLER_AARCH64_HPP diff --git a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp index 2ea457ed184..a0986200c87 100644 --- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp @@ -5339,49 +5339,6 @@ void MacroAssembler::safepoint_isb() { #endif } -void MacroAssembler::neon_compare(FloatRegister dst, BasicType bt, FloatRegister src1, - FloatRegister src2, int cond, bool isQ) { - SIMD_Arrangement size = esize2arrangement(type2aelembytes(bt), isQ); - if (bt == T_FLOAT || bt == T_DOUBLE) { - switch (cond) { - case BoolTest::eq: fcmeq(dst, size, src1, src2); break; - case BoolTest::ne: { - fcmeq(dst, size, src1, src2); - notr(dst, T16B, dst); - break; - } - case BoolTest::ge: fcmge(dst, size, src1, src2); break; - case BoolTest::gt: fcmgt(dst, size, src1, src2); break; - case BoolTest::le: fcmge(dst, size, src2, src1); break; - case BoolTest::lt: fcmgt(dst, size, src2, src1); break; - default: - assert(false, "unsupported"); - ShouldNotReachHere(); - } - } else { - switch (cond) { - case BoolTest::eq: cmeq(dst, size, src1, src2); break; - case BoolTest::ne: { - cmeq(dst, size, src1, src2); - notr(dst, T16B, dst); - break; - } - case BoolTest::ge: cmge(dst, size, src1, src2); break; - case BoolTest::gt: cmgt(dst, size, src1, src2); break; - case BoolTest::le: cmge(dst, size, src2, src1); break; - case BoolTest::lt: cmgt(dst, size, src2, src1); break; - case BoolTest::uge: cmhs(dst, size, src1, src2); break; - case BoolTest::ugt: cmhi(dst, size, src1, src2); break; - case BoolTest::ult: cmhi(dst, size, src2, src1); break; - case BoolTest::ule: cmhs(dst, size, src2, src1); break; - default: - assert(false, "unsupported"); - ShouldNotReachHere(); - } - } -} - - #ifndef PRODUCT void MacroAssembler::verify_cross_modify_fence_not_required() { if (VerifyCrossModifyFence) { diff --git a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp index db3006fe093..b70e197de98 100644 --- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp +++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp @@ -1058,8 +1058,6 @@ class MacroAssembler: public Assembler { bool acquire, bool release, bool weak, Register result); - // SIMD&FP comparison - void neon_compare(FloatRegister dst, BasicType bt, FloatRegister src1, FloatRegister src2, int cond, bool isQ); private: void compare_eq(Register rn, Register rm, enum operand_size size); From 344e3edf7602d8b788334bd103e9a63a8d74a6f8 Mon Sep 17 00:00:00 2001 From: Julia Boes Date: Thu, 17 Jun 2021 09:10:27 +0000 Subject: [PATCH 010/258] 8268080: java/util/concurrent/forkjoin/AsyncShutdownNow.java fails with java.util.concurrent.RejectedExecutionException Co-authored-by: Doug Lea Reviewed-by: chegar, dfuchs --- .../java/util/concurrent/forkjoin/AsyncShutdownNow.java | 9 +++++---- .../concurrent/forkjoin/AsyncShutdownNowInvokeAny.java | 5 +++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/test/jdk/java/util/concurrent/forkjoin/AsyncShutdownNow.java b/test/jdk/java/util/concurrent/forkjoin/AsyncShutdownNow.java index 7ae3a0a6853..68753d78836 100644 --- a/test/jdk/java/util/concurrent/forkjoin/AsyncShutdownNow.java +++ b/test/jdk/java/util/concurrent/forkjoin/AsyncShutdownNow.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,6 +38,7 @@ import java.util.concurrent.Executors; import java.util.concurrent.ForkJoinPool; import java.util.concurrent.Future; +import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; @@ -102,7 +103,7 @@ public void testFutureGet(ExecutorService executor) throws Exception { try { future.get(); assertTrue(false); - } catch (ExecutionException e) { + } catch (ExecutionException | RejectedExecutionException e) { // expected } } finally { @@ -123,7 +124,7 @@ public void testTimedFutureGet(ExecutorService executor) throws Exception { try { future.get(1, TimeUnit.HOURS); assertTrue(false); - } catch (ExecutionException e) { + } catch (ExecutionException | RejectedExecutionException e) { // expected } } finally { @@ -167,7 +168,7 @@ public void testInvokeAny(ExecutorService executor) throws Exception { // execute long running tasks executor.invokeAny(List.of(SLEEP_FOR_A_DAY, SLEEP_FOR_A_DAY)); assertTrue(false); - } catch (ExecutionException e) { + } catch (ExecutionException | RejectedExecutionException e) { // expected } } finally { diff --git a/test/jdk/java/util/concurrent/forkjoin/AsyncShutdownNowInvokeAny.java b/test/jdk/java/util/concurrent/forkjoin/AsyncShutdownNowInvokeAny.java index 4b1f2eccfe2..12afb6b2d49 100644 --- a/test/jdk/java/util/concurrent/forkjoin/AsyncShutdownNowInvokeAny.java +++ b/test/jdk/java/util/concurrent/forkjoin/AsyncShutdownNowInvokeAny.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,6 +36,7 @@ import java.util.concurrent.Executors; import java.util.concurrent.ForkJoinPool; import java.util.concurrent.Future; +import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; @@ -89,7 +90,7 @@ public void testInvokeAny() throws Exception { // execute long running tasks pool.invokeAny(List.of(SLEEP_FOR_A_DAY, SLEEP_FOR_A_DAY)); assertTrue(false); - } catch (ExecutionException e) { + } catch (ExecutionException | RejectedExecutionException e) { // expected } } finally { From 7d7bdbe135018f1452fa133b294575014e3e871b Mon Sep 17 00:00:00 2001 From: Patrick Concannon Date: Thu, 17 Jun 2021 09:35:08 +0000 Subject: [PATCH 011/258] 8268776: Test `ADatagramSocket.java` missing /othervm from @run tag Reviewed-by: dfuchs --- .../SetDatagramSocketImplFactory/ADatagramSocket.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/jdk/java/net/DatagramSocket/SetDatagramSocketImplFactory/ADatagramSocket.java b/test/jdk/java/net/DatagramSocket/SetDatagramSocketImplFactory/ADatagramSocket.java index 22005165b88..6be863782a0 100644 --- a/test/jdk/java/net/DatagramSocket/SetDatagramSocketImplFactory/ADatagramSocket.java +++ b/test/jdk/java/net/DatagramSocket/SetDatagramSocketImplFactory/ADatagramSocket.java @@ -26,7 +26,7 @@ * @summary DatagramSocket should use a factory for its impl * * @compile/module=java.base java/net/MyDatagramSocketImplFactory.java - * @run main ADatagramSocket + * @run main/othervm ADatagramSocket */ import java.io.*; import java.net.*; From 69d01b6bcabda177f5e27f6c7b141be57cd00619 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Thu, 17 Jun 2021 14:09:11 +0000 Subject: [PATCH 012/258] 8249899: jdk/javadoc/tool/InlineTagsWithBraces.java uses @ignore w/o bug-id 8249897: jdk/javadoc/tool/LangVers.java uses @ignore w/o bug-id 8249898: jdk/javadoc/tool/6176978/T6176978.java uses @ignore w/o bug-id Reviewed-by: hannesw --- .../jdk/javadoc/tool/6176978/T6176978.java | 81 ------------- .../langtools/jdk/javadoc/tool/6176978/X.java | 44 ------- .../javadoc/tool/InlineTagsWithBraces.java | 112 ------------------ test/langtools/jdk/javadoc/tool/LangVers.java | 96 --------------- 4 files changed, 333 deletions(-) delete mode 100644 test/langtools/jdk/javadoc/tool/6176978/T6176978.java delete mode 100644 test/langtools/jdk/javadoc/tool/6176978/X.java delete mode 100644 test/langtools/jdk/javadoc/tool/InlineTagsWithBraces.java delete mode 100644 test/langtools/jdk/javadoc/tool/LangVers.java diff --git a/test/langtools/jdk/javadoc/tool/6176978/T6176978.java b/test/langtools/jdk/javadoc/tool/6176978/T6176978.java deleted file mode 100644 index ca504eea62a..00000000000 --- a/test/langtools/jdk/javadoc/tool/6176978/T6176978.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 6176978 - * @summary current Javadoc's invocation and extension (Doclet) mechanisms are problematic - * @modules jdk.javadoc - * @ignore no longer applicable, should delete - * @build T6176978 - * @run main T6176978 - */ - -import java.io.*; -import java.net.*; - -public class T6176978 -{ - public static void main(String[] args) throws Exception { - // create and use a temp dir that will not be on jtreg's - // default class path - File tmpDir = new File("tmp"); - tmpDir.mkdirs(); - - File testSrc = new File(System.getProperty("test.src", ".")); - String[] javac_args = { - "-d", - "tmp", - new File(testSrc, "X.java").getPath() - }; - - int rc = com.sun.tools.javac.Main.compile(javac_args); - if (rc != 0) - throw new Error("javac exit code: " + rc); - - String[] jdoc_args = { - "-doclet", - "X", - new File(testSrc, "T6176978.java").getPath() - }; - - rc = jdk.javadoc.internal.tool.Main.execute(jdoc_args); - if (rc == 0) - throw new Error("javadoc unexpectedly succeeded"); - - - - Thread currThread = Thread.currentThread(); - ClassLoader saveClassLoader = currThread.getContextClassLoader(); - URLClassLoader urlCL = new URLClassLoader(new URL[] { tmpDir.toURL() }); - currThread.setContextClassLoader(urlCL); - - try { - rc = jdk.javadoc.internal.tool.Main.execute(jdoc_args); - if (rc != 0) - throw new Error("javadoc exit: " + rc); - } finally { - currThread.setContextClassLoader(saveClassLoader); - } - } -} diff --git a/test/langtools/jdk/javadoc/tool/6176978/X.java b/test/langtools/jdk/javadoc/tool/6176978/X.java deleted file mode 100644 index ddbb36f84f8..00000000000 --- a/test/langtools/jdk/javadoc/tool/6176978/X.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -import java.util.Collections; -import java.util.Locale; -import java.util.Set; - -import jdk.javadoc.doclet.Doclet; -import jdk.javadoc.doclet.Reporter; -import jdk.javadoc.doclet.DocletEnvironment; - -public class X { - public static boolean run(DocletEnvironment root) { - System.out.println("X.start"); - return true; - } - public Set getSupportedOptions() { - return Collections.emptySet(); - } - - public void init(Locale locale, Reporter reporter) { - return; - } -} diff --git a/test/langtools/jdk/javadoc/tool/InlineTagsWithBraces.java b/test/langtools/jdk/javadoc/tool/InlineTagsWithBraces.java deleted file mode 100644 index 1670d257710..00000000000 --- a/test/langtools/jdk/javadoc/tool/InlineTagsWithBraces.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 4965490 - * @summary Verify that matching braces can appear within inline tags. - * @ignore API, re-evaluate @bold, @maybe causes doclint to throw up. - * @modules jdk.javadoc - */ - -import java.io.File; -import java.util.Collections; -import java.util.List; -import java.util.Set; - -import javax.lang.model.SourceVersion; -import javax.lang.model.element.TypeElement; - -import com.sun.source.doctree.DocCommentTree; -import com.sun.source.doctree.DocTree; -import com.sun.source.util.DocTrees; -import jdk.javadoc.doclet.Doclet; -import jdk.javadoc.doclet.DocletEnvironment; - -/** - * This is a {@code test} comment. - * It is {@bold {@underline only} a test}. - * We would like some code - * {@code for (int i : nums) { doit(i); } return; } - * to be embedded {@maybe {even {a couple {of levels}}} deep}. - */ -public class InlineTagsWithBraces implements Doclet { - - private static String[] expectedTags = { - "Text", "@code", "Text", - "@bold", "Text", "@code", "Text", - "@maybe", "Text" - }; - private static String[] expectedText = { - "This is a ", "test", " comment.\n" + - " It is ", "{@underline only} a test", ".\n" + - " We would like some code\n" + - " ", "for (int i : nums) { doit(i); } return; ", "\n" + - " to be embedded ", "{even {a couple {of levels}}} deep", "." - }; - - public static void main(String[] args) { - String thisFile = "" + - new File(System.getProperty("test.src", "."), "InlineTagsWithBraces.java"); - - String[] argarray = { - "InlineTagsWithBraces", - "-Xwerror", - thisFile - }; - if (jdk.javadoc.internal.tool.Main.execute(argarray) != 0) - throw new Error("Javadoc encountered warnings or errors."); - } - - public boolean run(DocletEnvironment root) { - DocTrees trees = root.getDocTrees(); - TypeElement cd = ElementFilter.typesIn(root.getIncludedElements()).iterator().next(); - DocCommentTree docCommentTree = trees.getDocCommentTree(cd); - List tags = docCommentTree.getBody(); - - for (int i = 0; i < tags.size(); i++) { - System.out.println(tags.get(0).getKind()); -// if (!tags[i].name().equals(expectedTags[i]) || -// !tags[i].text().equals(expectedText[i])) { -// throw new Error("Tag \"" + tags[i] + "\" not as expected"); -// } - } - - return true; - } - - @Override - public String getName() { - return "Test"; - } - - @Override - public Set