[
https://issues.apache.org/jira/browse/FREEMARKER-40?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15668040#comment-15668040
]
Daniel Dekany commented on FREEMARKER-40:
-----------------------------------------
If a private class implements a public interface, then its methods will be
visible from the templates. The restriction is that public methods that are
originally declared in non-public classes/interfaces aren't accessible. It
seems that this works like that deliberately. Not sure why the original author
wanted this, but I don't like it either. So about two weeks ago I have added a
{{exposePublicMembersOfNonPublicClasses}} setting to {{BeansWrapper}}, however
I haven't yet committed it, as more test cases etc. are still needed. It's a
funny coincidence that bring it up now, because it's like that for 10+ years.
{{exposePublicMembersOfNonPublicClasses}} won't be {{true}} by default, for
backward compatibility. I will try to make the error message more helpful in
case it's {{false}}.
> ClassIntrospector should detect public methods in non-public classes
> --------------------------------------------------------------------
>
> Key: FREEMARKER-40
> URL: https://issues.apache.org/jira/browse/FREEMARKER-40
> Project: Apache Freemarker
> Issue Type: Bug
> Components: engine
> Affects Versions: 2.3.25-incubating
> Reporter: Jochen Wiedmann
> Priority: Minor
>
> In ClassIntrospector.discoverAccessibleMethods, the assumption is made, that
> only public classes can have accessible methods. This is plainly wrong: For
> example, a private object might be implementing an interface.
> Freemarker should detect public gettters, and treat them as accessible. At
> the very least, it should inform the user about the problem. A message like
> "Key <propertyName> was not found on an instance of ..."
> should be replaced by
> "Key <propertyName> was not found on an instance of ..."
> "A possible reason is,that the class must be public."
> Thanks,
> Jochen
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)