Although interface J declares it has a void function, Test::foo returns an Object.
It's inaccurate to say that Test::foo returns something. In different contexts, it could mean different things.
Supplier
It's more accurate to say that Test::foo can represent a target type the functional method of which returns either void or Object.
It's an example of expression statement (jls-14.8).
If the target type's function type has a void return, then the lambda body is either a statement expression (§14.8) or a void-compatible block (§15.27.2).
...
An expression statement is executed by evaluating the expression; if the expression has a value, the value is discarded.