Storyyeller / Krakatau

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

Attempting to define constant pool entry index 0 #106

Closed samczsun closed 7 years ago

samczsun commented 7 years ago

This program is provided as open source under the GNU General Public License.
See LICENSE.TXT for more details.

Processing file proof.j, 1/1 remaining
Traceback (most recent call last):
  File "Krakatau\assembler\parse.py", line 968, in assemble
    name, data = Parser(tokenizer).parseClass()
  File "Krakatau\assembler\parse.py", line 379, in parseClass
    a.class_item()
  File "Krakatau\assembler\parse.py", line 407, in class_item
    a.try_const_def() or a.try_field() or a.try_method() or a.try_attribute(a.cls) or a.fail()
  File "Krakatau\assembler\parse.py", line 422, in try_const_def
    a.cls.pool.sub(lhs).adddef(lhs, rhs, a.error)
  File "Krakatau\assembler\pool.py", line 100, in adddef
    'Conflicts with previous definition:', self.slot_def_tokens[lhs.index])
KeyError: 0
If you see this message, please file an issue at https://github.com/Storyyeller/Krakatau/issues, including the error message and the assembly file that caused the error.```
Storyyeller commented 7 years ago

Just so you know, I'm on vacation right now, but I'll try to fix them as soon as I get home. Thanks for all the reports!

Storyyeller commented 7 years ago

P.S. I find it ironic that in this case, the bug was introduced while making the error messages more helpful.

samczsun commented 7 years ago

While I have you here, do you prefer separate issues for each issue, issues grouping somewhat similar subjects (i.e. assembler bugs), or as grouped as possible.

Also, do you consider it a bug if the Krakatau assembler creates an invalid class file, or if the decompiler decompiles a class file which is considered invalid by the JVM?

Storyyeller commented 7 years ago

It doesn't really matter. I'll see the issue either way.

As for the second question, no and no. The assembler assumes you know what you're doing, and won't stop you from creating invalid classfiles. In fact, sometimes it is useful to create invalid classfiles for various reasons, such as testing.