Print this page


Split Close
Expand all
Collapse all
          --- old/src/share/classes/sun/rmi/rmic/RMIGenerator.java
          +++ new/src/share/classes/sun/rmi/rmic/RMIGenerator.java
↓ open down ↓ 53 lines elided ↑ open up ↑
  54   54   * a particular stub protocol version.
  55   55   *
  56   56   * WARNING: The contents of this source file are not part of any
  57   57   * supported API.  Code that depends on them does so at its own risk:
  58   58   * they are subject to change or removal without notice.
  59   59   *
  60   60   * @author      Peter Jones,  Bryan Atsatt
  61   61   */
  62   62  public class RMIGenerator implements RMIConstants, Generator {
  63   63  
  64      -    private static final Hashtable versionOptions = new Hashtable();
       64 +    private static final Hashtable<String, Integer> versionOptions = new Hashtable<>();
  65   65      static {
  66   66          versionOptions.put("-v1.1", new Integer(STUB_VERSION_1_1));
  67   67          versionOptions.put("-vcompat", new Integer(STUB_VERSION_FAT));
  68   68          versionOptions.put("-v1.2", new Integer(STUB_VERSION_1_2));
  69   69      }
  70   70  
  71   71      /**
  72   72       * Default constructor for Main to use.
  73   73       */
  74   74      public RMIGenerator() {
↓ open down ↓ 14 lines elided ↑ open up ↑
  89   89                  String arg = argv[i].toLowerCase();
  90   90                  if (versionOptions.containsKey(arg)) {
  91   91                      if (explicitVersion != null &&
  92   92                          !explicitVersion.equals(arg))
  93   93                      {
  94   94                          main.error("rmic.cannot.use.both",
  95   95                                     explicitVersion, arg);
  96   96                          return false;
  97   97                      }
  98   98                      explicitVersion = arg;
  99      -                    version = ((Integer) versionOptions.get(arg)).intValue();
       99 +                    version = versionOptions.get(arg);
 100  100                      argv[i] = null;
 101  101                  }
 102  102              }
 103  103          }
 104  104          return true;
 105  105      }
 106  106  
 107  107      /**
 108  108       * Generate the source files for the stub and/or skeleton classes
 109  109       * needed by RMI for the given remote implementation class.
↓ open down ↓ 402 lines elided ↑ open up ↑
 512  512           * any of the exceptions declared by this stub method, we want them
 513  513           * to pass through unharmed, so first we must catch any such
 514  514           * exceptions and rethrow it directly.
 515  515           *
 516  516           * We have to be careful generating the rethrowing catch blocks
 517  517           * here, because javac will flag an error if there are any
 518  518           * unreachable catch blocks, i.e. if the catch of an exception class
 519  519           * follows a previous catch of it or of one of its superclasses.
 520  520           * The following method invocation takes care of these details.
 521  521           */
 522      -        Vector catchList = computeUniqueCatchList(exceptions);
      522 +        Vector<ClassDefinition> catchList = computeUniqueCatchList(exceptions);
 523  523  
 524  524          /*
 525  525           * If we need to catch any particular exceptions (i.e. this method
 526  526           * does not declare java.lang.Exception), put the entire stub
 527  527           * method in a try block.
 528  528           */
 529  529          if (catchList.size() > 0) {
 530  530              p.plnI("try {");
 531  531          }
 532  532  
↓ open down ↓ 75 lines elided ↑ open up ↑
 608  608          if (version == STUB_VERSION_FAT) {
 609  609              p.pOln("}");                // end if/else (useNewInvoke) block
 610  610          }
 611  611  
 612  612          /*
 613  613           * If we need to catch any particular exceptions, finally write
 614  614           * the catch blocks for them, rethrow any other Exceptions with an
 615  615           * UnexpectedException, and end the try block.
 616  616           */
 617  617          if (catchList.size() > 0) {
 618      -            for (Enumeration enumeration = catchList.elements();
      618 +            for (Enumeration<ClassDefinition> enumeration = catchList.elements();
 619  619                   enumeration.hasMoreElements();)
 620  620              {
 621      -                ClassDefinition def = (ClassDefinition) enumeration.nextElement();
      621 +                ClassDefinition def = enumeration.nextElement();
 622  622                  p.pOlnI("} catch (" + def.getName() + " e) {");
 623  623                  p.pln("throw e;");
 624  624              }
 625  625              p.pOlnI("} catch (java.lang.Exception e) {");
 626  626              p.pln("throw new " + idUnexpectedException +
 627  627                  "(\"undeclared checked exception\", e);");
 628  628              p.pOln("}");                // end try/catch block
 629  629          }
 630  630  
 631  631          p.pOln("}");                    // end stub method
↓ open down ↓ 11 lines elided ↑ open up ↑
 643  643       *
 644  644       * RemoteException and RuntimeException are each automatically placed
 645  645       * in the returned Vector (if none of their superclasses are already
 646  646       * present), since those exceptions should always be directly rethrown
 647  647       * by a stub method.
 648  648       *
 649  649       * The returned Vector will be empty if java.lang.Exception or one
 650  650       * of its superclasses is in the throws clause of the method, indicating
 651  651       * that no exceptions need to be caught.
 652  652       */
 653      -    private Vector computeUniqueCatchList(ClassDeclaration[] exceptions) {
 654      -        Vector uniqueList = new Vector();       // unique exceptions to catch
      653 +    private Vector<ClassDefinition> computeUniqueCatchList(ClassDeclaration[] exceptions) {
      654 +        Vector<ClassDefinition> uniqueList = new Vector<>();       // unique exceptions to catch
 655  655  
 656  656          uniqueList.addElement(defRuntimeException);
 657  657          uniqueList.addElement(defRemoteException);
 658  658  
 659  659          /* For each exception declared by the stub method's throws clause: */
 660  660      nextException:
 661  661          for (int i = 0; i < exceptions.length; i++) {
 662  662              ClassDeclaration decl = exceptions[i];
 663  663              try {
 664  664                  if (defException.subClassOf(env, decl)) {
↓ open down ↓ 11 lines elided ↑ open up ↑
 676  676                       * since they do not need to be caught anyway.
 677  677                       */
 678  678                      continue;
 679  679                  }
 680  680                  /*
 681  681                   * Compare this exception against the current list of
 682  682                   * exceptions that need to be caught:
 683  683                   */
 684  684                  for (int j = 0; j < uniqueList.size();) {
 685  685                      ClassDefinition def =
 686      -                        (ClassDefinition) uniqueList.elementAt(j);
      686 +                        uniqueList.elementAt(j);
 687  687                      if (def.superClassOf(env, decl)) {
 688  688                          /*
 689  689                           * If a superclass of this exception is already on
 690  690                           * the list to catch, then ignore and continue;
 691  691                           */
 692  692                          continue nextException;
 693  693                      } else if (def.subClassOf(env, decl)) {
 694  694                          /*
 695  695                           * If a subclass of this exception is on the list
 696  696                           * to catch, then remove it.
↓ open down ↓ 607 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX