Skip to content

Commit 908bfec

Browse files
committed
add jni sample app
1 parent 3c3e411 commit 908bfec

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2024 Apple Inc. and the Swift.org project authors
6+
// Licensed under Apache License v2.0
7+
//
8+
// See LICENSE.txt for license information
9+
// See CONTRIBUTORS.txt for the list of Swift.org project authors
10+
//
11+
// SPDX-License-Identifier: Apache-2.0
12+
//
13+
//===----------------------------------------------------------------------===//
14+
15+
package com.example.swift;
16+
17+
// Import swift-extract generated sources
18+
19+
// Import javakit/swiftkit support libraries
20+
21+
import org.swift.swiftkit.SwiftKit;
22+
23+
public class HelloJava2Swift {
24+
25+
public static void main(String[] args) {
26+
System.out.print("Property: java.library.path = " + SwiftKit.getJavaLibraryPath());
27+
28+
examples();
29+
}
30+
31+
static void examples() {
32+
MySwiftLibrary.helloWorld();
33+
34+
MySwiftLibrary.globalTakeInt(1337);
35+
MySwiftLibrary.globalTakeIntInt(1337, 42);
36+
37+
long cnt = MySwiftLibrary.globalWriteString("String from Java");
38+
SwiftKit.trace("count = " + cnt);
39+
40+
long i = MySwiftLibrary.globalMakeInt();
41+
SwiftKit.trace("globalMakeInt() = " + i);
42+
43+
System.out.println("DONE.");
44+
}
45+
}

0 commit comments

Comments
 (0)