1.1 --- a/vm/src/test/java/org/apidesign/vm4brwsr/Exceptions.java Mon Feb 25 19:00:08 2013 +0100
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,88 +0,0 @@
1.4 -/**
1.5 - * Back 2 Browser Bytecode Translator
1.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
1.7 - *
1.8 - * This program is free software: you can redistribute it and/or modify
1.9 - * it under the terms of the GNU General Public License as published by
1.10 - * the Free Software Foundation, version 2 of the License.
1.11 - *
1.12 - * This program is distributed in the hope that it will be useful,
1.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.15 - * GNU General Public License for more details.
1.16 - *
1.17 - * You should have received a copy of the GNU General Public License
1.18 - * along with this program. Look for COPYING file in the top folder.
1.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
1.20 - */
1.21 -package org.apidesign.vm4brwsr;
1.22 -
1.23 -import org.apidesign.bck2brwsr.core.JavaScriptBody;
1.24 -
1.25 -/**
1.26 - *
1.27 - * @author tom
1.28 - */
1.29 -public class Exceptions {
1.30 - private Exceptions() {
1.31 - }
1.32 -
1.33 - public static int methodWithTryCatchNoThrow() {
1.34 - int res = 0;
1.35 - try {
1.36 - res = 1;
1.37 - } catch (IllegalArgumentException e) {
1.38 - res = 2;
1.39 - }
1.40 - //join point
1.41 - return res;
1.42 - }
1.43 -
1.44 - public static int methodWithTryCatchThrow() {
1.45 - int res = 0;
1.46 - try {
1.47 - res = 1;
1.48 - throw new IllegalArgumentException();
1.49 - } catch (IllegalArgumentException e) {
1.50 - res = 2;
1.51 - }
1.52 - //join point
1.53 - return res;
1.54 - }
1.55 -
1.56 - @JavaScriptBody(args = "msg", body = "throw msg;")
1.57 - public static void thrw(String msg) {}
1.58 -
1.59 - public static String catchThrowableCatchesAll() {
1.60 - try {
1.61 - thrw("Hello!");
1.62 - return "Not here!";
1.63 - } catch (Throwable ex) {
1.64 - return ex.getMessage();
1.65 - }
1.66 - }
1.67 -
1.68 - public static String newInstance(String n) {
1.69 - try {
1.70 - Class c;
1.71 - try {
1.72 - c = Class.forName(n);
1.73 - } catch (ClassNotFoundException ex) {
1.74 - return ("CNFE:" + ex.getMessage()).toString();
1.75 - }
1.76 - return c.newInstance().getClass().getName();
1.77 - } catch (InstantiationException | IllegalAccessException ex) {
1.78 - return ex.getMessage();
1.79 - }
1.80 - }
1.81 -
1.82 - private static int counter;
1.83 - public static int readCounter(String n) throws ClassNotFoundException {
1.84 - try {
1.85 - Class.forName(n);
1.86 - } finally {
1.87 - counter++;
1.88 - }
1.89 - return counter;
1.90 - }
1.91 -}