langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/Package.java
changeset 26107 a4a156a33c94
parent 26104 34de7e01b3c1
parent 25874 83c19f00452c
child 31115 8d8e98052d5d
equal deleted inserted replaced
25876:d06a6d3c66c0 26107:a4a156a33c94
     1 /*
     1 /*
     2  * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2012, 2014, 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.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    33 import java.util.HashSet;
    33 import java.util.HashSet;
    34 import java.util.Iterator;
    34 import java.util.Iterator;
    35 import java.util.List;
    35 import java.util.List;
    36 import java.util.Map;
    36 import java.util.Map;
    37 import java.util.Set;
    37 import java.util.Set;
       
    38 import com.sun.tools.javac.util.Assert;
    38 
    39 
    39 /**
    40 /**
    40  * The Package class maintains meta information about a package.
    41  * The Package class maintains meta information about a package.
    41  * For example its sources, dependents,its pubapi and its artifacts.
    42  * For example its sources, dependents,its pubapi and its artifacts.
    42  *
    43  *
    52  * It is also educational to see package dependencies triggering recompilation of
    53  * It is also educational to see package dependencies triggering recompilation of
    53  * other packages. Even though the recompilation was perhaps not necessary,
    54  * other packages. Even though the recompilation was perhaps not necessary,
    54  * the visible recompilation of the dependent packages indicates how much circular
    55  * the visible recompilation of the dependent packages indicates how much circular
    55  * dependencies your code has.
    56  * dependencies your code has.
    56  *
    57  *
    57  * <p><b>This is NOT part of any supported API.
    58  *  <p><b>This is NOT part of any supported API.
    58  * If you write code that depends on this, you do so at your own
    59  *  If you write code that depends on this, you do so at your own risk.
    59  * risk.  This code and its internal interfaces are subject to change
    60  *  This code and its internal interfaces are subject to change or
    60  * or deletion without notice.</b></p>
    61  *  deletion without notice.</b>
    61  */
    62  */
    62 public class Package implements Comparable<Package> {
    63 public class Package implements Comparable<Package> {
    63     // The module this package belongs to. (There is a legacy module with an empty string name,
    64     // The module this package belongs to. (There is a legacy module with an empty string name,
    64     // used for all legacy sources.)
    65     // used for all legacy sources.)
    65     private Module mod;
    66     private Module mod;
    81     // This package generated these artifacts.
    82     // This package generated these artifacts.
    82     private Map<String,File> artifacts = new HashMap<>();
    83     private Map<String,File> artifacts = new HashMap<>();
    83 
    84 
    84     public Package(Module m, String n) {
    85     public Package(Module m, String n) {
    85         int c = n.indexOf(":");
    86         int c = n.indexOf(":");
    86         assert(c != -1);
    87         Assert.check(c != -1);
    87         String mn = n.substring(0,c);
    88         String mn = n.substring(0,c);
    88         assert(m.name().equals(m.name()));
    89         Assert.check(m.name().equals(m.name()));
    89         name = n;
    90         name = n;
    90         dirname = n.replace('.', File.separatorChar);
    91         dirname = n.replace('.', File.separatorChar);
    91         if (m.name().length() > 0) {
    92         if (m.name().length() > 0) {
    92             // There is a module here, prefix the module dir name to the path.
    93             // There is a module here, prefix the module dir name to the path.
    93             dirname = m.dirname()+File.separatorChar+dirname;
    94             dirname = m.dirname()+File.separatorChar+dirname;
   254             addArtifact(new File(u));
   255             addArtifact(new File(u));
   255         }
   256         }
   256     }
   257     }
   257 
   258 
   258     public void setArtifacts(Set<URI> as) {
   259     public void setArtifacts(Set<URI> as) {
   259         assert(!artifacts.isEmpty());
   260         Assert.check(!artifacts.isEmpty());
   260         artifacts = new HashMap<>();
   261         artifacts = new HashMap<>();
   261         addArtifacts(as);
   262         addArtifacts(as);
   262     }
   263     }
   263 
   264 
   264     public void loadArtifact(String l) {
   265     public void loadArtifact(String l) {