In most cases, I'd say that Errors shouldn't even be caught and rethrown, personally -- something like an OOME doesn't need additional object creation, for instance.

On Fri, Apr 4, 2008 at 1:55 PM, Mark Proctor <mproctor@codehaus.org> wrote:
I don't see a problem with Throwable there? We rethrow again, adding in some additional information. I found that just catching Exception didn't work as you could get verification errors and other stuch things. If you look at the context of that that method is doing too, its using reflection to instantiate a class.

Mark
Zoltan Farkas wrote:

I was browsing through the drools source code

 

I am not a fan of seeing catching Throwable in any java code …

 

I see this in class org.drools.util.ClassUtils:

 

    /**

     * This method will attempt to create an instance of the specified Class. It uses

     * a syncrhonized HashMap to cache the reflection Class lookup.

     * @param className

     * @return

     */

    public static Object instantiateObject(String className) {

        Class cls = (Class) ClassUtils.classes.get( className );

        if ( cls == null ) {

            try {

                cls = Class.forName( className );

                ClassUtils.classes.put(  className, cls );

            } catch ( Throwable e ) {

                throw new RuntimeException("Unable to load class '" + className + "'", e );

            }           

        }

       

        Object object = null;

        try {

            object = cls.newInstance();           

        } catch ( Throwable e ) {

            throw new RuntimeException("Unable to instantiate object for class '" + className + "'", e );

        } 

        return object;

    }

 

I believe this masks important errors where the application should not continue to run and it would be preferable to crash…

 

--zoly

 


_______________________________________________ rules-dev mailing list rules-dev@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-dev


_______________________________________________
rules-dev mailing list
rules-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-dev




--
Geoffrey Wiseman