src/share/classes/sun/applet/AppletClassLoader.java
Print this page
rev 10175 : 8042872: Fix raw and unchecked warnings in sun.applet
Reviewed-by:
*** 135,145 ****
/*
* 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)
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('.');
--- 135,145 ----
/*
* 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)
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,174 ****
/*
* 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 {
int index = name.indexOf(';');
String cookie = "";
if(index != -1) {
cookie = name.substring(index, name.length());
--- 164,174 ----
/*
* 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 {
int index = name.indexOf(';');
String cookie = "";
if(index != -1) {
cookie = name.substring(index, name.length());
*** 190,202 ****
// 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 {
try {
URL finalURL = new URL(base, path);
// Make sure the codebase won't be modified
if (base.getProtocol().equals(finalURL.getProtocol()) &&
--- 190,202 ----
// 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 = 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,566 ****
/*
* 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 {
! final Enumeration e = super.findResources(name);
// 6215746: Disable META-INF/* lookup from codebase in
// applet/plugin classloader. [stanley.ho]
if (name.startsWith("META-INF/"))
return e;
--- 554,567 ----
/*
* 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.
*/
! @Override
! public Enumeration<URL> findResources(String name) throws IOException {
! 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,586 ****
if (!resourceExists(u)) {
u = null;
}
final URL url = u;
! return new Enumeration() {
private boolean done;
! public Object nextElement() {
if (!done) {
if (e.hasMoreElements()) {
return e.nextElement();
}
done = true;
--- 575,587 ----
if (!resourceExists(u)) {
u = null;
}
final URL url = u;
! return new Enumeration<URL>() {
private boolean done;
! public URL nextElement() {
if (!done) {
if (e.hasMoreElements()) {
return e.nextElement();
}
done = true;
*** 599,609 ****
/*
* 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 {
// first convert any '/' or native file separator to .
name = name.replace('/', '.');
name = name.replace(File.separatorChar, '.');
// deal with URL rewriting
--- 600,610 ----
/*
* 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 {
// first convert any '/' or native file separator to .
name = name.replace('/', '.');
name = name.replace(File.separatorChar, '.');
// deal with URL rewriting
*** 644,654 ****
private AppContext appContext;
public ThreadGroup getThreadGroup() {
synchronized (threadGroupSynchronizer) {
if (threadGroup == null || threadGroup.isDestroyed()) {
! AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
threadGroup = new AppletThreadGroup(base + "-threadGroup");
// threadGroup.setDaemon(true);
// threadGroup is now destroyed by AppContext.dispose()
--- 645,655 ----
private AppContext appContext;
public ThreadGroup getThreadGroup() {
synchronized (threadGroupSynchronizer) {
if (threadGroup == null || threadGroup.isDestroyed()) {
! AccessController.doPrivileged(new PrivilegedAction<Object>() {
public Object run() {
threadGroup = new AppletThreadGroup(base + "-threadGroup");
// threadGroup.setDaemon(true);
// threadGroup is now destroyed by AppContext.dispose()
*** 768,788 ****
return tempAppContext;
}
// Hash map to store applet compatibility info
! private HashMap jdk11AppletInfo = new HashMap();
! private HashMap 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)
{
jdk11AppletInfo.put(clazz.toString(), Boolean.valueOf(bool));
}
/**
--- 769,789 ----
return tempAppContext;
}
// Hash map to store applet compatibility info
! 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)
{
jdk11AppletInfo.put(clazz.toString(), Boolean.valueOf(bool));
}
/**
*** 790,800 ****
*
* @param clazz Applet class.
* @param bool true if JDK is targeted for JDK 1.2;
* false otherwise.
*/
! void setJDK12Target(Class clazz, boolean bool)
{
jdk12AppletInfo.put(clazz.toString(), Boolean.valueOf(bool));
}
/**
--- 791,801 ----
*
* @param clazz Applet class.
* @param bool true if JDK is targeted for JDK 1.2;
* false otherwise.
*/
! void setJDK12Target(Class<?> clazz, boolean bool)
{
jdk12AppletInfo.put(clazz.toString(), Boolean.valueOf(bool));
}
/**
*** 803,828 ****
* @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)
{
! return (Boolean) 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)
{
! return (Boolean) jdk12AppletInfo.get(clazz.toString());
}
private static AppletMessageHandler mh =
new AppletMessageHandler("appletclassloader");
--- 804,829 ----
* @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)
{
! 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)
{
! return jdk12AppletInfo.get(clazz.toString());
}
private static AppletMessageHandler mh =
new AppletMessageHandler("appletclassloader");