Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Final step methods not working #148

Closed
nikowitt opened this issue Oct 20, 2015 · 3 comments
Closed

Final step methods not working #148

nikowitt opened this issue Oct 20, 2015 · 3 comments

Comments

@nikowitt
Copy link
Contributor

Hi Jan,

I've just discovered that it is also not possible to properly use final step methods - in my case, it looks like this:

public final T param_with_query_type_$_is_set(@QuotedReadableEnumWithExposedOrdinal Enum<?> queryType) throws Exception {
        int value = queryType instanceof JAFQueryType ? JAFQueryType.class.cast(queryType).getQueryType() : queryType.ordinal();
        return param_with_query_type_$_is_set(value);
    }

    /**
     * Param_with_query_type_$_is_set.
     *
     * @param queryType
     *            the query type
     * @return the t
     * @throws Exception
     *             the exception
     */
    public T param_with_query_type_$_is_set(@Quoted Integer queryType) throws Exception {
        getRequestParams().setQueryType(queryType);
        return self();
    }

When I supply an enum, the second method is used for formatting, the first (correct) method is not used. When I remove the "final" modifier, everything works as expected. Is this a bug or a CGLib limitation, so it should be documented?

Regards,
Niko

@janschaefer
Copy link
Contributor

Yes that is completely right. This is a feature of Java ;-). But I will extend the documentation accordingly.

@nikowitt
Copy link
Contributor Author

It's a pity since it makes sense to make some wrapper methods final, but very well :)

So this means CGLib cannot intercept final methods or is this a generic Java thing?

@janschaefer
Copy link
Contributor

In order to intercept the method, cglib (and any other framework) has to override the method. This is forbidden by the definition of final, so it is not possible to intercept these methods (similar to private methods).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants