pocorall / scaloid

Scaloid makes your Android code easy to understand and maintain.
Other
2.09k stars 163 forks source link

Propagate Android API deprecation warnings to scaloid-using code. #120

Closed tvierling closed 9 years ago

tvierling commented 9 years ago

There are various Android APIs which have been deprecated over time, and the deprecation warnings are masked by scaloid. This means that code using scaloid won't see the deprecation warnings intended by the Android API libraries.

So here, note the deprecated elements and mark the corresponding scaloid elements as deprecated. This both silences most of the compile-time deprecation warnings for scaloid itself, and creates deprecation warnings in scaloid-using code. No deprecation message is included (it's just @deprecated("","")).

Note that this makes the generated code dependent on the highest API level available in $ANDROID_HOME, as that will be used to mark elements as deprecated. So along with this change, contributor wiki instructions should be updated to indicate the API level in use by the scaloid maintainer -- so that scaloid:generate produces the correct annotations for the newest public Android API.

Along with this change, update some non-generated code with explicit @deprecated annotations for things deprecated as of API 21.

ClipboardManager is explicitly not deprecated as it changed in API 11 with a richer, but compatible, subclass of the original.

tvierling commented 9 years ago

Note that this does not propagate deprecation messages, only the @Deprecated Java annotations. I don't know if the deprecation detail messages even exist in the library stubs shipped with the SDK. Even if they do, they can't be accessed without going a level deeper into the classes by using a bytecode library like BCEL.

pocorall commented 9 years ago

Thanks!

From the current snapshot, I increased the version number of Android API in which Scaloid depends on, while still retaining its compatibility with Android API Level 10. I didn't update the wiki page because the change is only applied in snapshot version.

Deprecation messages written in javadoc @deprecated annotation doesn't seems to be included in bytecode. The messages are for javadocs only. We have to analyze Android source code if we really want to retrieve these messages. I think this issue is not a serious one, so I would lower the priority of this issue.