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>();
selectedProfile
andprofiles
fields. Also if it's possible, please provide a non-obfuscated and obfuscated.class
file. And which version of ProGuard are you using? – Prolegprofiles
map? I suspect there is something in the Minecraft framework that uses reflection to decide what to populate your map with, and since the names have changed, it behaves differently with the obfuscated code. – GraingerRawProfileList
class. – Colfinproguard.cfg
contain these rules? – Colfin