+1 for the Defense static class. On 24.02.2012 01:36, Howard Lewis Ship wrote: > Wow, just when you think Java can't be any more broken, the fact that > assertions are disabled by default hits you. > > Well, we could either document that you want to generally developer > with assertions enabled, or we should bring back our old friend, the > Defense static class. > > On Thu, Feb 23, 2012 at 4:10 PM, Robert Zeigler > <[email protected]> wrote: >> Hm. Just noticed this: >> >> BeanModelSourceImpl.java: >> ... >> public <T> BeanModel<T> create(Class<T> beanClass, boolean >> filterReadOnlyProperties, Messages messages) >> { >> assert beanClass != null; >> assert messages != null; >> ... >> >> >> Why are we using assertions to check the arguments? Even in java >> 6,assertions are disabled by default at runtime, and according to: >> http://docs.oracle.com/javase/1.5.0/docs/guide/language/assert.html: >> >> "Do not use assertions for argument checking in public methods. >> Argument checking is typically part of the published specifications (or >> contract) of a method, and these specifications must be obeyed whether >> assertions are enabled or disabled. Another problem with using assertions >> for argument checking is that erroneous arguments should result in an >> appropriate runtime exception (such as IllegalArgumentException, >> IndexOutOfBoundsException, orNullPointerException). An assertion failure >> will not throw an appropriate exception." >> >> This just tripped up a new user; they received an NPE in >> TapestryInternalUtils.defaultLabel due to the message catalog being null. >> >> Robert >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [email protected] >> For additional commands, e-mail: [email protected] >> > >
--------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
