1818
1919// Import javakit/swiftkit support libraries
2020
21- import org .swift .swiftkitffm .SwiftArena ;
22- import org .swift .swiftkitffm .SwiftFFM ;
21+ import org .swift .swiftkit .core .SwiftLibraries ;
22+ import org .swift .swiftkit .ffm .AllocatingSwiftArena ;
23+ import org .swift .swiftkit .ffm .SwiftRuntime ;
2324
2425public class HelloJava2Swift {
2526
2627 public static void main (String [] args ) {
2728 boolean traceDowncalls = Boolean .getBoolean ("jextract.trace.downcalls" );
2829 System .out .println ("Property: jextract.trace.downcalls = " + traceDowncalls );
2930
30- System .out .print ("Property: java.library.path = " + SwiftFFM .getJavaLibraryPath ());
31+ System .out .print ("Property: java.library.path = " + SwiftLibraries .getJavaLibraryPath ());
3132
3233 examples ();
3334 }
@@ -39,30 +40,30 @@ static void examples() {
3940
4041 long cnt = MySwiftLibrary .globalWriteString ("String from Java" );
4142
42- SwiftFFM .trace ("count = " + cnt );
43+ SwiftRuntime .trace ("count = " + cnt );
4344
4445 MySwiftLibrary .globalCallMeRunnable (() -> {
45- SwiftFFM .trace ("running runnable" );
46+ SwiftRuntime .trace ("running runnable" );
4647 });
4748
48- SwiftFFM .trace ("getGlobalBuffer().byteSize()=" + MySwiftLibrary .getGlobalBuffer ().byteSize ());
49+ SwiftRuntime .trace ("getGlobalBuffer().byteSize()=" + MySwiftLibrary .getGlobalBuffer ().byteSize ());
4950
5051 MySwiftLibrary .withBuffer ((buf ) -> {
51- SwiftFFM .trace ("withBuffer{$0.byteSize()}=" + buf .byteSize ());
52+ SwiftRuntime .trace ("withBuffer{$0.byteSize()}=" + buf .byteSize ());
5253 });
5354 // Example of using an arena; MyClass.deinit is run at end of scope
54- try (var arena = SwiftArena .ofConfined ()) {
55+ try (var arena = AllocatingSwiftArena .ofConfined ()) {
5556 MySwiftClass obj = MySwiftClass .init (2222 , 7777 , arena );
5657
5758 // just checking retains/releases work
58- SwiftFFM .trace ("retainCount = " + SwiftFFM .retainCount (obj ));
59- SwiftFFM .retain (obj );
60- SwiftFFM .trace ("retainCount = " + SwiftFFM .retainCount (obj ));
61- SwiftFFM .release (obj );
62- SwiftFFM .trace ("retainCount = " + SwiftFFM .retainCount (obj ));
59+ SwiftRuntime .trace ("retainCount = " + SwiftRuntime .retainCount (obj ));
60+ SwiftRuntime .retain (obj );
61+ SwiftRuntime .trace ("retainCount = " + SwiftRuntime .retainCount (obj ));
62+ SwiftRuntime .release (obj );
63+ SwiftRuntime .trace ("retainCount = " + SwiftRuntime .retainCount (obj ));
6364
6465 obj .setCounter (12 );
65- SwiftFFM .trace ("obj.counter = " + obj .getCounter ());
66+ SwiftRuntime .trace ("obj.counter = " + obj .getCounter ());
6667
6768 obj .voidMethod ();
6869 obj .takeIntMethod (42 );
@@ -71,9 +72,9 @@ static void examples() {
7172 otherObj .voidMethod ();
7273
7374 MySwiftStruct swiftValue = MySwiftStruct .init (2222 , 1111 , arena );
74- SwiftFFM .trace ("swiftValue.capacity = " + swiftValue .getCapacity ());
75+ SwiftRuntime .trace ("swiftValue.capacity = " + swiftValue .getCapacity ());
7576 swiftValue .withCapLen ((cap , len ) -> {
76- SwiftFFM .trace ("withCapLenCallback: cap=" + cap + ", len=" + len );
77+ SwiftRuntime .trace ("withCapLenCallback: cap=" + cap + ", len=" + len );
7778 });
7879 }
7980
0 commit comments