Repository navigation
Conversation
📲 Install BuildsAndroid
|
runningcode
left a comment
There was a problem hiding this comment.
i'm all for this! i gave it a first round of reviews, ping me for another round!
| try { | ||
| final double enqueuedTimeSeconds = Double.parseDouble(enqueuedTimeStr); | ||
| final double nowSeconds = DateUtils.millisToSeconds(System.currentTimeMillis()); | ||
| final double nowSeconds = DateUtils.millisToSeconds((double) System.currentTimeMillis()); |
There was a problem hiding this comment.
unrelated to the PR what's going on here? why are we using a double? i don't see a comment
There was a problem hiding this comment.
yeah it's super odd. I assume it's because the incoming enqueuedTimeStr is already in seconds, so we go along with this format here.
Many timestamps within the sentry universe are transmitted as floating point numbers: seconds since unix time (e.g. event.timestamp). I guess this is due to the python's time.time() giving you exactly that.
| final @NotNull Object bean, @NotNull final String beanName) throws BeansException { | ||
| if (bean instanceof SentryOptions) { | ||
| final SentryOptions options = (SentryOptions) bean; | ||
| if (bean instanceof SentryOptions options) { |
There was a problem hiding this comment.
cool java syntax! does this at all affect the minimum java for this code? what even is the minimum java here?
There was a problem hiding this comment.
Yeah, it does. But as this module is already pinned to Java 17 features anyway, it will fine here.
It all comes down to us specifying -Werror. Here's the full log:
SentryInitBeanPostProcessor.java:45: warning: [PatternMatchingInstanceof] This code can be simplified to use a pattern-matching instanceof.
error: warnings found and -Werror specified
| id("com.apollographql.apollo") version "4.1.1" | ||
| } | ||
|
|
||
| // Not published. Mockito 5 and mockito-kotlin 5+ are built for Java 11. |
There was a problem hiding this comment.
if it isn't published why not bump to 21?
| // share the Java 8 target of the published code; it compiles for the build JDK instead. | ||
| // Registered once each plugin is applied, so this afterEvaluate runs after the plugins and the | ||
| // module have pinned the JVM target of all compile tasks. | ||
| listOf("java", "com.android.library", "com.android.application").forEach { pluginId -> |
There was a problem hiding this comment.
we shouldn't be adding any logic to the build.gradle.kts file. this should go in a convention plugin like we already have in build-logic
also don't we already have some code that sets this same type of logic to jdk 11 ? why do we set it to 21 here?
also: this seems like we should be using gradle's toolchains support here. https://docs.gradle.org/current/userguide/toolchains.html
| targetCompatibility = JavaVersion.VERSION_21.toString() | ||
| } | ||
| tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile>().matching(isTestTask).configureEach { | ||
| compilerOptions.jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_21) |
There was a problem hiding this comment.
same, we should probably be using toolchains here: https://docs.gradle.org/current/userguide/toolchains.html
| // JDK's, so newer JDK APIs (e.g. List.getFirst()) can't leak into published bytecode. | ||
| val javaExtension = the<JavaPluginExtension>() | ||
| tasks.named<JavaCompile>("compileJava") { | ||
| options.release.set( |
There was a problem hiding this comment.
📜 Description
Switches the build and CI from JDK 17 to JDK 21, and upgrades the tools that the new JDK forces us to move: Mockito, Error Prone and NullAway. Compilation and tests run on a JDK 21 toolchain. The bytecode we publish still targets Java 8 (Spring Boot 4 / Spring 7 modules target 17).
Just changing to 21 has a few ripple effects, so there's quite a broad set of changes involved across the codebase.
JDK 21
CONTRIBUTING.mdis updated.io.sentry.jvm-targetsconvention plugin (build-logic) compiles the code and runs the tests, so a contributor on a newer JDK gets the same output as CI. The foojay resolver fetches a JDK 21 when no local one matches.--release <target>. A newer JDK could otherwise let APIs such asList.getFirst()get into Java 8 bytecode without a compile error, reducing the risk of introducing breaking changes for Android.Mockito 4.8 → 5.24, mockito-kotlin 4.1 → 6.4
net.bytebuddy.experimental.mockito-inlineis replaced withmockito-core. Mockito 5 uses the inline mock maker by default.anyVararg(), because in Mockito 5any()on a varargs parameter matches exactly one argument.Error Prone 2.11 → 2.50, NullAway 0.9.5 → 0.14.2, Gradle plugin 3.0.1 → 5.1.1
NoSuchMethodError: TreeMaker.Select, and NullAway 0.9.5 cannot load against a newer Error Prone. Neither bump can be split out of this PR.Scope.executeBeforeBreadcrumbcould throw an NPE. This happens when the callback returnsnulland theclose()of the reentrancy guard then throws.MethodInvocation.getThis(), which isnullfor static methods. They now pass anulltarget class toAopUtils.getMostSpecificMethod.invoke()is now@Nullable, the same as the Spring 7 contract.SentryAppender(logback) passes an empty array instead ofnullvarargs. The behavior is the same.instanceof(Java 17 modules only),Locale.ROOTfortoUpperCase, explicitlong→doublecasts,/**on non-Javadoc comments, and modifiers on effectively-private members.JdkObsoletereplacements that need Java 10+,this-escapein public non-final classes,serial, and the vendored Gson.Samples
sentry-samples-spring), as otherwise those would stop working because ofUnsupported class file major version 65errors.Other
SentryEnvelopeItemTest."fromAttachment with file SecurityManager denies read access"installs aSecurityManager. Since JDK 18 this needs-Djava.security.manager=allow, which thesentrytests now set.Buildjob name no longer carries a Java version that goes stale at the next bump.💡 Motivation and Context
Preparation for SDK 37 support (for example
ActivityManager.registerAnrWarningListener). Robolectric 4.17 is the first version that supports SDK 37, and SDK 37 needs Java 21, so JDK 21 has to land first.💚 How did you test it?
Tests
📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
sentry-samples-android,-ktor-client,-openfeign,-servlet,-netflix-dgs) to main compilation, so every sample treats its test code the same wayInternalSentrySdkTest, which readssession.jsonright after an asynchronous write#skip-changelog