Skip to content

compile unused classes or methods #65

Open

Description

@wangshuli0315

How do I configure that I can force unused classes or methods to compile and generate wasm files?

Activity

  1. Horcrux7 commented on Oct 8, 2023

    @Horcrux7
    Member

    Why you want compile unused classes? This is not possible yet.

  2. wangshuli0315 commented on Oct 9, 2023

    @wangshuli0315
    Author

    I need to export some classes and methods for other modules to use, any suggestions?

  3. Horcrux7 commented on Oct 9, 2023

    @Horcrux7
    Member

    I am unclear what you want. You can't use it from other modules. It would only hidden, dead code. If you want export some methods then you must annotate with the annotation @export. All methods with this annotation will also be compiled.

  4. wangshuli0315 commented on Oct 10, 2023

    @wangshuli0315
    Author

    What I am doing now is compiling the source code of an existing jar package. Due to the large size of the code, I cannot annotate it with @export one by one. The reason for compiling the jar package is to use the jar package as a module of wasm to reduce the size of the java application code.Looking forward to your reply.

  5. Horcrux7 commented on Oct 10, 2023

    @Horcrux7
    Member

    If you want use it as module then you must declare the interface that you want use. How do you want use the module without any usable methods?

  6. wangshuli0315 commented on Oct 16, 2023

    @wangshuli0315
    Author

    I just want to convert a jar package source code to wasm, any suggestions? Even though I use the export annotation to export the methods I need one by one, the exported methods must also be static methods, so I have to change a lot of non-static methods to static methods, which is not feasible.

  7. Horcrux7 commented on Oct 21, 2023

    @Horcrux7
    Member

    Add an extra class in which you define the interface methods that you want use from JavaScript. This methods call your library methods.

    But if you have not write the library for the WASM target then there are only a low chance that it will compile. Many API like the file, network, reflection API can't compile to WASM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions