Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compile unused classes or methods #65

Open
wangshuli0315 opened this issue Oct 7, 2023 · 7 comments
Open

compile unused classes or methods #65

wangshuli0315 opened this issue Oct 7, 2023 · 7 comments

Comments

@wangshuli0315
Copy link

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

@Horcrux7
Copy link
Member

Horcrux7 commented Oct 8, 2023

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

@wangshuli0315
Copy link
Author

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

@Horcrux7
Copy link
Member

Horcrux7 commented Oct 9, 2023

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.

@wangshuli0315
Copy link
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.

@Horcrux7
Copy link
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?

@wangshuli0315
Copy link
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.

@Horcrux7
Copy link
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants