mobile: Index | Files

package java

import ""

The java package takes the result of an AST traversal by the importers package and queries the java command for the type information for the referenced Java classes and interfaces.

It is the of go/types for Java types and is used by the bind package to generate Go wrappers for Java API on Android.


Package Files


func IsAvailable Uses

func IsAvailable() bool

IsAvailable reports whether the required tools are available for Import to work. In particular, IsAvailable checks the existence of the javap binary.

func JNIMangle Uses

func JNIMangle(s string) string

Mangle a name according to

TODO: Support unicode characters

type Class Uses

type Class struct {
    // "java.pkg.Class.Inner"
    Name string
    // "java.pkg.Class$Inner"
    FindName string
    // JNI mangled name
    JNIName string
    // "Inner"
    PkgName string
    Funcs   []*FuncSet
    Methods []*FuncSet

    // All methods, including methods from
    // supers.
    AllMethods []*FuncSet
    Vars       []*Var
    Supers     []string
    Final      bool
    Abstract   bool
    Interface  bool
    Throwable  bool
    // Whether the class has a no-arg constructor
    HasNoArgCon bool
    // contains filtered or unexported fields

Class is the bind representation of a Java class or interface. Use Import to convert class references to Class.

type CommonSig Uses

type CommonSig struct {
    // Variadic is set if the signature covers variants
    // with varying number of parameters.
    Variadic bool
    // HasRet is true if at least one variant returns a
    // value.
    HasRet bool
    Throws bool
    Params []*Type
    Ret    *Type

CommonSig is a signature compatible with every overloaded variant of a FuncSet.

type Func Uses

type Func struct {
    ArgDesc string
    // Mangled JNI name
    JNIName     string
    Static      bool
    Abstract    bool
    Final       bool
    Public      bool
    Constructor bool
    Params      []*Type
    Ret         *Type
    Decl        string
    Throws      string

Func is a Java static function or method or constructor.

type FuncSet Uses

type FuncSet struct {
    Name   string
    GoName string
    Funcs  []*Func

FuncSet is the set of overloaded variants of a function. If the function is not overloaded, its FuncSet contains one entry.

type FuncSig Uses

type FuncSig struct {
    Name string
    // The method descriptor, in JNI format.
    Desc string

FuncSig uniquely identifies a Java Func.

type Importer Uses

type Importer struct {
    Bootclasspath string
    Classpath     string
    // JavaPkg is java package name for generated classes.
    JavaPkg string
    // contains filtered or unexported fields

func (*Importer) Import Uses

func (j *Importer) Import(refs *importers.References) ([]*Class, error)

Import returns Java Class descriptors for a list of references.

The javap command from the Java SDK is used to dump class information. Its output looks like this:

Compiled from "" public final class java.lang.System {

public static final in;
  descriptor: Ljava/io/InputStream;
public static final out;
  descriptor: Ljava/io/PrintStream;
public static final err;
  descriptor: Ljava/io/PrintStream;
public static void setIn(;
  descriptor: (Ljava/io/InputStream;)V



type Type Uses

type Type struct {
    Kind  TypeKind
    Class string
    Elem  *Type

Type is a Java type.

func (*Type) CType Uses

func (t *Type) CType() string

func (*Type) JNICallType Uses

func (t *Type) JNICallType() string

func (*Type) JNIType Uses

func (t *Type) JNIType() string

func (*Type) Type Uses

func (t *Type) Type() string

type TypeKind Uses

type TypeKind int
const (
    Int TypeKind = iota

type Var Uses

type Var struct {
    Name   string
    Static bool
    Final  bool
    Val    string
    Type   *Type

Var is a Java member variable.

func (*Var) Constant Uses

func (v *Var) Constant() bool

Package java imports 10 packages (graph) and is imported by 2 packages. Updated 2020-12-18. Refresh now. Tools for package owners.