I know that Java will let you do trickery with a variable’s type when initializing a class variable. Along the lines of:
SomeType foo = new SomeType() {
{
this.fooField = 12345;
}
@Override public void someMethod() {
throw new ReallyWeirdException();
}
};
which will create an instance variable foo where someMethod() has different semantics than in the usual SomeType, and where fooField is initialized to a value other than its normal default.
But what is the new Type() { ... } syntax called?
Anonymous Inner Class.
You define a class (class) inside your code (inner) that has no name (anonymous) but inherits from SomeType, then override some of its methods and properties.