Skip to content

Commit

Permalink
[jnigen] Use dollar signs for nested class name separator (#1791)
Browse files Browse the repository at this point in the history
* Close #1516
  • Loading branch information
HosseinYousefi authored Dec 10, 2024
1 parent da5dc14 commit d37df9c
Show file tree
Hide file tree
Showing 13 changed files with 1,157 additions and 1,084 deletions.
2 changes: 2 additions & 0 deletions pkgs/jnigen/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## 0.13.0-wip

- **Breaking Change**([#1516](https://github.com/dart-lang/native/issues/1516)):
Inner classes are now generated as `OuterClass$InnerClass`.
- **Breaking Change**([#1644](https://github.com/dart-lang/native/issues/1644)):
Generate null-safe Dart bindings for Java and Kotlin.
- Fixed a potential name collision when generating in multi-file mode.
Expand Down
24 changes: 24 additions & 0 deletions pkgs/jnigen/doc/java_differences.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,3 +213,27 @@ class $_Example extends JObject {
void $_printMessage() { /* ... */ }
}
```

### Inner classes

Java has the concept of inner classes, while Dart does not. Therefore, inner
classes are generated as separate classes named using the name of their
outer-class followed by a dollar sign (`$`) followed by their original name.

For example:

```java
// Java
public class Outer {
public class Inner {}
}
```

will be turned into:

```dart
// Dart Bindings - Boilerplate omitted for clarity.
class Outer extends JObject {}
class Outer$Inner extends JObject {}
```
Loading

0 comments on commit d37df9c

Please sign in to comment.