Repository navigation
Commit 033ce52
ref(android): Deprecate AndroidCurrentDateProvider (JAVA-728) (#6103)
* ref(android): Deprecate AndroidCurrentDateProvider (JAVA-728)
AndroidCurrentDateProvider.getCurrentTimeMillis() is
SystemClock.uptimeMillis(): not a date, and not a clock that counts deep
sleep. Neither the name nor the ICurrentDateProvider type says so, and
CurrentDateProvider implements that same interface with epoch
milliseconds, so a call site declaring the interface accepts either and
the two disagree by however long the device has been suspended.
MonotonicTicker names the guarantee it gives and keeps counting through
deep sleep.
The annotation goes on getInstance() rather than on the type. The
Android modules compile at Java 8, where javac still warns on an import
of a deprecated type, and an import declaration cannot carry a
@SuppressWarnings. Deprecating the sole factory method warns every
caller just the same, and each warning lands somewhere a suppression can
go.
Nothing is migrated and nothing is removed. The five suppressed call
sites are the migration list. AndroidEnvelopeCache cannot move on its
own: it subtracts TimeSpan.getStartUptimeMs(), which is
SystemClock.uptimeMillis() too, so moving one operand alone would
subtract two different clock bases.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* changelog
* ref(android): Deprecate the whole AndroidCurrentDateProvider type (JAVA-728)
Deprecating the type rather than getInstance() says the hazard is the
class itself, and warns on every mention of it, the import included.
That is only affordable because this class has five use sites. An import
of a deprecated type still warns at Java 8 (JEP 211 elides those only
from source 9 on), -Werror turns it into an error, and an import
declaration cannot carry a @SuppressWarnings. Dropping the five imports
for fully-qualified names puts every reference inside a declaration that
a suppression can cover. Verified by re-adding one import: the build
fails with "warning: [deprecation] AndroidCurrentDateProvider in
io.sentry.android.core.internal.util has been deprecated".
The suppression comments now point at JAVA-729, which tracks migrating
the call sites, rather than restating the reasoning at each one.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* changelog
* ref(android): Move the deprecation back onto getInstance() (JAVA-728)
Deprecating the type required replacing all five imports with fully
qualified names, since an import of a deprecated type warns at Java 8
and an import cannot carry a @SuppressWarnings. That churn bought
nothing. The constructor is private, so getInstance() is the only way
into this class and deprecating it warns every real caller identically.
Type-level deprecation would only add a warning for declaring a variable
of the concrete type, which nothing does: every holder declares
ICurrentDateProvider.
Measured the alternatives before reverting. Neither a class-level
@SuppressWarnings nor a static import silences the import warning; only
a fully qualified name, or a reference from inside the type's own
package, avoids it.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* changelog
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent e907d8d commit 033ce52
7 files changed
Lines changed: 31 additions & 0 deletions
File tree
- sentry-android-core/src/main/java/io/sentry/android/core
- cache
- internal/util
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
37 | 41 | | |
38 | 42 | | |
39 | 43 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
| 38 | + | |
37 | 39 | | |
38 | 40 | | |
39 | 41 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
50 | 52 | | |
51 | 53 | | |
52 | 54 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
298 | 298 | | |
299 | 299 | | |
300 | 300 | | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
301 | 304 | | |
302 | 305 | | |
303 | 306 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
| 50 | + | |
49 | 51 | | |
50 | 52 | | |
51 | 53 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
41 | 43 | | |
42 | 44 | | |
43 | 45 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
7 | 19 | | |
8 | 20 | | |
9 | 21 | | |
10 | 22 | | |
11 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
12 | 28 | | |
13 | 29 | | |
14 | 30 | | |
| |||
0 commit comments