summaryrefslogtreecommitdiff
path: root/libjava/testsuite/libjava.lang/invokethrow.java
blob: 8cf3ca0a51ba5ad3f0263b5213e0349d80a166f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Test a `throw' across a libffi call.

import java.lang.reflect.*;

public class invokethrow
{
  public static void doit () throws Throwable
  {
    throw new Throwable ("hi!");
  }

  public static void main (String[] args)
  {
    Class k = invokethrow.class;
    try
      {
	Class[] noargs = new Class[0];
	Method m = k.getMethod ("doit", noargs);
	m.invoke (null, null);
      }
    catch (InvocationTargetException x1)
      {
	System.out.println (x1.getTargetException ().getMessage ());
      }
    catch (UnsupportedOperationException _)
      {
	// Some systems don't support invocation, in which case we
	// will fake a passing result.
	System.out.println ("hi!");
      }
    catch (Throwable _)
      {
      }
  }
}