@@ -447,7 +447,7 @@ private void desugar() throws CompilationFailedException, IOException {
447447 ImmutableList .builder ();
448448 for (Path path : options .classpath ) {
449449 ClassFileResourceProvider provider = new ArchiveClassFileProvider (path );
450- if (isPlatform (provider )) {
450+ if (isPlatform (path , provider )) {
451451 bootclasspathProvidersBuilder .add (provider );
452452 } else {
453453 classpathProvidersBuilder .add (provider );
@@ -489,8 +489,20 @@ private int getShardNumberForString(int numberOfShards, String string) {
489489 return Math .floorMod (string .hashCode (), numberOfShards );
490490 }
491491
492- private static boolean isPlatform (ClassFileResourceProvider provider ) {
493- // See b/153106333.
492+ private static boolean isPlatform (Path path , ClassFileResourceProvider provider ) {
493+ // See b/456670962
494+ // If the jar name contains "wear_sdk_stubs" and it only contains classes in the package
495+ // com.google.wear, then it is part of the platform.
496+ if (path .toString ().contains ("android_libs/wear_sdk_stubs/" )) {
497+ for (String descriptor : provider .getClassDescriptors ()) {
498+ if (!descriptor .startsWith ("Lcom/google/wear/" )) {
499+ return false ;
500+ }
501+ }
502+ return true ;
503+ }
504+
505+ // See b/153106333
494506 boolean mightBePlatform = false ;
495507 for (String descriptor : provider .getClassDescriptors ()) {
496508 // If the jar contains classes in the package android.car.content this could be a platform
@@ -502,7 +514,6 @@ private static boolean isPlatform(ClassFileResourceProvider provider) {
502514 return false ;
503515 }
504516 }
505- // Found classes in the package android.car.content and not in the package android.car.test.
506517 return mightBePlatform ;
507518 }
508519
0 commit comments