-
Notifications
You must be signed in to change notification settings - Fork 28
BytecodePath NOP padding creates invalid class #31
Comments
I appreciate you finding these. I didn't have to touch exception handlers for the texture and font fixes, so it doesn't surprise me that something fell through the cracks. I'm still not sure I understand the problem though. Can you post a sample before and after bytecode? |
Here is the exception: Exception table: Last but not least, my code:
Also, FieldMapper doesn't seem to work, I still have to use the obfusicated name. |
I've had a chance to play with this now and I see the problem, but I'm not sure the best way to fix it. Looking at your example, the exception handler covers 15 to 110. Your match expression starts at 10 and runs to 113. So here's what you get now: [bunch of NOPs] Offset 110 is in the middle of an instruction which I assume is why it is complaining. But if I try your suggestion and put the replacement code first, this is what happens: 10: invokestatic #22; //Method org/jbls/LexManos/PackManager.GetSplash:()Ljava/lang/String; So it still fails because 15 is in the middle of the putfield instruction. Ugh, what a mess. Really the "right" way to fix this is to not reuse at space at all, but rather overwrite the old code with NOPs and insert the new code before or after it. [EDIT] Forgot to mention, the FieldMapper should work, but you have to do this reference(info, PUTFIELD, map(new FieldRef("GUIMainScreen", "splashText", "Ljava/lang/String;"))), It would be easier and more consistent if it just called map() for you. I may go ahead and change that. I can't remember why I didn't do it that way from the beginning. |
Swap the order of the nop padding, so that replaced code comes BEFORE the nop padding.
It may just be the fact that my replaced code returns from the function, but having a ton of NOPs before real code causes the Method to become invalid. {Various runtime errors when MC trys to use it.}
Possible future fix is to go in a dynamically remove all NOPs from the final {after all mods have had a pass} and condense the code. Also, need to figure out a way to verify all paths are reachable. {May not be an issue}
Also, Exception handlers need to be verified after the code has been replaced, if a exception handler spills over to NOPs/After return, java won't load the class.
Also, I may be bugging you with pointing out things at this stage. But I'm more then willing to help track things down and fix up the code.
The text was updated successfully, but these errors were encountered: