Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Tell ProGuard to preserve serialization hooks. (re: issue 122) #131

Merged
merged 1 commit into from

2 participants

@rst

Without specific notice, ProGuard will lop off readObject, readResolve, etc.,
which can lead to baffling failures, even when just serializing library
classes. For example, if you're serializing Scala Option[T] objects, losing
readResolve can get you duplicates of None, which is ordinarily a singleton;
that, in turn, can lead to spurious, and very strange-looking MatchExceptions.

@rst rst Tell ProGuard to preserve serialization hooks.
Without specific notice, ProGuard will lop off readObject, readResolve, etc.,
which can lead to baffling failures, even when just serializing library
classes.  For example, if you're serializing Scala Option[T] objects, losing
readResolve can get you duplicates of None, which is ordinarily a singleton;
that, in turn, can lead to spurious, and very strange-looking MatchExceptions.
a58c221
@jberkel jberkel merged commit 99639f8 into jberkel:master
@jberkel
Owner

as a side note, it's a bad idea to use Java serialization in Android - it is very slow (cf. http://code.google.com/p/android/issues/detail?id=13138).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 18, 2012
  1. @rst

    Tell ProGuard to preserve serialization hooks.

    rst authored
    Without specific notice, ProGuard will lop off readObject, readResolve, etc.,
    which can lead to baffling failures, even when just serializing library
    classes.  For example, if you're serializing Scala Option[T] objects, losing
    readResolve can get you duplicates of None, which is ordinarily a singleton;
    that, in turn, can lead to spurious, and very strange-looking MatchExceptions.
This page is out of date. Refresh to see the latest.
Showing with 9 additions and 0 deletions.
  1. +9 −0 src/main/scala/AndroidInstall.scala
View
9 src/main/scala/AndroidInstall.scala
@@ -94,6 +94,15 @@ object AndroidInstall {
"-keep public class * extends android.app.Application" ::
"-keep public class "+manifestPackage+".** { public protected *; }" ::
"-keep public class * implements junit.framework.Test { public void test*(); }" ::
+ """
+ -keepclassmembers class * implements java.io.Serializable {
+ private static final java.io.ObjectStreamField[] serialPersistentFields;
+ private void writeObject(java.io.ObjectOutputStream);
+ private void readObject(java.io.ObjectInputStream);
+ java.lang.Object writeReplace();
+ java.lang.Object readResolve();
+ }
+ """ ::
proguardOption :: Nil )
val config = new ProGuardConfiguration
new ConfigurationParser(args.toArray[String]).parse(config)
Something went wrong with that request. Please try again.