aboutsummaryrefslogtreecommitdiff
path: root/Examples/test-suite/java/java_typemaps_proxy_runme.java
blob: 997e5b8d1d02e3244999b9763ab64cf5d7674a84 (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

// This is the java_typemaps_proxy runtime testcase. Contrived example checks that the pure Java code from the Java typemaps compiles.

import java_typemaps_proxy.*;

public class java_typemaps_proxy_runme {

  static {
    try {
	System.loadLibrary("java_typemaps_proxy");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
      System.exit(1);
    }
  }

  public static void main(String argv[]) {

    Greeting greet = new Greeting();
    Farewell bye = new Farewell();

    // Check that pure Java methods have been added
    greet.sayhello();
    bye.saybye(new java.math.BigDecimal(java.math.BigInteger.ONE));

    // No finalize method so may as well delete manually
    bye.delete();

    // Check that Greeting is derived from Exception
    try {
      throw new Greeting();
    } catch (Greeting g) {
        String msg = g.getMessage(); 
    }

    // Check that Greeting has implemented the EventListener interface
    Greeting.cheerio(greet); 

    // The default getCPtr() call in each method will through an exception if null is passed.
    // Make sure the modified version works with and without null objects.
    Greeting.ciao(null);
    Greeting.ciao(greet);

    // Create a NULL pointer for Farewell using the constructor with changed modifiers
    Farewell nullFarewell = new Farewell(0, false);
  }
}