Print this page


Split Close
Expand all
Collapse all
          --- old/src/share/classes/sun/rmi/rmic/Main.java
          +++ new/src/share/classes/sun/rmi/rmic/Main.java
↓ open down ↓ 65 lines elided ↑ open up ↑
  66   66   * they are subject to change or removal without notice.
  67   67   */
  68   68  public class Main implements sun.rmi.rmic.Constants {
  69   69      String sourcePathArg;
  70   70      String sysClassPathArg;
  71   71      String extDirsArg;
  72   72      String classPathString;
  73   73      File destDir;
  74   74      int flags;
  75   75      long tm;
  76      -    Vector classes;
       76 +    Vector<String> classes;
  77   77      boolean nowrite;
  78   78      boolean nocompile;
  79   79      boolean keepGenerated;
  80   80      boolean status;
  81   81      String[] generatorArgs;
  82      -    Vector generators;
  83      -    Class environmentClass = BatchEnvironment.class;
       82 +    Vector<Generator> generators;
       83 +    Class<?> environmentClass = BatchEnvironment.class;
  84   84      boolean iiopGeneration = false;
  85   85  
  86   86      /**
  87   87       * Name of the program.
  88   88       */
  89   89      String program;
  90   90  
  91   91      /**
  92   92       * The stream where error message are printed.
  93   93       */
↓ open down ↓ 82 lines elided ↑ open up ↑
 176  176       */
 177  177      public boolean parseArgs(String argv[]) {
 178  178          sourcePathArg = null;
 179  179          sysClassPathArg = null;
 180  180          extDirsArg = null;
 181  181  
 182  182          classPathString = null;
 183  183          destDir = null;
 184  184          flags = F_WARNINGS;
 185  185          tm = System.currentTimeMillis();
 186      -        classes = new Vector();
      186 +        classes = new Vector<String>();
 187  187          nowrite = false;
 188  188          nocompile = false;
 189  189          keepGenerated = false;
 190  190          generatorArgs = getArray("generator.args",true);
 191  191          if (generatorArgs == null) {
 192  192              return false;
 193  193          }
 194      -        generators = new Vector();
      194 +        generators = new Vector<Generator>();
 195  195  
 196  196          // Pre-process command line for @file arguments
 197  197          try {
 198  198              argv = CommandLine.parse(argv);
 199  199          } catch (FileNotFoundException e) {
 200  200              error("rmic.cant.read", e.getMessage());
 201  201              return false;
 202  202          } catch (IOException e) {
 203  203              e.printStackTrace(out instanceof PrintStream ?
 204  204                                (PrintStream) out :
↓ open down ↓ 199 lines elided ↑ open up ↑
 404  404              gen = (Generator) Class.forName(className).newInstance();
 405  405          } catch (Exception e) {
 406  406              error("rmic.cannot.instantiate",className);
 407  407              return null;
 408  408          }
 409  409  
 410  410          generators.addElement(gen);
 411  411  
 412  412          // Get the environment required by this generator...
 413  413  
 414      -        Class envClass = BatchEnvironment.class;
      414 +        Class<?> envClass = BatchEnvironment.class;
 415  415          String env = getString("generator.env." + arg);
 416  416          if (env != null) {
 417  417              try {
 418  418                  envClass = Class.forName(env);
 419  419  
 420  420                  // Is the new class a subclass of the current one?
 421  421  
 422  422                  if (environmentClass.isAssignableFrom(envClass)) {
 423  423  
 424  424                      // Yes, so switch to the new one...
↓ open down ↓ 63 lines elided ↑ open up ↑
 488  488      public BatchEnvironment getEnv() {
 489  489  
 490  490          ClassPath classPath =
 491  491              BatchEnvironment.createClassPath(classPathString,
 492  492                                               sysClassPathArg,
 493  493                                               extDirsArg);
 494  494          BatchEnvironment result = null;
 495  495          try {
 496  496              Class[] ctorArgTypes = {OutputStream.class,ClassPath.class,Main.class};
 497  497              Object[] ctorArgs = {out,classPath,this};
 498      -            Constructor constructor = environmentClass.getConstructor(ctorArgTypes);
      498 +            Constructor<?> constructor = environmentClass.getConstructor(ctorArgTypes);
 499  499              result = (BatchEnvironment) constructor.newInstance(ctorArgs);
 500  500              result.reset();
 501  501          }
 502  502          catch (Exception e) {
 503  503              error("rmic.cannot.instantiate",environmentClass.getName());
 504  504          }
 505  505          return result;
 506  506      }
 507  507  
 508  508  
↓ open down ↓ 14 lines elided ↑ open up ↑
 523  523          // out of memory during the compile.
 524  524          String noMemoryErrorString = getText("rmic.no.memory");
 525  525          String stackOverflowErrorString = getText("rmic.stack.overflow");
 526  526  
 527  527          try {
 528  528              /** Load the classes on the command line
 529  529               * Replace the entries in classes with the ClassDefinition for the class
 530  530               */
 531  531              for (int i = classes.size()-1; i >= 0; i-- ) {
 532  532                  Identifier implClassName =
 533      -                    Identifier.lookup((String)classes.elementAt(i));
      533 +                    Identifier.lookup(classes.elementAt(i));
 534  534  
 535  535                  /*
 536  536                   * Fix bugid 4049354: support using '.' as an inner class
 537  537                   * qualifier on the command line (previously, only mangled
 538  538                   * inner class names were understood, like "pkg.Outer$Inner").
 539  539                   *
 540  540                   * The following method, also used by "javap", resolves the
 541  541                   * given unmangled inner class name to the appropriate
 542  542                   * internal identifier.  For example, it translates
 543  543                   * "pkg.Outer.Inner" to "pkg.Outer. Inner".
↓ open down ↓ 7 lines elided ↑ open up ↑
 551  551                   * cast to it.  To work around this problem, we mangle inner
 552  552                   * class name identifiers to their binary "outer" class name:
 553  553                   * "pkg.Outer. Inner" becomes "pkg.Outer$Inner".
 554  554                   */
 555  555                  implClassName = Names.mangleClass(implClassName);
 556  556  
 557  557                  ClassDeclaration decl = env.getClassDeclaration(implClassName);
 558  558                  try {
 559  559                      ClassDefinition def = decl.getClassDefinition(env);
 560  560                      for (int j = 0; j < generators.size(); j++) {
 561      -                        Generator gen = (Generator)generators.elementAt(j);
      561 +                        Generator gen = generators.elementAt(j);
 562  562                          gen.generate(env, def, destDir);
 563  563                      }
 564  564                  } catch (ClassNotFound ex) {
 565  565                      env.error(0, "rmic.class.not.found", implClassName);
 566  566                  }
 567  567  
 568  568              }
 569  569  
 570  570              // compile all classes that need compilation
 571  571              if (!nocompile) {
↓ open down ↓ 94 lines elided ↑ open up ↑
 666  666       */
 667  667      public void compileAllClasses (BatchEnvironment env)
 668  668          throws ClassNotFound,
 669  669                 IOException,
 670  670                 InterruptedException {
 671  671          ByteArrayOutputStream buf = new ByteArrayOutputStream(4096);
 672  672          boolean done;
 673  673  
 674  674          do {
 675  675              done = true;
 676      -            for (Enumeration e = env.getClasses() ; e.hasMoreElements() ; ) {
      676 +            for (Enumeration<?> e = env.getClasses() ; e.hasMoreElements() ; ) {
 677  677                  ClassDeclaration c = (ClassDeclaration)e.nextElement();
 678  678                  done = compileClass(c,buf,env);
 679  679              }
 680  680          } while (!done);
 681  681      }
 682  682  
 683  683      /*
 684  684       * Compile a single class.
      685 +     * Fallthrough is intentional
 685  686       */
      687 +    @SuppressWarnings("fallthrough")
 686  688      public boolean compileClass (ClassDeclaration c,
 687  689                                   ByteArrayOutputStream buf,
 688  690                                   BatchEnvironment env)
 689  691          throws ClassNotFound,
 690  692                 IOException,
 691  693                 InterruptedException {
 692  694          boolean done = true;
 693  695          env.flushErrors();
 694  696          SourceClass src;
 695  697  
↓ open down ↓ 176 lines elided ↑ open up ↑
 872  874          if (format == null) {
 873  875              format = "no text found: key = \"" + key + "\", " +
 874  876                  "arguments = \"{0}\", \"{1}\", \"{2}\"";
 875  877          }
 876  878  
 877  879          String[] args = new String[3];
 878  880          args[0] = (arg0 != null ? arg0.toString() : "null");
 879  881          args[1] = (arg1 != null ? arg1.toString() : "null");
 880  882          args[2] = (arg2 != null ? arg2.toString() : "null");
 881  883  
 882      -        return java.text.MessageFormat.format(format, args);
      884 +        return java.text.MessageFormat.format(format, (Object[]) args);
 883  885      }
 884  886  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX