8042872: Fix raw and unchecked warnings in sun.applet

Reviewed-by: darcy, herrick
This commit is contained in:
Henry Jen 2014-06-23 10:54:10 -07:00
parent be41c05edc
commit f5a99dfd8f
10 changed files with 138 additions and 129 deletions

View File

@ -137,7 +137,7 @@ public class AppletClassLoader extends URLClassLoader {
* Override loadClass so that class loading errors can be caught in
* order to print better error messages.
*/
public synchronized Class loadClass(String name, boolean resolve)
public synchronized Class<?> loadClass(String name, boolean resolve)
throws ClassNotFoundException
{
// First check if we have permission to access the package. This
@ -166,7 +166,7 @@ public class AppletClassLoader extends URLClassLoader {
* Finds the applet class with the specified name. First searches
* loaded JAR files then the applet code base for the class.
*/
protected Class findClass(String name) throws ClassNotFoundException {
protected Class<?> findClass(String name) throws ClassNotFoundException {
int index = name.indexOf(';');
String cookie = "";
@ -192,9 +192,9 @@ public class AppletClassLoader extends URLClassLoader {
String encodedName = ParseUtil.encodePath(name.replace('.', '/'), false);
final String path = (new StringBuffer(encodedName)).append(".class").append(cookie).toString();
try {
byte[] b = (byte[]) AccessController.doPrivileged(
new PrivilegedExceptionAction() {
public Object run() throws IOException {
byte[] b = AccessController.doPrivileged(
new PrivilegedExceptionAction<byte[]>() {
public byte[] run() throws IOException {
try {
URL finalURL = new URL(base, path);
@ -556,9 +556,10 @@ public class AppletClassLoader extends URLClassLoader {
* name. First checks loaded JAR files then the applet code base for all
* available resources.
*/
public Enumeration findResources(String name) throws IOException {
@Override
public Enumeration<URL> findResources(String name) throws IOException {
final Enumeration e = super.findResources(name);
final Enumeration<URL> e = super.findResources(name);
// 6215746: Disable META-INF/* lookup from codebase in
// applet/plugin classloader. [stanley.ho]
@ -576,9 +577,9 @@ public class AppletClassLoader extends URLClassLoader {
}
final URL url = u;
return new Enumeration() {
return new Enumeration<URL>() {
private boolean done;
public Object nextElement() {
public URL nextElement() {
if (!done) {
if (e.hasMoreElements()) {
return e.nextElement();
@ -601,7 +602,7 @@ public class AppletClassLoader extends URLClassLoader {
* attribute. The argument can either be the relative path
* of the class file itself or just the name of the class.
*/
Class loadCode(String name) throws ClassNotFoundException {
Class<?> loadCode(String name) throws ClassNotFoundException {
// first convert any '/' or native file separator to .
name = name.replace('/', '.');
name = name.replace(File.separatorChar, '.');
@ -646,7 +647,7 @@ public class AppletClassLoader extends URLClassLoader {
public ThreadGroup getThreadGroup() {
synchronized (threadGroupSynchronizer) {
if (threadGroup == null || threadGroup.isDestroyed()) {
AccessController.doPrivileged(new PrivilegedAction() {
AccessController.doPrivileged(new PrivilegedAction<Object>() {
public Object run() {
threadGroup = new AppletThreadGroup(base + "-threadGroup");
// threadGroup.setDaemon(true);
@ -770,8 +771,8 @@ public void grab() {
// Hash map to store applet compatibility info
private HashMap jdk11AppletInfo = new HashMap();
private HashMap jdk12AppletInfo = new HashMap();
private HashMap<String, Boolean> jdk11AppletInfo = new HashMap<>();
private HashMap<String, Boolean> jdk12AppletInfo = new HashMap<>();
/**
* Set applet target level as JDK 1.1.
@ -780,7 +781,7 @@ public void grab() {
* @param bool true if JDK is targeted for JDK 1.1;
* false otherwise.
*/
void setJDK11Target(Class clazz, boolean bool)
void setJDK11Target(Class<?> clazz, boolean bool)
{
jdk11AppletInfo.put(clazz.toString(), Boolean.valueOf(bool));
}
@ -792,7 +793,7 @@ public void grab() {
* @param bool true if JDK is targeted for JDK 1.2;
* false otherwise.
*/
void setJDK12Target(Class clazz, boolean bool)
void setJDK12Target(Class<?> clazz, boolean bool)
{
jdk12AppletInfo.put(clazz.toString(), Boolean.valueOf(bool));
}
@ -805,9 +806,9 @@ public void grab() {
* FALSE if applet is not;
* null if applet is unknown.
*/
Boolean isJDK11Target(Class clazz)
Boolean isJDK11Target(Class<?> clazz)
{
return (Boolean) jdk11AppletInfo.get(clazz.toString());
return jdk11AppletInfo.get(clazz.toString());
}
/**
@ -818,9 +819,9 @@ public void grab() {
* FALSE if applet is not;
* null if applet is unknown.
*/
Boolean isJDK12Target(Class clazz)
Boolean isJDK12Target(Class<?> clazz)
{
return (Boolean) jdk12AppletInfo.get(clazz.toString());
return jdk12AppletInfo.get(clazz.toString());
}
private static AppletMessageHandler mh =

View File

@ -65,7 +65,7 @@ class AppletImageRef {
* invoke reconstitute().
*/
public synchronized void flush() {
SoftReference s = soft;
SoftReference<Image> s = soft;
if (s != null) s.clear();
soft = null;
}
@ -74,9 +74,9 @@ class AppletImageRef {
* Sets the thing to the specified object.
* @param thing the specified object
*/
public synchronized void setThing(Object thing) {
public synchronized void setThing(Image thing) {
flush();
soft = new SoftReference(thing);
soft = new SoftReference<>(thing);
}
/**

View File

@ -59,7 +59,7 @@ class AppletObjectInputStream extends ObjectInputStream
* Make a primitive array class
*/
private Class primitiveType(char type) {
private Class<?> primitiveType(char type) {
switch (type) {
case 'B': return byte.class;
case 'C': return char.class;
@ -76,13 +76,13 @@ class AppletObjectInputStream extends ObjectInputStream
/**
* Use the given ClassLoader rather than using the system class
*/
protected Class resolveClass(ObjectStreamClass classDesc)
protected Class<?> resolveClass(ObjectStreamClass classDesc)
throws IOException, ClassNotFoundException {
String cname = classDesc.getName();
if (cname.startsWith("[")) {
// An array
Class component; // component class
Class<?> component; // component class
int dcount; // dimension
for (dcount=1; cname.charAt(dcount)=='['; dcount++) ;
if (cname.charAt(dcount) == 'L') {

View File

@ -179,7 +179,7 @@ abstract class AppletPanel extends Panel implements AppletStub, Runnable {
handler = new Thread(appletGroup, this, "thread " + nm);
// set the context class loader for this thread
AccessController.doPrivileged(new PrivilegedAction() {
AccessController.doPrivileged(new PrivilegedAction<Object>() {
@Override
public Object run() {
handler.setContextClassLoader(loader);
@ -253,7 +253,7 @@ abstract class AppletPanel extends Panel implements AppletStub, Runnable {
/**
* AppletEvent Queue
*/
private Queue queue = null;
private Queue<Integer> queue = null;
synchronized public void addAppletListener(AppletListener l) {
@ -282,7 +282,7 @@ abstract class AppletPanel extends Panel implements AppletStub, Runnable {
synchronized(this) {
if (queue == null) {
//System.out.println("SEND0= " + id);
queue = new Queue();
queue = new Queue<>();
}
Integer eventId = Integer.valueOf(id);
queue.enqueue(eventId);
@ -309,7 +309,7 @@ abstract class AppletPanel extends Panel implements AppletStub, Runnable {
while (queue == null || queue.isEmpty()) {
wait();
}
Integer eventId = (Integer)queue.dequeue();
Integer eventId = queue.dequeue();
return new AppletEvent(this, eventId.intValue(), null);
}
@ -631,14 +631,15 @@ abstract class AppletPanel extends Panel implements AppletStub, Runnable {
* calls KeyboardFocusManager directly.
*/
private Component getMostRecentFocusOwnerForWindow(Window w) {
Method meth = (Method)AccessController.doPrivileged(new PrivilegedAction() {
Method meth = AccessController.doPrivileged(
new PrivilegedAction<Method>() {
@Override
public Object run() {
public Method run() {
Method meth = null;
try {
meth = KeyboardFocusManager.class.getDeclaredMethod(
"getMostRecentFocusOwner",
new Class[]{Window.class});
new Class<?>[]{Window.class});
meth.setAccessible(true);
} catch (Exception e) {
// Must never happen
@ -988,7 +989,7 @@ abstract class AppletPanel extends Panel implements AppletStub, Runnable {
/**
* The class loaders
*/
private static HashMap classloaders = new HashMap();
private static HashMap<String, AppletClassLoader> classloaders = new HashMap<>();
/**
* Flush a class loader.
@ -1001,7 +1002,7 @@ abstract class AppletPanel extends Panel implements AppletStub, Runnable {
* Flush all class loaders.
*/
public static synchronized void flushClassLoaders() {
classloaders = new HashMap();
classloaders = new HashMap<>();
}
/**
@ -1018,14 +1019,14 @@ abstract class AppletPanel extends Panel implements AppletStub, Runnable {
* Get a class loader. Create in a restricted context
*/
synchronized AppletClassLoader getClassLoader(final URL codebase, final String key) {
AppletClassLoader c = (AppletClassLoader)classloaders.get(key);
AppletClassLoader c = classloaders.get(key);
if (c == null) {
AccessControlContext acc =
getAccessControlContext(codebase);
c = (AppletClassLoader)
AccessController.doPrivileged(new PrivilegedAction() {
c = AccessController.doPrivileged(
new PrivilegedAction<AppletClassLoader>() {
@Override
public Object run() {
public AppletClassLoader run() {
AppletClassLoader ac = createClassLoader(codebase);
/* Should the creation of the classloader be
* within the class synchronized block? Since
@ -1043,8 +1044,7 @@ abstract class AppletPanel extends Panel implements AppletStub, Runnable {
* (which timeout when called from the browser).
*/
synchronized (getClass()) {
AppletClassLoader res =
(AppletClassLoader)classloaders.get(key);
AppletClassLoader res = classloaders.get(key);
if (res == null) {
classloaders.put(key, ac);
return ac;
@ -1066,10 +1066,10 @@ abstract class AppletPanel extends Panel implements AppletStub, Runnable {
*/
private AccessControlContext getAccessControlContext(final URL codebase) {
PermissionCollection perms = (PermissionCollection)
AccessController.doPrivileged(new PrivilegedAction() {
PermissionCollection perms = AccessController.doPrivileged(
new PrivilegedAction<PermissionCollection>() {
@Override
public Object run() {
public PermissionCollection run() {
Policy p = java.security.Policy.getPolicy();
if (p != null) {
return p.getPermissions(new CodeSource(null,
@ -1172,13 +1172,15 @@ abstract class AppletPanel extends Panel implements AppletStub, Runnable {
// critical section of the window list in AppContext.
synchronized (Window.class)
{
WeakReference weakRef = null;
WeakReference<Window> weakRef = null;
// Remove frame from the Window list in wrong AppContext
{
// Lookup current frame's AppContext
Vector<WeakReference<Window>> windowList = (Vector<WeakReference<Window>>)oldAppContext.get(Window.class);
@SuppressWarnings("unchecked")
Vector<WeakReference<Window>> windowList =
(Vector<WeakReference<Window>>)oldAppContext.get(Window.class);
if (windowList != null) {
for (WeakReference ref : windowList) {
for (WeakReference<Window> ref : windowList) {
if (ref.get() == frame) {
weakRef = ref;
break;
@ -1195,7 +1197,9 @@ abstract class AppletPanel extends Panel implements AppletStub, Runnable {
// Insert frame into the Window list in the applet's AppContext map
{
Vector<WeakReference<Window>> windowList = (Vector)newAppContext.get(Window.class);
@SuppressWarnings("unchecked")
Vector<WeakReference<Window>> windowList =
(Vector<WeakReference<Window>>)newAppContext.get(Window.class);
if (windowList == null) {
windowList = new Vector<WeakReference<Window>>();
newAppContext.put(Window.class, windowList);
@ -1224,7 +1228,7 @@ abstract class AppletPanel extends Panel implements AppletStub, Runnable {
// synchronized on applet class object, so calling from
// different instances of the same applet will be
// serialized.
Class appletClass = applet.getClass();
Class<?> appletClass = applet.getClass();
synchronized(appletClass) {
// Determine if the JDK level of an applet has been

View File

@ -105,9 +105,9 @@ class AppletProps extends Frame {
String proxyPortValue = proxyPort.getText().trim();
// Get properties
final Properties props = (Properties) AccessController.doPrivileged(
new PrivilegedAction() {
public Object run() {
final Properties props = AccessController.doPrivileged(
new PrivilegedAction<Properties>() {
public Properties run() {
return System.getProperties();
}
});
@ -148,7 +148,7 @@ class AppletProps extends Frame {
// Save properties
try {
reset();
AccessController.doPrivileged(new PrivilegedExceptionAction() {
AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
public Object run() throws IOException {
File dotAV = Main.theUserPropertiesFile;
FileOutputStream out = new FileOutputStream(dotAV);

View File

@ -80,7 +80,7 @@ class AppletSecurity extends AWTSecurityManager {
}
// Cache to store known restricted packages
private HashSet restrictedPackages = new HashSet();
private HashSet<String> restrictedPackages = new HashSet<>();
/**
* Reset from Properties
@ -90,11 +90,11 @@ class AppletSecurity extends AWTSecurityManager {
// Clear cache
restrictedPackages.clear();
AccessController.doPrivileged(new PrivilegedAction() {
AccessController.doPrivileged(new PrivilegedAction<Object>() {
public Object run()
{
// Enumerate system properties
Enumeration e = System.getProperties().propertyNames();
Enumeration<?> e = System.getProperties().propertyNames();
while (e.hasMoreElements())
{
@ -130,7 +130,7 @@ class AppletSecurity extends AWTSecurityManager {
return (AppletClassLoader)loader;
// if that fails, get all the classes on the stack and check them.
Class[] context = getClassContext();
Class<?>[] context = getClassContext();
for (int i = 0; i < context.length; i++) {
loader = context[i].getClassLoader();
if (loader instanceof AppletClassLoader)
@ -148,37 +148,38 @@ class AppletSecurity extends AWTSecurityManager {
final ClassLoader currentLoader = context[i].getClassLoader();
if (currentLoader instanceof URLClassLoader) {
loader = (ClassLoader) AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
loader = AccessController.doPrivileged(
new PrivilegedAction<ClassLoader>() {
public ClassLoader run() {
AccessControlContext acc = null;
ProtectionDomain[] pds = null;
AccessControlContext acc = null;
ProtectionDomain[] pds = null;
try {
acc = (AccessControlContext) facc.get(currentLoader);
if (acc == null) {
return null;
try {
acc = (AccessControlContext) facc.get(currentLoader);
if (acc == null) {
return null;
}
pds = (ProtectionDomain[]) fcontext.get(acc);
if (pds == null) {
return null;
}
} catch (Exception e) {
throw new UnsupportedOperationException(e);
}
pds = (ProtectionDomain[]) fcontext.get(acc);
if (pds == null) {
return null;
for (int i=0; i<pds.length; i++) {
ClassLoader cl = pds[i].getClassLoader();
if (cl instanceof AppletClassLoader) {
return cl;
}
}
} catch (Exception e) {
throw new UnsupportedOperationException(e);
return null;
}
for (int i=0; i<pds.length; i++) {
ClassLoader cl = pds[i].getClassLoader();
if (cl instanceof AppletClassLoader) {
return cl;
}
}
return null;
}
});
});
if (loader != null) {
return (AppletClassLoader) loader;
@ -282,9 +283,9 @@ class AppletSecurity extends AWTSecurityManager {
super.checkPackageAccess(pkgname);
// now check the list of restricted packages
for (Iterator iter = restrictedPackages.iterator(); iter.hasNext();)
for (Iterator<String> iter = restrictedPackages.iterator(); iter.hasNext();)
{
String pkg = (String) iter.next();
String pkg = iter.next();
// Prevent matching "sun" and "sunir" even if they
// starts with similar beginning characters

View File

@ -94,7 +94,7 @@ final class StdAppletViewerFactory implements AppletViewerFactory {
@Override
public AppletViewer createAppletViewer(int x, int y,
URL doc, Hashtable atts) {
URL doc, Hashtable<String, String> atts) {
return new AppletViewer(x, y, doc, atts, System.out, this);
}
@ -156,7 +156,7 @@ public class AppletViewer extends Frame implements AppletContext, Printable {
/**
* Create the applet viewer.
*/
public AppletViewer(int x, int y, URL doc, Hashtable atts,
public AppletViewer(int x, int y, URL doc, Hashtable<String, String> atts,
PrintStream statusMsgStream, AppletViewerFactory factory) {
this.factory = factory;
this.statusMsgStream = statusMsgStream;
@ -350,7 +350,7 @@ public class AppletViewer extends Frame implements AppletContext, Printable {
* s. Whitespace not stripped.
*/
private String [] splitSeparator(String sep, String s) {
Vector v = new Vector();
Vector<String> v = new Vector<>();
int tokenStart = 0;
int tokenEnd = 0;
@ -370,7 +370,7 @@ public class AppletViewer extends Frame implements AppletContext, Printable {
* Methods for java.applet.AppletContext
*/
private static Map audioClips = new HashMap();
private static Map<URL, AudioClip> audioClips = new HashMap<>();
/**
* Get an audio clip.
@ -379,7 +379,7 @@ public class AppletViewer extends Frame implements AppletContext, Printable {
public AudioClip getAudioClip(URL url) {
checkConnect(url);
synchronized (audioClips) {
AudioClip clip = (AudioClip)audioClips.get(url);
AudioClip clip = audioClips.get(url);
if (clip == null) {
audioClips.put(url, clip = new AppletAudioClip(url));
}
@ -387,7 +387,7 @@ public class AppletViewer extends Frame implements AppletContext, Printable {
}
}
private static Map imageRefs = new HashMap();
private static Map<URL, AppletImageRef> imageRefs = new HashMap<>();
/**
* Get an image.
@ -403,7 +403,7 @@ public class AppletViewer extends Frame implements AppletContext, Printable {
static Image getCachedImage(URL url) {
// System.getSecurityManager().checkConnection(url.getHost(), url.getPort());
synchronized (imageRefs) {
AppletImageRef ref = (AppletImageRef)imageRefs.get(url);
AppletImageRef ref = imageRefs.get(url);
if (ref == null) {
ref = new AppletImageRef(url);
imageRefs.put(url, ref);
@ -419,7 +419,7 @@ public class AppletViewer extends Frame implements AppletContext, Printable {
imageRefs.clear();
}
static Vector appletPanels = new Vector();
static Vector<AppletPanel> appletPanels = new Vector<>();
/**
* Get an applet by name.
@ -430,8 +430,8 @@ public class AppletViewer extends Frame implements AppletContext, Printable {
name = name.toLowerCase();
SocketPermission panelSp =
new SocketPermission(panel.getCodeBase().getHost(), "connect");
for (Enumeration e = appletPanels.elements() ; e.hasMoreElements() ;) {
AppletPanel p = (AppletPanel)e.nextElement();
for (Enumeration<AppletPanel> e = appletPanels.elements() ; e.hasMoreElements() ;) {
AppletPanel p = e.nextElement();
String param = p.getParameter("name");
if (param != null) {
param = param.toLowerCase();
@ -455,14 +455,14 @@ public class AppletViewer extends Frame implements AppletContext, Printable {
* applets on this page.
*/
@Override
public Enumeration getApplets() {
public Enumeration<Applet> getApplets() {
AppletSecurity security = (AppletSecurity)System.getSecurityManager();
Vector v = new Vector();
Vector<Applet> v = new Vector<>();
SocketPermission panelSp =
new SocketPermission(panel.getCodeBase().getHost(), "connect");
for (Enumeration e = appletPanels.elements() ; e.hasMoreElements() ;) {
AppletPanel p = (AppletPanel)e.nextElement();
for (Enumeration<AppletPanel> e = appletPanels.elements() ; e.hasMoreElements() ;) {
AppletPanel p = e.nextElement();
if (p.getDocumentBase().equals(panel.getDocumentBase())) {
SocketPermission sp =
@ -509,7 +509,7 @@ public class AppletViewer extends Frame implements AppletContext, Printable {
}
@Override
public Iterator getStreamKeys(){
public Iterator<String> getStreamKeys(){
// We do nothing.
return null;
}
@ -517,7 +517,7 @@ public class AppletViewer extends Frame implements AppletContext, Printable {
/**
* System parameters.
*/
static Hashtable systemParam = new Hashtable();
static Hashtable<String, String> systemParam = new Hashtable<>();
static {
systemParam.put("codebase", "codebase");
@ -533,32 +533,32 @@ public class AppletViewer extends Frame implements AppletContext, Printable {
/**
* Print the HTML tag.
*/
public static void printTag(PrintStream out, Hashtable atts) {
public static void printTag(PrintStream out, Hashtable<String, String> atts) {
out.print("<applet");
String v = (String)atts.get("codebase");
String v = atts.get("codebase");
if (v != null) {
out.print(" codebase=\"" + v + "\"");
}
v = (String)atts.get("code");
v = atts.get("code");
if (v == null) {
v = "applet.class";
}
out.print(" code=\"" + v + "\"");
v = (String)atts.get("width");
v = atts.get("width");
if (v == null) {
v = "150";
}
out.print(" width=" + v);
v = (String)atts.get("height");
v = atts.get("height");
if (v == null) {
v = "100";
}
out.print(" height=" + v);
v = (String)atts.get("name");
v = atts.get("name");
if (v != null) {
out.print(" name=\"" + v + "\"");
}
@ -568,8 +568,8 @@ public class AppletViewer extends Frame implements AppletContext, Printable {
int len = atts.size();
String params[] = new String[len];
len = 0;
for (Enumeration e = atts.keys() ; e.hasMoreElements() ;) {
String param = (String)e.nextElement();
for (Enumeration<String> e = atts.keys() ; e.hasMoreElements() ;) {
String param = e.nextElement();
int i = 0;
for (; i < len ; i++) {
if (params[i].compareTo(param) >= 0) {
@ -649,7 +649,7 @@ public class AppletViewer extends Frame implements AppletContext, Printable {
* Save the applet to a well known file (for now) as a serialized object
*/
void appletSave() {
AccessController.doPrivileged(new PrivilegedAction() {
AccessController.doPrivileged(new PrivilegedAction<Object>() {
@Override
public Object run() {
@ -702,8 +702,10 @@ public class AppletViewer extends Frame implements AppletContext, Printable {
void appletClone() {
Point p = location();
updateAtts();
@SuppressWarnings("unchecked")
Hashtable<String, String> tmp = (Hashtable<String, String>) panel.atts.clone();
factory.createAppletViewer(p.x + XDELTA, p.y + YDELTA,
panel.documentURL, (Hashtable)panel.atts.clone());
panel.documentURL, tmp);
}
/**
@ -884,8 +886,8 @@ public class AppletViewer extends Frame implements AppletContext, Printable {
@Override
public void run()
{
for (Enumeration e = appletPanels.elements() ; e.hasMoreElements() ;) {
AppletPanel p = (AppletPanel)e.nextElement();
for (Enumeration<AppletPanel> e = appletPanels.elements() ; e.hasMoreElements() ;) {
AppletPanel p = e.nextElement();
appletShutdown(p);
}
appletSystemExit();
@ -1016,8 +1018,8 @@ public class AppletViewer extends Frame implements AppletContext, Printable {
/**
* Scan tag
*/
public static Hashtable scanTag(Reader in) throws IOException {
Hashtable atts = new Hashtable();
public static Hashtable<String, String> scanTag(Reader in) throws IOException {
Hashtable<String, String> atts = new Hashtable<>();
skipSpace(in);
while (c >= 0 && c != '>') {
String att = scanIdentifier(in);
@ -1122,7 +1124,7 @@ public class AppletViewer extends Frame implements AppletContext, Printable {
url = conn.getURL();
int ydisp = 1;
Hashtable atts = null;
Hashtable<String, String> atts = null;
while(true) {
c = in.read();
@ -1172,12 +1174,12 @@ public class AppletViewer extends Frame implements AppletContext, Printable {
else {
String nm = scanIdentifier(in);
if (nm.equalsIgnoreCase("param")) {
Hashtable t = scanTag(in);
String att = (String)t.get("name");
Hashtable<String, String> t = scanTag(in);
String att = t.get("name");
if (att == null) {
statusMsgStream.println(requiresNameWarning);
} else {
String val = (String)t.get("value");
String val = t.get("value");
if (val == null) {
statusMsgStream.println(requiresNameWarning);
} else if (atts != null) {
@ -1235,13 +1237,13 @@ public class AppletViewer extends Frame implements AppletContext, Printable {
}
else if (nm.equalsIgnoreCase("app")) {
statusMsgStream.println(appNotLongerSupportedWarning);
Hashtable atts2 = scanTag(in);
nm = (String)atts2.get("class");
Hashtable<String, String> atts2 = scanTag(in);
nm = atts2.get("class");
if (nm != null) {
atts2.remove("class");
atts2.put("code", nm + ".class");
}
nm = (String)atts2.get("src");
nm = atts2.get("src");
if (nm != null) {
atts2.remove("src");
atts2.put("codebase", nm);

View File

@ -35,7 +35,8 @@ import java.awt.MenuBar;
public
interface AppletViewerFactory {
public AppletViewer createAppletViewer(int x, int y, URL doc, Hashtable atts);
public AppletViewer createAppletViewer(int x, int y, URL doc,
Hashtable<String, String> atts);
public MenuBar getBaseMenuBar();
public boolean isStandalone();
}

View File

@ -59,7 +59,7 @@ class AppletViewerPanel extends AppletPanel {
/**
* The attributes of the applet.
*/
Hashtable atts;
Hashtable<String, String> atts;
/*
* JDK 1.1 serialVersionUID
@ -69,7 +69,7 @@ class AppletViewerPanel extends AppletPanel {
/**
* Construct an applet viewer and start the applet.
*/
AppletViewerPanel(URL documentURL, Hashtable atts) {
AppletViewerPanel(URL documentURL, Hashtable<String, String> atts) {
this.documentURL = documentURL;
this.atts = atts;
@ -105,7 +105,7 @@ class AppletViewerPanel extends AppletPanel {
* Get an applet parameter.
*/
public String getParameter(String name) {
return (String)atts.get(name.toLowerCase());
return atts.get(name.toLowerCase());
}
/**

View File

@ -84,7 +84,7 @@ public class Main {
/**
* The list of valid URLs passed in to AppletViewer.
*/
private static Vector urlList = new Vector(1);
private static Vector<URL> urlList = new Vector<>(1);
// This is used in init(). Getting rid of this is desirable but depends
// on whether the property that uses it is necessary/standard.
@ -153,7 +153,7 @@ public class Main {
// XXX 5/17 this parsing method should be changed/fixed so that
// it doesn't do both parsing of the html file and launching of
// the AppletPanel
AppletViewer.parse((URL) urlList.elementAt(i), encoding);
AppletViewer.parse(urlList.elementAt(i), encoding);
} catch (IOException e) {
System.err.println(lookup("main.err.io", e.getMessage()));
return 1;
@ -307,10 +307,10 @@ public class Main {
// 2) Reflection removes any build dependency between appletviewer
// and jdb.
try {
Class c = Class.forName("com.sun.tools.example.debug.tty.TTY", true,
Class<?> c = Class.forName("com.sun.tools.example.debug.tty.TTY", true,
ClassLoader.getSystemClassLoader());
Method m = c.getDeclaredMethod("main",
new Class[] { String[].class });
new Class<?>[] { String[].class });
m.invoke(null, new Object[] { newArgs });
} catch (ClassNotFoundException cnfe) {
System.err.println(lookup("main.debug.cantfinddebug"));
@ -367,7 +367,7 @@ public class Main {
// Read in the System properties. If something is going to be
// over-written, warn about it.
Properties sysProps = System.getProperties();
for (Enumeration e = sysProps.propertyNames(); e.hasMoreElements(); ) {
for (Enumeration<?> e = sysProps.propertyNames(); e.hasMoreElements(); ) {
String key = (String) e.nextElement();
String val = sysProps.getProperty(key);
String oldVal;