fix(decompiler): Signature-attribute throws recovery + catch merge + throw typevar cast + try-break-return#6
Merged
Conversation
… method arg cast
Two fixes in sameClassMethodParamType + resolvedParameterizedArgCast, both
zero-regression (8-JAR A/B delta >= 0):
1. sameClassMethodParamType: accept a parameterized formal `Class<L>` (L a
class-scope type variable), not just bare type variables. The old code
checked `params[i].RawType().(*types.JavaClass)` which rejects
`*JavaParameterizedType` (Class<L>'s RawType), so the resolver returned nil
for any parameterized formal and no cast was emitted. Now also checks
`*JavaParameterizedType` with RawClassName "java.lang.Class" and a single
class-scope type-var argument.
2. resolvedParameterizedArgCast same-erasure branch: a raw `Class` argument
fed to a `Class<L>` formal (L a class-scope type variable) cannot convert
without an unchecked `(Class<L>)` cast ("Class<CAP#1> cannot be converted
to Class<L>"; commons-lang3 EventListenerSupport.readObject
`this.initializeTransientFields(var2.getClass().getComponentType(), ...)`
where the formal is `Class<L>`). Re-emit the cast.
Also: fix funcCtx.ClassName empty fallback in sameClassMethodParamType for
private method calls where ClassName isn't set in the rendering context.
Fixes commons-lang3 EventListenerSupport.readObject (tree 3->2). Load-bearing
test: class_typevar_param_test.go (ClassTypeVarParamSeed).
Status: commons-lang3 2, guava 26, spring 28. Total 56 (was 57).
…atch merge + throw typevar cast + try-break-return Four fixes clearing commons-lang3 tree errors, all zero-regression across 8 jars (provenClean codec/gson/fastjson2/snakeyaml/jsoup all stay 0; spring 28 same; guava 26 same): 1. Signature-attribute throws-type-variable recovery (JDEC_THROWS_SIG_RECOVERY_OFF): ParseMethodSignature/ParseMethodSignatureFull now parse the -prefixed throws types from the method Signature attribute. When a throws type IS a type variable (e.g. where ), the ExceptionsAttribute's erasure () is overridden with the Signature-derived . Without this, a call site like fails unreported
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Four fixes clearing commons-lang3 tree errors, all zero-regression across 8 jars (provenClean codec/gson/fastjson2/snakeyaml/jsoup all stay 0; spring 28 same; guava 26 same).
Fixes
Signature-attribute throws-type-variable recovery (
JDEC_THROWS_SIG_RECOVERY_OFF):ParseMethodSignature/ParseMethodSignatureFullnow parse the^-prefixed throws types from the method Signature attribute. When a throws type IS a type variable (e.g.throws TwhereT extends Throwable), the ExceptionsAttribute's erasure (throws Throwable) is overridden withthrows T. Clears commons-lang3ObjectUtils.wait.Catch merge for wrapping rethrow (
JDEC_NO_CATCH_MERGEenhancement):mergeNestedSameTypeCatchesnow handles wrapping rethrows (throw Failable.rethrow(t)). The first catch's throw is PRESERVED and the cleanup code inserted before it. Clears commons-lang3LockingVisitors.LockVisitor(latent).Throw type-variable cast recovery (
JDEC_FIX_THROW_TYPEVAR_CAST_OFF):Re-emits
throw (T) var;when the method declaresthrows Tand the thrown variable isThrowable. Clears commons-lang3ExceptionUtils.typeErasure(latent).Try-break-return fix (
JDEC_FIX_TRY_BREAK_RETURN_OFF):Moves hoisted
return expr;back intotry { break; }inside do-while(true) loops. Clears commons-lang3Memoizer.compute(latent).Results
Tests
4 load-bearing tests with regression seeds:
throws_typevar_test.go,catch_merge_test.go,throw_typevar_cast_test.go,try_break_return_test.go.