langtools/src/share/classes/com/sun/tools/javac/sym/CreateSymbols.java
changeset 22163 3651128c74eb
parent 22159 682da512ec17
child 22165 ec53c8946fc2
equal deleted inserted replaced
22162:3b3e23e67329 22163:3651128c74eb
    94 public class CreateSymbols extends AbstractProcessor {
    94 public class CreateSymbols extends AbstractProcessor {
    95 
    95 
    96     static Set<String> getLegacyPackages() {
    96     static Set<String> getLegacyPackages() {
    97         ResourceBundle legacyBundle
    97         ResourceBundle legacyBundle
    98             = ResourceBundle.getBundle("com.sun.tools.javac.resources.legacy");
    98             = ResourceBundle.getBundle("com.sun.tools.javac.resources.legacy");
    99         Set<String> keys = new HashSet<String>();
    99         Set<String> keys = new HashSet<>();
   100         for (Enumeration<String> e = legacyBundle.getKeys(); e.hasMoreElements(); )
   100         for (Enumeration<String> e = legacyBundle.getKeys(); e.hasMoreElements(); )
   101             keys.add(e.nextElement());
   101             keys.add(e.nextElement());
   102         return keys;
   102         return keys;
   103     }
   103     }
   104 
   104 
   127     }
   127     }
   128 
   128 
   129     void createSymbols() throws IOException {
   129     void createSymbols() throws IOException {
   130         Set<String> legacy = getLegacyPackages();
   130         Set<String> legacy = getLegacyPackages();
   131         Set<String> legacyProprietary = getLegacyPackages();
   131         Set<String> legacyProprietary = getLegacyPackages();
   132         Set<String> documented = new HashSet<String>();
   132         Set<String> documented = new HashSet<>();
   133         Set<PackageSymbol> packages =
   133         Set<PackageSymbol> packages =
   134             ((JavacProcessingEnvironment)processingEnv).getSpecifiedPackages();
   134             ((JavacProcessingEnvironment)processingEnv).getSpecifiedPackages();
   135         Map<String,String> pOptions = processingEnv.getOptions();
   135         Map<String,String> pOptions = processingEnv.getOptions();
   136         String jarName = pOptions.get("com.sun.tools.javac.sym.Jar");
   136         String jarName = pOptions.get("com.sun.tools.javac.sym.Jar");
   137         if (jarName == null)
   137         if (jarName == null)
   156         File jarFile = new File(jarName);
   156         File jarFile = new File(jarName);
   157         fm.setLocation(jarLocation, List.of(jarFile));
   157         fm.setLocation(jarLocation, List.of(jarFile));
   158         fm.setLocation(StandardLocation.CLASS_PATH, List.<File>nil());
   158         fm.setLocation(StandardLocation.CLASS_PATH, List.<File>nil());
   159         fm.setLocation(StandardLocation.SOURCE_PATH, List.<File>nil());
   159         fm.setLocation(StandardLocation.SOURCE_PATH, List.<File>nil());
   160         {
   160         {
   161             ArrayList<File> bootClassPath = new ArrayList<File>();
   161             ArrayList<File> bootClassPath = new ArrayList<>();
   162             bootClassPath.add(jarFile);
   162             bootClassPath.add(jarFile);
   163             for (File path : fm.getLocation(StandardLocation.PLATFORM_CLASS_PATH)) {
   163             for (File path : fm.getLocation(StandardLocation.PLATFORM_CLASS_PATH)) {
   164                 if (!new File(path.getName()).equals(new File("rt.jar")))
   164                 if (!new File(path.getName()).equals(new File("rt.jar")))
   165                     bootClassPath.add(path);
   165                     bootClassPath.add(path);
   166             }
   166             }
   171         File destDir = new File(destName);
   171         File destDir = new File(destName);
   172         if (!destDir.exists())
   172         if (!destDir.exists())
   173             if (!destDir.mkdirs())
   173             if (!destDir.mkdirs())
   174                 throw new RuntimeException("Could not create " + destDir);
   174                 throw new RuntimeException("Could not create " + destDir);
   175         fm.setLocation(StandardLocation.CLASS_OUTPUT, List.of(destDir));
   175         fm.setLocation(StandardLocation.CLASS_OUTPUT, List.of(destDir));
   176         Set<String> hiddenPackages = new HashSet<String>();
   176         Set<String> hiddenPackages = new HashSet<>();
   177         Set<String> crisp = new HashSet<String>();
   177         Set<String> crisp = new HashSet<>();
   178         List<String> options = List.of("-XDdev");
   178         List<String> options = List.of("-XDdev");
   179         // options = options.prepend("-doe");
   179         // options = options.prepend("-doe");
   180         // options = options.prepend("-verbose");
   180         // options = options.prepend("-verbose");
   181         JavacTaskImpl task = (JavacTaskImpl)
   181         JavacTaskImpl task = (JavacTaskImpl)
   182             tool.getTask(null, fm, null, options, null, null);
   182             tool.getTask(null, fm, null, options, null, null);
   190                                    List.<Pair<Symbol.MethodSymbol,Attribute>>nil());
   190                                    List.<Pair<Symbol.MethodSymbol,Attribute>>nil());
   191         Attribute.Compound[] profileAnnos = new Attribute.Compound[profiles.getProfileCount() + 1];
   191         Attribute.Compound[] profileAnnos = new Attribute.Compound[profiles.getProfileCount() + 1];
   192         Symbol.MethodSymbol profileValue = (MethodSymbol) syms.profileType.tsym.members().lookup(names.value).sym;
   192         Symbol.MethodSymbol profileValue = (MethodSymbol) syms.profileType.tsym.members().lookup(names.value).sym;
   193         for (int i = 1; i < profileAnnos.length; i++) {
   193         for (int i = 1; i < profileAnnos.length; i++) {
   194             profileAnnos[i] = new Attribute.Compound(syms.profileType,
   194             profileAnnos[i] = new Attribute.Compound(syms.profileType,
   195                     List.<Pair<Symbol.MethodSymbol, Attribute>>of(
   195                     List.<Pair<Symbol.MethodSymbol, Attribute>>of(new Pair<>(profileValue, new Attribute.Constant(syms.intType, i))));
   196                     new Pair<Symbol.MethodSymbol, Attribute>(profileValue, new Attribute.Constant(syms.intType, i))));
       
   197         }
   196         }
   198 
   197 
   199         Type.moreInfo = true;
   198         Type.moreInfo = true;
   200         Types types = Types.instance(task.getContext());
   199         Types types = Types.instance(task.getContext());
   201         Pool pool = new Pool(types);
   200         Pool pool = new Pool(types);