langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java
changeset 19923 4895f15b3845
parent 19657 48226ff07b84
child 19927 8793c5627ba7
equal deleted inserted replaced
19922:52810e1bbb4f 19923:4895f15b3845
    47 import static com.sun.tools.javac.code.Flags.BLOCK;
    47 import static com.sun.tools.javac.code.Flags.BLOCK;
    48 import static com.sun.tools.javac.code.Kinds.*;
    48 import static com.sun.tools.javac.code.Kinds.*;
    49 import static com.sun.tools.javac.code.TypeTag.*;
    49 import static com.sun.tools.javac.code.TypeTag.*;
    50 import static com.sun.tools.javac.jvm.ByteCodes.*;
    50 import static com.sun.tools.javac.jvm.ByteCodes.*;
    51 import static com.sun.tools.javac.tree.JCTree.Tag.*;
    51 import static com.sun.tools.javac.tree.JCTree.Tag.*;
    52 import javax.lang.model.type.TypeKind;
       
    53 
    52 
    54 /** This pass translates away some syntactic sugar: inner classes,
    53 /** This pass translates away some syntactic sugar: inner classes,
    55  *  class literals, assertions, foreach loops, etc.
    54  *  class literals, assertions, foreach loops, etc.
    56  *
    55  *
    57  *  <p><b>This is NOT part of any supported API.
    56  *  <p><b>This is NOT part of any supported API.
  3828         result = tree;
  3827         result = tree;
  3829     }
  3828     }
  3830 
  3829 
  3831     @Override
  3830     @Override
  3832     public void visitTry(JCTry tree) {
  3831     public void visitTry(JCTry tree) {
  3833         /* special case of try without catchers and with finally emtpy.
       
  3834          * Don't give it a try, translate only the body.
       
  3835          */
       
  3836         if (tree.resources.isEmpty()) {
  3832         if (tree.resources.isEmpty()) {
       
  3833             /* special case of try without catchers and with finally emtpy.
       
  3834              * Don't give it a try, translate only the body.
       
  3835              */
  3837             if (tree.catchers.isEmpty() &&
  3836             if (tree.catchers.isEmpty() &&
  3838                 tree.finalizer.getStatements().isEmpty()) {
  3837                 tree.finalizer.getStatements().isEmpty()) {
  3839                 result = translate(tree.body);
  3838                 result = translate(tree.body);
  3840             } else {
  3839             } else {
  3841                 super.visitTry(tree);
  3840                 /* also if the body is empty we only need to generate the finalizer
       
  3841                  * provided that it's not empty.
       
  3842                  */
       
  3843                 if (tree.body.getStatements().isEmpty()) {
       
  3844                     if (tree.finalizer.getStatements().isEmpty()) {
       
  3845                         result = translate(tree.body);
       
  3846                     } else {
       
  3847                         result = translate(tree.finalizer);
       
  3848                     }
       
  3849                 } else {
       
  3850                     super.visitTry(tree);
       
  3851                 }
  3842             }
  3852             }
  3843         } else {
  3853         } else {
  3844             result = makeTwrTry(tree);
  3854             result = makeTwrTry(tree);
  3845         }
  3855         }
  3846     }
  3856     }