mobile/bind: move generated Java classes to package level

Before this CL, generated Java classes or interfaces were inner
classes to the top package class. That is both unnecessary and creates
ugly class names. Instead, move every generated class and interface to its
own package level class.

NOTE: This is a backwards incompatible change and requires every client
of gomobile APIs to be updated to leave out the package class in the
type names. For example, the Go type

package pkg

type S struct {
}

now generates (with the default java package name go) a Java class named
go.pkg.S. The name before this CL was go.pkg.Pkg.S.

Also, change the custom java package to specify the package prefix and
not the full package as before. This is an unfortunate change needed
to avoid name clashes between two bound packages. On the plus side,
the change brings the custom package case closer to the default behaviour,
which is a commen prefix, "go.", and a distinct java package for every
Go package bound.

Change-Id: Iadfaad56e101d1caf7e2a05006f4d384859a20fe
Reviewed-on: https://go-review.googlesource.com/27436
Reviewed-by: David Crawshaw <crawshaw@golang.org>
This commit is contained in:
Elias Naur
2016-08-22 07:41:35 +00:00
parent 0ba4e6463d
commit 80e11ad074
37 changed files with 867 additions and 565 deletions
+4 -3
View File
@@ -9,6 +9,7 @@ import java.util.IdentityHashMap;
import java.util.logging.Logger;
import go.Universe;
import go.error;
// Seq is a sequence of machine-dependent encoded values.
// Used by automatically generated language bindings to talk to Go.
@@ -47,12 +48,12 @@ public class Seq {
private Seq() {
}
private static void throwException(Universe.error err) throws Exception {
private static void throwException(error err) throws Exception {
throw new Exception(err.Error());
}
private static Universe.error wrapThrowable(final Throwable t) {
return new Universe.error() {
private static error wrapThrowable(final Throwable t) {
return new error() {
@Override public String Error() {
return t.getMessage();
}