如何使用 Proguard 缩小 scala swing 库?

发布于 2024-12-10 04:42:09 字数 1552 浏览 0 评论 0原文

我尝试使用 Proguard 来缩小和混淆我的 Scala/Java 程序。当我只使用 scala-library.jar 时,一切都很好,但是当我将 scala-swing.jar 添加到我的 jar 中时,我得到以下信息:

Warning: scala.swing.ComboBox: can't find referenced class scala.swing.ComboBox$selection
Warning: scala.swing.ListView: can't find referenced class scala.swing.ListView$selection
Warning: scala.swing.ListView$selection$: can't find referenced class scala.swing.ListView$selection$indices
Warning: scala.swing.ListView$selection$: can't find referenced class scala.swing.ListView$selection$items
Warning: scala.swing.ListView$selection$$anon$7: can't find referenced class scala.swing.ListView$selection
Warning: scala.swing.ListView$selection$Indices: can't find referenced class scala.swing.ListView$selection
Warning: scala.swing.ListView$selection$indices$: can't find referenced class scala.swing.ListView$selection$indices
Warning: scala.swing.ListView$selection$indices$: can't find referenced class scala.swing.ListView$selection$indices
Warning: scala.swing.ListView$selection$indices$: can't find referenced class scala.swing.ListView$selection
Warning: scala.swing.ListView$selection$items$: can't find referenced class scala.swing.ListView$selection

如果我查看该 jar,我发现实际上没有这样的文件 -有 scala.swing.ComboBox$selection$.class 而不是 scala.swing.ComboBox$selection.class。手动重命名并不能解决问题 - 然后它会抱怨该文件包含具有不同名称的类。

那么,scala-swing.jar 中的这些引用是非法的吗?还是 Proguard 中的错误?

你能建议一个解决方法吗?

编辑:我正在使用 Scala 2.9.0.1 和 Proguard 4.6

编辑2:使用 Scala 2.9.1.final jar 没有帮助。

I tried to shrink and obfuscate my Scala/Java program using Proguard. While I was using only scala-library.jar, everything was fine, but when I add scala-swing.jar to my jars, I get the following:

Warning: scala.swing.ComboBox: can't find referenced class scala.swing.ComboBox$selection
Warning: scala.swing.ListView: can't find referenced class scala.swing.ListView$selection
Warning: scala.swing.ListView$selection$: can't find referenced class scala.swing.ListView$selection$indices
Warning: scala.swing.ListView$selection$: can't find referenced class scala.swing.ListView$selection$items
Warning: scala.swing.ListView$selection$anon$7: can't find referenced class scala.swing.ListView$selection
Warning: scala.swing.ListView$selection$Indices: can't find referenced class scala.swing.ListView$selection
Warning: scala.swing.ListView$selection$indices$: can't find referenced class scala.swing.ListView$selection$indices
Warning: scala.swing.ListView$selection$indices$: can't find referenced class scala.swing.ListView$selection$indices
Warning: scala.swing.ListView$selection$indices$: can't find referenced class scala.swing.ListView$selection
Warning: scala.swing.ListView$selection$items$: can't find referenced class scala.swing.ListView$selection

If I look into the jar, I see that there are really no such files - there is scala.swing.ComboBox$selection$.class instead of scala.swing.ComboBox$selection.class. Manually renaming does not do the trick - it then complains that the file contains class with different name.

So, are these illegal references in scala-swing.jar? Or a bug in Proguard?

Can you suggest a workaround?

EDIT: I'm using Scala 2.9.0.1 and Proguard 4.6

EDIT2: Using Scala 2.9.1.final jars didn't help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

瀞厅☆埖开 2024-12-17 04:42:09

它看起来像是 scala 编译器中的一个错误。例如,类文件 scala/swing/ComboBox.class 包含以下方法:

public final scala.swing.ComboBox$selection$ selection()

在内部,方法签名表示如下:

()Lscala/swing/ComboBox$selection$;

看起来不错。但是,该方法还有一个 Signature 属性来跟踪已删除的泛型:

()Lscala/swing/ComboBox<TA;>.selection;

如您所见,签名末尾缺少 $。在 ProGuard 中,您可以通过指定来解决该问题

-dontwarn scala.swing.**

It looks like a bug in the scala compiler. For instance, the class file scala/swing/ComboBox.class contains the following method:

public final scala.swing.ComboBox$selection$ selection()

Internally, the method signature is represented as follows:

()Lscala/swing/ComboBox$selection$;

That looks ok. However, the method also has a Signature attribute to keep track of erased generics:

()Lscala/swing/ComboBox<TA;>.selection;

As you can see, the signature is missing a $ at the end. In ProGuard, you can work around the problem by specifying

-dontwarn scala.swing.**
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文