Slide 18
Slide 18 text
Method overloading
func Mathmax(args ...interface{}) (jnigo.JObject, error) {
convertedArgs, err := jvm.ConvertAll(args)
if err != nil {
return nil, err
}
sigArgs := ""
for _, arg := range convertedArgs {
sigArgs += arg.Signature()
}
sigMap := map[string]string{"JJ":"(JJ)J", "FF":"(FF)F", "DD":"(DD)D", "II":"(II)I"}
return jvm.CallStaticFunction("java/lang/Math", "max", sigMap[sigArgs], convertedArgs)
}
Simulated by reflection.
Switch function signature by
argument signatures