[Openjnlp-devel] Lazy jars
Brought to you by:
kherr
|
From: Mario C. <mar...@po...> - 2002-05-08 19:31:32
|
I tried running a JNLP app that used lazy loading of some jars, and it =
simply didn't work because of ClassNotFoundExceptions. Going through =
the code, I noticed that nothing is done about lazy jars. My =
understanding of the spec. is that these jars should always be loaded =
over the network, like applet jars. Is so, the correct way to implement =
it would be to add the remote (http:) URLs of the jars when constructing =
the class loader for the application (eager jars use local file: URLs). =
I went ahead and made the required changes in FileCacheEntry, and =
included them below. Maybe it will be useful to some people, maybe it =
will be included in the CVS tree, or maybe someone will set me straight =
on this issue.
Also note that on the Windows 2000 system I'm using to test this, the =
FileCache.toSafeURL() method breaks the local file: URLs, even though it =
seems like the correct thing to do.
Hope this will be useful to someone,
Mario
Index: FileCacheEntry.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: =
/cvsroot/openjnlp/devel/src/org/nanode/launcher/cache/FileCacheEntry.java=
,v
retrieving revision 1.12
diff -w -r1.12 FileCacheEntry.java
157,159c157
< ArrayList eager =3D new ArrayList();
< File jarFile;
< URL jarURL;
---
> ArrayList urlList =3D new ArrayList();
162,164c160,166
< for (Enumeration enum =3D entryDescriptor.getResources().eagerJars(); =
enum.hasMoreElements();) {
< jarURL =3D ((Reference) enum.nextElement()).getURL();
< jarFile =3D new File(getResourceDir(), FileCache.cacheName(jarURL));
---
> for (Enumeration enum =3D entryDescriptor.getResources().jars(); =
enum.hasMoreElements();) {
> Reference jarReference =3D (Reference) enum.nextElement ();
> URL jarURL =3D jarReference.getURL ();
> if (jarReference.isLazy ()) {
> urlList.add (jarURL);
> } else { // Eager
> File jarFile =3D new File(getResourceDir(), =
FileCache.cacheName(jarURL));
167c169,170
< eager.add(FileCache.toSafeURL(jarFile));
---
> // TODO: This safeURL thing doesn't work under Windows 2000...
> urlList.add(jarFile.toURL () /* MC: WAS: =
FileCache.toSafeURL(jarFile)*/);
171a175
> }
173,174c177,178
< URL[] classpath =3D new URL[eager.size()];
< classpath =3D (URL[]) eager.toArray((Object[]) classpath);
---
> URL[] classpath =3D new URL[urlList.size()];
> classpath =3D (URL[]) urlList.toArray((Object[]) classpath);
|