Skip to content

Conversation

Ladicek
Copy link
Contributor

@Ladicek Ladicek commented Jun 9, 2025

Fixes #416

@Ladicek
Copy link
Contributor Author

Ladicek commented Jun 9, 2025

Commits best reviewed in isolation.

I'm not sure about the last commit, actually. It imposes an artificial restriction on generating lambdas so that the behavior is consistent between the default and debug mode. I tried to find a way to allow defining parameters before captures in the debug mode, but failed, and this extra restriction isn't terribly bad, so I felt I'll just submit this and see what you think.

@Ladicek Ladicek added the 2.x Issue applies to Gizmo 2.x label Jun 9, 2025
@Ladicek Ladicek moved this to In Progress in WG - Gizmo 2 Jun 9, 2025
@Ladicek Ladicek force-pushed the improve-decompilation-experience branch 2 times, most recently from 02131c5 to 694c3a8 Compare June 13, 2025 13:04
Ladicek added 2 commits June 23, 2025 14:38
This is to workaround the IntelliJ IDEA decompiler (FernFlower) deficiency
where it ignores all synthetic members of decompiled classes. Since we used
to mark all members as synthetic, a decompiled class would be just empty,
which is certainly not good.

We still mark the generated classes/interfaces as synthetic, which should
be good enough of a marker to everyone that all members are also synthetic.
This is in inticipation of another change: in the debugging mode, we'll
generate lambdas that use the classic `LambdaMetafactory` translation
strategy instead of our custom one. Our custom strategy cannot pass
through decompilation, which is not good.
@Ladicek Ladicek force-pushed the improve-decompilation-experience branch from 694c3a8 to 8169f98 Compare June 23, 2025 12:40
Ladicek added 4 commits June 23, 2025 21:00
Previously, the counter was present in `BlockCreatorImpl` and so was unique
for each block. This is not necessarily correct; it is possible for one method
to have multiple blocks and each of those blocks to generate an anonymous
class. With this commit, the counter is present in `TypeCreatorImpl` and so
is unique to each generated type. This is always correct.
This is (likely) slower and bigger than our custom translation strategy,
but is supported by decompilers (at least by FernFlower), so it should
be used in the debug mode.

The following limitations exist:

- serializable lambdas are not supported yet (but they are not supported
  by our custom translation strategy either)
- captures must be defined first, before parameters
This is to unify the behavior in the standard ("release") mode and debug mode
when it comes to lambdas. Our custom translation strategy doesn't care about
ordering between defining captures and parameters, but the standard one (based
on `LambdaMetafactory`) does, so this restriction brings them both on par.
@Ladicek Ladicek force-pushed the improve-decompilation-experience branch from 8169f98 to 93b6e3a Compare June 23, 2025 19:03
@Ladicek Ladicek merged commit a9b1780 into quarkusio:main Jun 24, 2025
1 check passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in WG - Gizmo 2 Jun 24, 2025
@Ladicek Ladicek deleted the improve-decompilation-experience branch June 24, 2025 06:47
@Ladicek Ladicek added this to the 2.0.0.Beta2 milestone Jul 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.x Issue applies to Gizmo 2.x
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

improve decompilation experience
2 participants