Storyyeller / Krakatau

Java decompiler, assembler, and disassembler
GNU General Public License v3.0
1.95k stars 220 forks source link

Add Support For RuntimeVisibleAnnotations Attributes #4

Closed ghost closed 11 years ago

ghost commented 11 years ago

I love this tool that you made and works much better then having to use JBE to edit Java Bytecode to make modifications w/o a recompile. The only issue I have is that some of the things I have to modify use Runtime Annotations either w/ @Override or custom interfaces.

Storyyeller commented 11 years ago

Do you have any proposed syntax? My main concern is to find a way to represent all the possible optional attributes in a way that is easy to use and avoids unnecessarily cluttering up the grammar.

ghost commented 11 years ago

@Ltest/TestClass;(value = "Test")

Storyyeller commented 11 years ago

I've added runtime annotation support. Try it now.

By the way, annotations like @Override are source only, so they're not going to show up in the classfile anyway.

ghost commented 11 years ago

http://pastebin.com/mJC2Q8KR

Having an issue trying to disassemble now.

Storyyeller commented 11 years ago

Try it now. Sorry I couldn't really test it due to not having any examples of classes with runtime annotations to test it with. But I tested it with ScenterMod so it should work now.

ghost commented 11 years ago

I tested it out and it managed to only do @Mod.PreInit, @Mod.Init, @Mod.PostInit which are methods. But it missed the two used for the class along w/ the two used for the class fields. When I did a reassemble it didn't place anything w/ the annotations. I also noticed there is another Class Attribute called InnerClasses that might have to be used w/ reassembly.

Storyyeller commented 11 years ago

Sorry, RuntimeAnnotations are currently only implemented for methods. I would add them for classes and fields, but I'm still investigating a good way to do this. The problem is that fields are currently only a single line, with no obvious way to add attributes.

InnerClasses is a seperate attribute, but I can add support for that once the class/field thing is cleared up.

Storyyeller commented 11 years ago

I just discovered several more bugs in the assembler. I'll upload everything once I'm done adding support for the other attributes and testing to try to find any more bugs that might be hiding.

Storyyeller commented 11 years ago

Everything should be working now. The disassembler now supports all defined attributes except for LineNumberTable, LocalVariableTable, and LocalVariableTypeTable, though contentless ones like Deprecated are handled through the generic attribute syntax.