2

So recently I been trying to simply just change a class name and I just cant . Here is my code InjectorClassNode https://0bin.net/paste/9REMNddwqjm8vRms#hyr4RG3BI36J+kRwMfC2pJoXb7I3+7AwKKzYhhXZQfw

MethodClassNode https://0bin.net/paste/UwKCvIG+cliZAYja#gILvBXxaQ1CyfQ602c6h7UE9dimhlo6q+GbKIwZ6m8B

Now when I run it , it throws a class not found for some stuiped reason "com/kirelcodes/cool/Task" is in the import list and I dont know why I would love to get help

NacOJerk
  • 73
  • 11

2 Answers2

1

The signature parameter of all visit… methods refers to the generic signature, which is relevant to Reflection only at runtime. You should have noticed, that the class visit method has a name parameter which is much more relevant to the name of the class, which is what you want to change.

For the members, it’s not so obvious that the desc parameter is what the JVM specification calls “signature”, but at least, the ASM API is consistent in calling the generic signature description parameters signature. That’s why the signature can be null, which indicates that there are no generic types involved. For what you want to achieve, you have to adapt the desc parameter.

Further, note that when processing the instructions, you not only have to care for converting the owner type of referred members, the types of the members have to be adapted too. It’s not helpful to name the parameters arg0, arg1, arg2, arg3, arg4 in this context, by the way. There might be additional type references you are not processing, e.g. ldc instructions may push a Class reference, but I don’t know whether this matters for this specific case.

Holger
  • 285,553
  • 42
  • 434
  • 765
0

In your solution you would only be renaming the class in one file. The other classes won't be notified of the name change and will throw "ClassNotFoundException".

It would be better to rename the class after you have done your modification with a Remapper.

Graham
  • 7,431
  • 18
  • 59
  • 84
Display Name
  • 942
  • 1
  • 10
  • 20
  • I actually did update refernces the problem is that at the end there is an import that is useless for the original name – NacOJerk Oct 21 '16 at 08:32
  • 1
    @NacOJerk: did you read and attempt to understand [my answer](http://stackoverflow.com/a/40152920/2711488)? Your code doesn’t do what you intent, i.e. it doesn’t rename anything. `import` statements are pure source code artifacts that don’t show up in the bytecode at all. – Holger Oct 21 '16 at 14:35