Skip to content
Permalink
Browse files
8149110: Introduce DISABLED_WARNINGS for Java compilation
Reviewed-by: erikj
  • Loading branch information
magicus committed Mar 12, 2020
1 parent 3aceb74 commit ed8c11e0d102dad21e66711cb1a02752ee9bc391
@@ -1,5 +1,5 @@
#
# Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -94,6 +94,7 @@ COPY_TO_IMAGE := *.html *.txt *.png *.xml README*
# EXTRA_MANIFEST_ATTR Extra manifest attribute
# SKIP_COMPILATION Skip Java compilation iff true
# DISABLE_SJAVAC Passed to SetupJavaCompilation
# DISABLED_WARNINGS Additional disabled warnings
SetupBuildDemo = $(NamedParamsMacroTemplate)
define SetupBuildDemoBody
ifeq ($$($1_SRC_DIR), )
@@ -135,6 +136,7 @@ define SetupBuildDemoBody
EXTRA_MANIFEST_ATTR := $$($1_EXTRA_MANIFEST_ATTR), \
SRCZIP := $(SUPPORT_OUTPUTDIR)/demos/image/$$($1_DEMO_SUBDIR)/$1/src.zip, \
EXCLUDE_FILES := $$($1_EXCLUDE_FILES), \
DISABLED_WARNINGS := $$($1_DISABLED_WARNINGS), \
DISABLE_SJAVAC := $$($1_DISABLE_SJAVAC), \
))

@@ -173,35 +175,42 @@ $(BUILD_DEMO_CodePointIM_JAR): $(CODEPOINT_METAINF_SERVICE_FILE)

$(eval $(call SetupBuildDemo, FileChooserDemo, \
DEMO_SUBDIR := jfc, \
DISABLED_WARNINGS := rawtypes deprecation unchecked, \
))

$(eval $(call SetupBuildDemo, SwingSet2, \
DEMO_SUBDIR := jfc, \
EXTRA_COPY_TO_JAR := .java, \
EXTRA_MANIFEST_ATTR := SplashScreen-Image: resources/images/splash.png, \
DISABLED_WARNINGS := rawtypes deprecation unchecked static serial cast, \
DISABLE_SJAVAC := true, \
))

$(eval $(call SetupBuildDemo, Font2DTest, \
DISABLED_WARNINGS := rawtypes deprecation unchecked serial cast, \
DEMO_SUBDIR := jfc, \
))

$(eval $(call SetupBuildDemo, J2Ddemo, \
DEMO_SUBDIR := jfc, \
MAIN_CLASS := java2d.J2Ddemo, \
DISABLED_WARNINGS := rawtypes deprecation unchecked cast, \
JAR_NAME := J2Ddemo, \
))

$(eval $(call SetupBuildDemo, Metalworks, \
DISABLED_WARNINGS := rawtypes unchecked, \
DEMO_SUBDIR := jfc, \
))

$(eval $(call SetupBuildDemo, Notepad, \
DISABLED_WARNINGS := rawtypes, \
DEMO_SUBDIR := jfc, \
))

$(eval $(call SetupBuildDemo, Stylepad, \
DEMO_SUBDIR := jfc, \
DISABLED_WARNINGS := rawtypes unchecked, \
EXTRA_SRC_DIR := $(DEMO_SHARE_SRC)/jfc/Notepad, \
EXCLUDE_FILES := $(DEMO_SHARE_SRC)/jfc/Notepad/README.txt, \
))
@@ -211,6 +220,7 @@ $(eval $(call SetupBuildDemo, SampleTree, \
))

$(eval $(call SetupBuildDemo, TableExample, \
DISABLED_WARNINGS := rawtypes unchecked deprecation, \
DEMO_SUBDIR := jfc, \
))

@@ -1,5 +1,5 @@
#
# Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -77,12 +77,12 @@ define SetupInterimModule
EXTRA_FILES := $(BUILDTOOLS_OUTPUTDIR)/gensrc/$1.interim/module-info.java, \
COPY := .gif .png .xml .css .js javax.tools.JavaCompilerTool, \
BIN := $(BUILDTOOLS_OUTPUTDIR)/interim_langtools_modules/$1.interim, \
DISABLED_WARNINGS := module, \
ADD_JAVAC_FLAGS := --module-path $(BUILDTOOLS_OUTPUTDIR)/interim_langtools_modules \
$$(INTERIM_LANGTOOLS_ADD_EXPORTS) \
--patch-module java.base=$(BUILDTOOLS_OUTPUTDIR)/gensrc/java.base.interim \
--add-exports java.base/jdk.internal=java.compiler.interim \
--add-exports java.base/jdk.internal=jdk.compiler.interim \
-Xlint:-module, \
--add-exports java.base/jdk.internal=jdk.compiler.interim, \
))

$1_DEPS_INTERIM := $$(addsuffix .interim, $$(filter \
@@ -1,5 +1,5 @@
#
# Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -67,6 +67,7 @@ $(eval $(call SetupJavaCompilation, BUILD_jdk.rmic.interim, \
INCLUDES := $(RMIC_PKGS), \
BIN := $(BUILDTOOLS_OUTPUTDIR)/interim_rmic_modules/jdk.rmic.interim, \
COPY := .properties, \
DISABLED_WARNINGS := deprecation, \
ADD_JAVAC_FLAGS := \
--module-path $(BUILDTOOLS_OUTPUTDIR)/interim_rmic_modules \
$(INTERIM_RMIC_ADD_EXPORTS), \
@@ -80,7 +80,7 @@ java.datatransfer_COPY += flavormap.properties
################################################################################

java.desktop_ADD_JAVAC_FLAGS += -Xdoclint:all/protected,-reference \
'-Xdoclint/package:java.*,javax.*' -Xlint:exports \
'-Xdoclint/package:java.*,javax.*' \
--doclint-format html4
java.desktop_COPY += .gif .png .wav .txt .xml .css .pf
java.desktop_CLEAN += iio-plugin.properties cursors.properties
@@ -245,7 +245,6 @@ java.transaction.xa_ADD_JAVAC_FLAGS += -Xdoclint:all/protected '-Xdoclint/packag
################################################################################

java.sql_ADD_JAVAC_FLAGS += -Xdoclint:all/protected '-Xdoclint/package:java.*,javax.*'
java.sql_SETUP := GENERATE_JDKBYTECODE_NOWARNINGS

################################################################################

@@ -270,7 +269,7 @@ java.xml_CLEAN += .properties

################################################################################

java.naming_ADD_JAVAC_FLAGS += -Xdoclint:all/protected,-accessibility '-Xdoclint/package:java.*,javax.*' -Xlint:-exports
java.naming_ADD_JAVAC_FLAGS += -Xdoclint:all/protected,-accessibility '-Xdoclint/package:java.*,javax.*'
java.naming_CLEAN += jndiprovider.properties

################################################################################
@@ -304,7 +303,8 @@ jdk.compiler_CLEAN_FILES += $(wildcard \

################################################################################

jdk.hotspot.agent_ADD_JAVAC_FLAGS += $(DISABLE_WARNINGS),-overrides
jdk.hotspot.agent_DISABLED_WARNINGS += deprecation rawtypes serial unchecked \
cast static overrides fallthrough
jdk.hotspot.agent_COPY += .gif .png sa.js .properties

################################################################################
@@ -341,17 +341,17 @@ jdk.jartool_ADD_JAVAC_FLAGS += -XDstringConcat=inline

################################################################################

jdk.scripting.nashorn_ADD_JAVAC_FLAGS += $(DISABLE_WARNINGS),-overrides
jdk.scripting.nashorn_DISABLED_WARNINGS += removal
jdk.scripting.nashorn_COPY := .properties .js

################################################################################

jdk.scripting.nashorn.shell_ADD_JAVAC_FLAGS += $(DISABLE_WARNINGS),-overrides
jdk.scripting.nashorn.shell_DISABLED_WARNINGS += removal
jdk.scripting.nashorn.shell_COPY += .js .properties

################################################################################

jdk.rmic_SETUP := GENERATE_JDKBYTECODE_NOWARNINGS
jdk.rmic_DISABLED_WARNINGS += deprecation
jdk.rmic_CLEAN += .properties

################################################################################
@@ -431,7 +431,7 @@ jdk.internal.jvmstat_COPY += aliasmap
# The exports are needed since JVMCI is dynamically exported (see
# jdk.vm.ci.services.internal.ReflectionAccessJDK::openJVMCITo).

jdk.internal.vm.ci_ADD_JAVAC_FLAGS += -parameters -Xlint:-exports -XDstringConcat=inline
jdk.internal.vm.ci_ADD_JAVAC_FLAGS += -parameters -XDstringConcat=inline

################################################################################

@@ -536,13 +536,9 @@ jdk.localedata_EXCLUDE_FILES += sun/text/resources/ext/BreakIteratorRules_th.jav
jdk.localedata_KEEP_ALL_TRANSLATIONS := true
################################################################################

# There is an issue in sjavac that triggers a warning in jdk.jfr that isn't
# triggered without sjavac.
ifeq ($(ENABLE_SJAVAC), yes)
jdk.jfr_SETUP := GENERATE_JDKBYTECODE_NOWARNINGS
endif
jdk.jfr_DISABLED_WARNINGS += exports
jdk.jfr_COPY := .xsd .xml .dtd
jdk.jfr_ADD_JAVAC_FLAGS := -XDstringConcat=inline -Xlint:-exports
jdk.jfr_ADD_JAVAC_FLAGS := -XDstringConcat=inline

################################################################################
# If this is an imported module that has prebuilt classes, only compile
@@ -1,5 +1,5 @@
#
# Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -42,6 +42,7 @@ $(eval $(call SetupJavaCompilation,BUILD_JIGSAW_TOOLS, \
build/tools/jigsaw, \
COPY := .properties .html, \
BIN := $(TOOLS_CLASSES_DIR), \
DISABLED_WARNINGS := fallthrough, \
ADD_JAVAC_FLAGS := \
--add-modules jdk.jdeps \
--add-exports java.base/jdk.internal.module=ALL-UNNAMED \
@@ -53,6 +53,7 @@ $(eval $(call SetupJavaCompilation,BUILD_TOOLS_JDK, \
build/tools/jigsaw \
build/tools/depend \
, \
DISABLED_WARNINGS := unchecked rawtypes deprecation cast, \
BIN := $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes, \
ADD_JAVAC_FLAGS := \
--add-exports java.desktop/sun.awt=ALL-UNNAMED \
@@ -1,5 +1,5 @@
#
# Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -154,6 +154,7 @@ endef
# SETUP:=must point to a previously setup java compiler, for example: SETUP:=BOOTJAVAC
# JVM:=path to ..bin/java
# ADD_JAVAC_FLAGS:=javac flags to append to the default ones.
# DISABLED_WARNINGS:=list of Xlint warnings that should be disabled
# SRC:=one or more directories to search for sources. The order of the source roots
# is significant. The first found file of a certain name has priority.
# BIN:=store classes here
@@ -198,9 +199,15 @@ define SetupJavaCompilationBody
$1_FLAGS := -g
endif
$1_FLAGS += $$($$($1_SETUP)_FLAGS) $$($1_ADD_JAVAC_FLAGS) $(JAVAC_FLAGS)

ifneq ($$($1_DISABLED_WARNINGS), )
$1_FLAGS += -Xlint:$$(call CommaList, $$(addprefix -, $$($1_DISABLED_WARNINGS)))
endif

ifneq ($$($1_CLASSPATH), )
$1_FLAGS += -cp $$(call PathList, $$($1_CLASSPATH))
endif

ifeq ($$($1_JAVAC),)
$$(error The Java compilation $1 refers to a non-existant java compiler setup $$($1_SETUP))
endif
@@ -1,5 +1,5 @@
#
# Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -31,8 +31,6 @@ $(eval $(call IncludeCustomExtension, common/SetupJavaCompilers.gmk))

include JavaCompilation.gmk

DISABLE_WARNINGS ?= -Xlint:all,-deprecation,-removal,-unchecked,-rawtypes,-cast,-serial,-dep-ann,-static,-fallthrough,-try,-varargs,-empty,-finally

JDK_SOURCE_TARGET_FLAGS := -source $(JDK_SOURCE_TARGET_VERSION) \
-target $(JDK_SOURCE_TARGET_VERSION)

@@ -48,7 +46,7 @@ $(eval $(call SetupJavaCompiler,BOOT_JAVAC, \
$(JAVA_TOOL_FLAGS_SMALL) \
$(BOOT_JDK_SOURCETARGET) \
-XDignore.symbol.file=true -g \
-Xlint:all$(COMMA)-deprecation$(COMMA)-options -Werror, \
$(JAVAC_WARNINGS) -Xlint:-options, \
DISABLE_SJAVAC := true, \
))

@@ -66,7 +64,7 @@ $(eval $(call SetupJavaCompiler,GENERATE_OLDBYTECODE, \
JVM := $(JAVA_SMALL), \
JAVAC := $(NEW_JAVAC), \
FLAGS := $(BOOT_JDK_SOURCETARGET) -XDignore.symbol.file=true -XDstringConcat=inline \
$(DISABLE_WARNINGS) -Xlint:-options, \
$(JAVAC_WARNINGS) -Xlint:-options, \
SERVER_DIR := $(SJAVAC_SERVER_DIR), \
SERVER_JVM := $(SJAVAC_SERVER_JAVA)))

@@ -80,24 +78,15 @@ $(eval $(call SetupJavaCompiler,GENERATE_JDKBYTECODE, \
SERVER_DIR := $(SJAVAC_SERVER_DIR), \
SERVER_JVM := $(SJAVAC_SERVER_JAVA)))

# The generate new bytecode javac setup uses the new compiler to compile for the
# new jdk. This new bytecode might only be possible to run using the new jvm.
$(eval $(call SetupJavaCompiler,GENERATE_JDKBYTECODE_NOWARNINGS, \
JVM := $(JAVA_JAVAC), \
JAVAC := $(NEW_JAVAC), \
FLAGS := $(JDK_SOURCE_TARGET_FLAGS) \
-encoding ascii -XDignore.symbol.file=true $(DISABLE_WARNINGS), \
SERVER_DIR := $(SJAVAC_SERVER_DIR), \
SERVER_JVM := $(SJAVAC_SERVER_JAVA)))

# After the jdk is built, we want to build demos using only the recently
# generated jdk classes and nothing else, no jdk source, etc etc.
# I.e. the rt.jar, but since rt.jar has not yet been generated
# (it will be in "make images") therefore we use classes instead.
$(eval $(call SetupJavaCompiler,GENERATE_USINGJDKBYTECODE, \
JVM := $(JAVA_SMALL), \
JAVAC := $(NEW_JAVAC), \
FLAGS := --upgrade-module-path $(JDK_OUTPUTDIR)/modules --system none $(DISABLE_WARNINGS), \
FLAGS := --upgrade-module-path $(JDK_OUTPUTDIR)/modules --system none \
$(JAVAC_WARNINGS), \
SERVER_DIR := $(SJAVAC_SERVER_DIR), \
SERVER_JVM := $(SJAVAC_SERVER_JAVA)))

@@ -108,7 +97,7 @@ $(eval $(call SetupJavaCompiler,GENERATE_8_BYTECODE, \
$(JAVA_TOOL_FLAGS_SMALL) \
--release 8 \
-XDignore.symbol.file=true -g \
-Xlint:all -Werror, \
$(JAVAC_WARNINGS), \
DISABLE_SJAVAC := true, \
))

@@ -1,5 +1,5 @@
#
# Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -31,7 +31,7 @@ JFR_TOOLS_OUTPUTDIR := $(JVM_VARIANT_OUTPUTDIR)/buildtools/tools_classes

$(eval $(call SetupJavaCompiler, GENERATE_JFRBYTECODE, \
JAVAC := $(JAVAC), \
FLAGS := $(DISABLE_WARNINGS), \
FLAGS := -Xlint:all -Werror, \
SERVER_DIR := $(SJAVAC_SERVER_DIR), \
SERVER_JVM := $(SJAVAC_SERVER_JAVA), \
DISABLE_SJAVAC := true, \
@@ -41,6 +41,7 @@ $(eval $(call SetupJavaCompilation, BUILD_JFR_TOOLS, \
SETUP := GENERATE_JFRBYTECODE, \
SRC := $(JFR_TOOLS_SRCDIR), \
BIN := $(JFR_TOOLS_OUTPUTDIR), \
DISABLED_WARNINGS := try, \
))

TARGETS += $(BUILD_JFR_TOOLS)
@@ -1,5 +1,5 @@
#
# Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -34,7 +34,7 @@ JVMTI_TOOLS_OUTPUTDIR := $(JVM_VARIANT_OUTPUTDIR)/tools/jvmti

$(eval $(call SetupJavaCompiler, GENERATE_OLDBYTECODE, \
JAVAC := $(JAVAC), \
FLAGS := $(DISABLE_WARNINGS), \
FLAGS := -Xlint:all -Werror, \
SERVER_DIR := $(SJAVAC_SERVER_DIR), \
SERVER_JVM := $(SJAVAC_SERVER_JAVA), \
DISABLE_SJAVAC := true, \
@@ -43,6 +43,7 @@ $(eval $(call SetupJavaCompiler, GENERATE_OLDBYTECODE, \
$(eval $(call SetupJavaCompilation, BUILD_JVMTI_TOOLS, \
SETUP := GENERATE_OLDBYTECODE, \
SRC := $(JVMTI_TOOLS_SRCDIR), \
DISABLED_WARNINGS := rawtypes cast, \
INCLUDE_FILES := jvmtiGen.java jvmtiEnvFill.java, \
BIN := $(JVMTI_TOOLS_OUTPUTDIR), \
))
@@ -1,5 +1,5 @@
#
# Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -98,7 +98,7 @@ ifeq ($(call isTargetOs, windows), true)

$(eval $(call SetupJavaCompilation, BUILD_PROJECT_CREATOR, \
SETUP := GENERATE_OLDBYTECODE, \
ADD_JAVAC_FLAGS := -Xlint:-auxiliaryclass, \
DISABLED_WARNINGS := auxiliaryclass deprecation rawtypes unchecked cast, \
SRC := $(TOPDIR)/make/hotspot/src/classes, \
BIN := $(TOOLS_OUTPUTDIR), \
))
@@ -1,5 +1,5 @@
#
# Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -52,6 +52,7 @@ $(eval $(call SetupJavaCompilation, BUILD_FAILURE_HANDLER, \
SETUP := GENERATE_OLDBYTECODE, \
SRC := $(FH_BASEDIR)/src/share/classes $(FH_BASEDIR)/src/share/conf, \
BIN := $(FH_SUPPORT)/classes, \
DISABLED_WARNINGS := deprecation serial try, \
COPY := .properties, \
CLASSPATH := $(JTREG_JAR) $(TOOLS_JAR), \
JAR := $(FH_JAR), \

0 comments on commit ed8c11e

Please sign in to comment.