You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "henrykuijpers (via GitHub)" <gi...@apache.org> on 2026/10/08 13:45:26 UTC

[PR] SLING-13381 - Support Java records in EL expressions [sling-org-apache-sling-scripting-jsp]

henrykuijpers opened a new pull request, #13:
URL: https://github.com/apache/sling-org-apache-sling-scripting-jsp/pull/13

   https://issues.apache.org/jira/browse/SLING-13381
   
   ### Changes
   - New `RecordELResolver`: resolves record components through their accessor methods, so `${record.name}` calls `record.name()`. Records are read-only (`setValue` throws `PropertyNotWritableException`).
   - The record API (`Class.isRecord()`, `RecordComponent`) is accessed reflectively, so the bundle still targets Java 8 and only resolves records when running on Java 16+. Accessors are cached per class in a `ClassValue`, so classloaders aren't leaked.
   - The resolver is registered **before** the `BeanELResolver` in both resolver chains:
     - `JspApplicationContextImpl` (EL in JSP pages)
     - `ELResolverImpl.DefaultResolver` (`ExpressionEvaluator` API)
   
     If it came after, the `BeanELResolver` would throw a `PropertyNotFoundException` for record components.
   - Properties that aren't record components (e.g. a regular `getFoo()` on a record) are left unresolved, so the `BeanELResolver` still handles them as before.
   
   No changes to the pom or the bundle manifest.
   
   ### Tests
   - `RecordELResolverTest`: unit tests for every resolver method, covering records, non-public records, accessors that throw, non-records, a `null` base and a `null` context.
   - `ELResolverImplTest` and `JspApplicationContextImplTest`: EL expressions evaluated through both resolver chains, including the fallback to bean getters, and checks that beans and maps still resolve.
   - The test sources are compiled for Java 8, so the records are compiled at runtime by the `TestRecords` class rule. **Tests that need a record are skipped on JVMs older than Java 16.**
   
   The CI build only runs on JDK 11 (`.sling-module.json`), so it skips the record tests. To run them locally, keep building with JDK 11 (parent 35's bnd 4.2.0 fails on JDK 17+) and run the tests on a newer JVM:
   
   ```
   mvn clean install -Djvm=/path/to/jdk-17/bin/java
   ```
   
   Results: on JDK 11, 65 tests run and 24 are skipped. With the tests on JDK 17 or 21, all 65 run and none are skipped. I also temporarily broke the code three ways (resolver order in each chain, removing `setAccessible`), and each one fails the corresponding tests.
   
   The record tests will run in CI once the build moves to JDK 17+ (e.g. via SLING-12438 / #10).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] SLING-13381 - Support Java records in EL expressions [sling-org-apache-sling-scripting-jsp]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #13:
URL: https://github.com/apache/sling-org-apache-sling-scripting-jsp/pull/13#issuecomment-6061652704

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_sling-org-apache-sling-scripting-jsp&pullRequest=13) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [8 New issues](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-scripting-jsp&pullRequest=13&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-scripting-jsp&pullRequest=13&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_sling-org-apache-sling-scripting-jsp&pullRequest=13&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [87.5% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-scripting-jsp&pullRequest=13&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-scripting-jsp&pullRequest=13&metric=new_duplicated_lines_density&view=list)  
     
   <!-- sqra-placement-anchor -->
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_sling-org-apache-sling-scripting-jsp&pullRequest=13)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] SLING-13381 - Support Java records in EL expressions [sling-org-apache-sling-scripting-jsp]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #13:
URL: https://github.com/apache/sling-org-apache-sling-scripting-jsp/pull/13#issuecomment-6061335698

   ## [![Quality Gate Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png 'Quality Gate Failed')](https://sonarcloud.io/dashboard?id=apache_sling-org-apache-sling-scripting-jsp&pullRequest=13) **Quality Gate failed**  
   Failed conditions  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png '') [50.8% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-scripting-jsp&pullRequest=13&metric=new_coverage&view=list) (required ≥ 80%)  
     
   <!-- sqra:qg_revision=9b2aedccda4471e4512d1141b0c4332839f064b4c192c156dd717d20465b8667 -->
   <!-- sqra-placement-anchor -->
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_sling-org-apache-sling-scripting-jsp&pullRequest=13)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org