-
Notifications
You must be signed in to change notification settings - Fork 244
Open
Labels
C-ffi-infraComponent: Diplomat, horizontal FFIComponent: Diplomat, horizontal FFItrackingThis issue tracks a ticket in another projectThis issue tracks a ticket in another project
Milestone
Description
All public APIs should be Java-friendly (should contain only Java types and should have valid Java names).
For example there is no way to use a org.unicode.icu4x.Locale class from Java.
companion object {
@JvmStatic fun fromString(name: String): Result<Locale> { ... }
@JvmStatic fun normalize(s: String): Result<String> { ... }
}
fun setLanguage(s: String): Result<Unit> { ... }
fun setRegion(s: String): Result<Unit> { ... }
fun setScript(s: String): Result<Unit> { ... }All of them return Result, which is a Kotlin class (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-result/).
How to inspect what is available for Java:
- go to
<repo_root>/ffi/mvn - build (
makethenmvn compile) - dump public methods and grep for
-(javap target/classes/org/unicode/icu4x/Locale.class | grep ".*-.*")
Result:
public final java.lang.Object setLanguage-IoAF18A(java.lang.String);
public final java.lang.Object setRegion-IoAF18A(java.lang.String);
public final java.lang.Object setScript-IoAF18A(java.lang.String);
public static final java.lang.Object fromString-IoAF18A(java.lang.String);
public static final java.lang.Object normalize-IoAF18A(java.lang.String);
Since the methods return Object there is no way to call any Result methods (isFailure, getOrNull, getOrThrow, etc.)
Locale is just one example, but this happens in a lot of other classes.
Metadata
Metadata
Assignees
Labels
C-ffi-infraComponent: Diplomat, horizontal FFIComponent: Diplomat, horizontal FFItrackingThis issue tracks a ticket in another projectThis issue tracks a ticket in another project