I'm getting this annoying ClassCastException
when I obfuscate my Java code (which works fine before I obfuscate using ProGuard
).
java.lang.ClassCastException: com.google.gson.internal.StringMap cannot be cast to net.minecraft.launcher.profile.Profile
at java.lang.ClassCastException: com.google.gson.internal.StringMap cannot be cast to net.minecraft.launcher.profile.Profile
at net.minecraft.launcher.profile.ProfileManager.getSelectedProfile(SourceFile:117)
at net.minecraft.launcher.g.run(SourceFile:184)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
That ClastCastException error points to this bit of code, here (the bolded line being the exact line):
public Profile getSelectedProfile()
{
if ((this.selectedProfile == null) || (!this.profiles.containsKey(this.selectedProfile))) {
if (this.profiles.get("Default") != null)
{
this.selectedProfile = "Default";
}
else if (this.profiles.size() > 0)
{
this.selectedProfile = ((Profile)this.profiles.values().iterator().next()).getName();
}
else
{
this.selectedProfile = "Default";
this.profiles.put("Default", new Profile(this.selectedProfile));
}
}
*Profile profile = this.profiles.get(this.selectedProfile);*
return profile;
}
Whole Class File (Un obfuscated) : http://pastebin.com/Jgh4x1SS
RawProfileList
Class File (Un obfuscated) : http://pastebin.com/vPxFpYfC
ProGuard
version : 5.2.1
Declaration of Profiles field:
private final Map<String, Profile> profiles = new HashMap<String, Profile>();
Your classes look fine.
ClassCastException
means thatGson
didn't know that a field should have been serialized asProfile
.Make sure your
proguard.cfg
contains all of these rules.