[
http://jira.magnolia-cms.com/browse/MAGNOLIA-3082?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=26608#action_26608
]
Grégory Joseph commented on MAGNOLIA-3082:
------------------------------------------
Now that I read the tests again, I'm not sure about this anymore. I see why we
need it - but it's the second part of
{{testCanInstantiateWithBestMatchingConstructorWhenTheSignatureIsMorePrecise()}}
I don't feel comfortable with. IMO, we should be able to do
{code}
classFactory.newInstance(FooBar.class, arr(Baz.class),
someInstanceOfABazSubclass)
{code} - ie we know the constructor takes exactly 1 Baz instance, and we pass
it whatever we have. If you can't do that, you either
* create an array with the types *of your arguments* with defaults to handle
nulls
* use the newInstance(class, args) variation of the method, and can't have null
parameters.
In any case, we should also have a couple of tests using generics to validate
the cases in question.
> DefaultClassFactory.newInstance(Class<T>, Class<?>[], Object...) should not
> use invokeExactConstructor but invokeConstructor
> ----------------------------------------------------------------------------------------------------------------------------
>
> Key: MAGNOLIA-3082
> URL: http://jira.magnolia-cms.com/browse/MAGNOLIA-3082
> Project: Magnolia
> Issue Type: Improvement
> Affects Versions: 4.3 M1
> Reporter: Philipp Bärfuss
> Assignee: Philipp Bärfuss
> Fix For: 4.3
>
>
> The method DefaultClassFactory.newInstance(Class<T>, Object...) calls
> ConstructorUtils.invokeConstructor(Class, Object[]) while this is not the
> case for DefaultClassFactory.newInstance(Class<T>, Class<?>[], Object...).
> This is especially a problem if you have more precise constructors in
> subclasses (especially if you use generics).
> Example: after introducing generics for models (MAGNOLIA-3081) the method
> AbstractRenderable.newModel(...) fails to find the correct constructor.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.magnolia-cms.com/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------