From: Peter W. <pet...@ve...> - 2009-09-17 13:13:49
|
You need the empty constructor because PropertySheet calls newInstance() public synchronized Configurable getOwner() { try { if (!isInstanciated()) { // ensure that all mandatory properties are set before instantiating the component Collection<String> undefProps = getUndefinedMandatoryProps(); if (!undefProps.isEmpty()) { throw new InternalConfigurationException(getInstanceName(), undefProps.toString(), "not all mandatory properties are defined"); } >>> owner = ownerClass.newInstance(); owner.newProperties(this); } } catch (IllegalAccessException e) { throw new InternalConfigurationException(e, getInstanceName(), null, "Can't access class " + ownerClass); } catch (InstantiationException e) { throw new InternalConfigurationException(e, getInstanceName(), null, "Can't instantiate class " + ownerClass); } return owner; } newInstance() chokes if there is not a constructor with no args. If there is no constructor, than a no args is assumed. If I add a constructor with args, I also need to add a no args version. P Joe Wölfel wrote: >> The reason is that SimpleAcousticScorer has no empty public constructor. >> I'm not really sure why it so, but can we avoid writing public >> constructors without arguments everywhere? They don't look necessary. >> > > Hmm. The compiler's choking on red tape. It's ironic that that language > 'feature' is allegedly supposed to prevent bugs. > > Joe > |