sunmingtao / sample-code

3 stars 4 forks source link

Freemarker doesn't expose all the methods of bean #169

Closed sunmingtao closed 4 years ago

sunmingtao commented 4 years ago

path.toFile() evaluates to null on Freemarker.

sunmingtao commented 4 years ago

Interface default methods (Path.toFile()) are not exposed in Freemarker template by default.

https://stackoverflow.com/questions/30503889/freemarker-and-java8-default-methods

sunmingtao commented 4 years ago

Then I find some non default methods, such as Path.normalize(), are also not exposed.

That's because the return type of Path.normalize() is Path, while the return type of WindowsPath.normalize() is WindowsPath. For the method to be exposed in the template, the return type must be the same.

image