Treat core_platform as stable unless module uses legacy

The sdk_version: "core_platform" refers to the stable core platform
unless the module is in the exception list. This change makes sure that
CheckStableSdkVersion() reflects that behavior.

Bug: 180399951
Test: m nothing
Change-Id: Ia0b1e13322352b87f5a3c6621e37f23ba637ffb6
diff --git a/java/java.go b/java/java.go
index 9e35835..2f8edff 100644
--- a/java/java.go
+++ b/java/java.go
@@ -122,7 +122,16 @@
 	if sdkVersion.stable() {
 		return nil
 	}
-	return fmt.Errorf("non stable SDK %v", sdkVersion)
+	if sdkVersion.kind == sdkCorePlatform {
+		if useLegacyCorePlatformApiByName(j.BaseModuleName()) {
+			return fmt.Errorf("non stable SDK %v - uses legacy core platform", sdkVersion)
+		} else {
+			// Treat stable core platform as stable.
+			return nil
+		}
+	} else {
+		return fmt.Errorf("non stable SDK %v", sdkVersion)
+	}
 }
 
 func (j *Module) checkSdkVersions(ctx android.ModuleContext) {