今天在执行某个项目分析时,100多个jar包只有BC库的三个jar包导入失败。错误如下:
[DefaultDispatcher-worker-1 @coroutine#1] INFO org.jacodb.impl.storage.PersistenceService - Starting app version [1.4]
[DefaultDispatcher-worker-16 @coroutine#150] WARN org.jacodb.impl.fs.JarLocation - error loading classes from jar: bcutil-jdk15on-1.70.jar. returning empty loader
java.lang.IllegalStateException: zip file closed
at java.base/java.util.zip.ZipFile.ensureOpen(ZipFile.java:840)
at java.base/java.util.zip.ZipFile.getInputStream(ZipFile.java:369)
at java.base/java.util.jar.JarFile.getBytes(JarFile.java:800)
at java.base/java.util.jar.JarFile.checkForSpecialAttributes(JarFile.java:1006)
at java.base/java.util.jar.JarFile.isMultiRelease(JarFile.java:388)
at java.base/java.util.jar.JarFile$JarFileEntry.realEntry(JarFile.java:691)
at java.base/java.util.jar.JarFile.verifiableEntry(JarFile.java:869)
at java.base/java.util.jar.JarFile.getInputStream(JarFile.java:861)
at org.jacodb.impl.fs.JarFacade.getBytecode(Jars.kt:84)
at org.jacodb.impl.fs.JarLocation.getClasses(JarLocationImpl.kt:48)
at org.jacodb.impl.fs.ByteCodeLoaderImplKt.getSources(ByteCodeLoaderImpl.kt:24)
at org.jacodb.impl.JcDatabaseImpl$process$3$1$1.invokeSuspend(JcDatabaseImpl.kt:138)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42)
at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
刚开始看到这个错误,以为时多个线程同时加载class文件,之间没同不好,有线程提前关闭了文件导致的。看了读取源码实在没看懂,后续将正常可以加载的jar包对比了下,发现BC库的jar包多了签名文件,删除这几个文件就可以正常加载了。
jar包对比:
红框中的四个文件时jar包的签名文件。