[ 
https://issues.apache.org/jira/browse/FREEMARKER-133?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Dániel Dékány resolved FREEMARKER-133.
--------------------------------------
    Fix Version/s: 2.3.31
       Resolution: Fixed

This is fixed in Git (2.3 and 2.3-gae branches).

Turns out, the code just didn't put together the list of accessible methods 
well, and has put in some inaccessible ones too sometimes. I'm very surprising 
that this bug could survive so long.

The Collection return type you mention, that in itself is not a bug or 
something, that's just a synthetic method, because the superclass declared it 
as Collection, and then the generic type is narrowed down to List.

> BeansWrapper IllegalAccessException when class defining accessed method is 
> package-private, but subclass is public
> ------------------------------------------------------------------------------------------------------------------
>
>                 Key: FREEMARKER-133
>                 URL: https://issues.apache.org/jira/browse/FREEMARKER-133
>             Project: Apache Freemarker
>          Issue Type: Bug
>            Reporter: Lauri Keel
>            Priority: Major
>             Fix For: 2.3.31
>
>
> Consider the following code:
> {code:java}
> <#list orders.get(type) as order></#list>{code}
> where orders is com.google.common.collect.ArrayListMultimap. An 
> IllegalAccessException is thrown, because 
> com.google.common.collect.AbstractListMultimap where the get method is 
> defined is package-private.
> {code:java}
> ----
> FTL stack trace ("~" means nesting-related):
>         - Failed at: #list orders.get(type) as order  [in template 
> "admin-orders.ftl" at line 4, column 9]
> ----
>         at 
> freemarker.ext.beans._MethodUtil.newInvocationTemplateModelException(_MethodUtil.java:289)
>         at 
> freemarker.ext.beans._MethodUtil.newInvocationTemplateModelException(_MethodUtil.java:252)
>         at 
> freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:77)
>         at freemarker.core.MethodCall._eval(MethodCall.java:65)
>         at freemarker.core.Expression.eval(Expression.java:83)
>         at 
> freemarker.core.IteratorBlock.acceptWithResult(IteratorBlock.java:98)
>         at freemarker.core.IteratorBlock.accept(IteratorBlock.java:93)
>         at freemarker.core.Environment.visit(Environment.java:366)
>         at 
> freemarker.core.IteratorBlock$IterationContext.executedNestedContentForCollOrSeqListing(IteratorBlock.java:291)
>         at 
> freemarker.core.IteratorBlock$IterationContext.executeNestedContent(IteratorBlock.java:271)
>         at 
> freemarker.core.IteratorBlock$IterationContext.accept(IteratorBlock.java:242)
>         at 
> freemarker.core.Environment.visitIteratorBlock(Environment.java:642)
>         at 
> freemarker.core.IteratorBlock.acceptWithResult(IteratorBlock.java:107)
>         at freemarker.core.IteratorBlock.accept(IteratorBlock.java:93)
>         at freemarker.core.Environment.visit(Environment.java:330)
>         at freemarker.core.Environment.visit(Environment.java:336)
>         at freemarker.core.Environment.process(Environment.java:309)
>         at freemarker.template.Template.process(Template.java:384)
>         at puu.page.PageHandler.getRendered(PageHandler.java:550)
>         ... 36 common frames omitted
> Caused by: java.lang.IllegalAccessException: class 
> freemarker.ext.beans.BeansWrapper cannot access a member of class 
> com.google.common.collect.AbstractListMultimap with modifiers "public 
> volatile"
>         at 
> java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:361)
>         at 
> java.base/java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:591)
>         at java.base/java.lang.reflect.Method.invoke(Method.java:558)
>         at 
> freemarker.ext.beans.BeansWrapper.invokeMethod(BeansWrapper.java:1505)
>         at 
> freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:72)
>         ... 52 common frames omitted
> {code}
> Tested in 2.3.29, 2.3.28, 2.3.23. Strangely it occasionally randomly does 
> work.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to