summaryrefslogtreecommitdiffstats
path: root/libjava/java
diff options
context:
space:
mode:
authormkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4>2004-11-18 19:00:32 +0000
committermkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4>2004-11-18 19:00:32 +0000
commit2c2a2b0fb8d265af45a2f25eb3bb857d3be833ef (patch)
tree8f06b1ee077416e54bef712351d3e4a6da209618 /libjava/java
parentf03a9d7be10949337d56432d8d11a9e29fd77370 (diff)
downloadppe42-gcc-2c2a2b0fb8d265af45a2f25eb3bb857d3be833ef.tar.gz
ppe42-gcc-2c2a2b0fb8d265af45a2f25eb3bb857d3be833ef.zip
2004-11-18 Michael Koch <konqueror@gmx.de>
* java/net/URLClassLoader.java: Whitespace cleanup. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@90877 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/java')
-rw-r--r--libjava/java/net/URLClassLoader.java342
1 files changed, 172 insertions, 170 deletions
diff --git a/libjava/java/net/URLClassLoader.java b/libjava/java/net/URLClassLoader.java
index b641e704e1f..4ffd4c532db 100644
--- a/libjava/java/net/URLClassLoader.java
+++ b/libjava/java/net/URLClassLoader.java
@@ -35,6 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package java.net;
import java.io.ByteArrayOutputStream;
@@ -248,9 +249,9 @@ public class URLClassLoader extends SecureClassLoader
{
Certificate[] certs = getCertificates();
if (certs == null)
- return loader.noCertCodeSource;
+ return loader.noCertCodeSource;
else
- return new CodeSource(loader.baseURL, certs);
+ return new CodeSource(loader.baseURL, certs);
}
/**
@@ -305,15 +306,15 @@ public class URLClassLoader extends SecureClassLoader
JarFile jarfile = null;
try
{
- baseJarURL =
- new URL(null, jarURL, classloader.getURLStreamHandler("jar"));
+ baseJarURL =
+ new URL(null, jarURL, classloader.getURLStreamHandler("jar"));
- jarfile =
- ((JarURLConnection) baseJarURL.openConnection()).getJarFile();
+ jarfile =
+ ((JarURLConnection) baseJarURL.openConnection()).getJarFile();
}
catch (IOException ioe)
{
- /* ignored */
+ /* ignored */
}
this.baseJarURL = baseJarURL;
@@ -324,27 +325,27 @@ public class URLClassLoader extends SecureClassLoader
Resource getResource(String name)
{
if (jarfile == null)
- return null;
+ return null;
if (name.startsWith("/"))
- name = name.substring(1);
+ name = name.substring(1);
JarEntry je = jarfile.getJarEntry(name);
if (je != null)
- return new JarURLResource(this, name, je);
+ return new JarURLResource(this, name, je);
else
- return null;
+ return null;
}
Manifest getManifest()
{
try
{
- return (jarfile == null) ? null : jarfile.getManifest();
+ return (jarfile == null) ? null : jarfile.getManifest();
}
catch (IOException ioe)
{
- return null;
+ return null;
}
}
}
@@ -378,14 +379,14 @@ public class URLClassLoader extends SecureClassLoader
{
try
{
- return new URL(((JarURLLoader) loader).baseJarURL, name,
- loader.classloader.getURLStreamHandler("jar"));
+ return new URL(((JarURLLoader) loader).baseJarURL, name,
+ loader.classloader.getURLStreamHandler("jar"));
}
catch (MalformedURLException e)
{
- InternalError ie = new InternalError();
- ie.initCause(e);
- throw ie;
+ InternalError ie = new InternalError();
+ ie.initCause(e);
+ throw ie;
}
}
}
@@ -411,32 +412,32 @@ public class URLClassLoader extends SecureClassLoader
{
try
{
- URL url =
- new URL(baseURL, name, classloader.getURLStreamHandler(protocol));
- URLConnection connection = url.openConnection();
-
- // Open the connection and check the stream
- // just to be sure it exists.
- int length = connection.getContentLength();
- InputStream stream = connection.getInputStream();
-
- // We can do some extra checking if it is a http request
- if (connection instanceof HttpURLConnection)
- {
- int response =
- ((HttpURLConnection) connection).getResponseCode();
- if (response / 100 != 2)
- return null;
- }
-
- if (stream != null)
- return new RemoteResource(this, name, url, stream, length);
- else
- return null;
+ URL url =
+ new URL(baseURL, name, classloader.getURLStreamHandler(protocol));
+ URLConnection connection = url.openConnection();
+
+ // Open the connection and check the stream
+ // just to be sure it exists.
+ int length = connection.getContentLength();
+ InputStream stream = connection.getInputStream();
+
+ // We can do some extra checking if it is a http request
+ if (connection instanceof HttpURLConnection)
+ {
+ int response =
+ ((HttpURLConnection) connection).getResponseCode();
+ if (response / 100 != 2)
+ return null;
+ }
+
+ if (stream != null)
+ return new RemoteResource(this, name, url, stream, length);
+ else
+ return null;
}
catch (IOException ioe)
{
- return null;
+ return null;
}
}
}
@@ -551,7 +552,7 @@ public class URLClassLoader extends SecureClassLoader
{
File file = new File(dir, name);
if (file.exists() && ! file.isDirectory())
- return new FileResource(this, name, file);
+ return new FileResource(this, name, file);
return null;
}
}
@@ -580,14 +581,14 @@ public class URLClassLoader extends SecureClassLoader
{
try
{
- return new URL(loader.baseURL, name,
- loader.classloader.getURLStreamHandler("file"));
+ return new URL(loader.baseURL, name,
+ loader.classloader.getURLStreamHandler("file"));
}
catch (MalformedURLException e)
{
- InternalError ie = new InternalError();
- ie.initCause(e);
- throw ie;
+ InternalError ie = new InternalError();
+ ie.initCause(e);
+ throw ie;
}
}
}
@@ -711,12 +712,12 @@ public class URLClassLoader extends SecureClassLoader
addURLs(urls);
// If this factory is still not in factoryCache, add it,
- // since we only support three protocols so far, 5 is enough
+ // since we only support three protocols so far, 5 is enough
// for cache initial size
synchronized (factoryCache)
{
- if (factory != null && factoryCache.get(factory) == null)
- factoryCache.put(factory, new HashMap(5));
+ if (factory != null && factoryCache.get(factory) == null)
+ factoryCache.put(factory, new HashMap(5));
}
}
@@ -735,32 +736,33 @@ public class URLClassLoader extends SecureClassLoader
{
synchronized (urlloaders)
{
- if (newUrl == null)
- return; // Silently ignore...
-
- // Check global cache to see if there're already url loader
- // for this url.
- URLLoader loader = (URLLoader) urlloaders.get(newUrl);
- if (loader == null)
- {
- String file = newUrl.getFile();
- String protocol = newUrl.getProtocol();
- // Check that it is not a directory
+ if (newUrl == null)
+ return; // Silently ignore...
+
+ // Check global cache to see if there're already url loader
+ // for this url.
+ URLLoader loader = (URLLoader) urlloaders.get(newUrl);
+ if (loader == null)
+ {
+ String file = newUrl.getFile();
+ String protocol = newUrl.getProtocol();
+
+ // Check that it is not a directory
if ("gcjlib".equals(protocol))
loader = new SoURLLoader(this, newUrl);
else if (! (file.endsWith("/") || file.endsWith(File.separator)))
- loader = new JarURLLoader(this, newUrl);
- else if ("file".equals(protocol))
- loader = new FileURLLoader(this, newUrl);
- else
- loader = new RemoteURLLoader(this, newUrl);
-
- // Cache it.
- urlloaders.put(newUrl, loader);
- }
-
- urls.add(newUrl);
- urlinfos.add(loader);
+ loader = new JarURLLoader(this, newUrl);
+ else if ("file".equals(protocol))
+ loader = new FileURLLoader(this, newUrl);
+ else
+ loader = new RemoteURLLoader(this, newUrl);
+
+ // Cache it.
+ urlloaders.put(newUrl, loader);
+ }
+
+ urls.add(newUrl);
+ urlinfos.add(loader);
}
}
@@ -849,8 +851,8 @@ public class URLClassLoader extends SecureClassLoader
// construct the class (and watch out for those nasty IOExceptions)
try
{
- byte[] data;
- InputStream in = resource.getInputStream();
+ byte[] data;
+ InputStream in = resource.getInputStream();
int length = resource.getLength();
if (length != -1)
{
@@ -881,50 +883,50 @@ public class URLClassLoader extends SecureClassLoader
out.write(b, 0, l);
}
data = out.toByteArray();
- }
- final byte[] classData = data;
-
- // Now get the CodeSource
- final CodeSource source = resource.getCodeSource();
-
- // Find out package name
- String packageName = null;
- int lastDot = className.lastIndexOf('.');
- if (lastDot != -1)
- packageName = className.substring(0, lastDot);
-
- if (packageName != null && getPackage(packageName) == null)
- {
- // define the package
- Manifest manifest = resource.loader.getManifest();
- if (manifest == null)
- definePackage(packageName, null, null, null, null, null, null,
- null);
- else
- definePackage(packageName, manifest, resource.loader.baseURL);
- }
-
- // And finally construct the class!
- SecurityManager sm = System.getSecurityManager();
- if (sm != null && securityContext != null)
- {
+ }
+ final byte[] classData = data;
+
+ // Now get the CodeSource
+ final CodeSource source = resource.getCodeSource();
+
+ // Find out package name
+ String packageName = null;
+ int lastDot = className.lastIndexOf('.');
+ if (lastDot != -1)
+ packageName = className.substring(0, lastDot);
+
+ if (packageName != null && getPackage(packageName) == null)
+ {
+ // define the package
+ Manifest manifest = resource.loader.getManifest();
+ if (manifest == null)
+ definePackage(packageName, null, null, null, null, null, null,
+ null);
+ else
+ definePackage(packageName, manifest, resource.loader.baseURL);
+ }
+
+ // And finally construct the class!
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null && securityContext != null)
+ {
return (Class)AccessController.doPrivileged
- (new PrivilegedAction()
- {
- public Object run()
- {
- return defineClass(className, classData,
- 0, classData.length,
- source);
- }
- }, securityContext);
- }
- else
+ (new PrivilegedAction()
+ {
+ public Object run()
+ {
+ return defineClass(className, classData,
+ 0, classData.length,
+ source);
+ }
+ }, securityContext);
+ }
+ else
return defineClass(className, classData, 0, classData.length, source);
}
catch (IOException ioe)
{
- throw new ClassNotFoundException(className, ioe);
+ throw new ClassNotFoundException(className, ioe);
}
}
@@ -940,13 +942,13 @@ public class URLClassLoader extends SecureClassLoader
int max = urls.size();
for (int i = 0; i < max; i++)
{
- URLLoader loader = (URLLoader) urlinfos.elementAt(i);
- if (loader == null)
- continue;
+ URLLoader loader = (URLLoader) urlinfos.elementAt(i);
+ if (loader == null)
+ continue;
- Resource resource = loader.getResource(resourceName);
- if (resource != null)
- return resource;
+ Resource resource = loader.getResource(resourceName);
+ if (resource != null)
+ return resource;
}
return null;
}
@@ -982,15 +984,15 @@ public class URLClassLoader extends SecureClassLoader
URLStreamHandler handler;
synchronized (factoryCache)
{
- // Check if there're handler for the same protocol in cache.
- HashMap cache = (HashMap) factoryCache.get(factory);
- handler = (URLStreamHandler) cache.get(protocol);
- if (handler == null)
- {
- // Add it to cache.
- handler = factory.createURLStreamHandler(protocol);
- cache.put(protocol, handler);
- }
+ // Check if there're handler for the same protocol in cache.
+ HashMap cache = (HashMap) factoryCache.get(factory);
+ handler = (URLStreamHandler) cache.get(protocol);
+ if (handler == null)
+ {
+ // Add it to cache.
+ handler = factory.createURLStreamHandler(protocol);
+ cache.put(protocol, handler);
+ }
}
return handler;
}
@@ -1011,10 +1013,10 @@ public class URLClassLoader extends SecureClassLoader
int max = urls.size();
for (int i = 0; i < max; i++)
{
- URLLoader loader = (URLLoader) urlinfos.elementAt(i);
- Resource resource = loader.getResource(resourceName);
- if (resource != null)
- resources.add(resource.getURL());
+ URLLoader loader = (URLLoader) urlinfos.elementAt(i);
+ Resource resource = loader.getResource(resourceName);
+ if (resource != null)
+ resources.add(resource.getURL());
}
return resources.elements();
}
@@ -1051,28 +1053,28 @@ public class URLClassLoader extends SecureClassLoader
String protocol = url.getProtocol();
if (protocol.equals("file"))
{
- String file = url.getFile();
-
- // If the file end in / it must be an directory.
- if (file.endsWith("/") || file.endsWith(File.separator))
- {
- // Grant permission to read everything in that directory and
- // all subdirectories.
- permissions.add(new FilePermission(file + "-", "read"));
- }
- else
- {
- // It is a 'normal' file.
- // Grant permission to access that file.
- permissions.add(new FilePermission(file, "read"));
- }
+ String file = url.getFile();
+
+ // If the file end in / it must be an directory.
+ if (file.endsWith("/") || file.endsWith(File.separator))
+ {
+ // Grant permission to read everything in that directory and
+ // all subdirectories.
+ permissions.add(new FilePermission(file + "-", "read"));
+ }
+ else
+ {
+ // It is a 'normal' file.
+ // Grant permission to access that file.
+ permissions.add(new FilePermission(file, "read"));
+ }
}
else
{
- // Grant permission to connect to and accept connections from host
- String host = url.getHost();
- if (host != null)
- permissions.add(new SocketPermission(host, "connect,accept"));
+ // Grant permission to connect to and accept connections from host
+ String host = url.getHost();
+ if (host != null)
+ permissions.add(new SocketPermission(host, "connect,accept"));
}
return permissions;
@@ -1130,24 +1132,24 @@ public class URLClassLoader extends SecureClassLoader
return new URLClassLoader(urls, parent);
else
{
- final Object securityContext = sm.getSecurityContext();
-
- // XXX - What to do with anything else then an AccessControlContext?
- if (! (securityContext instanceof AccessControlContext))
- throw new SecurityException("securityContext must be AccessControlContext: "
- + securityContext);
-
- URLClassLoader loader =
- (URLClassLoader) AccessController.doPrivileged(new PrivilegedAction()
- {
- public Object run()
- {
- return new URLClassLoader(parent,
- (AccessControlContext) securityContext);
- }
- });
- loader.addURLs(urls);
- return loader;
+ final Object securityContext = sm.getSecurityContext();
+
+ // XXX - What to do with anything else then an AccessControlContext?
+ if (! (securityContext instanceof AccessControlContext))
+ throw new SecurityException("securityContext must be AccessControlContext: "
+ + securityContext);
+
+ URLClassLoader loader =
+ (URLClassLoader) AccessController.doPrivileged(new PrivilegedAction()
+ {
+ public Object run()
+ {
+ return new URLClassLoader(parent,
+ (AccessControlContext) securityContext);
+ }
+ });
+ loader.addURLs(urls);
+ return loader;
}
}
}
OpenPOWER on IntegriCloud