mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 19:17:10 +00:00
fix(testrun): pass the jvm the flag that silences the jdk 24 unsafe warning
This commit is contained in:
1 parent
7b44b0c9a9
commit
8c31e2bf6f
2 files changed
+61
-7
No files matched your search
@@ -154,13 +154,7 @@ func buildDriver(ctx context.Context, options Options, stdout io.Writer) (driver
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
sidecarArgs := []string{"-jar", jarPath,
|
||||
"--port", strconv.Itoa(sidecarPort),
|
||||
"--platform", options.Platform,
|
||||
}
|
||||
if options.Device != "" {
|
||||
sidecarArgs = append(sidecarArgs, "--serial", options.Device)
|
||||
}
|
||||
sidecarArgs := sidecarArguments(ctx, jarPath, sidecarPort, options.Platform, options.Device)
|
||||
adbPath, err := android.AdbBinary()
|
||||
if err != nil {
|
||||
return nil, nil, preflightFailure("android", err)
|
||||
@@ -212,6 +206,25 @@ func buildDriver(ctx context.Context, options Options, stdout io.Writer) (driver
|
||||
return driverClient, cleanup, nil
|
||||
}
|
||||
|
||||
// From JDK 24 the JVM prints a four-line sun.misc.Unsafe deprecation warning
|
||||
// on every sidecar start, because the netty that grpc pulls in still reads
|
||||
// field offsets through it. The flag that silences it did not exist before JDK
|
||||
// 23 and an older JVM refuses to start when handed it, so ask this JVM whether
|
||||
// it takes the flag rather than reading its version string.
|
||||
const unsafeMemoryAccessAllow = "--sun-misc-unsafe-memory-access=allow"
|
||||
|
||||
func sidecarArguments(ctx context.Context, jarPath string, port int, platform, serial string) []string {
|
||||
var args []string
|
||||
if exec.CommandContext(ctx, "java", unsafeMemoryAccessAllow, "-version").Run() == nil {
|
||||
args = append(args, unsafeMemoryAccessAllow)
|
||||
}
|
||||
args = append(args, "-jar", jarPath, "--port", strconv.Itoa(port), "--platform", platform)
|
||||
if serial != "" {
|
||||
args = append(args, "--serial", serial)
|
||||
}
|
||||
return args
|
||||
}
|
||||
|
||||
// watchSidecar reaps the sidecar and publishes its exit status. The channel is
|
||||
// closed after the send so the shutdown path can still receive once the startup
|
||||
// path has taken the status.
|
||||
|
||||
Reference in new issue
Block a user