bharal...It looks a javac compiler bug. I think it was introduced in SE 5.
Null can be assigned to any reference type. However, "the type of null" is not itself a reference type. The program compiles it because null can simply cast into Exception.
And moreover throw looks for object reference after the declaration and as null can work as an object reference it displays the result.
The JLS doc about throw as :
“A throw statement first evaluates the Expression. If the evaluation
of the Expression completes abruptly for some reason, then the throw
completes abruptly for that reason. If evaluation of the Expression
completes normally, producing a non-null value V, then the throw
statement completes abruptly, the reason being a throw with value V.
If evaluation of the Expression completes normally, producing a null
value, then an instance V’ of class NullPointerException is created
and thrown instead of null. The throw statement then completes
abruptly, the reason being a throw with value V’.”