New and changed in Gosu in 10.0.0

GUnit Test Framework

The GUnit Test Framework enables the writing of tests to exercise the application's Gosu configuration code.

Tests are written in Gosu. You can execute these tests from the command line to include the tests in an automated continuous integration work flow. You can also execute these tests from Guidewire Studio.

For more information, refer to the GUnit section of the Testing Guide.

Support for static imports

Gosu now provides support for importing static features of Gosu and Java classes. The syntax for a static import uses a # symbol between the class name and the static features to import. After importing the static features, you can use them in your code without qualifying them with their path.

See also

New modifier reified for generic functions

In previous releases, the type parameter for a generic method was always reified, so type information was always available at run time. This parameter is now reified only if the reified keyword is a modifier on the method definition.

Gosu now requires the modifier reified on generic functions that have any of the following characteristics, where T is the token for the type parameter of a generic type:

  • The method uses the new keyword to create an instance of T.
  • The method uses the new keyword to create an instance of a generic type and includes the <T> qualifier on the type name.
  • An expression in the method uses the generic type with the typeis or typeof operator.
  • The method contains code that uses as T to cast a value to the generic type.
  • The method overrides a reified method in a parent class or implements a reified method in an interface.
  • The method calls another reified method and passes an argument of a generic type to that method.

The modifier reified is optional on a parameterized method that does not have any of these characteristics.

Gosu forbids the modifier reified on methods that are not generic.

See also

Support for empty vararg arguments in calls to Java methods

In previous releases, if you called a Java method that had a vararg parameter, you had to provide an empty list if you did not want to provide a value. Now, you do not have to pass that empty list.

Consider a Java method that has the following signature. The method has a single named parameter that is a vararg. The method accepts zero, one, or many String arguments.

public String makeOneString(String... args)
To pass values to this method, use code like the following lines.
var noArgsResult  = makeOneString()               // No arguments
var oneArgResult  = makeOneString({"one"})        // One argument value
var twoArgsResult = makeOneString({"one", "two"}) // Two argument values

See also

Support for class path in manifest in JAR file

To provide support for long class paths, Gosu now recognizes the Class-Path header in the manifest of a JAR file. The class path in this header adds to the existing class path that Gosu uses to find classes.

See also

Syntax has changed for numeric literal of short integer type

The Gosu syntax for short integer numeric literals has changed. Instead of using the s suffix, Gosu now requires the explicit specification as short. Using the s suffix for a short integer numeric literal is a syntax error. For example, you must now use the following assignment syntax:
var aShort = 4 as short

The following line is no longer valid:

var aShort = 4s

Stricter property access validation

Accessing properties in the following ways now causes compilation errors.
  • Accessing a property on an internal class from outside the package
  • Accessing a protected property on an abstract class from an anonymous instance

Getter and setter method syntax for properties is not supported

In previous releases, for Java compatibility, Gosu supported using getXXX and setXXX methods to get and set the value for a property XXX on a Gosu class. This syntax is not supported in release 10.0.0. You must use the dot notation and the property name to get and set property values, as shown in the following code examples.

The class MyClass has a property MyProperty.

class MyClass {
  private var  _myPropertyValue : String

  property get MyProperty() : String   {
    return  _myPropertyValue
  }
  property set MyProperty(str : String)   {
    _myPropertyValue = str
  }
}

The following code demonstrates valid and invalid syntax to access the property MyProperty.

var c = new MyClass()
c.MyProperty = "Yes"    // Sets to "Yes" by calling the set MyProperty property function
c.setMyProperty("Java") // *Compiler error*
print("Gosu Style " + c.MyProperty)      // Calls the get MyProperty property function
print("Java Style " + c.getMyProperty()) // *Compiler error*