Skip to content

Commit

Permalink
Use strictfp instead of bridge for determining previously synthetic m…
Browse files Browse the repository at this point in the history
…ethods
  • Loading branch information
Gaming32 committed Jan 5, 2024
1 parent 736d229 commit 6825625
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/main/kotlin/com/replaymod/gradle/remap/PsiUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ fun PsiJavaCodeReferenceElement.smartMultiResolve(): PsiElement? {
return null // Only do heuristic search on methods
}
val nonSynthetic = methods.filter {
!it.modifierList.hasModifierProperty("volatile") // ACC_VOLATILE is access 0x40, which is what ACC_BRIDGE is on methods
!it.modifierList.hasModifierProperty(PsiModifier.STRICTFP)
}
if (nonSynthetic.size == 1) {
return nonSynthetic[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,13 @@ val desynthesizeTransformer = ClasspathTransformer { parent ->
signature: String?,
exceptions: Array<out String>?
): MethodVisitor {
// Remap synthetic to some other meaningless access. All methods that are already bridge should also already be synthetic.
val newAccess = desynthesize(access) or if ((access and Opcodes.ACC_SYNTHETIC) != 0) Opcodes.ACC_BRIDGE else 0
var newAccess = desynthesize(access)
// We store the synthetic flag as strictfp so that smartMultiResolve can detect if a method was initially synthetic
newAccess = if ((access and Opcodes.ACC_SYNTHETIC) != 0) {
newAccess or Opcodes.ACC_STRICT
} else {
newAccess and Opcodes.ACC_STRICT.inv()
}
return object : MethodVisitor(api, super.visitMethod(newAccess, name, descriptor, signature, exceptions)) {
override fun visitParameter(name: String?, access: Int) =
super.visitParameter(name, desynthesize(access))
Expand Down

0 comments on commit 6825625

Please sign in to comment.