-
Notifications
You must be signed in to change notification settings - Fork 189
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
Java.addToClasspath() doesn't allow class resource loading inside of a jar #413
Comments
I extracted the contents of
and it works perfectly. So, it's a problem accessing resources within a jar. |
Thanks for the report. I've been able to reproduce this bug using the following script: Java.addToClasspath("./plantuml.jar");
var SpriteImage = Java.type("net.sourceforge.plantuml.sprite.SpriteImage");
console.log(SpriteImage.fromInternal("archimate/access")); This seems to happen when a class is loaded from the same jar while a resource stream is open and still being read, because the streams share state that they shouldn't. This only happens with jar files as you discovered. |
Yes. Loading the class Java.addToClasspath("./plantuml.jar");
var SpriteImage = Java.type("net.sourceforge.plantuml.sprite.SpriteImage");
var ImageIO = Java.type("net.sourceforge.plantuml.security.ImageIO"); // dummy load of class here
console.log(SpriteImage.fromInternal("archimate/access"));
|
Should be fixed now (oracle/graal@9e83f61 @ |
@woess Wow that was quick!
I will try to do this. However, I'm not sure how to get the particular jar files for my Eclipse-based RCP application. I manually download the following jar files from Maven Central and add them to our plug-in:
|
I don't know how to get the correct updated jar files in the list in my previous comment to test this. But I'll add a test case here in case someone can test it. Requirements:
JavaScript example: Java.addToClasspath("./plantuml.jar");
var plantUMLText = "@startuml\n";
plantUMLText += "!include ./Archimate.puml\n";
plantUMLText += "Application_Component(Service, Service)\n";
plantUMLText += "@enduml\n";
var fileOutputStream = new Packages.java.io.FileOutputStream("./PlantUMLDemo.png");
var reader = new Packages.net.sourceforge.plantuml.SourceStringReader(plantUMLText);
console.log("Generation result : " + reader.outputImage(fileOutputStream).getDescription());
fileOutputStream.close(); [1] https://plantuml.com/download |
Sorry for the long delay in getting back to this one. I tested the above cases in 22.2 and can confirm the problem is fixed. |
We're accessing a Java
plantuml.jar
[1] in JS like this:Now we are able to access the classes in this jar.
However, within this jar there are various *.PNG files in a directory, "sprites". The plantuml Java code is loading these image resources from within the jar file like this[2]:
And this is failing, because the resource is not being loaded.
I suspect that
Java.addToClasspath()
is somehow not sufficient for this. Is there anther setting I need to make so that the resources in the jar can be loaded or is this an issue with how jars are accessed?[1] https://plantuml.com/download
[2] https://github.com/plantuml/plantuml/blob/master/src/net/sourceforge/plantuml/sprite/SpriteImage.java
The text was updated successfully, but these errors were encountered: