jgpc42 / insn

Functional JVM bytecode generation for Clojure.
Eclipse Public License 1.0
198 stars 5 forks source link

Upgrading to 0.5.3 causes `Constant pool index 75 is invalid` #12

Closed borkdude closed 2 years ago

borkdude commented 2 years ago

Hi @jgpc42 - I upgraded to 0.5.3 for the new support for the invokespecial of a default interface method. But doing so broke generation of the classes that worked using 0.5.2. When constructing such a class, I'm getting errors like:

Syntax error (VerifyError) compiling new at (build/reify2.clj:171:1).
Illegal type at constant pool entry 75 in class babashka.impl.clojure.lang.IFn
Exception Details:
  Location:
    babashka/impl/clojure/lang/IFn.invoke(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; @7: invokeinterface
  Reason:
    Constant pool index 75 is invalid
  Bytecode:
    0000000: 2ab4 0036 b200 24b9 004b 0200 c000 063a
    0000010: 0b19 0bc6 001d 190b 2a2b 2c2d 1904 1905
    0000020: 1906 1907 1908 1909 190a b900 5f0c 00b0
    0000030: 2a2b 2c2d 1904 1905 1906 1907 1908 1909
    0000040: 190a b700 87b0                         
  Stackmap Table:
    append_frame(@48,Object[#6])

I tried downgrading ASM to 9.0 but that wasn't the issue.

The code to repro:

https://github.com/babashka/babashka/blob/72efde064e4e62ae847999479df31f35092c9588/reify/build/reify2.clj

borkdude commented 2 years ago

Here is the sample class:

IFn.class.zip

javap -v IFn.class is showing that there is a InterfaceMethodref in the constant pool:

#75 = InterfaceMethodref #71.#74       // java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
borkdude commented 2 years ago

Actually that was the same with 0.5.2 and even the javap output seems to be the same.

jgpc42 commented 2 years ago

I just released 0.5.4. Thank you for opening this and thank you @phronmophobic for the fix.