diff --git a/test/jdk/java/net/Socket/SocketImplTest.java b/test/jdk/java/net/Socket/SocketImplTest.java deleted file mode 100644 index 28f49b26183..00000000000 --- a/test/jdk/java/net/Socket/SocketImplTest.java +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Copyright (c) 2002, 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.applet.Applet; -import java.io.*; -import java.net.*; - -/** - * Simple Applet for exposing the Socket constructor - * bug. - */ -public class SocketImplTest extends Applet { - - static public void main(String[] args) { - System.setSecurityManager(new SecurityManager()); - SocketImplTest s = new SocketImplTest(); - s.init(); - s.start(); - } - - - /** - * A no-op SocketImpl descendant. - */ - class MySocketImpl extends SocketImpl { - protected void accept(SocketImpl impl) throws IOException { - } - - protected int available(){ - return 0; - } - - protected void bind(InetAddress host, int port){ - } - - protected void close(){ - } - - protected void connect(InetAddress address, int port){ - } - - protected void connect(String host, int port){ - } - - protected void connect(SocketAddress a, int t) throws IOException { - } - - - protected void create(boolean stream){ - } - - protected InputStream getInputStream(){ - return null; - } - - protected OutputStream getOutputStream(){ - return null; - } - - protected void listen(int backlog){ - } - - public Object getOption(int optID){ - return null; - } - - public void setOption(int optID, Object value){ - } - - protected void sendUrgentData(int i){ - } - } - - class MyDatagramSocketImpl extends DatagramSocketImpl { - protected void create() throws SocketException { - } - - protected void bind(int lport, InetAddress laddr) throws SocketException { - } - - protected void send(DatagramPacket p) throws IOException { - } - - protected int peek(InetAddress i) throws IOException { - return 0; - } - - protected int peekData(DatagramPacket p) throws IOException { - return 0; - } - - protected void receive(DatagramPacket p) throws IOException { - } - - protected void setTTL(byte ttl) throws IOException { - } - - protected byte getTTL() throws IOException { - return 0; - } - - protected void setTimeToLive(int ttl) throws IOException { - } - - protected int getTimeToLive() throws IOException { - return 0; - } - - protected void join(InetAddress inetaddr) throws IOException { - } - - protected void leave(InetAddress inetaddr) throws IOException { - } - - protected void joinGroup(SocketAddress mcastaddr, NetworkInterface netIf) - throws IOException { - } - - protected void leaveGroup(SocketAddress mcastaddr, NetworkInterface netIf) - throws IOException { - } - - protected void close() { - } - - public Object getOption(int optID){ - return null; - } - - public void setOption(int optID, Object value){ - } - - } - - /** - * A no-op Socket descendant. - */ - class MySocket extends Socket { - public MySocket(SocketImpl impl) throws IOException { - super(impl); - } - } - - class MyDatagramSocket extends DatagramSocket { - public MyDatagramSocket(DatagramSocketImpl impl) { - super(impl); - } - } - - /** - * Our test case entrypoint. Generates - * a SecurityException. - */ - public void init(){ - MySocketImpl socketImpl = new MySocketImpl(); - MyDatagramSocketImpl dgramSocketImpl = new MyDatagramSocketImpl(); - - try{ - MySocket socko = new MySocket(socketImpl); - MyDatagramSocket dsock = new MyDatagramSocket(dgramSocketImpl); - } catch(IOException ioex){ - System.err.println(ioex); - } catch(SecurityException sec) { - throw new RuntimeException("Failed. Creation of socket throwing SecurityException: "); - } - } -} diff --git a/test/jdk/java/util/TimeZone/DefaultTimeZoneTest.html b/test/jdk/java/util/TimeZone/DefaultTimeZoneTest.html deleted file mode 100644 index 1fa0659ed63..00000000000 --- a/test/jdk/java/util/TimeZone/DefaultTimeZoneTest.html +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - Disable Auto-adjust Daylight Saving Time Test - - - -This applet tests the platform time zone detection on all platforms (Part I) -and on/off of DST adjustment on Windows (Part II). - -Part I: - -Observe the displayed Time zone ID and the local time. If you can change -the platform time zone setting, try several time zones. If both the ID and -the local time, including the time zone name and its time zone offset, are -always correct, Part I passes. Note that some time zone IDs have their -aliases that may be displayed. For example, "US/Pacific" is an alias of -"America/Los_Angeles". - -If you are running this applet in non-English locale, the time zone names -can be displayed in the local language and English by pushing the -English/Local button. - -If platform time zones are NOT detected correctly, press the Fail button -to finish this applet. - -If this platform is Windows, proceed to Part II. Otherwise, press the Pass -button to finish this applet. - -Part II: - -Note that Part II may require the Administrator privilege to change -Windows setting. - - 1. Open the Date and Time control panel. - 2. Select any time zone where daylight saving time is *currently* in effect, - such as "(GMT-08:00) Pacific Time (US & Canada); Tijuana", - "(GMT+10:00) Canberra, Melbourne, Sydney", and Apply. - 3. Observe the local time on the control panel (Date&Time pane) and - the applet local time should be the same (daylight time). - 4. Clear "Automatically adjust clock for daylight saving changes" and Apply. - 5. Observe the two local times should be the same (standard time). - 6. Select "Automatically adjust clock for daylight saving changes" and Apply. - -If the local time in the control panel and applet are always the same, -then this test passes. Press the Pass or Fail button based on the Part II -result and finish this applet. - - - - diff --git a/test/jdk/java/util/TimeZone/DefaultTimeZoneTest.java b/test/jdk/java/util/TimeZone/DefaultTimeZoneTest.java index a6d3ac50866..4dd644d58b5 100644 --- a/test/jdk/java/util/TimeZone/DefaultTimeZoneTest.java +++ b/test/jdk/java/util/TimeZone/DefaultTimeZoneTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, 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 @@ -24,85 +24,94 @@ /* * @test * @bug 4296930 5033603 7092679 - * @summary Make sure that Java runtime detects the platform time zone - * correctly. Also make sure that the system time zone detection code - * detects the "Automatically adjust clock for daylight saving - * changes" setting correctly on Windows. - * @run applet/manual=yesno DefaultTimeZoneTest.html + * @summary Ensure that Java detects the platform time zone correctly, even + * if changed during runtime. Also ensure that the system time zone detection code + * detects the "Automatically adjust clock for daylight saving changes" setting + * correctly on Windows. This is a manual test dependent on making changes to + * the platform setting of the machine and thus cannot be automated. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual DefaultTimeZoneTest */ -import javax.swing.*; -import java.awt.*; -import java.awt.event.*; -import java.text.*; -import java.util.*; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Window; +import java.lang.reflect.InvocationTargetException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.TimeZone; -public class DefaultTimeZoneTest extends JApplet implements Runnable { - static final String FORMAT = "yyyy-MM-dd HH:mm:ss zzzz (XXX)"; - JLabel tzid; - JLabel label; - SimpleDateFormat sdf = new SimpleDateFormat(FORMAT); - JButton button = new JButton("English"); - Thread clock; - boolean english = false; +public class DefaultTimeZoneTest { - @Override - public void init() { - tzid = new JLabel("Time zone ID: " + sdf.getTimeZone().getID(), SwingConstants.CENTER); - tzid.setAlignmentX(Component.CENTER_ALIGNMENT); - label = new JLabel(sdf.format(new Date()), SwingConstants.CENTER); - label.setAlignmentX(Component.CENTER_ALIGNMENT); - button.addActionListener(new ActionListener() { - @Override - @SuppressWarnings("deprecation") - public void actionPerformed(ActionEvent e) { - english = (english == false); - Locale loc = english ? Locale.US : Locale.getDefault(); - sdf = new SimpleDateFormat(FORMAT, loc); - button.setLabel(!english ? "English" : "Local"); - } - }); - button.setAlignmentX(Component.CENTER_ALIGNMENT); - JPanel panel = new JPanel(); - panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS)); - panel.add(Box.createRigidArea(new Dimension(0, 10))); - panel.add(tzid); - panel.add(Box.createRigidArea(new Dimension(0, 5))); - panel.add(label); - panel.add(Box.createRigidArea(new Dimension(0, 10))); + private static final SimpleDateFormat SDF = + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss zzzz (XXX)"); + private static final String INSTRUCTIONS = + """ + Tests the platform time zone detection on all platforms. + (Part I) and on/off of DST adjustment on Windows (Part II). + + Part I: + Observe the displayed Time zone ID and the local time. + Change the platform time zone setting, then click the + "Update Time Zone" button. If the ID and local time + update correctly, part I passes, otherwise press fail. Note that + some time zone IDs have their aliases that may be displayed. + For example, "US/Pacific" is an alias of "America/Los_Angeles". + If this platform is Windows, proceed to Part II. Otherwise, press + the Pass button to complete this test. + + Part II: + Note that Part II may require the Administrator privilege to change + Windows setting. + + 1. Open the Settings app and navigate to Time & Language > Date & Time + 2. Select any time zone where daylight saving time is *currently* + in effect, such as "(GMT-08:00) Pacific Time (US & Canada); + Tijuana", "(GMT+10:00) Canberra, Melbourne, Sydney", and Apply. + 3. After pressing "Update Time Zone" button, observe that the local + time on the Settings app and the test local time are the same (daylight time). + 4. Turn off "Adjust for daylight saving time automatically" + 5. Observe the two local times should be the same (standard time). + 6. Turn on "Adjust for daylight saving time automatically" + + If the local time in the Settings app and test window are always the same, + then this test passes. Press the Pass or Fail button based on the Part II + result and complete the test. + """; + + public static void main(String[] args) + throws InterruptedException, InvocationTargetException { + // Force platform time zone as default time zone + TimeZone.setDefault(null); + System.setProperty("user.timezone", ""); + // Construct test window + PassFailJFrame.builder() + .title("DefaultTimeZoneTest Instructions") + .testUI(createTest()) + .instructions(INSTRUCTIONS) + .build().awaitAndCheck(); + } + + private static Window createTest() { + var contents = new JFrame("DefaultTimeZoneTest"); + var label = new JLabel(SDF.format(new Date())); + var panel = new JPanel(); + var button = new JButton("Update Time Zone"); panel.add(button); - getContentPane().add(panel); - } - - @Override - public void start() { - clock = new Thread(this); - clock.start(); - } - - @Override - public void stop() { - clock = null; - } - - @Override - public void run() { - Thread me = Thread.currentThread(); - - while (clock == me) { - // Reset the default time zone so that - // TimeZone.getDefault will detect the platform time zone - TimeZone.setDefault(null); - System.setProperty("user.timezone", ""); + contents.setSize(350, 250); + contents.add(label, BorderLayout.NORTH); + contents.add(panel, BorderLayout.CENTER); + // Update default time zone on button click + button.addActionListener(e -> { TimeZone tz = TimeZone.getDefault(); - sdf.setTimeZone(tz); - tzid.setText("Time zone ID: " + tz.getID()); - label.setText(sdf.format(new Date())); - repaint(); - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - } - } + SDF.setTimeZone(tz); + label.setText(SDF.format(new Date())); + contents.repaint(); + }); + return contents; } } diff --git a/test/jdk/java/util/logging/TestMainAppContext.java b/test/jdk/java/util/logging/TestMainAppContext.java index 49f371aa321..0bfcbbad9d8 100644 --- a/test/jdk/java/util/logging/TestMainAppContext.java +++ b/test/jdk/java/util/logging/TestMainAppContext.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2024, 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 @@ -46,8 +46,8 @@ public class TestMainAppContext { rootTG = rootTG.getParent(); } - ThreadGroup tg = new ThreadGroup(rootTG, "FakeApplet"); - final Thread t1 = new Thread(tg, "createNewAppContext") { + ThreadGroup tg = new ThreadGroup(rootTG, "main"); + final Thread t1 = new Thread(tg, "child") { @Override public void run() { try { diff --git a/test/jdk/jdk/internal/loader/URLClassPath/ClassnameCharTest.java b/test/jdk/jdk/internal/loader/URLClassPath/ClassnameCharTest.java index 9e14957ef62..85987ef6f5e 100644 --- a/test/jdk/jdk/internal/loader/URLClassPath/ClassnameCharTest.java +++ b/test/jdk/jdk/internal/loader/URLClassPath/ClassnameCharTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2024, 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 @@ -95,9 +95,9 @@ public class ClassnameCharTest { server.stop(0); } } - // the class loader code was copied from the now deleted AppletClassLoader + static class MyURLClassLoader extends URLClassLoader { - private URL base; /* applet code base URL */ + private URL base; /* code base URL */ private CodeSource codesource; /* codesource for the base URL */ private AccessControlContext acc; MyURLClassLoader(URL base) { diff --git a/test/jdk/sun/net/www/ParseUtil_6380332.java b/test/jdk/sun/net/www/ParseUtil_6380332.java index a517742f2c4..bd0331d52bd 100644 --- a/test/jdk/sun/net/www/ParseUtil_6380332.java +++ b/test/jdk/sun/net/www/ParseUtil_6380332.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2024, 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 @@ -22,12 +22,13 @@ */ /* @test - * @summary SunTea applet fails to load under Mustang + * @summary Ensure ParseUtil.toURI does not fail when port number is -1 * @bug 6380332 * @modules java.base/sun.net.www */ import sun.net.www.ParseUtil; + import java.net.URI; import java.net.URL; diff --git a/test/jdk/sun/net/www/protocol/http/B6296310.java b/test/jdk/sun/net/www/protocol/http/B6296310.java index dbb3ead18c5..867b4edaf32 100644 --- a/test/jdk/sun/net/www/protocol/http/B6296310.java +++ b/test/jdk/sun/net/www/protocol/http/B6296310.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, 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,7 +27,8 @@ * @library /test/lib * @run main/othervm B6296310 * @run main/othervm -Djava.net.preferIPv6Addresses=true B6296310 - * @summary REGRESSION: AppletClassLoader.getResourceAsStream() behaviour is wrong in some cases + * @summary Prevent NPE in HttpURLConnection.getInputStream0() when + * content length is 0 */ import java.io.IOException; diff --git a/test/jdk/sun/net/www/protocol/http/ResponseCacheStream.java b/test/jdk/sun/net/www/protocol/http/ResponseCacheStream.java index 841279fa76d..2fba6d8ab75 100644 --- a/test/jdk/sun/net/www/protocol/http/ResponseCacheStream.java +++ b/test/jdk/sun/net/www/protocol/http/ResponseCacheStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, 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 @@ -26,7 +26,7 @@ * @bug 6262486 * @library /test/lib * @run main/othervm -Dhttp.keepAlive=false ResponseCacheStream - * @summary COMPATIBILITY: jagex_com - Monkey Puzzle applet fails to load + * @summary Ensure HttpInputStream resets properly when cache is in use */ import java.io.ByteArrayOutputStream; diff --git a/test/jdk/sun/rmi/transport/tcp/disableMultiplexing/DisableMultiplexing.java b/test/jdk/sun/rmi/transport/tcp/disableMultiplexing/DisableMultiplexing.java index 4a8748ab253..253f166cae4 100644 --- a/test/jdk/sun/rmi/transport/tcp/disableMultiplexing/DisableMultiplexing.java +++ b/test/jdk/sun/rmi/transport/tcp/disableMultiplexing/DisableMultiplexing.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, 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 @@ -24,7 +24,7 @@ /* @test * @bug 4183204 * @summary The RMI runtime should fail to export a remote object on a TCP - * port for an applet or application that does not have permission to listen + * port for an application that does not have permission to listen * on that port, rather than engage in the deprecated "multiplexing protocol". * @author Peter Jones * diff --git a/test/jdk/tools/launcher/HelpFlagsTest.java b/test/jdk/tools/launcher/HelpFlagsTest.java index 15c6c101dd0..0e8bc345ddc 100644 --- a/test/jdk/tools/launcher/HelpFlagsTest.java +++ b/test/jdk/tools/launcher/HelpFlagsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, 2020 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -45,7 +45,6 @@ public class HelpFlagsTest extends TestHelper { // Tools that should not be tested because a usage message is pointless. static final String[] TOOLS_NOT_TO_TEST = { - "appletviewer", // deprecated, don't test "jaccessinspector", // gui, don't test, win only "jaccessinspector-32", // gui, don't test, win-32 only "jaccesswalker", // gui, don't test, win only diff --git a/test/jdk/tools/launcher/VersionCheck.java b/test/jdk/tools/launcher/VersionCheck.java index 8ce636c4af7..539af8698d4 100644 --- a/test/jdk/tools/launcher/VersionCheck.java +++ b/test/jdk/tools/launcher/VersionCheck.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ -67,7 +67,6 @@ public class VersionCheck extends TestHelper { // tools that do not accept -version static final String[] BLACKLIST_VERSION = { - "appletviewer", "controlpanel", "jaccessinspector", "jaccessinspector-32",