我尝试使用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的bug ?
你能建议一个解决方法吗?
编辑:我使用Scala 2.9.0.1和Proguard 4.6
EDIT2: Using Scala 2.9.1最后的jar没有帮助。
这看起来像是scala编译器中的一个bug。例如,类文件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.**