ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/JniDemo.java
Revision: 1.2
Committed: Wed Mar 24 20:32:33 2004 UTC (20 years, 2 months ago) by tim
Branch: MAIN
CVS Tags: JSR166_PFD
Changes since 1.1: +11 -1 lines
Log Message:
Added first cut at SelectorCompletionService, with matching test
case that isn't really a test case.

File Contents

# Content
1 /*
2 * Demo the use of JNI in Ant
3 */
4 import java.util.*;
5
6 public class JniDemo {
7
8 static {
9 System.loadLibrary("JniDemo");
10 }
11
12 public native int getCount();
13 public native void setCount(int count);
14
15 public static void main(String[] args) {
16 Map<String, Integer> m = new HashMap<String, Integer>();
17 for (String s : args) {
18 if (!m.containsKey(s)) m.put(s, 0);
19 m.put(s, m.get(s)+1);
20 }
21 for (String s : m.keySet()) {
22 System.out.println(""+m.get(s)+" "+s);
23 }
24
25 JniDemo demo = new JniDemo();
26 int count = demo.getCount();
27 System.out.println("Count starts at "+count);
28 demo.setCount(4);
29 System.out.println("Count set to 4");
30 count = demo.getCount();
31 System.out.println("Count is actually "+count);
32 }
33 }