This commit is contained in:
Daniel D. Daugherty 2015-07-03 06:39:38 -07:00
commit 92febebcac
4 changed files with 61 additions and 43 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -1594,15 +1594,20 @@ public class ToolBox {
}
/*
* A jar: URL is of the form jar:URL!/entry where URL is a URL for the .jar file itself.
* A jar: URL is of the form jar:URL!/<entry> where URL is a URL for the .jar file itself.
* In Symbol files (i.e. ct.sym) the underlying entry is prefixed META-INF/sym/<base>.
*/
private final Pattern jarEntry = Pattern.compile(".*!/(?:META-INF/sym/[^/]+/)?(.*)");
/*
* A jrt: URL is of the form jrt:/module/package/file
* A jrt: URL is of the form jrt:/modules/<module>/<package>/<file>
*/
private final Pattern jrtEntry = Pattern.compile("/([^/]+)/(.*)");
private final Pattern jrtEntry = Pattern.compile("/modules/([^/]+)/(.*)");
/*
* A file: URL is of the form file:/path/to/modules/<module>/<package>/<file>
*/
private final Pattern fileEntry = Pattern.compile(".*/modules/([^/]+)/(.*)");
private String guessPath(FileObject fo) {
URI u = fo.toUri();
@ -1621,6 +1626,13 @@ public class ToolBox {
}
break;
}
case "file": {
Matcher m = fileEntry.matcher(u.getSchemeSpecificPart());
if (m.matches()) {
return m.group(2);
}
break;
}
}
throw new IllegalArgumentException(fo.getName() + "--" + fo.toUri());
}