Skip to content

Commit 542215d

Browse files
Additional changes : PR Review comments
1 parent 0802a16 commit 542215d

File tree

2 files changed

+36
-7
lines changed

2 files changed

+36
-7
lines changed

io.openliberty.java.internal_fat_26/README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,12 @@ With this flag enabled:
8484
### FAT Validation
8585

8686
When running the FAT test:
87-
1. **Default mode**: Check server logs for WARNING messages about illegal reflection
88-
2. **Strict mode**: Verify test catches `IllegalAccessException` and logs it
87+
1. **Default mode**:
88+
- Check server logs for WARNING messages about illegal reflection
89+
- Verify the field value was or was not mutated by checking the logged value
90+
- Expected: Mutation will succeed with warnings logged
91+
92+
2. **Strict mode**:
93+
- Verify test catches `IllegalAccessException` and logs it
94+
- Verify the field value remains unchanged (should be "Original")
95+
- Expected: Mutation blocked, exception thrown

io.openliberty.java.internal_fat_26/src/main/java/io/openliberty/java/internal/TestService.java

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,25 @@
2323
@ApplicationScoped
2424
public class TestService {
2525

26+
static class FirstName {
27+
private final String value;
28+
29+
public FirstName(String value) {
30+
this.value = value;
31+
}
32+
33+
public String getValue() {
34+
return value;
35+
}
36+
37+
@Override
38+
public String toString() {
39+
return value;
40+
}
41+
}
42+
2643
static class Person {
27-
public final String name = "Original";
44+
public final FirstName name = new FirstName("Original");
2845
}
2946

3047
private StringWriter sw = new StringWriter();
@@ -76,7 +93,7 @@ private void testFinalMeanFinal() throws Exception {
7693

7794
// Attempt to set the final field directly
7895
log("Attempting direct mutation of final field...");
79-
f.set(p, "Mutated");
96+
f.set(p, new FirstName("Mutated"));
8097

8198
// If we reach here, mutation succeeded (WARN mode)
8299
mode = "WARN";
@@ -95,14 +112,19 @@ private void testFinalMeanFinal() throws Exception {
95112

96113
// Verify results based on mode
97114
if (mode.equals("DENY")) {
98-
if (!"Original".equals(p.name)) {
115+
if (!"Original".equals(p.name.getValue())) {
99116
throw new Exception("JEP 500 test FAILED: Final field was mutated despite exception. Value: " + p.name);
100117
}
101118
log("RESULT: Final field remained immutable (value: " + p.name + ")");
102119
} else {
103-
// WARN mode - mutation may succeed but should log warnings - Current Java 26 Behaviour
104-
log("RESULT: Mutation completed in WARN mode");
120+
// WARN mode - mutation may succeed but should log warnings - Current Java 26 Behaviour
121+
if ("Mutated".equals(p.name.getValue())) {
122+
log("RESULT: Mutation succeeded in WARN mode - field value changed to: " + p.name);
123+
} else {
124+
log("RESULT: Mutation attempted in WARN mode but value unchanged: " + p.name);
125+
}
105126
log("Note: Check console.log/messages.log for JEP 500 warnings");
127+
106128
}
107129

108130
log("JEP 500 Test Summary:");

0 commit comments

Comments
 (0)