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

Try teavm #9

Open
sakirtemel opened this issue Jan 26, 2023 · 13 comments
Open

Try teavm #9

sakirtemel opened this issue Jan 26, 2023 · 13 comments

Comments

@sakirtemel
Copy link
Collaborator

Seems like a well supported project, and we may reduce the need of sending jars

@sakirtemel
Copy link
Collaborator Author

@sakirtemel
Copy link
Collaborator Author

sakirtemel commented Jan 27, 2023

first try:

mvn_clean_package.txt

Caused by: java.lang.IllegalArgumentException: Unsupported class file major version 61

second try with dev version 0.7.0-dev-1212:

log_v1212.txt

Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private final java.util.Comparator java.util.TreeMap.comparator accessible: module java.base does not "opens java.util" to unnamed module @7b21d3c5

[WARNING] Error injecting: org.apache.maven.plugin.war.WarMojo
com.google.inject.ProvisionException: Unable to provision, see the following errors:

1) Error injecting constructor, java.lang.ExceptionInInitializerError
  at org.apache.maven.plugin.war.WarMojo.<init>(Unknown Source)
  while locating org.apache.maven.plugin.war.WarMojo

third try with maven-war-plugin 3.3.2:
compile.txt

attaching the pom:

pomxml.txt

mvn -e clean package

@sakirtemel
Copy link
Collaborator Author

Initialized teavm directory for trying affc58e

Basic application is able to run, and when I clicked on the index.html, I'm able to see Java-coded text rendered in browser

Screenshot 2023-01-27 at 22 40 28

Now I'm going to add plantuml-wasm jar as a dependency and run some command in there 🤞

@sakirtemel
Copy link
Collaborator Author

@arnaudroques TeaVM worked for the main class :)

https://plantuml.github.io/plantuml-wasm/compiled-teavm/

https://github.com/plantuml/plantuml-wasm/blob/5c482adf1bfd948e2a1f34a72af033d006747e71/teavm/teavm-maven-webapp/src/main/java/org/teavm/Client.java#L15

Screenshot 2023-01-27 at 23 28 02

I'm going to try it further, if TeaVM works, some of the complications we have with cheerpj will be resolved

@sakirtemel
Copy link
Collaborator Author

When I called the Utils ( https://github.com/plantuml/plantuml-wasm/blob/74b0f7b145fb9735518bd68346c05ebab933013a/teavm/teavm-maven-webapp/src/main/java/org/teavm/Client.java#L17 )

it gave such an error Caused by: java.lang.NullPointerException: Cannot read the array length because "<local7>" is null

also, even after it works, we probably will need to do something with the files

@arnaudroques
Copy link
Contributor

it gave such an error Caused by: java.lang.NullPointerException: Cannot read the array length because "<local7>" is null

There are no stack trace somewhere? It would help to debug :-)

@sakirtemel
Copy link
Collaborator Author

I thought local7 is something known :) just added the result of mvn -e -X clean package, also used convertSvg instead of convertPng this time, just to see if the error would disappear.

compile.txt

Some of the issues are related to teavm, I saw something like https://teavm.org/docs/tooling/debugging.html and of course got help from https://github.com/konsoletyper/teavm/issues

from the log, I'm not able to understand which part of plantuml was failing

@sakirtemel
Copy link
Collaborator Author

sakirtemel commented Jan 27, 2023

@arnaudroques maybe you can run this pom with the source code instead of jar dependency? it may compile then, or give better errors actually?

https://github.com/plantuml/plantuml-wasm/blob/74b0f7b145fb9735518bd68346c05ebab933013a/teavm/teavm-maven-webapp/pom.xml

by the way, there's still no guarantee that teavm will actually work, but if it works, it'll be really great (no dependencies, simpler js files etc)

@arnaudroques
Copy link
Contributor

I suggest that we keep this repo for cheerpj only.
For teavm experimentation, I've created another repo https://github.com/plantuml/teavm1

In this new repo, there is a very minimal version of PlantUML:

public class Run1 {

	public static void main(String[] args) throws IOException {
		System.err.println("Starting Run1");
		final BufferedImage img = new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB);
		final String filename = args[0];
		final File file = new File(filename);
		System.err.println(file.getAbsolutePath());
		final FileOutputStream fos = new FileOutputStream(file);
		ImageIO.write(img, "png", fos);
		fos.close();
	}
}

So it only create a 100 x 100 white image.
Let's try to make this very simple example working with teavm.
We will increase complexity step by step :-)

Any though ?

@kongfu-cat
Copy link

I attempted to compile PlantUML using TeaVM, and then I find this issue.
How is the progress now? I noticed that the main branch still uses CheerpJ.

@sakirtemel
Copy link
Collaborator Author

sakirtemel commented Dec 26, 2023 via email

@kongfu-cat
Copy link

How was your attempt? Did you try it with plantuml core or the binary from the website ? I haven’t tried it again as I was focusing on delivering the end to end solution, but happy to explore the teavm again. The main branch uses cherrpj and you can also see the plantuml-core repository is providing a lightweight version of cheerpj compiled plantuml + basic js.

Not yet started😂

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

3 participants