< prev index next >

make/src/classes/build/tools/charsetmapping/SRC.java

Print this page
rev 17642 : 8186517: sun.nio.cs.StandardCharsets$Aliases and Classes can be lazily loaded
Reviewed-by: sherman, martin, plevart


  34         throws Exception
  35     {
  36         String clzName = cs.clzName;
  37         String csName  = cs.csName;
  38         String pkgName = cs.pkgName;
  39 
  40         try (Scanner s = new Scanner(new File(srcDir, clzName + ".java.template"));
  41              PrintStream out = new PrintStream(new FileOutputStream(
  42                                   new File(dstDir, clzName + ".java")));) {
  43             while (s.hasNextLine()) {
  44                 String line = s.nextLine();
  45                 if (line.indexOf("$") < 0) {
  46                     out.println(line);
  47                     continue;
  48                 }
  49                 if (line.indexOf("$PACKAGE$") != -1) {
  50                     out.println(line.replace("$PACKAGE$", pkgName));
  51                 } else if (line.indexOf("$ALIASES$") != -1) {
  52                     if ("sun.nio.cs".equals(pkgName))
  53                         out.println(line.replace("$ALIASES$",
  54                                                  "StandardCharsets.aliases_" + clzName));
  55                     else
  56                         out.println(line.replace("$ALIASES$",
  57                                                  "ExtendedCharsets.aliasesFor(\"" + csName + "\")"));
  58                 } else {
  59                     out.println(line);
  60                 }
  61             }
  62         }
  63     }
  64 }


  34         throws Exception
  35     {
  36         String clzName = cs.clzName;
  37         String csName  = cs.csName;
  38         String pkgName = cs.pkgName;
  39 
  40         try (Scanner s = new Scanner(new File(srcDir, clzName + ".java.template"));
  41              PrintStream out = new PrintStream(new FileOutputStream(
  42                                   new File(dstDir, clzName + ".java")));) {
  43             while (s.hasNextLine()) {
  44                 String line = s.nextLine();
  45                 if (line.indexOf("$") < 0) {
  46                     out.println(line);
  47                     continue;
  48                 }
  49                 if (line.indexOf("$PACKAGE$") != -1) {
  50                     out.println(line.replace("$PACKAGE$", pkgName));
  51                 } else if (line.indexOf("$ALIASES$") != -1) {
  52                     if ("sun.nio.cs".equals(pkgName))
  53                         out.println(line.replace("$ALIASES$",
  54                                                  "StandardCharsets.aliases_" + clzName + "()"));
  55                     else
  56                         out.println(line.replace("$ALIASES$",
  57                                                  "ExtendedCharsets.aliasesFor(\"" + csName + "\")"));
  58                 } else {
  59                     out.println(line);
  60                 }
  61             }
  62         }
  63     }
  64 }
< prev index next >