Skip to content

Commit

Permalink
Bring some gRPC backports
Browse files Browse the repository at this point in the history
  • Loading branch information
jponge committed Apr 3, 2024
1 parent 95ce4af commit 136a802
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ NativeImageConfigBuildItem nativeImageConfiguration() {
.addRuntimeInitializedClass("io.grpc.netty.Utils")
.addRuntimeInitializedClass("io.grpc.netty.NettyServerBuilder")
.addRuntimeInitializedClass("io.grpc.netty.NettyChannelBuilder")
.addRuntimeInitializedClass("io.grpc.internal.RetriableStream");
.addRuntimeInitializedClass("io.grpc.internal.RetriableStream")
.addRuntimeReinitializedClass("com.google.protobuf.UnsafeUtil");
return builder.build();
}

Expand Down
19 changes: 19 additions & 0 deletions extensions/grpc-common/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,28 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-core</artifactId>
<exclusions>
<exclusion>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
</exclusion>
<exclusion>
<groupId>org.codehaus.mojo</groupId>
<artifactId>animal-sniffer-annotations</artifactId>
</exclusion>
<exclusion>
<groupId>com.google.android</groupId>
<artifactId>annotations</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.graalvm.nativeimage</groupId>
<artifactId>svm</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static io.grpc.InternalServiceProviders.getCandidatesViaHardCoded;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
Expand All @@ -12,6 +13,8 @@
import com.oracle.svm.core.annotate.Substitute;
import com.oracle.svm.core.annotate.TargetClass;

import sun.misc.Unsafe;

@SuppressWarnings("unused")
@TargetClass(className = "io.grpc.ServiceProviders")
final class Target_io_grpc_ServiceProviders { // NOSONAR
Expand Down Expand Up @@ -79,6 +82,20 @@ interface Target_io_grpc_ServiceProviders_PriorityAccessor<T> { // NOSONAR
int getPriority(T provider);
}

@TargetClass(className = "com.google.protobuf.UnsafeUtil")
final class Target_com_google_protobuf_UnsafeUtil {
@Substitute
static sun.misc.Unsafe getUnsafe() {
try {
Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe");
theUnsafe.setAccessible(true);
return (Unsafe) theUnsafe.get(null);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}

@SuppressWarnings("unused")
class GrpcSubstitutions {
}

0 comments on commit 136a802

Please sign in to comment.