2015-01-14 Richard Biener <rguenther@suse.de>
[official-gcc.git] / libjava / testsuite / libjava.lang / instance.java
bloba509cb3857cc9639e2dbf322f998b6ab150c3a66
1 // instance.java -- test the `instanceof' operator.
3 import java.util.EventListener;
5 public class instance implements EventListener
7 public static void main (String[] args)
9 Object x1 = new instance ();
10 EventListener x2 = new instance ();
11 IllegalArgumentException iae
12 = new IllegalArgumentException ("any random class");
13 String x3 = "zardoz";
14 Object x4 = "zardoz";
16 // Test simple object stuff
17 System.out.println (x1 instanceof Object);
18 System.out.println (x1 instanceof IllegalArgumentException);
19 System.out.println (x1 instanceof EventListener);
20 System.out.println (x1 instanceof String);
21 System.out.println ("=");
23 // Test with value which is an interface.
24 System.out.println (x2 instanceof Object);
25 System.out.println (x2 instanceof IllegalArgumentException);
26 System.out.println (x2 instanceof EventListener);
27 System.out.println ("=");
29 // Test with value which is a final class.
30 System.out.println (x3 instanceof Object);
31 System.out.println (x3 instanceof String);
32 System.out.println ("=");
34 // Test with value which is a random class.
35 System.out.println (iae instanceof Object);
36 System.out.println (iae instanceof IllegalArgumentException);
37 System.out.println (iae instanceof EventListener);
38 System.out.println ("=");
40 // Test with value which is a final class, but not known
41 // statically.
42 System.out.println (x4 instanceof Object);
43 System.out.println (x4 instanceof IllegalArgumentException);
44 System.out.println (x4 instanceof EventListener);
45 System.out.println (x4 instanceof String);
46 System.out.println (x4 instanceof int[]);