psteitz 2004/07/10 09:04:47 Modified: math/src/java/org/apache/commons/math/stat/univariate DescriptiveStatistics.java SummaryStatistics.java Log: Caught NoClassDefFound Error when DiscoverClass is not present, eliminating runtime dependency on [discovery], [logging]. Removed factory method taking string class name (use of Class.ForName()). Revision Changes Path 1.9 +3 -20 jakarta-commons/math/src/java/org/apache/commons/math/stat/univariate/DescriptiveStatistics.java Index: DescriptiveStatistics.java =================================================================== RCS file: /home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/stat/univariate/DescriptiveStatistics.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- DescriptiveStatistics.java 23 Jun 2004 16:26:16 -0000 1.8 +++ DescriptiveStatistics.java 10 Jul 2004 16:04:47 -0000 1.9 @@ -50,22 +50,6 @@ * created. * @throws IllegalAccessException is thrown if the type's default * constructor is not accessible. - * @throws ClassNotFoundException if the named - * <code>DescriptiveStatistics</code> type can not be found. - */ - public static DescriptiveStatistics newInstance(String cls) throws InstantiationException, IllegalAccessException, ClassNotFoundException { - return newInstance(Class.forName(cls)); - } - - /** - * Create an instance of a <code>DescriptiveStatistics</code> - * @param cls the type of <code>DescriptiveStatistics</code> object to - * create. - * @return a new factory. - * @throws InstantiationException is thrown if the object can not be - * created. - * @throws IllegalAccessException is thrown if the type's default - * constructor is not accessible. */ public static DescriptiveStatistics newInstance(Class cls) throws InstantiationException, IllegalAccessException { return (DescriptiveStatistics)cls.newInstance(); @@ -82,9 +66,8 @@ factory = (DescriptiveStatistics) dc.newInstance( DescriptiveStatistics.class, "org.apache.commons.math.stat.univariate.DescriptiveStatisticsImpl"); - } catch(Exception ex) { - ex.printStackTrace(); - // ignore as default implementation will be used. + } catch(Throwable t) { + return new DescriptiveStatisticsImpl(); } return factory; } 1.10 +7 -23 jakarta-commons/math/src/java/org/apache/commons/math/stat/univariate/SummaryStatistics.java Index: SummaryStatistics.java =================================================================== RCS file: /home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/stat/univariate/SummaryStatistics.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- SummaryStatistics.java 23 Jun 2004 16:26:16 -0000 1.9 +++ SummaryStatistics.java 10 Jul 2004 16:04:47 -0000 1.10 @@ -29,22 +29,6 @@ /** Serialization UID */ static final long serialVersionUID = -6400596334135654825L; - - /** - * Create an instance of a <code>SummaryStatistics</code> - * @param cls the type of <code>SummaryStatistics</code> object to - * create. - * @return a new factory. - * @throws InstantiationException is thrown if the object can not be - * created. - * @throws IllegalAccessException is thrown if the type's default - * constructor is not accessible. - * @throws ClassNotFoundException if the named - * <code>SummaryStatistics</code> type can not be found. - */ - public static SummaryStatistics newInstance(String cls) throws InstantiationException, IllegalAccessException, ClassNotFoundException { - return newInstance(Class.forName(cls)); - } /** * Create an instance of a <code>DescriptiveStatistics</code> @@ -62,19 +46,19 @@ /** * Create an instance of a <code>DescriptiveStatistics</code> - * @return a new factory. + * @return a new SummaryStatistics instance. */ public static SummaryStatistics newInstance() { - SummaryStatistics factory = null; + SummaryStatistics instance = null; try { DiscoverClass dc = new DiscoverClass(); - factory = (SummaryStatistics) dc.newInstance( + instance = (SummaryStatistics) dc.newInstance( SummaryStatistics.class, "org.apache.commons.math.stat.univariate.SummaryStatisticsImpl"); - } catch(Exception ex) { - // ignore as default implementation will be used. + } catch(Throwable t) { + return new SummaryStatisticsImpl(); } - return factory; + return instance; }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]