[libbluray-devel] [PATCH] Fix jar resource urls fixing.

Petri Hintukainen phintuka at users.sourceforge.net
Fri Sep 26 09:53:06 CEST 2014


On ma, 2014-09-22 at 10:39 +0200, Andreas Zelend wrote:
> The condition was too strict. On win32 I get, e.g.,
> "file:d:\\BDMV\\JAR\\77771.jar!\\00000.otf".
> I'm not sure if my proposal is too lax.
>
> btw the font couldn't be loaded by the FontFactory anyway.

Maybe it was trying to load from wrong .jar file(s). Currently it just
assumes all files are in the class path, but this is not necessarily
true. Did you check if the file is in 77771.jar ? And, is that .jar in
xlet class path ?

I have no idea if FontFactrory actually works (and fonts can be used for
rendering). If it ends using libbluray/freetype font renderer, fonts
can't be loaded (freetype does not load fonts from .jar).

> From 68da796f80c89aa048f2bd2feb0bfd653d586a3c Mon Sep 17 00:00:00 2001
> From: ace20022 <ace20022 at ymail.com>
> Date: Mon, 22 Sep 2014 10:14:58 +0200
> Subject: [PATCH 2/2] Fix jar resource urls fixing.
> 
> ---
>  src/libbluray/bdj/java/java/io/FileInputStream.java | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/src/libbluray/bdj/java/java/io/FileInputStream.java
> b/src/libbluray/bdj/java/java/io/FileInputStream.java
> index 464e42c..627dfab 100644
> --- a/src/libbluray/bdj/java/java/io/FileInputStream.java
> +++ b/src/libbluray/bdj/java/java/io/FileInputStream.java
> @@ -83,9 +83,11 @@ public class FileInputStream extends InputStream
>          }
>  
>          /* J2SE URL.getPath() returns file:/xxx.jar!/... for jar
> resource urls ... */
> -        if (name.indexOf("file:/") == 0 && name.indexOf(".jar!/") >
> 0) {
> +        if (name.indexOf(".jar!") > 0) {

I would leave the check for "file:" prefix here (unless you've spotted
resource paths without file: prefix ?)

>              logger.error("Fixing invalid resource url: " + name);
> -            name = name.substring(name.indexOf(".jar!") + 6);
> +            name = name.substring(name.indexOf(".jar!") + 5);
> +            while (name.startsWith("/") || name.startsWith("\\"))
> +                name = name.substring(1);

Is this necessary ? I think there must be always one (and only one) /
after .jar!

Also, I think paths inside .jar should use / as separator (not \), but
those are already converted in class loader. Maybe those could be
converted also here, if we need to load files from .jar outside of class
path.

>          }
>  
>          /* try to locate file in Xlet home directory (inside JAR
> file) */




More information about the libbluray-devel mailing list