Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot modify ASM api level without reflection #12

Open
jpenilla opened this issue Nov 17, 2021 · 1 comment · Fixed by MinecraftPlus/Atlas#1 · May be fixed by #13
Open

Cannot modify ASM api level without reflection #12

jpenilla opened this issue Nov 17, 2021 · 1 comment · Fixed by MinecraftPlus/Atlas#1 · May be fixed by #13

Comments

@jpenilla
Copy link

When attempting to transform a jar compiled with JDK 17, I get java.lang.UnsupportedOperationException: PermittedSubclasses requires ASM9.

This is due to Atlas using the constructor for ClassProviderInheritanceProvider without an API version:

new ClassProviderInheritanceProvider(new CompositeClassProvider(classpath))
, which defaults to ASM7: https://github.com/CadixDev/Bombe/blob/446e809ffce194eb70ae3f3f9bb7db4af63bf3de/bombe/src/main/java/org/cadixdev/bombe/analysis/asm/ClassProviderInheritanceProvider.java#L71

My temporary solution has been some ugly reflection:

atlas.install {
  // Replace the inheritance provider start
  val inheritanceProvider = AtlasTransformerContext::class.java.getDeclaredField("inheritanceProvider")
  inheritanceProvider.isAccessible = true
  val classProvider = ClassProviderInheritanceProvider::class.java.getDeclaredField("provider")
  classProvider.isAccessible = true
  inheritanceProvider.set(
    it,
    ClassProviderInheritanceProvider(
      Opcodes.ASM9,
      classProvider.get(inheritanceProvider.get(it)) as ClassProvider
    )
  )
  // Replace the inheritance provider end
  
  // return transformer to install...
}

Not sure if this should be fixed in Atlas or Bombe, so I am opening this issue. Thanks!

@phase
Copy link
Member

phase commented Nov 17, 2021

Thanks for the bug report! I think the best solution to this would be to add a constructor to Atlas that accepts an ASM API version to pass to ClassProviderInheritanceProvider. Updating the default version in Bombe would be a plus. I can submit some PRs later this week if no one gets to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants