< prev index next >

test/langtools/tools/javac/recovery/ClassBlockExits.java

Print this page

  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  */
 23 
 24 /*
 25  * @test
 26  * @bug 8243047
 27  * @summary javac should not crash while processing exits in class initializers in Flow

 28  * @library /tools/lib /tools/javac/lib
 29  * @modules jdk.compiler/com.sun.tools.javac.api
 30  *          jdk.compiler/com.sun.tools.javac.file
 31  *          jdk.compiler/com.sun.tools.javac.main
 32  *          jdk.compiler/com.sun.tools.javac.util
 33  * @build toolbox.ToolBox toolbox.JavacTask
 34  * @build combo.ComboTestHelper
 35  * @compile ClassBlockExits.java
 36  * @run main ClassBlockExits
 37  */
 38 
 39 import combo.ComboInstance;
 40 import combo.ComboParameter;
 41 import combo.ComboTask;
 42 import combo.ComboTestHelper;
 43 import java.io.StringWriter;
 44 import toolbox.ToolBox;
 45 
 46 public class ClassBlockExits extends ComboInstance<ClassBlockExits> {
 47     protected ToolBox tb;

121 
122     public enum Exit implements ComboParameter {
123         RETURN("return;"),
124         RETURN_VALUE("return null;"),
125         BREAK("break;"),
126         BREAK_LABEL("break LABEL;"),
127         CONTINUE("continue;"),
128         CONTINUE_LABEL("continue LABEL;"),
129         YIELD("yield 0;");
130         private final String code;
131 
132         private Exit(String code) {
133             this.code = code;
134         }
135 
136         @Override
137         public String expand(String optParameter) {
138             return code;
139         }
140     }
141 }

  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  */
 23 
 24 /*
 25  * @test
 26  * @bug 8243047
 27  * @summary javac should not crash while processing exits in class initializers in Flow
 28  * @enablePreview
 29  * @library /tools/lib /tools/javac/lib
 30  * @modules jdk.compiler/com.sun.tools.javac.api
 31  *          jdk.compiler/com.sun.tools.javac.file
 32  *          jdk.compiler/com.sun.tools.javac.main
 33  *          jdk.compiler/com.sun.tools.javac.util
 34  * @build toolbox.ToolBox toolbox.JavacTask
 35  * @build combo.ComboTestHelper
 36  * @compile ClassBlockExits.java
 37  * @run main ClassBlockExits
 38  */
 39 
 40 import combo.ComboInstance;
 41 import combo.ComboParameter;
 42 import combo.ComboTask;
 43 import combo.ComboTestHelper;
 44 import java.io.StringWriter;
 45 import toolbox.ToolBox;
 46 
 47 public class ClassBlockExits extends ComboInstance<ClassBlockExits> {
 48     protected ToolBox tb;

122 
123     public enum Exit implements ComboParameter {
124         RETURN("return;"),
125         RETURN_VALUE("return null;"),
126         BREAK("break;"),
127         BREAK_LABEL("break LABEL;"),
128         CONTINUE("continue;"),
129         CONTINUE_LABEL("continue LABEL;"),
130         YIELD("yield 0;");
131         private final String code;
132 
133         private Exit(String code) {
134             this.code = code;
135         }
136 
137         @Override
138         public String expand(String optParameter) {
139             return code;
140         }
141     }
142 }
< prev index next >