Skip to content

Commit

Permalink
Java: rename delete function to _delete and make private.
Browse files Browse the repository at this point in the history
At the moment, Java classes are created with a special `delete`
function that is in charge of clearing the Rust object, e.g.:

```
public synchronized void delete() {
    if (mNativeObj != 0) {
        do_delete(mNativeObj);
        mNativeObj = 0;
   }
}
```

Delete is quite a useful name to have (I use it in my API) and
this function being called this way is confusing, but also
needlessly limits the API.

Fixes Dushistov#350
  • Loading branch information
tasn committed Aug 26, 2020
1 parent cd5f502 commit faf975d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions macroslib/src/java_jni/fclass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ May be you need to use `private constructor = empty;` syntax?",
writeln!(
file,
r#"
public synchronized void delete() {{
private synchronized void _delete() {{
if ({rust_self_name} != 0) {{
do_delete({rust_self_name});
{rust_self_name} = 0;
Expand All @@ -451,7 +451,7 @@ May be you need to use `private constructor = empty;` syntax?",
@Override
protected void finalize() throws Throwable {{
try {{
delete();
_delete();
}}
finally {{
super.finalize();
Expand Down

0 comments on commit faf975d

Please sign in to comment.