From 07a8c19674daccbfcce30e606e3ce689671ce2c1 Mon Sep 17 00:00:00 2001 From: Tobias Thierer Date: Thu, 30 Nov 2017 23:30:21 +0000 Subject: 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 --- tools/lint | 8 ++++++++ 1 file changed, 8 insertions(+) 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 "$@" -- cgit v1.2.3