langtools/test/tools/lib/ToolBox.java
changeset 31755 c6a3df5917fd
parent 31506 4e07f827a794
parent 31753 72417309a675
child 34473 5f7202c2125d
equal deleted inserted replaced
31506:4e07f827a794 31755:c6a3df5917fd
     1 /*
     1 /*
     2  * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
  1592             }
  1592             }
  1593             }
  1593             }
  1594         }
  1594         }
  1595 
  1595 
  1596         /*
  1596         /*
  1597          * A jar: URL is of the form  jar:URL!/entry  where URL is a URL for the .jar file itself.
  1597          * A jar: URL is of the form  jar:URL!/<entry>  where URL is a URL for the .jar file itself.
  1598          * In Symbol files (i.e. ct.sym) the underlying entry is prefixed META-INF/sym/<base>.
  1598          * In Symbol files (i.e. ct.sym) the underlying entry is prefixed META-INF/sym/<base>.
  1599          */
  1599          */
  1600         private final Pattern jarEntry = Pattern.compile(".*!/(?:META-INF/sym/[^/]+/)?(.*)");
  1600         private final Pattern jarEntry = Pattern.compile(".*!/(?:META-INF/sym/[^/]+/)?(.*)");
  1601 
  1601 
  1602         /*
  1602         /*
  1603          * A jrt: URL is of the form  jrt:/module/package/file
  1603          * A jrt: URL is of the form  jrt:/modules/<module>/<package>/<file>
  1604          */
  1604          */
  1605         private final Pattern jrtEntry = Pattern.compile("/([^/]+)/(.*)");
  1605         private final Pattern jrtEntry = Pattern.compile("/modules/([^/]+)/(.*)");
       
  1606 
       
  1607         /*
       
  1608          * A file: URL is of the form  file:/path/to/modules/<module>/<package>/<file>
       
  1609          */
       
  1610         private final Pattern fileEntry = Pattern.compile(".*/modules/([^/]+)/(.*)");
  1606 
  1611 
  1607         private String guessPath(FileObject fo) {
  1612         private String guessPath(FileObject fo) {
  1608             URI u = fo.toUri();
  1613             URI u = fo.toUri();
  1609             switch (u.getScheme()) {
  1614             switch (u.getScheme()) {
  1610                 case "jar": {
  1615                 case "jar": {
  1619                     if (m.matches()) {
  1624                     if (m.matches()) {
  1620                         return m.group(2);
  1625                         return m.group(2);
  1621                     }
  1626                     }
  1622                     break;
  1627                     break;
  1623                 }
  1628                 }
       
  1629                 case "file": {
       
  1630                     Matcher m = fileEntry.matcher(u.getSchemeSpecificPart());
       
  1631                     if (m.matches()) {
       
  1632                         return m.group(2);
       
  1633                     }
       
  1634                     break;
       
  1635                 }
  1624             }
  1636             }
  1625             throw new IllegalArgumentException(fo.getName() + "--" + fo.toUri());
  1637             throw new IllegalArgumentException(fo.getName() + "--" + fo.toUri());
  1626         }
  1638         }
  1627 
  1639 
  1628         private void error(String message, Throwable t) {
  1640         private void error(String message, Throwable t) {