8340326: Remove references to Applet in core-libs/security tests

Reviewed-by: prr, naoto, dfuchs
This commit is contained in:
Justin Lu 2024-10-04 17:34:08 +00:00
parent f5f0852f51
commit 2e5b420f81
11 changed files with 102 additions and 353 deletions

View File

@ -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: ");
}
}
}

View File

@ -1,74 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!--
Copyright (c) 2005, 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.
-->
<!---->
<html>
<head>
<title>Disable Auto-adjust Daylight Saving Time Test</title>
</head>
<body>
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.
<applet code="DefaultTimeZoneTest.class" width=500 height=90></applet>
</body>
</html>

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -24,85 +24,94 @@
/* /*
* @test * @test
* @bug 4296930 5033603 7092679 * @bug 4296930 5033603 7092679
* @summary Make sure that Java runtime detects the platform time zone * @summary Ensure that Java detects the platform time zone correctly, even
* correctly. Also make sure that the system time zone detection code * if changed during runtime. Also ensure that the system time zone detection code
* detects the "Automatically adjust clock for daylight saving * detects the "Automatically adjust clock for daylight saving changes" setting
* changes" setting correctly on Windows. * correctly on Windows. This is a manual test dependent on making changes to
* @run applet/manual=yesno DefaultTimeZoneTest.html * 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 javax.swing.JButton;
import java.awt.*; import javax.swing.JFrame;
import java.awt.event.*; import javax.swing.JLabel;
import java.text.*; import javax.swing.JPanel;
import java.util.*; 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 { public class DefaultTimeZoneTest {
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;
@Override private static final SimpleDateFormat SDF =
public void init() { new SimpleDateFormat("yyyy-MM-dd HH:mm:ss zzzz (XXX)");
tzid = new JLabel("Time zone ID: " + sdf.getTimeZone().getID(), SwingConstants.CENTER); private static final String INSTRUCTIONS =
tzid.setAlignmentX(Component.CENTER_ALIGNMENT); """
label = new JLabel(sdf.format(new Date()), SwingConstants.CENTER); Tests the platform time zone detection on all platforms.
label.setAlignmentX(Component.CENTER_ALIGNMENT); (Part I) and on/off of DST adjustment on Windows (Part II).
button.addActionListener(new ActionListener() {
@Override Part I:
@SuppressWarnings("deprecation") Observe the displayed Time zone ID and the local time.
public void actionPerformed(ActionEvent e) { Change the platform time zone setting, then click the
english = (english == false); "Update Time Zone" button. If the ID and local time
Locale loc = english ? Locale.US : Locale.getDefault(); update correctly, part I passes, otherwise press fail. Note that
sdf = new SimpleDateFormat(FORMAT, loc); some time zone IDs have their aliases that may be displayed.
button.setLabel(!english ? "English" : "Local"); 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.
button.setAlignmentX(Component.CENTER_ALIGNMENT);
JPanel panel = new JPanel(); Part II:
panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS)); Note that Part II may require the Administrator privilege to change
panel.add(Box.createRigidArea(new Dimension(0, 10))); Windows setting.
panel.add(tzid);
panel.add(Box.createRigidArea(new Dimension(0, 5))); 1. Open the Settings app and navigate to Time & Language > Date & Time
panel.add(label); 2. Select any time zone where daylight saving time is *currently*
panel.add(Box.createRigidArea(new Dimension(0, 10))); 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); panel.add(button);
getContentPane().add(panel); contents.setSize(350, 250);
} contents.add(label, BorderLayout.NORTH);
contents.add(panel, BorderLayout.CENTER);
@Override // Update default time zone on button click
public void start() { button.addActionListener(e -> {
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", "");
TimeZone tz = TimeZone.getDefault(); TimeZone tz = TimeZone.getDefault();
sdf.setTimeZone(tz); SDF.setTimeZone(tz);
tzid.setText("Time zone ID: " + tz.getID()); label.setText(SDF.format(new Date()));
label.setText(sdf.format(new Date())); contents.repaint();
repaint(); });
try { return contents;
Thread.sleep(1000);
} catch (InterruptedException e) {
}
}
} }
} }

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -46,8 +46,8 @@ public class TestMainAppContext {
rootTG = rootTG.getParent(); rootTG = rootTG.getParent();
} }
ThreadGroup tg = new ThreadGroup(rootTG, "FakeApplet"); ThreadGroup tg = new ThreadGroup(rootTG, "main");
final Thread t1 = new Thread(tg, "createNewAppContext") { final Thread t1 = new Thread(tg, "child") {
@Override @Override
public void run() { public void run() {
try { try {

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -95,9 +95,9 @@ public class ClassnameCharTest {
server.stop(0); server.stop(0);
} }
} }
// the class loader code was copied from the now deleted AppletClassLoader
static class MyURLClassLoader extends URLClassLoader { 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 CodeSource codesource; /* codesource for the base URL */
private AccessControlContext acc; private AccessControlContext acc;
MyURLClassLoader(URL base) { MyURLClassLoader(URL base) {

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -22,12 +22,13 @@
*/ */
/* @test /* @test
* @summary SunTea applet fails to load under Mustang * @summary Ensure ParseUtil.toURI does not fail when port number is -1
* @bug 6380332 * @bug 6380332
* @modules java.base/sun.net.www * @modules java.base/sun.net.www
*/ */
import sun.net.www.ParseUtil; import sun.net.www.ParseUtil;
import java.net.URI; import java.net.URI;
import java.net.URL; import java.net.URL;

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -27,7 +27,8 @@
* @library /test/lib * @library /test/lib
* @run main/othervm B6296310 * @run main/othervm B6296310
* @run main/othervm -Djava.net.preferIPv6Addresses=true 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; import java.io.IOException;

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -26,7 +26,7 @@
* @bug 6262486 * @bug 6262486
* @library /test/lib * @library /test/lib
* @run main/othervm -Dhttp.keepAlive=false ResponseCacheStream * @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; import java.io.ByteArrayOutputStream;

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -24,7 +24,7 @@
/* @test /* @test
* @bug 4183204 * @bug 4183204
* @summary The RMI runtime should fail to export a remote object on a TCP * @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". * on that port, rather than engage in the deprecated "multiplexing protocol".
* @author Peter Jones * @author Peter Jones
* *

View File

@ -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. * Copyright (c) 2018, 2020 SAP SE. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * 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. // Tools that should not be tested because a usage message is pointless.
static final String[] TOOLS_NOT_TO_TEST = { static final String[] TOOLS_NOT_TO_TEST = {
"appletviewer", // deprecated, don't test
"jaccessinspector", // gui, don't test, win only "jaccessinspector", // gui, don't test, win only
"jaccessinspector-32", // gui, don't test, win-32 only "jaccessinspector-32", // gui, don't test, win-32 only
"jaccesswalker", // gui, don't test, win only "jaccesswalker", // gui, don't test, win only

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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 // tools that do not accept -version
static final String[] BLACKLIST_VERSION = { static final String[] BLACKLIST_VERSION = {
"appletviewer",
"controlpanel", "controlpanel",
"jaccessinspector", "jaccessinspector",
"jaccessinspector-32", "jaccessinspector-32",