summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Thierer <tobiast@google.com>2017-11-30 23:30:21 +0000
committerTobias Thierer <tobiast@google.com>2017-12-05 13:02:26 +0000
commit07a8c19674daccbfcce30e606e3ce689671ce2c1 (patch)
treea0b179fee9cce861b12a2af957070735dbb2efef
parentb6b85b68670e8df17b70a6a5eac5251d98e7b72a (diff)
downloaddevtools-07a8c19674daccbfcce30e606e3ce689671ce2c1.tar.gz
Fix lint to run under java 9.
Under java 9, the java invocation in the lint script requires the additional argument --add-modules java.xml.bind because lint depends on classes from the package javax.xml.bind.annotation which is part of the (deprecated) module java.xml.bind. This CL updates the Linux/Unix version of the lint script to pass the new argument when running java 9. The Windows version of the script, which is never used during Android platform development and may be dead code, is not changed. Therefore, after this CL, the Linux version of the script (lint) will work up to java 9, whereas the Windows version (lint.bat) continues to only work up to java 8. If the script is updated from upstream (which last happened several years ago) in future, and if the lint tool at that time still relies on java.xml.bind, then this patch would need to be kept/re-applied at that time. Bug: 69947523 Test: Checked that the linter succeeds on Linux under both OpenJDK 8 and 9. The way I tested this was by running "repo upload" for a dummy CL in vendor/google/apps/SetupWizard but aborting the upload after the linter run had completed. Change-Id: Icda014e00eaf8e3e6740d2ab97eac746684c525e
-rwxr-xr-xtools/lint8
1 files changed, 8 insertions, 0 deletions
diff --git a/tools/lint b/tools/lint
index 4a09eb9..0a54482 100755
--- a/tools/lint
+++ b/tools/lint
@@ -65,9 +65,17 @@ javaCmd="java"
jarpath="$frameworkdir/$jarfile"
+is_java_version_9=$(java -version 2>&1| grep 'version [ "]9.*[ "]')
+if [ "${is_java_version_9}" = "" ]; then
+ modules_arg=""
+else
+ modules_arg="--add-modules=java.xml.bind"
+fi
+
exec "$javaCmd" \
-Xmx512m $os_opts $java_debug \
-Dcom.android.tools.lint.bindir="$progdir" \
-Djava.awt.headless=true \
-classpath "$jarpath" \
+ ${modules_arg} \
com.android.tools.lint.Main "$@"