Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to shrink scala swing library using Proguard?

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.

like image 385
Rogach Avatar asked Oct 16 '11 14:10

Rogach


1 Answers

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.**
like image 113
Eric Lafortune Avatar answered Sep 17 '22 19:09

Eric Lafortune