Wrap the logging Messsage of desugar-identified boot class path entry under verbose mode and flag guard auto_desugar_shadowed_api_use
Avoid Message flusing and possible cause more memory use.
@@ -129,7 +129,8 @@ public class Desugar {
/** An instance of Desugar is expected to be used ONLY ONCE */
private boolean used;
- private TypeHierarchy typeHierarchy;
+ @Nullable private TypeHierarchy typeHierarchy;
+ @Nullable private BootClassPathDigest bootClassPathDigest;
private Desugar(DesugarOptions options, Path dumpDirectory) {
this.options = options;
@@ -157,11 +158,15 @@ public class Desugar {
.filter(path -> JarDigest.fromPath(path).isPlatformJar())
.collect(Collectors.toList());
if (!platformJars.isEmpty()) {
- logger.atInfo().log("Platform Jars in class path added to boot class path: %s", platformJars);
+ if (options.verbose) {
+ logger.atInfo().log(
+ "Platform Jars in class path added to boot class path: %s", platformJars);
+ }
options.bootclasspath =
ImmutableList.<Path>builder().addAll(options.bootclasspath).addAll(platformJars).build();
}
+ if (options.autoDesugarShadowedApiUse) {
typeHierarchy =
TypeHierarchyScavenger.analyze(
ImmutableList.<Path>builder()
@@ -170,10 +175,9 @@ public class Desugar {
.addAll(options.bootclasspath)
.build(),
/* requireTypeResolutionComplete= */ false);
+ bootClassPathDigest = BootClassPathDigest.create(ImmutableList.copyOf(options.bootclasspath));
- BootClassPathDigest bootClassPathDigest =
- BootClassPathDigest.create(ImmutableList.copyOf(options.bootclasspath));
-
+ if (options.verbose) {
ImmutableList<ClassName> shadowedTypes =
typeHierarchy.methodMetadata().values().stream()
.filter(method -> method.owner().isAndroidDomainType())
@@ -182,8 +186,6 @@ public class Desugar {
.distinct()
.sorted()
.collect(toImmutableList());
-
- if (options.verbose) {
logger.atInfo().log(
"---> Total number of boot class entries(%d) from packages: %s, from jars %s on input"
+ " %s.",
@@ -194,6 +196,7 @@ public class Desugar {
logger.atInfo().log(
"<shadowed size=%d>\n%s\n</shadowed>", shadowedTypes.size(), shadowedTypes);
}
+ }
try (Closer closer = Closer.create()) {
IndexedInputs indexedBootclasspath =
