2323@ ApplicationScoped
2424public 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