reporting getClass problem in android

10 views
Skip to first unread message

romanca...@gmail.com

unread,
Jul 10, 2016, 12:22:36 PM7/10/16
to CodenameOne Discussions
Hi , yesterday i found that in android when you call to getClass().getSimpleName() or getClass().getName() it doesent return for example "Container" returning as the name "i"

that is normal? thanks


If you are experiencing an issue please mention the full platform your issue applies to:
IDE: NetBeans/Eclipse/IDEA
Desktop OS
Simulator
Device

Shai Almog

unread,
Jul 10, 2016, 11:35:22 PM7/10/16
to CodenameOne Discussions, romanca...@gmail.com
Hi,
from the developer guide https://www.codenameone.com/manual/files-storage-networking.html
"It’s a common mistake to use getClass().getName() to implement getObjectId() and it would seem to work in the simulator. This isn’t the case though!
Since devices obfuscate the class names this becomes a problem as data is stored in a random name that changes with every release.
"

We obfuscate by default for Android, JavaScript etc. It's the "right thing to do". If you are relying on class names that is a mistake that will slow your application and will make it less secure. Unfortunately it is a mistake made by some senior developers but it is a mistake none the less...
Reply all
Reply to author
Forward
0 new messages