#6 Embedding runtime & backport fails in UNIX Environments

closed-fixed
nobody
None
5
2006-09-11
2006-09-08
Anonymous
No

private void prependLocationToSource(Class aClass) in
Retrotranslator class fails since the prefix is to long:
...
String url = resource.toExternalForm();
String prefix = "jar:file:/";
String suffix = "!" + path;
if (!url.startsWith(prefix) || !url.endsWith(suffix)) {
throw new IllegalArgumentException("Not in a jar
file: " + aClass);
}
File file = new File(url.substring(prefix.length(),
url.length() - suffix.length()));

jar:file:/home/sannies/...

is truncated to: home/sannies/... but this cannot be
found since suddenly the path is relative.

On windows this procedure works:

jar:file:/C:\\a\\b\\...

is truncated to C:\\a\\b\\...

RESOLUTION:

shorten the prefix by '/' to "jar:file:".
jar:file:/home/sannies/...
--> /home/sannies/...

jar:file:/C:\\a\\b\\...
--> /C:\\a\\b\\...

And on Windows the slash in front of the path is no
harm! --> new File("/C:\\a\\b\\...").exists() == true

Hope someone can fix that soon

Discussion

  • Taras Puchko

    Taras Puchko - 2006-09-08

    Logged In: YES
    user_id=1384557

    I will fix it in a day or two. Let me know if you need a
    new release with this fix included.

     
  • Nobody/Anonymous

    Logged In: NO

    I fixed it for myself but my colleages feel better using an
    official release instead of a home brewn version. Thanks for
    the prompt response.

    Regards,
    Sebastian

     
  • Taras Puchko

    Taras Puchko - 2006-09-11
    • status: open --> closed-fixed
     

Log in to post a comment.