java 17 引入依赖:org.slf4j:slf4j-simple, org.bytedeco:javacpp. javacpp无法访问slf4j
异常:
Exception in thread "JavaFX Application Thread" java.lang.IllegalAccessError: class org.bytedeco.javacpp.tools.Slf4jLogger (in module org.bytedeco.javacpp) cannot access class org.slf4j.LoggerFactory (in module org.slf4j) because module org.bytedeco.javacpp does not read module org.slf4j
at org.bytedeco.javacpp/org.bytedeco.javacpp.tools.Slf4jLogger.<init>(Slf4jLogger.java:35)
at org.bytedeco.javacpp/org.bytedeco.javacpp.tools.Logger.create(Logger.java:36)
at org.bytedeco.javacpp/org.bytedeco.javacpp.Pointer.<clinit>(Pointer.java:402)
at apobates.gui.media.altar/apobates.gui.media.altar.mpeg.ConvertVideoPakcet.from(ConvertVideoPakcet.java:46)
at apobates.gui.media.altar/apobates.gui.media.altar.MediaStreamController.lambda$startPsuhAction$0(MediaStreamController.java:66)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:457)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:456)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:184)
at java.base/java.lang.Thread.run(Thread.java:833)
module-info.java
requires org.slf4j;
requires org.bytedeco.javacpp;
...
若在module-info.java中增加:opens org.slf4j to org.bytedeco.javacpp;
则报错:
Error occurred during initialization of boot layer
java.lang.module.FindException: Error reading module: D:\apobates.altar\target\classes
Caused by: java.lang.module.InvalidModuleDescriptorException: Package org.slf4j not found in module
添加一下 JVM 参数:
--add-reads org.bytedeco.javacpp=org.slf4j