Skip to content

Commit 94a5613

Browse files
committed
more docs
1 parent e335290 commit 94a5613

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

USER_GUIDE.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,19 @@ A number of JavaKit modules provide Swift projections of Java classes and interf
326326

327327
The `Java2Swift` tool can translate any other Java classes into Swift projections. The easiest way to use `Java2Swift` is with the SwiftPM plugin described above. More information about using this tool directly are provided later in this document.
328328

329+
#### Improve parameter names of imported Java methods
330+
When building Java libraries you can pass the `-parameters` option to javac
331+
in your build system (Gradle, Maven, sbt, etc) in order to retain the parameter names in the resulting byte code.
332+
333+
This way the imported methods will keep their original parameter names, and you'd get e.g.:
334+
```swift
335+
// public func hello(String name)
336+
func hello(_ name: String)
337+
```
338+
rather than just `arg0` parameters.
339+
340+
When building Java sources using the JavaCompilerPlugin this option is passed by default.
341+
329342
### Up and downcasting
330343

331344
All `AnyJavaObject` instances provide `is` and `as` methods to check whether an object dynamically matches another type. The `is` operation is the equivalent of Java's `instanceof` and Swift's `is` operator, and will checkin whether a given object is of the specified type, e.g.,

0 commit comments

Comments
 (0)