summaryrefslogtreecommitdiff
path: root/libjava/testsuite/libjava.lang/instance.java
blob: a509cb3857cc9639e2dbf322f998b6ab150c3a66 (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
// instance.java -- test the `instanceof' operator.

import java.util.EventListener;

public class instance implements EventListener
{
  public static void main (String[] args)
  {
    Object x1 = new instance ();
    EventListener x2 = new instance ();
    IllegalArgumentException iae
      = new IllegalArgumentException ("any random class");
    String x3 = "zardoz";
    Object x4 = "zardoz";

    // Test simple object stuff
    System.out.println (x1 instanceof Object);
    System.out.println (x1 instanceof IllegalArgumentException);
    System.out.println (x1 instanceof EventListener);
    System.out.println (x1 instanceof String);
    System.out.println ("=");

    // Test with value which is an interface.
    System.out.println (x2 instanceof Object);
    System.out.println (x2 instanceof IllegalArgumentException);
    System.out.println (x2 instanceof EventListener);
    System.out.println ("=");

    // Test with value which is a final class.
    System.out.println (x3 instanceof Object);
    System.out.println (x3 instanceof String);
    System.out.println ("=");

    // Test with value which is a random class.
    System.out.println (iae instanceof Object);
    System.out.println (iae instanceof IllegalArgumentException);
    System.out.println (iae instanceof EventListener);
    System.out.println ("=");

    // Test with value which is a final class, but not known
    // statically.
    System.out.println (x4 instanceof Object);
    System.out.println (x4 instanceof IllegalArgumentException);
    System.out.println (x4 instanceof EventListener);
    System.out.println (x4 instanceof String);
    System.out.println (x4 instanceof int[]);
  }
}