diff --git a/make/Docs.gmk b/make/Docs.gmk index 0948f8ff76c..5f10d623211 100644 --- a/make/Docs.gmk +++ b/make/Docs.gmk @@ -92,10 +92,6 @@ REFERENCE_TAGS := $(JAVADOC_TAGS) JAVADOC_DISABLED_DOCLINT_WARNINGS := missing JAVADOC_DISABLED_DOCLINT_PACKAGES := org.w3c.* javax.smartcardio -# Allow overriding on the command line -# (intentionally sharing name with the javac option) -JAVA_WARNINGS_ARE_ERRORS ?= -Werror - # The initial set of options for javadoc JAVADOC_OPTIONS := -use -keywords -notimestamp \ -serialwarn -encoding ISO-8859-1 -docencoding UTF-8 -breakiterator \ @@ -322,7 +318,9 @@ define SetupApiDocsGenerationBody # Ignore the doclint warnings in certain packages $1_OPTIONS += -Xdoclint/package:$$(call CommaList, $$(addprefix -, \ $$(JAVADOC_DISABLED_DOCLINT_PACKAGES))) - $1_OPTIONS += $$(JAVA_WARNINGS_ARE_ERRORS) + ifeq ($$(JAVA_WARNINGS_AS_ERRORS), true) + $1_OPTIONS += -Werror + endif $1_DOC_TITLE := $$($1_LONG_NAME)
Version $$(VERSION_SPECIFICATION) API \ Specification diff --git a/make/autoconf/configure.ac b/make/autoconf/configure.ac index fffe17daad8..e05b5ae3b90 100644 --- a/make/autoconf/configure.ac +++ b/make/autoconf/configure.ac @@ -261,6 +261,7 @@ JDKOPT_ENABLE_DISABLE_CDS_ARCHIVE_COH JDKOPT_ENABLE_DISABLE_COMPATIBLE_CDS_ALIGNMENT JDKOPT_SETUP_MACOSX_SIGNING JDKOPT_SETUP_SIGNING_HOOK +JDKOPT_SETUP_JAVA_WARNINGS ################################################################################ # diff --git a/make/autoconf/jdk-options.m4 b/make/autoconf/jdk-options.m4 index 72e731e7ffc..79e44dd4ad1 100644 --- a/make/autoconf/jdk-options.m4 +++ b/make/autoconf/jdk-options.m4 @@ -988,6 +988,18 @@ AC_DEFUN([JDKOPT_SETUP_SIGNING_HOOK], AC_SUBST(SIGNING_HOOK) ]) +################################################################################ +# +# Setup how javac should handle warnings. +# +AC_DEFUN([JDKOPT_SETUP_JAVA_WARNINGS], +[ + UTIL_ARG_ENABLE(NAME: java-warnings-as-errors, DEFAULT: true, + RESULT: JAVA_WARNINGS_AS_ERRORS, + DESC: [consider java warnings to be an error]) + AC_SUBST(JAVA_WARNINGS_AS_ERRORS) +]) + ################################################################################ # # fallback linker diff --git a/make/autoconf/spec.gmk.template b/make/autoconf/spec.gmk.template index 17a913a2d90..907a60290ec 100644 --- a/make/autoconf/spec.gmk.template +++ b/make/autoconf/spec.gmk.template @@ -517,6 +517,7 @@ DISABLED_WARNINGS_CXX := @DISABLED_WARNINGS_CXX@ # A global flag (true or false) determining if native warnings are considered errors. WARNINGS_AS_ERRORS := @WARNINGS_AS_ERRORS@ +JAVA_WARNINGS_AS_ERRORS := @JAVA_WARNINGS_AS_ERRORS@ CFLAGS_CCACHE := @CFLAGS_CCACHE@ ADLC_LANGSTD_CXXFLAGS := @ADLC_LANGSTD_CXXFLAGS@ diff --git a/make/common/JavaCompilation.gmk b/make/common/JavaCompilation.gmk index f48aefcd517..70b3557baea 100644 --- a/make/common/JavaCompilation.gmk +++ b/make/common/JavaCompilation.gmk @@ -264,15 +264,16 @@ define SetupJavaCompilationBody $$(error Invalid value for COMPILER in SetupJavaCompilation for $1: '$$($1_COMPILER)') endif - # Allow overriding on the command line - JAVA_WARNINGS_ARE_ERRORS ?= -Werror - # Tell javac to do exactly as told and no more PARANOIA_FLAGS := -implicit:none -Xprefer:source -XDignore.symbol.file=true -encoding ascii - $1_FLAGS += -g -Xlint:all $$($1_TARGET_RELEASE) $$(PARANOIA_FLAGS) $$(JAVA_WARNINGS_ARE_ERRORS) + $1_FLAGS += -g -Xlint:all $$($1_TARGET_RELEASE) $$(PARANOIA_FLAGS) $1_FLAGS += $$($1_JAVAC_FLAGS) + ifeq ($$(JAVA_WARNINGS_AS_ERRORS), true) + $1_FLAGS += -Werror + endif + ifneq ($$($1_DISABLED_WARNINGS), ) $1_FLAGS += -Xlint:$$(call CommaList, $$(addprefix -, $$($1_DISABLED_WARNINGS))) endif