OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [testsuite/] [libjava.lang/] [Throw_3.java] - Blame information for rev 778

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 765 jeremybenn
// Check that a NPE likely thrown from the first instruction of a
2
// method (foo) is properly caught.
3
public class Throw_3
4
{
5
  public static void main(String[] args)
6
  {
7
    Throw_3 al = new Throw_3();
8
    try
9
      {
10
        al.foo(null);
11
      }
12
    catch (NullPointerException npe)
13
      {
14
        StackTraceElement ste[] = npe.getStackTrace();
15
        StackTraceElement top = ste[0];
16
        if ("foo".equals(top.getMethodName()))
17
          {
18
            System.out.println("ok");
19
            return;
20
          }
21
      }
22
    System.out.println("bad");
23
  }
24
 
25
  public int bar(int[] a)
26
  {
27
    System.out.println("Bar");
28
    return 5;
29
  }
30
 
31
  /**
32
   * If the second parameter ('this' being the first) is passed in a
33
   * register, then the first machine instruction in foo is likely to
34
   * fault when null is passed.
35
   */
36
  public int foo(int[] a)
37
  {
38
    int l = a.length;
39
    return l + l;
40
  }
41
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.