summaryrefslogtreecommitdiff
path: root/libjava/testsuite/libjava.lang/ArrayStore.java
blob: 9afac71c2b57a621acce64825a0c2c0277450600 (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
public class ArrayStore
{
  public static void main(String[] args)
  {
    ArrayStore s = new ArrayStore();

    /* Check that bounds check takes precedence over array store check. */
    try 
    {
      s.a(new String[1]);
    }
    catch (Exception x)
    {
      System.out.println (x.getClass().getName());
    }

    try 
    {
      s.a(new String[2]);
    }
    catch (Exception x)
    {
      System.out.println (x.getClass().getName());
    }

    /* Check that += operator on String[] element works and throws bounds 
       exception. */
    try 
    {
      s.b(new String[1]);
    }
    catch (Exception x)
    {
      System.out.println (x.getClass().getName());
    }

    String[] sb = new String[2];
    sb[1] = "foo";
    s.b(sb);
    System.out.println (sb[1]);
  }

  void a(Object[] oa)
  {
    oa[1] = new Integer(2);
  }

  void b(String[] sa)
  {
    sa[1] += "bar";
  }
}