src/share/classes/sun/applet/AppletClassLoader.java
Print this page
rev 10175 : 8042872: Fix raw and unchecked warnings in sun.applet
Reviewed-by:
@@ -135,11 +135,11 @@
/*
* 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
// should go away once we've added support for exported packages.
int i = name.lastIndexOf('.');
@@ -164,11 +164,11 @@
/*
* 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 = "";
if(index != -1) {
cookie = name.substring(index, name.length());
@@ -190,13 +190,13 @@
// final String path = name.replace('.', '/').concat(".class").concat(cookie);
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);
// Make sure the codebase won't be modified
if (base.getProtocol().equals(finalURL.getProtocol()) &&
@@ -554,13 +554,14 @@
/*
* Returns an enumeration of all the applet resources with the specified
* 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]
if (name.startsWith("META-INF/"))
return e;
@@ -574,13 +575,13 @@
if (!resourceExists(u)) {
u = null;
}
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();
}
done = true;
@@ -599,11 +600,11 @@
/*
* Load and resolve the file specified by the applet tag CODE
* 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, '.');
// deal with URL rewriting
@@ -644,11 +645,11 @@
private AppContext appContext;
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);
// threadGroup is now destroyed by AppContext.dispose()
@@ -768,21 +769,21 @@
return tempAppContext;
}
// 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.
*
* @param clazz Applet class.
* @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));
}
/**
@@ -790,11 +791,11 @@
*
* @param clazz Applet class.
* @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));
}
/**
@@ -803,26 +804,26 @@
* @param applet Applet class.
* @return TRUE if applet is targeted for JDK 1.1;
* 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());
}
/**
* Determine if applet is targeted for JDK 1.2.
*
* @param applet Applet class.
* @return TRUE if applet is targeted for JDK 1.2;
* 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 =
new AppletMessageHandler("appletclassloader");