Documentation ¶
Overview ¶
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 ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsAvailable ¶
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 ¶
Mangle a name according to http://docs.oracle.com/javase/6/docs/technotes/guides/jni/spec/design.html#wp16696
TODO: Support unicode characters
Types ¶
type Class ¶
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 ¶
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 ¶
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 ¶
FuncSet is the set of overloaded variants of a function. If the function is not overloaded, its FuncSet contains one entry.
type Importer ¶
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 ¶
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 ...
}