replace assert by throw new AssertionError

Jonathan Gibbons Jonathan.Gibbons at Sun.COM
Tue Oct 2 17:17:08 PDT 2007


Team,

javac currently contains assertion statements, and goes out of its way 
to ensure assertions are enabled.
As such, it would seem better to replace "assert cond: expr" with "if 
(!cond) throw new AssertionError(expr)".
Then we could remove the code from all the places where we force 
assertions to be enabled for javac.
Does anyone have comments, especially any reasons why this would *not* 
be a good idea?

-- Jon



More information about the compiler-dev mailing list