[ 
https://issues.apache.org/jira/browse/FELIX-5237?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15255419#comment-15255419
 ] 

Pierre De Rop commented on FELIX-5237:
--------------------------------------

Thanks for proposing this enhancement.

committed in revision 1740677.
I slightly modified the proposed patch: added a check in case the configuration 
type is really an annotation, and added also the support for java8 default 
methods.

Also added a test case: FELIX5238_TypeSafeConfigWithDefaultMethodTest.java

The patch does the following:

- annotations are now supported: if the configuration type is an annotation, 
then default methods (if any) are used as default values.
For example:

{code}
    public @interface MyConfig {
        String getTestkey();
        String getTestkey2() default "123";
    }
{code}

- if the configuration type is an interface (but not an annotation), then a 
check is also done in order to detect the presence of java8 default methods. 
for example:

{code}
    public interface MyConfig {
        String getTestkey();
        default String getTestkey2() { return "123"; }
    }
{code}

I think it's ok.  I leave this issue in the Unresolved state because I have to 
update the documentation and maybe Jan Willem want to also make a code review ?


> Configurable invocation handler should use default method values
> ----------------------------------------------------------------
>
>                 Key: FELIX-5237
>                 URL: https://issues.apache.org/jira/browse/FELIX-5237
>             Project: Felix
>          Issue Type: Improvement
>          Components: Dependency Manager
>    Affects Versions: dependencymanager-4.3.0
>            Reporter: Guillaume Nodet
>            Assignee: Pierre De Rop
>
> Simple patch:
> {code}
>         private Object getDefaultValue(Method method, String key) throws 
> Exception {
>             return convert(method.getGenericReturnType(), key, 
> method.getDefaultValue(), true /* useImplicitDefault */);
>         }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to