Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed an issue with Android N's OpenJDK where invalid instantiator is… #38

Merged
merged 1 commit into from
May 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ public final class PlatformDescription {
/** Android version. Will be 0 for none android platform */
public static final int ANDROID_VERSION = getAndroidVersion();

/** Boot classpath for detecting OpenJDK on Android */
public static final String BOOT_CLASSPATH = System.getProperty("java.boot.class.path");

/** Google App Engine version or null is we are not on GAE */
public static final String GAE_VERSION = getGaeRuntimeVersion();

Expand Down Expand Up @@ -112,6 +115,10 @@ public static boolean isThisJVM(String name) {
return JVM_NAME.startsWith(name);
}

public static boolean isAndroidOpenJDK() {
return BOOT_CLASSPATH != null && BOOT_CLASSPATH.toLowerCase().contains("core-oj.jar");
}

public static boolean isGoogleAppEngine() {
return getGaeRuntimeVersion() != null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ public <T> ObjectInstantiator<T> newInstantiatorOf(Class<T> type) {
return new ObjectStreamClassInstantiator<T>(type);
}
else if(JVM_NAME.startsWith(DALVIK)) {
if(PlatformDescription.isAndroidOpenJDK()) {
return new ObjectStreamClassInstantiator<T>(type);
}
return new AndroidSerializationInstantiator<T>(type);
}
else if(JVM_NAME.startsWith(GNU)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.objenesis.instantiator.android.Android18Instantiator;
import org.objenesis.instantiator.basic.AccessibleInstantiator;
import org.objenesis.instantiator.basic.ObjectInputStreamInstantiator;
import org.objenesis.instantiator.basic.ObjectStreamClassInstantiator;
import org.objenesis.instantiator.gcj.GCJInstantiator;
import org.objenesis.instantiator.jrockit.JRockitLegacyInstantiator;
import org.objenesis.instantiator.perc.PercInstantiator;
Expand Down Expand Up @@ -84,6 +85,9 @@ else if(PlatformDescription.isThisJVM(JROCKIT)) {
return new SunReflectionFactoryInstantiator<T>(type);
}
else if(PlatformDescription.isThisJVM(DALVIK)) {
if(PlatformDescription.isAndroidOpenJDK()) {
return new ObjectStreamClassInstantiator<T>(type);
}
if(ANDROID_VERSION <= 10) {
// Android 2.3 Gingerbread and lower
return new Android10Instantiator<T>(type);
Expand Down