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.
*
* 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)));
panel.add(button);
getContentPane().add(panel);
}
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).
@Override
public void start() {
clock = new Thread(this);
clock.start();
}
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.
@Override
public void stop() {
clock = null;
}
Part II:
Note that Part II may require the Administrator privilege to change
Windows setting.
@Override
public void run() {
Thread me = Thread.currentThread();
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"
while (clock == me) {
// Reset the default time zone so that
// TimeZone.getDefault will detect the platform time zone
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);
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;
}
}

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.
*
* 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 {

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.
*
* 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) {

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.
*
* 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;

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.
*
* 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;

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.
*
* 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;

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.
*
* 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
*

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.
* 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

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.
*
* 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",