[lworld] RFR: 8352068: [lworld] test StrictFinalInstanceFieldsTest.java needs to be updated after fix for JDK-8351951 [v4]

Matias Saavedra Silva matsaave at openjdk.org
Thu May 29 19:50:05 UTC 2025


On Thu, 22 May 2025 18:37:20 GMT, Dan Heidinga <heidinga at openjdk.org> wrote:

> Maintaining jasm and jcod files can be a pain. The less those files contain, the better as it is less classfile / bytecode to try to build in your head while debugging.
> 
> One option for set of common tests like this that all have x & y fields, as well as getter methods and a complicated toString, is to use an abstract parent class:
> 
> ```
> abstract JasmParent extends Parent {
>   abstract int get_x();
>   abstract int get_y();
>   
>   public String toString() {
>           return "x: " + get_x() + "\n" + "y: " + get_y() + "\n" + super.toString();
>     }
> }
> ```
> 
> and have all the .jasm file class extend this class instead of using Parent directly. This will move all the bootstrap methods & indy related code out of jasm files and hopefully result in something simpler to look at.
> 
> Another option is to keep Parent as it is, but have its toString() use Reflection like: `this.getClass().getDeclaredFeilds()` to find all the fields and print them. Any solution that moves code out of jasm / jcod files makes the code easier to maintain and understand longterm

Thanks for this suggestion! I've opted to use reflection for toString() so I can get rid of get_x() and get_y(). The jasm and jcod files have been cleaned up and now include the equivalent java source code as a comment to better illustrate what is being tested. I snuck in a logging improvement as well.

-------------

PR Comment: https://git.openjdk.org/valhalla/pull/1449#issuecomment-2920412790


More information about the valhalla-dev mailing list