Minor update · SwiftJava/SwiftJava@3c10853 · GitHub
Skip to content

Commit 3c10853

Browse files
committed
Minor update
1 parent f00895d commit 3c10853

20 files changed

Lines changed: 196 additions & 182 deletions

CJavaVM

JDBC/AppDelegate.swift

Lines changed: 1 addition & 1 deletion

README.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11

22
## SwiftJava - bridging Swift to a JavaVM
33

4-
I know what you've been thinking.. what I really need is a way to bridge Swift
5-
to Java but there are a number of use cases:
4+
I know you've been thinking.. "What I really need is a way to bridge Swift to Java"
5+
but there are a number of use cases:
66

77
1. Making Java technologies such as JDBC available to macOS applications.
88

9-
2. Giving Swift applications on Linux a portable user interface.
9+
2. Giving Swift applications on Linux a portable user interface using Swing.
1010

11-
3. Making business logic in Swift available to Android apps.
11+
3. Making business logic in written in Swift available to Android apps.
1212

1313
![](http://johnholdsworth.com/Linux.png) ![](http://johnholdsworth.com/Android.png)
1414

1515
SwiftJava is a Swift code generator along with a small framework of supporting code written in
16-
the Xcode beta6 vintage of Swift 3.0. The starting point was Boris Bügling's talk on
17-
[Cross Platform Swift](https://realm.io/news/altconf-boris-bugling-cross-platform-swift/).
16+
the Xcode beta6 vintage of Swift 3.0. The starting point was Boris Bügling's
17+
[Cross Platform Swift](https://realm.io/news/altconf-boris-bugling-cross-platform-swift/) talk.
1818
The code generator takes a java class, interface or package and generates Swift classes
1919
that interface to corresponding Java methods using the Java Native Interface "JNI".
2020
These generated methods on the corresponding Swift class look something like this:
@@ -34,7 +34,7 @@ These generated methods on the corresponding Swift class look something like thi
3434
On macOS, this has been used to generate frameworks bridging the java.lang, java.util,
3535
java.sql, java.awt and javax.swing packages along with the Apple specific additions
3636
in the com.apple package. This makes the Java apis available with auto-completion in
37-
the Xcode source editor. The final application can be a ".app" or command line utility
37+
the Xcode source editor. The final application can be a ".app" or a command line utility
3838
which should be portable to Linux using the Swift Package manager. For Android, the code
3939
generator can generate JNI code for a pair of interfaces from Java to Swift and from
4040
Swift to Java saving the developer the chore of a lot of error prone manual stubbing.
@@ -45,7 +45,7 @@ To use, clone this project using the following command:
4545
git clone https://github.com/SwiftJava/SwiftJava.git --recurse-submodules
4646
```
4747

48-
This project contains the pre-generated java frameworks and an example macOS app using
48+
This project contains the pre-generated java frameworks, an example macOS app using
4949
JDBC and a command line project with assorted AWT and Swing source. Development inside
5050
Xcode uses the legacy "JavaVM" framework which requires Apple's JVM downloadable from:
5151

@@ -57,7 +57,7 @@ runloop. Use the JNI.background and JNI.run methods to achieve this in a portabl
5757

5858
When using the Swift package manager to build code from the command line, install the
5959
latest Oracle JDK and locate the directory containing the file libjvm.so or .dylib in
60-
the jre. Use this directory to build using the following commands:
60+
the jre. Use the examples. directory to build using the following commands:
6161

6262
```Shell
6363
git clone https://github.com/SwiftJava/examples.git
@@ -108,7 +108,7 @@ You then use ./genswift.sh from this project to generate the Swift binding code:
108108
./genswift.sh your.package your.jar
109109
```
110110

111-
This generates Swift classes and a third Java source src/org/genie/your_package/<YourApp>Proxy.java
111+
This generates Swift classes and a third Java source src/org/genie/your_package/YourAppProxy.java
112112
that also needs to be included in your project. Consult the script genhello.sh and project
113113
"swift-android-samples/swifthello" for details. The source "swift-android-samples/swifthello/src/main/swift/Sources/main.swift"
114114
shows how to set this up with a native method called from the main activity.
@@ -144,12 +144,12 @@ shows how to set this up with a native method called from the main activity.
144144
### Forward, Runnable, Listener, Adapter, subclass responsibility and Base classes.
145145

146146
For every Java interface the code generator generates a Swift Protocol along
147-
with a <Protocol>Forward class in instance of which conforms to the protocol and
147+
with a ProtocolForward class an instance of which conforms to the protocol and
148148
can be used to message Java instances conforming to the interface/protocol.
149149

150150
For the Runnable interface used in threading the converse needs to be possible
151151
where Java code can call through to Swift code. This is performed using a Java
152-
proxy class which has a pointer to the associated Swift object and a "native"e
152+
proxy class which has a pointer to the associated Swift object and a "native"
153153
implementation of the "run()" method that calls through to Swift. On the Swift
154154
side this is surfaced as the "RunnableBase" class which can be subclassed to
155155
provide a Swift implementation of the "run()" method callable from Java.
@@ -176,11 +176,11 @@ of the subclasses such as java.awt.Canvas.paint(). A list of these methods needs
176176
maintained in the code generator unfortunately. If one of these methods encountered
177177
a Base class and Proxy is generated for the concrete class that can be subclassed.
178178

179-
As these "Base" subclasses cant close over variable in your program you may want to
179+
As these "Base" subclasses can't close over variables in your program you may want to
180180
have an initialiser to capture these instead. There is a bit of a standard dance
181-
that needs to be performed. First instantiate the "Base" superclass and pass this
181+
that needs to be performed. First, instantiate the "Base" superclass and pass this
182182
to the designated initialiser of your superclass. Due to the use of generics you'll
183-
also be prompted to provide a null implementation of the required initialiser.
183+
also be prompted to provide a null implementation of the "required" initialiser.
184184

185185
```Swift
186186
init(imageProducer:ImageProducer) {

SwiftJava.xcodeproj/project.pbxproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10-
BB19B4421D673986002F5586 /* README.md in Sources */ = {isa = PBXBuildFile; fileRef = BB19B4411D673986002F5586 /* README.md */; };
1110
BB31E20F1D4FF13400779860 /* genpkg.sh in Resources */ = {isa = PBXBuildFile; fileRef = BB31E20E1D4FF13400779860 /* genpkg.sh */; };
1211
BB4AF49E1D4C1F80001DCA63 /* java_sql.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BBBF2E8E1D49A0C3004142AE /* java_sql.framework */; };
1312
BB4AF4A61D4C2CE2001DCA63 /* java_lang.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BBC13EBC1D4997FB0035A039 /* java_lang.framework */; };
@@ -720,7 +719,6 @@
720719
BBBF3A691D4BCE36004142AE /* main.swift in Sources */,
721720
BBBF3A671D4B1B95004142AE /* PopupTest.swift in Sources */,
722721
BBBF3A611D4AC24F004142AE /* TableColumnColor.swift in Sources */,
723-
BB19B4421D673986002F5586 /* README.md in Sources */,
724722
BBBF3A731D4BF8CF004142AE /* AWTGraphicsDemo.swift in Sources */,
725723
BBAD3EDA1D59DDBC0091D139 /* TableColorSelection.swift in Sources */,
726724
BBBF3A5D1D4AA59E004142AE /* TextText.swift in Sources */,

com_apple

genie.jar

-2 Bytes
Binary file not shown.

genpkg.sh

Lines changed: 1 addition & 1 deletion

java_awt

java_lang

java_sql

0 commit comments

Comments
 (0)