freemarker-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Emmanuel Keller (JIRA)" <j...@apache.org>
Subject [jira] [Created] (FREEMARKER-24) Support of default methods in objet model
Date Tue, 17 May 2016 10:12:12 GMT
Emmanuel Keller created FREEMARKER-24:
-----------------------------------------

             Summary: Support of default methods in objet model
                 Key: FREEMARKER-24
                 URL: https://issues.apache.org/jira/browse/FREEMARKER-24
             Project: Apache Freemarker
          Issue Type: Improvement
          Components: engine
    Affects Versions: 2.3.24
            Reporter: Emmanuel Keller
            Priority: Minor
             Fix For: 2.3.25


The default object method model currently does not support default methods:
https://docs.oracle.com/javase/tutorial/java/IandI/defaultmethods.html

Here is the current error:

{noformat}
FTL stack trace ("~" means nesting-related):
	- Failed at: #if task.switchable  [in template "...../home.ftl" at line 43, column 25]
----
	at freemarker.core.InvalidReferenceException.getInstance(InvalidReferenceException.java:131)
	at freemarker.core.UnexpectedTypeException.newDesciptionBuilder(UnexpectedTypeException.java:77)
	at freemarker.core.UnexpectedTypeException.<init>(UnexpectedTypeException.java:40)
	at freemarker.core.NonBooleanException.<init>(NonBooleanException.java:44)
	at freemarker.core.Expression.modelToBoolean(Expression.java:142)
	at freemarker.core.Expression.evalToBoolean(Expression.java:125)
	at freemarker.core.Expression.evalToBoolean(Expression.java:110)
	at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:46)
	at freemarker.core.Environment.visit(Environment.java:324)
	at freemarker.core.MixedContent.accept(MixedContent.java:54)
	at freemarker.core.Environment.visitByHiddingParent(Environment.java:345)
	at freemarker.core.IteratorBlock$IterationContext.executeNestedBlockInner(IteratorBlock.java:240)
	at freemarker.core.IteratorBlock$IterationContext.executeNestedBlock(IteratorBlock.java:220)
	at freemarker.core.IteratorBlock$IterationContext.accept(IteratorBlock.java:194)
	at freemarker.core.Environment.visitIteratorBlock(Environment.java:572)
	at freemarker.core.IteratorBlock.acceptWithResult(IteratorBlock.java:78)
	at freemarker.core.IteratorBlock.accept(IteratorBlock.java:64)
	at freemarker.core.Environment.visit(Environment.java:324)
	at freemarker.core.MixedContent.accept(MixedContent.java:54)
	at freemarker.core.Environment.visit(Environment.java:324)
	at freemarker.core.Environment.process(Environment.java:302)
	at freemarker.template.Template.process(Template.java:325)
	at com.qwazr.tools.FreeMarkerTool.template(FreeMarkerTool.java:86)
	at com.qwazr.tools.FreeMarkerTool.template(FreeMarkerTool.java:101)
{noformat}

To reproduce this.

1. Use an interface

{code:java}
public interface UpdatableTask extends Runnable {

    default boolean isSwitchable() {
        return false;
    }
}
{code}

2. Use an object that implements this interface with the following template:

{code}
<#if task.switchable>
...
</#if>
{code}



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

Mime
View raw message