• Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: Release 6.0.0
    • Component/s: Android
    • Labels:
    • Story Points:
    • Sprint:
      2016 Sprint 13 SDK


      Constants in Android are able to be "overwritten". Things like Ti.App.EVENT_ACCESSIBILITY_ANNOUNCEMENT should be truly constant and the user shouldn't be able to overwrite the value or delete the property.

      Currently you can "overwrite" the value:'original value: ' + Ti.App.EVENT_ACCESSIBILITY_ANNOUNCEMENT);
      Ti.App.EVENT_ACCESSIBILITY_ANNOUNCEMENT = 'my very own made-up value';'modified value: ' + Ti.App.EVENT_ACCESSIBILITY_ANNOUNCEMENT);


      I think the underlying cause here is actually different than TIMOB-23475. I Believe this is because we hang 'constants' on the prototype of the proxy (i.e. Object.getPrototypeOf(Ti.App);) while the global object living at Ti.App is an instance. So what's happening looks to be "property shadowing" where we're actually adding a new EVENT_ACCESSIBILITY_ANNOUNCEMENT property with our own value onto the instance of Ti.App that lives in the global namespace at Ti.App. This instance property "shadows" the original constant declared on the prototype.

      To prove my point, calling Object.getPrototypeOf(Ti.App) gives:


      You can clearly see the constants there.

      It makes sense to hang the constants at the "prototype" level since they're supposed to be "class-level/static" constants and we shouldn't need to have every instance hold a copy. However, it looks like we're not preventing shadowing properly (even though it appears we're setting the constant property attributes to ReadOnly|DontDelete).

      See for discussion on cases where there seems to be prevented shadowing.

      One possible solution may be to do an Object.seal() on all our proxies after they're set up. This marks all properties as DontDelete and prevents new properties from being added.


          Issue Links



              • Assignee:
                cwilliams Christopher Williams
                cwilliams Christopher Williams
              • Watchers:
                1 Start watching this issue


                • Created:

                  Backbone Issue Sync

                  • Titanium SDK/CLI <> Titanium Mobile
                    Synced with:
                    Sync status:
                    Last received:
                    Last sent:

                    Git Integration