Skip to content

Commit

Permalink
8015831: Add lint check for calling overridable methods from a constr…
Browse files Browse the repository at this point in the history
…uctor

6557145: Warn about calling abstract methods in constructors

Reviewed-by: ihse, vromero, mcimadamore
  • Loading branch information
archiecobbs authored and Vicente Romero committed Mar 17, 2023
1 parent b085ab9 commit 8f5bb53
Show file tree
Hide file tree
Showing 54 changed files with 2,463 additions and 18 deletions.
17 changes: 9 additions & 8 deletions make/CompileDemos.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -171,41 +171,41 @@ $(BUILD_DEMO_CodePointIM_JAR): $(CODEPOINT_METAINF_SERVICE_FILE)

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

$(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, \
DISABLED_WARNINGS := rawtypes deprecation unchecked static serial cast this-escape, \
))

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

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

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

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

$(eval $(call SetupBuildDemo, Stylepad, \
DEMO_SUBDIR := jfc, \
DISABLED_WARNINGS := rawtypes unchecked, \
DISABLED_WARNINGS := rawtypes unchecked this-escape, \
EXTRA_SRC_DIR := $(DEMO_SHARE_SRC)/jfc/Notepad, \
EXCLUDE_FILES := $(DEMO_SHARE_SRC)/jfc/Notepad/README.txt, \
))
Expand All @@ -215,11 +215,12 @@ $(eval $(call SetupBuildDemo, SampleTree, \
))

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

$(eval $(call SetupBuildDemo, TransparentRuler, \
DISABLED_WARNINGS := this-escape, \
DEMO_SUBDIR := jfc, \
MAIN_CLASS := transparentruler.Ruler, \
))
Expand Down
2 changes: 1 addition & 1 deletion make/CompileModuleTools.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ $(eval $(call SetupJavaCompilation, BUILD_JIGSAW_TOOLS, \
build/tools/jigsaw, \
COPY := .properties .html, \
BIN := $(TOOLS_CLASSES_DIR), \
DISABLED_WARNINGS := fallthrough, \
DISABLED_WARNINGS := fallthrough this-escape, \
JAVAC_FLAGS := \
--add-modules jdk.jdeps \
--add-exports java.base/jdk.internal.module=ALL-UNNAMED \
Expand Down
2 changes: 2 additions & 0 deletions make/modules/java.base/Java.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
# questions.
#

DISABLED_WARNINGS_java += this-escape

DOCLINT += -Xdoclint:all/protected \
'-Xdoclint/package:java.*,javax.*'
JAVAC_FLAGS += -XDstringConcat=inline \
Expand Down
2 changes: 2 additions & 0 deletions make/modules/java.datatransfer/Java.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
# questions.
#

DISABLED_WARNINGS_java += this-escape

DOCLINT += -Xdoclint:all/protected \
'-Xdoclint/package:java.*,javax.*'
COPY += flavormap.properties
2 changes: 1 addition & 1 deletion make/modules/java.desktop/Java.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# questions.
#

DISABLED_WARNINGS_java += lossy-conversions
DISABLED_WARNINGS_java += lossy-conversions this-escape
DOCLINT += -Xdoclint:all/protected \
'-Xdoclint/package:java.*,javax.*'
COPY += .gif .png .wav .txt .xml .css .pf
Expand Down
2 changes: 2 additions & 0 deletions make/modules/java.logging/Java.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,7 @@
# questions.
#

DISABLED_WARNINGS_java += this-escape

DOCLINT += -Xdoclint:all/protected \
'-Xdoclint/package:java.*,javax.*'
2 changes: 2 additions & 0 deletions make/modules/java.management/Java.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,7 @@
# questions.
#

DISABLED_WARNINGS_java += this-escape

DOCLINT += -Xdoclint:all/protected \
'-Xdoclint/package:java.*,javax.*'
2 changes: 2 additions & 0 deletions make/modules/java.naming/Java.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
# questions.
#

DISABLED_WARNINGS_java += this-escape

DOCLINT += -Xdoclint:all/protected \
'-Xdoclint/package:java.*,javax.*'
CLEAN += jndiprovider.properties
26 changes: 26 additions & 0 deletions make/modules/java.net.http/Java.gmk
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#
# Copyright (c) 2023, 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
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#

DISABLED_WARNINGS_java += this-escape
2 changes: 2 additions & 0 deletions make/modules/java.rmi/Java.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
# questions.
#

DISABLED_WARNINGS_java += this-escape

DOCLINT += -Xdoclint:all/protected \
'-Xdoclint/package:java.*,javax.*'
CLEAN_FILES += $(wildcard \
Expand Down
2 changes: 2 additions & 0 deletions make/modules/java.security.jgss/Java.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,7 @@
# questions.
#

DISABLED_WARNINGS_java += this-escape

DOCLINT += -Xdoclint:all/protected \
'-Xdoclint/package:java.*,javax.*'
26 changes: 26 additions & 0 deletions make/modules/java.security.sasl/Java.gmk
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#
# Copyright (c) 2023, 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
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#

DISABLED_WARNINGS_java += this-escape
2 changes: 2 additions & 0 deletions make/modules/java.sql.rowset/Java.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
# questions.
#

DISABLED_WARNINGS_java += this-escape

DOCLINT += -Xdoclint:all/protected \
'-Xdoclint/package:java.*,javax.*'
CLEAN_FILES += $(wildcard \
Expand Down
2 changes: 2 additions & 0 deletions make/modules/java.sql/Java.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,7 @@
# questions.
#

DISABLED_WARNINGS_java += this-escape

DOCLINT += -Xdoclint:all/protected \
'-Xdoclint/package:java.*,javax.*'
2 changes: 2 additions & 0 deletions make/modules/java.xml.crypto/Java.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
# questions.
#

DISABLED_WARNINGS_java += this-escape

DOCLINT += -Xdoclint:all/protected \
'-Xdoclint/package:java.*,javax.*'
COPY += .dtd .xml
Expand Down
2 changes: 1 addition & 1 deletion make/modules/java.xml/Java.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# questions.
#

DISABLED_WARNINGS_java += lossy-conversions
DISABLED_WARNINGS_java += lossy-conversions this-escape
DOCLINT += -Xdoclint:all/protected \
'-Xdoclint/package:$(call CommaList, javax.xml.catalog javax.xml.datatype \
javax.xml.transform javax.xml.validation javax.xml.xpath)'
Expand Down
2 changes: 2 additions & 0 deletions make/modules/jdk.charsets/Java.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@
# questions.
#

DISABLED_WARNINGS_java += this-escape

COPY += .dat
2 changes: 1 addition & 1 deletion make/modules/jdk.compiler/Gendata.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ $(eval $(call SetupJavaCompilation, COMPILE_CREATE_SYMBOLS, \
$(TOPDIR)/src/jdk.jdeps/share/classes, \
INCLUDES := build/tools/symbolgenerator com/sun/tools/classfile, \
BIN := $(BUILDTOOLS_OUTPUTDIR)/create_symbols, \
DISABLED_WARNINGS := options, \
DISABLED_WARNINGS := options this-escape, \
JAVAC_FLAGS := \
$(INTERIM_LANGTOOLS_ARGS) \
$(COMPILECREATESYMBOLS_ADD_EXPORTS), \
Expand Down
2 changes: 2 additions & 0 deletions make/modules/jdk.compiler/Java.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
# questions.
#

DISABLED_WARNINGS_java += this-escape

DOCLINT += -Xdoclint:all/protected \
'-Xdoclint/package:-com.sun.tools.*,-jdk.internal.*,sun.tools.serialver.resources.*'
JAVAC_FLAGS += -XDstringConcat=inline
Expand Down
26 changes: 26 additions & 0 deletions make/modules/jdk.crypto.ec/Java.gmk
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#
# Copyright (c) 2023, 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
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#

DISABLED_WARNINGS_java += this-escape
26 changes: 26 additions & 0 deletions make/modules/jdk.crypto.mscapi/Java.gmk
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#
# Copyright (c) 2023, 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
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#

DISABLED_WARNINGS_java += this-escape
2 changes: 1 addition & 1 deletion make/modules/jdk.hotspot.agent/Java.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@
#

DISABLED_WARNINGS_java += rawtypes serial cast static overrides \
fallthrough
fallthrough this-escape
COPY += .gif .png .properties
2 changes: 1 addition & 1 deletion make/modules/jdk.httpserver/Java.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
# questions.
#

DISABLED_WARNINGS_java += missing-explicit-ctor
DISABLED_WARNINGS_java += missing-explicit-ctor this-escape
2 changes: 2 additions & 0 deletions make/modules/jdk.internal.jvmstat/Java.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@
# questions.
#

DISABLED_WARNINGS_java += this-escape

COPY += aliasmap
2 changes: 2 additions & 0 deletions make/modules/jdk.internal.le/Java.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@
# questions.
#

DISABLED_WARNINGS_java += this-escape

COPY += .properties .caps .txt
2 changes: 2 additions & 0 deletions make/modules/jdk.internal.opt/Java.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@
# questions.
#

DISABLED_WARNINGS_java += this-escape

COPY += .properties
2 changes: 2 additions & 0 deletions make/modules/jdk.internal.vm.ci/Java.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
# questions.
#

DISABLED_WARNINGS_java += this-escape

# -parameters provides method's parameters information in class file,
# JVMCI compilers make use of that information for various sanity checks.
# Don't use Indy strings concatenation to have good JVMCI startup performance.
Expand Down
2 changes: 1 addition & 1 deletion make/modules/jdk.javadoc/Gendata.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ $(eval $(call SetupJavaCompilation, COMPILE_CREATE_SYMBOLS, \
$(TOPDIR)/src/jdk.jdeps/share/classes, \
INCLUDES := build/tools/symbolgenerator com/sun/tools/classfile, \
BIN := $(BUILDTOOLS_OUTPUTDIR)/create_symbols_javadoc, \
DISABLED_WARNINGS := options, \
DISABLED_WARNINGS := options this-escape, \
JAVAC_FLAGS := \
$(INTERIM_LANGTOOLS_ARGS) \
$(COMPILECREATESYMBOLS_ADD_EXPORTS), \
Expand Down
2 changes: 2 additions & 0 deletions make/modules/jdk.javadoc/Java.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@
# questions.
#

DISABLED_WARNINGS_java += this-escape

COPY += .xml .css .svg .js .js.template .png .txt
2 changes: 2 additions & 0 deletions make/modules/jdk.jcmd/Java.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@
# questions.
#

DISABLED_WARNINGS_java += this-escape

COPY += _options
2 changes: 2 additions & 0 deletions make/modules/jdk.jconsole/Java.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
# questions.
#

DISABLED_WARNINGS_java += this-escape

COPY += .gif .png

CLEAN_FILES += $(wildcard \
Expand Down
2 changes: 2 additions & 0 deletions make/modules/jdk.jdeps/Gensrc.gmk