didi / booster

🚀Optimizer for mobile applications
https://booster.johnsonlee.io
Apache License 2.0
4.83k stars 576 forks source link

编译时候报错Broken class: 21.jar!/org/bouncycastle/LICENSE.class #382

Closed lexluthors closed 1 year ago

lexluthors commented 1 year ago

org/bouncycastle整个包下面的文件都没有编译打包进去。导致运行的时候报错找不到类。 fun ZipFile.transform( output: OutputStream, entryFactory: (ZipEntry) -> ZipArchiveEntry = ::ZipArchiveEntry, transformer: (ByteArray) -> ByteArray = { it -> it } ) { val entries = mutableSetOf() val creator = ParallelScatterZipCreator(ThreadPoolExecutor(NCPU, NCPU, 0L, TimeUnit.MILLISECONDS, LinkedBlockingQueue(), Executors.defaultThreadFactory(), RejectedExecutionHandler { runnable, _ -> runnable.run() }))

entries().asSequence().forEach { entry ->
    if (!entries.contains(entry.name)) {
        val zae = entryFactory(entry)
        val stream = InputStreamSupplier {
            when (entry.name.substringAfterLast('.', "")) {
                "class" -> getInputStream(entry).use { src ->
                    try {
                        src.transform(transformer).inputStream()
                    } catch (e: Throwable) {
                        System.err.println("Broken class: ${this.name}!/${entry.name}")
                        getInputStream(entry)
                    }
                }
                else -> getInputStream(entry)
            }
        }

        creator.addArchiveEntry(zae, stream)
        entries.add(entry.name)
    } else {
        System.err.println("Duplicated jar entry: ${this.name}!/${entry.name}")
    }
}

ZipArchiveOutputStream(output).use(creator::writeTo)

}

在这个函数里抛出的异常。使用的依赖库是: implementation "org.bouncycastle:bcprov-jdk15on:1.56" 这个库始终无法打包进去。希望能收到回复。谢谢。

johnsonlee commented 1 year ago

Duplication of #368

Already been fixed, please upgrade to 4.13.0 and above