eclipse-ee4j / eclipse-ee4j/expressly
Nested property type in the same package can not be accessed
- Dominant language
- Java
- Stars
- 15
- Forks
- 10
- PR merge metrics
- No merged PRs in 30d
Description
I tried to create a record type like this.
```java
public record Customer(
String firstName,
String lastName,
Optional phoneNumber,
...
) {
}
record PhoneNumber(...){}
```
When access the `phoneNumber` via EL, it will throw exception like this.
```bash
Caused by: java.lang.IllegalAccessException: class jakarta.el.RecordELResolver cannot access a member of class com.example.PhoneNumber with modifiers "public"
at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:400)
at java.base/java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:670)
at java.base/java.lang.reflect.Method.invoke(Method.java:556)
at jakarta.el.RecordELResolver.getValue(RecordELResolver.java:76)
... 16 more
```
If I move the `PhoneNumber` into a standalone file and add a `public` modifier, it will work.
```java
// Customer.java
public record Customer(
String firstName,
String lastName,
Optional phoneNumber,
...
) {
}
// PhoneNumber.java
public record PhoneNumber(...){}
```
The example project can be found [here](https://github.com/hantsy/jakartaee11-sandbox/tree/master/el).
1. Clone the project.
2. Remove the standalone nested properties related files.
3. Uncomment the record types in the `Customer`
4. Run the test.
Contributor guide
Assessment
This issue has not been assessed yet.