2
0
mirror of synced 2025-02-24 15:28:28 +00:00
mobile/bind/testdata/java.java.golden
Elias Naur 60d29bfb46 bind: pin Go objects while incrementing their reference count
When passing a refnum across the language barrier there is a small
window where a proxy object itself can be garbage collected, its
reference count go to 0 and the object be gone when the refnum
is dereferenced on the other side.

In Go the proxy object is pinned with runtime.KeepAlive. This CL
implements the same mechanism in Java by passing the proxy object to
native code, ensuring the Java GC can't reclaim it during the call.

Change-Id: I23824439012eb00f90d729f59d4846999f24f01f
Reviewed-on: https://go-review.googlesource.com/107095
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2018-04-17 15:00:19 +00:00

148 lines
3.5 KiB
Plaintext

// Java class java.F is a proxy for talking to a Go program.
// gobind -lang=java java
//
// File is generated by gobind. Do not edit.
package java;
import go.Seq;
public interface F extends R {
public String toString();
}
// Java class java.L is a proxy for talking to a Go program.
// gobind -lang=java java
//
// File is generated by gobind. Do not edit.
package java;
import go.Seq;
public interface L extends R {
public String toString();
}
// Java class java.O is a proxy for talking to a Go program.
// gobind -lang=java java
//
// File is generated by gobind. Do not edit.
package java;
import go.Seq;
public interface O extends R {
public String toString();
}
// Java class java.R is a proxy for talking to a Go program.
// gobind -lang=java java
//
// File is generated by gobind. Do not edit.
package java;
import go.Seq;
public interface R {
}
// Java class java.S is a proxy for talking to a Go program.
// gobind -lang=java java
//
// File is generated by gobind. Do not edit.
package java;
import go.Seq;
public interface S extends R {
public String toString();
}
// Java class java.Java is a proxy for talking to a Go program.
// gobind -lang=java java
//
// File is generated by gobind. Do not edit.
package java;
import go.Seq;
public abstract class Java {
static {
Seq.touch(); // for loading the native library
_init();
}
private Java() {} // uninstantiable
// touch is called from other bound packages to initialize this package
public static void touch() {}
private static native void _init();
private static final class proxyF implements Seq.Proxy, F {
private final int refnum;
@Override public final int incRefnum() {
Seq.incGoRef(refnum, this);
return refnum;
}
proxyF(int refnum) { this.refnum = refnum; Seq.trackGoRef(refnum, this); }
public native String toString();
}
private static final class proxyL implements Seq.Proxy, L {
private final int refnum;
@Override public final int incRefnum() {
Seq.incGoRef(refnum, this);
return refnum;
}
proxyL(int refnum) { this.refnum = refnum; Seq.trackGoRef(refnum, this); }
public native String toString();
}
private static final class proxyO implements Seq.Proxy, O {
private final int refnum;
@Override public final int incRefnum() {
Seq.incGoRef(refnum, this);
return refnum;
}
proxyO(int refnum) { this.refnum = refnum; Seq.trackGoRef(refnum, this); }
public native String toString();
}
private static final class proxyR implements Seq.Proxy, R {
private final int refnum;
@Override public final int incRefnum() {
Seq.incGoRef(refnum, this);
return refnum;
}
proxyR(int refnum) { this.refnum = refnum; Seq.trackGoRef(refnum, this); }
}
private static final class proxyS implements Seq.Proxy, S {
private final int refnum;
@Override public final int incRefnum() {
Seq.incGoRef(refnum, this);
return refnum;
}
proxyS(int refnum) { this.refnum = refnum; Seq.trackGoRef(refnum, this); }
public native String toString();
}
}