stevedlawrence commented on code in PR #1524:
URL: https://github.com/apache/daffodil/pull/1524#discussion_r2256886977


##########
daffodil-core/src/main/scala/org/apache/daffodil/lib/util/Misc.scala:
##########
@@ -746,17 +746,12 @@ object Misc {
     }
   }
 
-  // helper function for scala 2.13 and 3 compatibility
+  /**
+   * scala 3 changes the way lazy val are deserialized so it looks like 
fieldName$lzy1
+   * This is a helper function to keep from dirtying the code
+   */
   def lookupDeclaredField(clazz: Class[?], fieldName: String): Field = {
-    try {
-      // TODO scala 2.12 phase out, we can remove the check for the plain 
name, and always
-      // check the lazy name version instead
-      clazz.getDeclaredField(fieldName)

Review Comment:
   Should we keep this try/catch, just with a tweak to the comment?
   
   This function is about using reflection to find a specific field of a class, 
so ideally it would work regardless if the field is lazy. With this change it 
only works for lazy fields.
   
   Currently we only use it for `parents`, which is lazy and so everything 
works, but if we ever change `parents` to be non-lazy or use this function for 
some other non-lazy field it won't work as expected.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to