summaryrefslogtreecommitdiff
path: root/java/java.go
diff options
context:
space:
mode:
authorJiyong Park <jiyong@google.com>2021-02-18 13:10:18 +0900
committerJiyong Park <jiyong@google.com>2021-02-18 13:10:18 +0900
commit670e0f62a6cea17e7c0916313db1a1bb855d3384 (patch)
treeaa41e12d59eeab0b67ac060686e15cb3ef19d0fb /java/java.go
parent608b6912996faf78814df71aa73b502289622c1d (diff)
Linktype check error message becomes more correct
The type linkType has String() method and the error message is created using it. Bug: 180477804 Test: m nothing Change-Id: I74fe9c93b74904177dbe9d29cd3aa3304b67ba4f
Diffstat (limited to 'java/java.go')
-rw-r--r--java/java.go51
1 files changed, 33 insertions, 18 deletions
diff --git a/java/java.go b/java/java.go
index 69ec2a442..ecd0589fa 100644
--- a/java/java.go
+++ b/java/java.go
@@ -1022,6 +1022,25 @@ const (
javaPlatform
)
+func (lt linkType) String() string {
+ switch lt {
+ case javaCore:
+ return "core Java API"
+ case javaSdk:
+ return "Android API"
+ case javaSystem:
+ return "system API"
+ case javaModule:
+ return "module API"
+ case javaSystemServer:
+ return "system server API"
+ case javaPlatform:
+ return "private API"
+ default:
+ panic(fmt.Errorf("unrecognized linktype: %v", lt))
+ }
+}
+
type linkTypeContext interface {
android.Module
getLinkType(name string) (ret linkType, stubs bool)
@@ -1081,45 +1100,41 @@ func checkLinkType(ctx android.ModuleContext, from *Module, to linkTypeContext,
return
}
otherLinkType, _ := to.getLinkType(ctx.OtherModuleName(to))
- commonMessage := " In order to fix this, consider adjusting sdk_version: OR platform_apis: " +
- "property of the source or target module so that target module is built with the same " +
- "or smaller API set when compared to the source."
+ violation := false
switch myLinkType {
case javaCore:
if otherLinkType != javaCore {
- ctx.ModuleErrorf("compiles against core Java API, but dependency %q is compiling against non-core Java APIs."+commonMessage,
- ctx.OtherModuleName(to))
+ violation = true
}
- break
case javaSdk:
if otherLinkType != javaCore && otherLinkType != javaSdk {
- ctx.ModuleErrorf("compiles against Android API, but dependency %q is compiling against non-public Android API."+commonMessage,
- ctx.OtherModuleName(to))
+ violation = true
}
- break
case javaSystem:
if otherLinkType == javaPlatform || otherLinkType == javaModule || otherLinkType == javaSystemServer {
- ctx.ModuleErrorf("compiles against system API, but dependency %q is compiling against private API."+commonMessage,
- ctx.OtherModuleName(to))
+ violation = true
}
- break
case javaModule:
if otherLinkType == javaPlatform || otherLinkType == javaSystemServer {
- ctx.ModuleErrorf("compiles against module API, but dependency %q is compiling against private API."+commonMessage,
- ctx.OtherModuleName(to))
+ violation = true
}
- break
case javaSystemServer:
if otherLinkType == javaPlatform {
- ctx.ModuleErrorf("compiles against system server API, but dependency %q is compiling against private API."+commonMessage,
- ctx.OtherModuleName(to))
+ violation = true
}
- break
case javaPlatform:
// no restriction on link-type
break
}
+
+ if violation {
+ ctx.ModuleErrorf("compiles against %v, but dependency %q is compiling against %v. "+
+ "In order to fix this, consider adjusting sdk_version: OR platform_apis: "+
+ "property of the source or target module so that target module is built "+
+ "with the same or smaller API set when compared to the source.",
+ myLinkType, ctx.OtherModuleName(to), otherLinkType)
+ }
}
func (j *Module) collectDeps(ctx android.ModuleContext) deps {