Add TCK coverage for Section 1.6 when `expr-a` is the `null` literal (`${null.prop}`, `${null['prop']}`, `${null.method()}`)

Open Beginner friendly
#501 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 7 days

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
java
Domain
testing

Research direction

Start by locating the TCK tests for Section 1.6 operators [] and . and read nearby cases for null property resolution. Add coverage for ${null.prop}, ${null['prop']}, and ${null.method()} following the issue's stated expected result. Run the relevant TCK tests; done when all three cases pass consistently.

Written by the indexing model from the issue text.

Description

In Section 1.6 ("Operators [] and .") of the Jakarta Expression Language 6.1 specification:

To evaluate expr-a[expr-b] or expr-a[expr-b](params):

  • Evaluate expr-a into value-a.
  • If value-a is null:
    • If expr-a[expr-b] is the last property being resolved:
      • If the expression is a value expression and ValueExpression.getValue(context) was called to initiate this expression evaluation, return null.
      • Otherwise, throw PropertyNotFoundException. [trying to de-reference null for an lvalue]
    • Otherwise, return null.

Section 1.6 makes no distinction between expr-a evaluating to null via an identifier/property (e.g. ${person.nullAddress.street}) versus expr-a being the null literal itself (e.g. ${null.prop}, ${null['prop']}, or ${null.method()}).
However, because the TCK currently only tests value-a == null when resolved from a bean/variable and does not test a literal null base, implementations behave differently:

  • Eclipse Expressly: Returns null (conforming to Section 1.6).
  • Apache Tomcat Jasper EL: Throws jakarta.el.PropertyNotFoundException: ELResolver did not handle type: [null] with property of [null].
Steps to Reproduce
import jakarta.el.ELProcessor;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertNull;
public class NullLiteralBaseTest {
    @Test
    void testNullLiteralPropertyAndMethod() {
        ELProcessor processor = new ELProcessor();
        // Expressly returns null; Jasper EL throws PropertyNotFoundException
        assertNull(processor.eval("null.prop"));
        assertNull(processor.eval("null['prop']"));
        assertNull(processor.eval("null.method()"));
    }
}
Request

Please add TCK tests for ${null.prop}, ${null['prop']}, and ${null.method()} to ensure all certified implementations consistently follow Section 1.6 when expr-a is a null literal.

Dominant language
Java
Stars
86
Forks
54
Avg merge
6d 9h
Merged PRs (30d)
11

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from jakartaee/expression-language

All issues in jakartaee/expression-language

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.