6

I'm writing a module-info.java for Ikonli's Fontawesom5 module, org.kordamp.ikonli.fontawesome5. That jar has some resources that need to be accessed: https://github.com/aalmiray/ikonli/tree/master/subprojects/ikonli-fontawesome5-pack/src/main/resources/META-INF/resources/fontawesome5/5.0.1

How do I add the exports or the opens for those resources so that other modules can load them? I tried:

exports fonts;

and

exports fontawesome5.fonts;

and

exports fontawesome5.5.0.1.fonts;

but they all throw the same error when I jlink the whole application:

Error reading module: C:\Users\pupeno\Documents\Dashman\code\dashman\target\modules\ikonli-fontawesome5-pack-2.3.0.jar

What's the correct syntax to export those resources?

With

module org.kordamp.ikonli.fontawesome5 {
    exports org.kordamp.ikonli.fontawesome5;
    provides org.kordamp.ikonli.IkonHandler with org.kordamp.ikonli.fontawesome5.FontAwesomeBrandsIkonHandler, org.kordamp.ikonli.fontawesome5.FontAwesomeRegularIkonHandler, org.kordamp.ikonli.fontawesome5.FontAwesomeSolidIkonHandler;
}

these are the modules in that jar:

>java -p target\modules\ikonli-fontawesome5-pack-2.3.0.jar --list-modules
java.activation@10.0.1
java.base@10.0.1
java.compiler@10.0.1
java.corba@10.0.1
java.datatransfer@10.0.1
java.desktop@10.0.1
java.instrument@10.0.1
java.jnlp@10.0.1
java.logging@10.0.1
java.management@10.0.1
java.management.rmi@10.0.1
java.naming@10.0.1
java.prefs@10.0.1
java.rmi@10.0.1
java.scripting@10.0.1
java.se@10.0.1
java.se.ee@10.0.1
java.security.jgss@10.0.1
java.security.sasl@10.0.1
java.smartcardio@10.0.1
java.sql@10.0.1
java.sql.rowset@10.0.1
java.transaction@10.0.1
java.xml@10.0.1
java.xml.bind@10.0.1
java.xml.crypto@10.0.1
java.xml.ws@10.0.1
java.xml.ws.annotation@10.0.1
javafx.base@10.0.1
javafx.controls@10.0.1
javafx.deploy@10.0.1
javafx.fxml@10.0.1
javafx.graphics@10.0.1
javafx.media@10.0.1
javafx.swing@10.0.1
javafx.web@10.0.1
jdk.accessibility@10.0.1
jdk.charsets@10.0.1
jdk.crypto.cryptoki@10.0.1
jdk.crypto.ec@10.0.1
jdk.crypto.mscapi@10.0.1
jdk.deploy@10.0.1
jdk.deploy.controlpanel@10.0.1
jdk.dynalink@10.0.1
jdk.httpserver@10.0.1
jdk.incubator.httpclient@10.0.1
jdk.internal.ed@10.0.1
jdk.internal.le@10.0.1
jdk.internal.vm.ci@10.0.1
jdk.internal.vm.compiler@10.0.1
jdk.internal.vm.compiler.management@10.0.1
jdk.javaws@10.0.1
jdk.jdwp.agent@10.0.1
jdk.jfr@10.0.1
jdk.jsobject@10.0.1
jdk.localedata@10.0.1
jdk.management@10.0.1
jdk.management.agent@10.0.1
jdk.management.cmm@10.0.1
jdk.management.jfr@10.0.1
jdk.management.resource@10.0.1
jdk.naming.dns@10.0.1
jdk.naming.rmi@10.0.1
jdk.net@10.0.1
jdk.pack@10.0.1
jdk.plugin@10.0.1
jdk.plugin.server@10.0.1
jdk.scripting.nashorn@10.0.1
jdk.scripting.nashorn.shell@10.0.1
jdk.sctp@10.0.1
jdk.security.auth@10.0.1
jdk.security.jgss@10.0.1
jdk.snmp@10.0.1
jdk.unsupported@10.0.1
jdk.xml.dom@10.0.1
jdk.zipfs@10.0.1
oracle.desktop@10.0.1
oracle.net@10.0.1
org.kordamp.ikonli.fontawesome5@2.3.0 file:///C:/Users/pupeno/Documents/Dashman/code/dashman/target/modules/ikonli-fontawesome5-pack-2.3.0.jar

The exception I'm trying to solve is this:

Caused by: java.lang.UnsupportedOperationException: Cannot resolve 'fas-user'
        at org.kordamp.ikonli.javafx@2.3.0/org.kordamp.ikonli.javafx.IkonResolver.resolveIkonHandler(IkonResolver.java:60)
        at org.kordamp.ikonli.javafx@2.3.0/org.kordamp.ikonli.javafx.FontIcon.setIconLiteral(FontIcon.java:252)
        ... 41 more

Ikonli has a way of dynamically loading the icons and when I try to load fas-user it cannot find it.

Pablo Fernandez
  • 279,434
  • 135
  • 377
  • 622
  • 4
    If the fonts are in META-INF then you don't need to do anything. Code in other modules can use the getResourcesXXX APIs to locate them. You'll need to provide more context for the "Error reading module" error as it's not clear where that is coming from. – Alan Bateman Jul 06 '18 at 18:43
  • @AlanBateman: my apologies. I forgot to add that error happens when running jlink. That's pretty much all I get. jlink is not very good at giving errors. – Pablo Fernandez Jul 06 '18 at 20:28
  • 1
    There must be something wrong with ikonli-fontawesome5-pack-2.3.0.jar. What does `java -p ikonli-fontawesome5-pack-2.3.0.jar --list-modules` say? As regards errors detected by jlink then this has improved in JDK 10 and JDK 11. It can also be run with an undocumented/unsupported -J-Djlink.debug=true to debug cases where it fails over on bad input. – Alan Bateman Jul 07 '18 at 06:30
  • @AlanBateman: I'm already using JDK 10. I added the output of that command to the question. – Pablo Fernandez Jul 07 '18 at 08:05
  • 1
    @AlanBateman: I got the source code for ikonli and started playing with it. I think the problem is that the service providers are not being loaded, so, it fails silently. To avoid muddling this question I'm going to post a different one. I think the correct answer to this question is that those files do not need any exporting to be accessible. – Pablo Fernandez Jul 07 '18 at 09:15
  • @AlanBateman: here's the new question: https://stackoverflow.com/questions/51221802/what-else-am-i-missing-to-load-service-providers-using-the-new-java-module-syste – Pablo Fernandez Jul 07 '18 at 09:32

0 Answers0