Documentation
¶
Overview ¶
The JavaClassWrapper singleton provides a way for the Godot application to send and receive data through the Java Native Interface (JNI).
Note: This singleton is only available in Android builds.
package main import ( "fmt" "graphics.gd/classdb/JavaClassWrapper" "graphics.gd/variant/Object" ) func ExampleJavaClassWrapper() { var LocalDateTime = JavaClassWrapper.Wrap("java.time.LocalDateTime") var DateTimeFormatter = JavaClassWrapper.Wrap("java.time.format.DateTimeFormatter") var datetime = Object.Call(LocalDateTime, "now") var formatter = Object.Call(DateTimeFormatter, "ofPattern", "dd-MM-yyyy HH:mm:ss") fmt.Println(Object.Call(datetime.(Object.Instance), "format", formatter)) }
Warning: When calling Java methods, be sure to check graphics.gd/classdb/JavaClassWrapper.GetException to check if the method threw an exception.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Advanced ¶
func Advanced() class
Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.
func GetException ¶
func GetException() JavaObject.Instance
Returns the Java exception from the last call into a Java class. If there was no exception, it will return null.
Note: This method only works on Android. On every other platform, this method will always return null.
func Wrap ¶
Wraps a class defined in Java, and returns it as a graphics.gd/classdb/JavaClass graphics.gd/classdb/Object type that Godot can interact with.
When wrapping inner (nested) classes, use $ instead of . to separate them. For example, JavaClassWrapper.wrap("android.view.WindowManager$LayoutParams") wraps the WindowManager.LayoutParams class.
Note: To invoke a constructor, call a method with the same name as the class. For example:
Note: This method only works on Android. On every other platform, this method does nothing and returns an empty graphics.gd/classdb/JavaClass.
Types ¶
type Extension ¶
Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension
type ID ¶
ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.
type Instance ¶
type Instance [1]gdclass.JavaClassWrapper
Instance of the class with convieniently typed arguments and results.