2
0
mirror of synced 2025-02-24 23:38:22 +00:00
Elias Naur bf31dd1a5e bind,cmd/gomobile: add a new generator for Java API wrappers
Using the new Java class analyzer API, scan the bound packages
for references to Java classes and interfaces and generate Go
wrappers for them.

This is the second part of the implementation of proposal golang/go#16876.

For golang/go#16876

Change-Id: I59ec0ebdae0081a615dc34d450f344c20c03f871
Reviewed-on: https://go-review.googlesource.com/28596
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-09-16 17:25:25 +00:00

58 lines
1.1 KiB
Go

// Copyright 2016 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package javapkg
import (
"Java/java/lang/Float"
"Java/java/lang/Integer"
"Java/java/lang/System"
"Java/java/util/Collections"
"Java/java/util/jar/JarFile"
"fmt"
)
func SystemCurrentTimeMillis() int64 {
return System.CurrentTimeMillis()
}
func FloatMin() float32 {
return Float.MIN_VALUE
}
func ManifestName() string {
return JarFile.MANIFEST_NAME
}
func IntegerBytes() int {
return Integer.SIZE
}
func IntegerValueOf(v int32) int32 {
i := Integer.ValueOf_I(v)
return i.IntValue()
}
func IntegerDecode(v string) (int32, error) {
i, err := Integer.Decode(v)
if err != nil {
return 0, fmt.Errorf("wrapped error: %v", err)
}
// Call methods from super class
i.HashCode()
return i.IntValue(), nil
}
func IntegerParseInt(v string, radix int32) (int32, error) {
return Integer.ParseInt2(v, radix)
}
func ProvokeRuntimeException() (err error) {
defer func() {
err = recover().(error)
}()
Collections.Copy(nil, nil)
return
}