konsoletyper / teavm

Compiles Java bytecode to JavaScript, WebAssembly and C
https://teavm.org
Apache License 2.0
2.55k stars 260 forks source link

Ignore later classes in Multi-Release jars (snakeyaml-2.2) #882

Open taylortails opened 4 months ago

taylortails commented 4 months ago

When transpiling org.yaml::snakeyaml::2.2, I found that teavm-maven-plugin::compile::0.9.2 errored because jigsaw (JDK9) logging classes weren't available in teavm-classlib, however....

snakeyaml-2.2 is a Multi-Release jar meaning that both a jdk8 and jdk9 implementations were available in the jar. I therefore worked around the issue by using maven shade to strip out the jdk9 implementation that wasn't currently supported by teavm-classlib.

I propose that teavm compiler should ignore all classes in 'META-INF/versions/**' (where multi version jar stores alternative versions)

konsoletyper commented 4 months ago

Oh, it's something exotic, didn't even know about this feature. I think it's a rare case, so I don't think I have enough motivation to implement it. I think this workaround on your side is better in this situation. Another question is: which version do you expect TeaVM to pick?

I think the cleaner way to solve your problem is just to support these logging classes. I think there are many users who benefit from supporting more Java class library methods.

taylortails commented 4 months ago

which version do you expect TeaVM to pick?

All class implementations under 'META-INF/versions/**' override the implementation in the normal place. I'd suggest you ignore all classes under 'META-INF/versions/**' because they will use newer apis which may not yet have been ported.

I think the cleaner way to solve your problem is just to support these logging classes. I think there are many users who benefit from supporting more Java class library methods.

I have no numbers to be able to confirm or deny this, I assume you are correct.

Thank you for your response, with this suggestion now aired. I suggest it's closed.