codope commented on code in PR #6657:
URL: https://github.com/apache/hudi/pull/6657#discussion_r981256090


##########
hudi-common/src/main/java/org/apache/hudi/common/util/ObjectSizeCalculator.java:
##########
@@ -127,6 +129,16 @@ public synchronized long calculateObjectSize(Object obj) {
         }
         obj = pending.removeFirst();
       }
+    } catch (IllegalAccessException | SecurityException e) {
+      // JDK versions 16 or later enforce strong encapsulation and do now 
allow to invoke `setAccessible` on a field,
+      // especially when the `isAccessible` is false. More details in JEP 403. 
While integrating Hudi with other
+      // software packages that compile against JDK 16 or later (e.g. Trino), 
the IllegalAccessException will be thrown.
+      // In that case, we use Java Object Layout (JOL) to estimate the object 
size.
+      //
+      // NOTE: We cannot get the object size base on the amount of byte 
serialized because there is no guarantee
+      //       that the incoming object is serializable. We could have used 
Java's Instrumentation API but it
+      //       needs an instrumentation agent that can be hooked to the JVM. 
In lieu of that, we are using JOL.
+      return ClassLayout.parseClass(obj.getClass()).instanceSize();

Review Comment:
   Actually, there is no strong reason. We can remove the older implementation.



-- 
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