• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

grpc / grpc-java / #20177

23 Feb 2026 03:46PM UTC coverage: 88.701% (-0.01%) from 88.714%
#20177

push

github

web-flow
Trigger R8's ServiceLoader optimization

This simplifies R8 Full Mode's configuration when paired with R8
optimizations (which is made more difficult to avoid in AGP 9), as when
the optimization is triggered Full Mode will automatically keep the
constructor for the relevant classes.

android-interop-test doesn't currently enable R8 optimizations, so it
doesn't actually demonstrate the benefit, but I have manually confirmed
that enabling proguard-android-optimize.txt does cause the ServiceLoader
optimization in android-interop-test. Note that full mode is a separate
configuration and not necessary to get the ServiceLoader optimization.

35461 of 39978 relevant lines covered (88.7%)

0.89 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

42.86
/../api/src/main/java/io/grpc/InternalServiceProviders.java
1
/*
2
 * Copyright 2017 The gRPC Authors
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16

17
package io.grpc;
18

19
import com.google.common.annotations.VisibleForTesting;
20
import java.util.Iterator;
21
import java.util.List;
22
import java.util.ServiceLoader;
23

24
@Internal
25
public final class InternalServiceProviders {
26
  private InternalServiceProviders() {
27
  }
28

29
  /**
30
   * Accessor for method.
31
   */
32
  @Deprecated
33
  public static <T> List<T> loadAll(
34
      Class<T> klass,
35
      Iterable<Class<?>> hardCodedClasses,
36
      ClassLoader classLoader,
37
      PriorityAccessor<T> priorityAccessor) {
38
    return loadAll(
×
39
        klass,
40
        ServiceLoader.load(klass, classLoader).iterator(),
×
41
        () -> hardCodedClasses,
×
42
        priorityAccessor);
43
  }
44

45
  /**
46
   * Accessor for method.
47
   */
48
  public static <T> List<T> loadAll(
49
      Class<T> klass,
50
      Iterator<T> serviceLoader,
51
      Supplier<Iterable<Class<?>>> hardCodedClasses,
52
      PriorityAccessor<T> priorityAccessor) {
53
    return ServiceProviders.loadAll(klass, serviceLoader, hardCodedClasses::get, priorityAccessor);
1✔
54
  }
55

56
  /**
57
   * Accessor for method.
58
   */
59
  @VisibleForTesting
60
  public static <T> Iterable<T> getCandidatesViaServiceLoader(Class<T> klass, ClassLoader cl) {
61
    return ServiceProviders.getCandidatesViaServiceLoader(klass, cl);
1✔
62
  }
63

64
  /**
65
   * Accessor for method.
66
   */
67
  @VisibleForTesting
68
  public static <T> Iterable<T> getCandidatesViaHardCoded(
69
      Class<T> klass, Iterable<Class<?>> hardcoded) {
70
    return ServiceProviders.getCandidatesViaHardCoded(klass, hardcoded);
×
71
  }
72

73
  /**
74
   * Accessor for {@link ServiceProviders#isAndroid}.
75
   */
76
  public static boolean isAndroid(ClassLoader cl) {
77
    return ServiceProviders.isAndroid(cl);
1✔
78
  }
79

80
  public interface PriorityAccessor<T> extends ServiceProviders.PriorityAccessor<T> {}
81

82
  public interface Supplier<T> {
83
    T get();
84
  }
85
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc