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 2024/01/04 18:57:00 UTC
[jira] [Comment Edited] (FREEMARKER-216) IllegalAccessException in Java 17
[ https://issues.apache.org/jira/browse/FREEMARKER-216?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17803291#comment-17803291 ]
Christopher Smith edited comment on FREEMARKER-216 at 1/4/24 6:56 PM:
----------------------------------------------------------------------
The project is available on Github at https://github.com/vendorflow/vendorflow-jsonapi. Running {{./mvnw test}} with a Java 17 SDK (I am using {{OpenJDK 64-Bit Server VM Temurin-17.0.9+9 (build 17.0.9+9, mixed mode, sharing)}}) will demonstrate the failure. (The {{release}} is set to 11, but that makes no difference.) The current master HEAD revision is c924c397b10746bef890346dc27df084c5a2de72.
was (Author: chrylis):
The project is available on Github at https://github.com/vendorflow/vendorflow-jsonapi. Running {{./mvnw test}} with a Java 17 SDK will demonstrate the failure. (The {{release}} is set to 11, but that makes no difference.) The current master HEAD revision is c924c397b10746bef890346dc27df084c5a2de72.
> 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
> Priority: Critical
>
> 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? I see that {{ClassIntrospector#discoverAccessibleMethods}} tries to do this, but perhaps it's not taking into account JPMS?
> {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)