mobile: golang.org/x/mobile/internal/importers/java Index | Files

package java

import "golang.org/x/mobile/internal/importers/java"

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.

Index

Package Files

java.go

func IsAvailable Uses

func IsAvailable() bool

IsAvailable returns 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 http://docs.oracle.com/javase/6/docs/technotes/guides/jni/spec/design.html#wp16696

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 {
    FuncSig
    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
    CommonSig
}

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 "System.java" public final class java.lang.System {

public static final java.io.InputStream in;
  descriptor: Ljava/io/InputStream;
public static final java.io.PrintStream out;
  descriptor: Ljava/io/PrintStream;
public static final java.io.PrintStream err;
  descriptor: Ljava/io/PrintStream;
public static void setIn(java.io.InputStream);
  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
    Boolean
    Short
    Char
    Byte
    Long
    Float
    Double
    String
    Array
    Object
)

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 3 packages. Updated 2017-11-19. Refresh now. Tools for package owners.