konsoletyper / teavm

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

Class replacements outside of java.* #919

Closed xupwup closed 1 month ago

xupwup commented 1 month ago

Hi,

I noticed that TeaVM does not do class replacements for classes like org.lwjgl.opengl.GL11C if I put a class named org.teavm.classlib.org.lwjgl.opengl.TGL11C in my project. I also found a comment (https://github.com/konsoletyper/teavm/pull/911#discussion_r1580017972) where this seems to be confirmed. Is there a reason why only java.* is considered? I would be able to improve my code if I could override LWJGL's classes this way.

konsoletyper commented 1 month ago

There are several ways to replace lwjgl:

  1. You can just create another jar and replace with it original dependency
  2. You can apply some configuratoin for TeaVM by providing your own META-INF/teavm.properties. See example. Note that this format is ugly and subject of change in some future (see #791).
  3. You can replace classes from within custom plugin.