You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@freemarker.apache.org by "Christopher Smith (Jira)" <ji...@apache.org> on 2023/05/02 21:12:00 UTC
[jira] [Created] (FREEMARKER-216) IllegalAccessException in Java 17
Christopher Smith created FREEMARKER-216:
--------------------------------------------
Summary: IllegalAccessException in Java 17
Key: FREEMARKER-216
URL: https://issues.apache.org/jira/browse/FREEMARKER-216
Project: Apache Freemarker
Issue Type: Bug
Components: engine
Affects Versions: 2.3.32
Reporter: Christopher Smith
I am using Freemarker in an annotation processor to generate code. I supply an instance of {{javax.lang.model.element.TypeElement}}, which implements {{QualifiedNameable}}, to the template model and use {{element.qualifiedName}} as a template variable.
My code works fine under Java 11, but after updating the compiler to Java 17 (even with Java 11 compliance settings), I am receiving an {{IllegalAccessException}}.
There seems to be a severely deficient implementation in the encapsulation of Java internals that does not make methods that implement an interface accessible, but perhaps it's possible to get the {{Method}} handles for the property accessors on interfaces?
{code}
Caused by: java.lang.IllegalAccessException: class freemarker.ext.beans.BeansWrapper cannot access class com.sun.tools.javac.code.Symbol$ClassSymbol (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.code to unnamed module @43c3d622 at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:392) at java.base/java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:674) at java.base/java.lang.reflect.Method.invoke(Method.java:560) at freemarker.ext.beans.BeansWrapper.invokeMethod(BeansWrapper.java:1553) at freemarker.ext.beans.BeanModel.invokeThroughDescriptor(BeanModel.java:233) at freemarker.ext.beans.BeanModel.get(BeanModel.java:152) ... 129 more
{code}
{code}
FreeMarker template error:An error has occurred when reading existing sub-variable "qualifiedName"; see cause exception! The type of the containing value was: extended_hash+string (com.sun.tools.javac.code.Symbol$ClassSymbol wrapped into f.e.b.StringModel)
{code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)