Catch_NPE_08.java revision 12651:6ef01bd40ce2
187514Scjc/*
287514Scjc * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
387514Scjc * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
487514Scjc *
587514Scjc * This code is free software; you can redistribute it and/or modify it
687514Scjc * under the terms of the GNU General Public License version 2 only, as
787514Scjc * published by the Free Software Foundation.
887514Scjc *
987514Scjc * This code is distributed in the hope that it will be useful, but WITHOUT
1087514Scjc * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1187514Scjc * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1287514Scjc * version 2 for more details (a copy is included in the LICENSE file that
1387514Scjc * accompanied this code).
1487514Scjc *
1587514Scjc * You should have received a copy of the GNU General Public License version
1687514Scjc * 2 along with this work; if not, write to the Free Software Foundation,
1787514Scjc * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1887514Scjc *
1987514Scjc * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2087514Scjc * or visit www.oracle.com if you need additional information or have any
2187514Scjc * questions.
2287514Scjc */
2387514Scjcpackage org.graalvm.compiler.jtt.except;
2487514Scjc
2587514Scjcimport org.junit.Test;
2687514Scjc
2787514Scjcimport org.graalvm.compiler.jtt.JTTTest;
2887514Scjc
2987514Scjc/*
3087514Scjc */
3187514Scjcpublic class Catch_NPE_08 extends JTTTest {
3287514Scjc
3387514Scjc    public static int test(int a) {
3487514Scjc        try {
3587514Scjc            throwNPE(a);
3687514Scjc        } catch (NullPointerException npe) {
3787514Scjc            return a;
3887514Scjc        }
3987514Scjc        return -1;
4087514Scjc    }
41105936Sthomas
42105936Sthomas    @SuppressWarnings("unused")
43254974Sjlh    private static void throwNPE(int a) {
44254974Sjlh        throw null;
45254974Sjlh    }
46254974Sjlh
47254974Sjlh    @Test
4887514Scjc    public void run0() throws Throwable {
4987514Scjc        runTest("test", 0);
50254974Sjlh    }
51254974Sjlh
52254974Sjlh    @Test
5387514Scjc    public void run1() throws Throwable {
5487514Scjc        runTest("test", 1);
5587514Scjc    }
5687514Scjc
57197552Scperciva    @Test
58197552Scperciva    public void run2() throws Throwable {
59197552Scperciva        runTest("test", -2);
60184265Sed    }
61105936Sthomas
62254974Sjlh}
63254974Sjlh