diff --git a/make/langtools/tools/propertiesparser/gen/ClassGenerator.java b/make/langtools/tools/propertiesparser/gen/ClassGenerator.java index e3ab548491b76..e869d60bbc569 100644 --- a/make/langtools/tools/propertiesparser/gen/ClassGenerator.java +++ b/make/langtools/tools/propertiesparser/gen/ClassGenerator.java @@ -48,6 +48,7 @@ import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.Properties; import java.util.Set; import java.util.TreeMap; @@ -87,9 +88,12 @@ enum StubKind { FACTORY_METHOD_DECL("factory.decl.method"), FACTORY_METHOD_ARG("factory.decl.method.arg"), FACTORY_METHOD_BODY("factory.decl.method.body"), + FACTORY_METHOD_BODY_LINT("factory.decl.method.body.lint"), FACTORY_FIELD("factory.decl.field"), + FACTORY_FIELD_LINT("factory.decl.field.lint"), WILDCARDS_EXTENDS("wildcards.extends"), - SUPPRESS_WARNINGS("suppress.warnings"); + SUPPRESS_WARNINGS("suppress.warnings"), + LINT_CATEGORY("lint.category"); /** stub key (as it appears in the property file) */ String key; @@ -114,6 +118,7 @@ String format(Object... args) { enum FactoryKind { ERR("err", "Error", "Errors"), WARN("warn", "Warning", "Warnings"), + LINT_WARN("warn", "LintWarning", "LintWarnings"), NOTE("note", "Note", "Notes"), MISC("misc", "Fragment", "Fragments"), OTHER(null, null, null); @@ -136,13 +141,24 @@ enum FactoryKind { /** * Utility method for parsing a factory kind from a resource key prefix. */ - static FactoryKind parseFrom(String prefix) { + static FactoryKind of(Entry messageEntry) { + String prefix = messageEntry.getKey().split("\\.")[1]; + FactoryKind selected = null; for (FactoryKind k : FactoryKind.values()) { if (k.prefix == null || k.prefix.equals(prefix)) { - return k; + selected = k; + break; } } - return null; + if (selected == WARN) { + for (MessageLine line : messageEntry.getValue().getLines(false)) { + if (line.isLint()) { + selected = LINT_WARN; + break; + } + } + } + return selected; } } @@ -155,7 +171,7 @@ public void generateFactory(MessageFile messageFile, File outDir) { messageFile.messages.entrySet().stream() .collect( Collectors.groupingBy( - e -> FactoryKind.parseFrom(e.getKey().split("\\.")[1]), + FactoryKind::of, TreeMap::new, toList())); //generate nested classes @@ -165,7 +181,7 @@ public void generateFactory(MessageFile messageFile, File outDir) { if (entry.getKey() == FactoryKind.OTHER) continue; //emit members String members = entry.getValue().stream() - .flatMap(e -> generateFactoryMethodsAndFields(e.getKey(), e.getValue()).stream()) + .flatMap(e -> generateFactoryMethodsAndFields(entry.getKey(), e.getKey(), e.getValue()).stream()) .collect(Collectors.joining("\n\n")); //emit nested class String factoryDecl = @@ -230,7 +246,7 @@ List generateImports(Set importedTypes) { /** * Generate a list of factory methods/fields to be added to a given factory nested class. */ - List generateFactoryMethodsAndFields(String key, Message msg) { + List generateFactoryMethodsAndFields(FactoryKind k, String key, Message msg) { MessageInfo msgInfo = msg.getMessageInfo(); List lines = msg.getLines(false); String javadoc = lines.stream() @@ -238,14 +254,27 @@ List generateFactoryMethodsAndFields(String key, Message msg) { .map(ml -> ml.text) .collect(Collectors.joining("\n *")); String[] keyParts = key.split("\\."); - FactoryKind k = FactoryKind.parseFrom(keyParts[1]); + String lintCategory = lines.stream() + .filter(MessageLine::isLint) + .map(MessageLine::lintCategory) + .findFirst().orElse(null); + //System.out.println("category for " + key + " = " + lintCategory); String factoryName = factoryName(key); if (msgInfo.getTypes().isEmpty()) { //generate field - String factoryField = StubKind.FACTORY_FIELD.format(k.keyClazz, factoryName, - "\"" + keyParts[0] + "\"", - "\"" + Stream.of(keyParts).skip(2).collect(Collectors.joining(".")) + "\"", - javadoc); + String factoryField; + if (lintCategory == null) { + factoryField = StubKind.FACTORY_FIELD.format(k.keyClazz, factoryName, + "\"" + keyParts[0] + "\"", + "\"" + Stream.of(keyParts).skip(2).collect(Collectors.joining(".")) + "\"", + javadoc); + } else { + factoryField = StubKind.FACTORY_FIELD_LINT.format(k.keyClazz, factoryName, + StubKind.LINT_CATEGORY.format("\"" + lintCategory + "\""), + "\"" + keyParts[0] + "\"", + "\"" + Stream.of(keyParts).skip(2).collect(Collectors.joining(".")) + "\"", + javadoc); + } return Collections.singletonList(factoryField); } else { //generate method @@ -255,12 +284,22 @@ List generateFactoryMethodsAndFields(String key, Message msg) { List argNames = argNames(types.size()); String suppressionString = needsSuppressWarnings(msgTypes) ? StubKind.SUPPRESS_WARNINGS.format() : ""; + String methodBody; + if (lintCategory == null) { + methodBody = StubKind.FACTORY_METHOD_BODY.format(k.keyClazz, + "\"" + keyParts[0] + "\"", + "\"" + Stream.of(keyParts).skip(2).collect(Collectors.joining(".")) + "\"", + argNames.stream().collect(Collectors.joining(", "))); + } else { + methodBody = StubKind.FACTORY_METHOD_BODY_LINT.format(k.keyClazz, + StubKind.LINT_CATEGORY.format("\"" + lintCategory + "\""), + "\"" + keyParts[0] + "\"", + "\"" + Stream.of(keyParts).skip(2).collect(Collectors.joining(".")) + "\"", + argNames.stream().collect(Collectors.joining(", "))); + } String factoryMethod = StubKind.FACTORY_METHOD_DECL.format(suppressionString, k.keyClazz, factoryName, argDecls(types, argNames).stream().collect(Collectors.joining(", ")), - indent(StubKind.FACTORY_METHOD_BODY.format(k.keyClazz, - "\"" + keyParts[0] + "\"", - "\"" + Stream.of(keyParts).skip(2).collect(Collectors.joining(".")) + "\"", - argNames.stream().collect(Collectors.joining(", "))), 1), + indent(methodBody, 1), javadoc); factoryMethods.add(factoryMethod); } diff --git a/make/langtools/tools/propertiesparser/parser/Message.java b/make/langtools/tools/propertiesparser/parser/Message.java index 02a2f5e4f5c75..3c1191084ec1c 100644 --- a/make/langtools/tools/propertiesparser/parser/Message.java +++ b/make/langtools/tools/propertiesparser/parser/Message.java @@ -49,6 +49,9 @@ public final class Message { public MessageInfo getMessageInfo() { if (messageInfo == null) { MessageLine l = firstLine.prev; + if (l != null && l.isLint()) { + l = l.prev; + } if (l != null && l.isInfo()) messageInfo = new MessageInfo(l.text); else @@ -71,7 +74,7 @@ public List getLines(boolean includeAllPrecedingComments) { while (l.text.isEmpty()) l = l.next; } else { - if (l.prev != null && l.prev.isInfo()) + if (l.prev != null && (l.prev.isInfo() || l.prev.isLint())) l = l.prev; } diff --git a/make/langtools/tools/propertiesparser/parser/MessageLine.java b/make/langtools/tools/propertiesparser/parser/MessageLine.java index e370eefa38a82..c73021e08274e 100644 --- a/make/langtools/tools/propertiesparser/parser/MessageLine.java +++ b/make/langtools/tools/propertiesparser/parser/MessageLine.java @@ -25,6 +25,7 @@ package propertiesparser.parser; +import java.util.regex.Matcher; import java.util.regex.Pattern; /** @@ -37,6 +38,7 @@ public class MessageLine { static final Pattern typePattern = Pattern.compile("[-\\\\'A-Z\\.a-z ]+( \\([-A-Za-z 0-9]+\\))?"); static final Pattern infoPattern = Pattern.compile(String.format("# ([0-9]+: %s, )*[0-9]+: %s", typePattern.pattern(), typePattern.pattern())); + static final Pattern lintPattern = Pattern.compile("# lint: ([a-z\\-]+)"); public String text; MessageLine prev; @@ -54,6 +56,19 @@ public boolean isInfo() { return infoPattern.matcher(text).matches(); } + public boolean isLint() { + return lintPattern.matcher(text).matches(); + } + + public String lintCategory() { + Matcher matcher = lintPattern.matcher(text); + if (matcher.matches()) { + return matcher.group(1); + } else { + return null; + } + } + boolean hasContinuation() { return (next != null) && text.endsWith("\\"); } diff --git a/make/langtools/tools/propertiesparser/resources/templates.properties b/make/langtools/tools/propertiesparser/resources/templates.properties index b6685e688912e..bb403238f804b 100644 --- a/make/langtools/tools/propertiesparser/resources/templates.properties +++ b/make/langtools/tools/propertiesparser/resources/templates.properties @@ -29,8 +29,10 @@ toplevel.decl=\ {1}\n\ import com.sun.tools.javac.util.JCDiagnostic.Error;\n\ import com.sun.tools.javac.util.JCDiagnostic.Warning;\n\ + import com.sun.tools.javac.util.JCDiagnostic.LintWarning;\n\ import com.sun.tools.javac.util.JCDiagnostic.Note;\n\ import com.sun.tools.javac.util.JCDiagnostic.Fragment;\n\ + import com.sun.tools.javac.code.Lint.LintCategory;\n\ \n\ public class {2} '{'\n\ {3}\n\ @@ -58,16 +60,27 @@ factory.decl.method.arg=\ factory.decl.method.body=\ return new {0}({1}, {2}, {3}); +factory.decl.method.body.lint=\ + return new {0}({1}, {2}, {3}, {4}); + factory.decl.field=\ /**\n\ ' '* {4}\n\ ' '*/\n\ public static final {0} {1} = new {0}({2}, {3}); +factory.decl.field.lint=\ + /**\n\ + ' '* {5}\n\ + ' '*/\n\ + public static final {0} {1} = new {0}({2}, {3}, {4}); + wildcards.extends=\ {0} suppress.warnings=\ @SuppressWarnings("rawtypes")\n +lint.category=\ + LintCategory.get({0}) diff --git a/src/hotspot/cpu/ppc/c1_CodeStubs_ppc.cpp b/src/hotspot/cpu/ppc/c1_CodeStubs_ppc.cpp index 451f3b7e9cd6b..4d3927dc644b8 100644 --- a/src/hotspot/cpu/ppc/c1_CodeStubs_ppc.cpp +++ b/src/hotspot/cpu/ppc/c1_CodeStubs_ppc.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2021 SAP SE. All rights reserved. + * Copyright (c) 2012, 2024 SAP SE. 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 diff --git a/src/hotspot/cpu/ppc/c2_init_ppc.cpp b/src/hotspot/cpu/ppc/c2_init_ppc.cpp index a02b9668c92a9..d570abc431a9d 100644 --- a/src/hotspot/cpu/ppc/c2_init_ppc.cpp +++ b/src/hotspot/cpu/ppc/c2_init_ppc.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2020 SAP SE. All rights reserved. + * Copyright (c) 2012, 2024 SAP SE. 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 diff --git a/src/hotspot/cpu/ppc/frame_ppc.cpp b/src/hotspot/cpu/ppc/frame_ppc.cpp index 07243ed1c8c31..f698b14d312b8 100644 --- a/src/hotspot/cpu/ppc/frame_ppc.cpp +++ b/src/hotspot/cpu/ppc/frame_ppc.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2023 SAP SE. All rights reserved. + * Copyright (c) 2012, 2024 SAP SE. 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 diff --git a/src/hotspot/cpu/ppc/frame_ppc.hpp b/src/hotspot/cpu/ppc/frame_ppc.hpp index 67456158b97ac..560615089fe12 100644 --- a/src/hotspot/cpu/ppc/frame_ppc.hpp +++ b/src/hotspot/cpu/ppc/frame_ppc.hpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2023 SAP SE. All rights reserved. + * Copyright (c) 2012, 2024 SAP SE. 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 diff --git a/src/hotspot/cpu/ppc/frame_ppc.inline.hpp b/src/hotspot/cpu/ppc/frame_ppc.inline.hpp index c390449dc33ff..19a90367353f3 100644 --- a/src/hotspot/cpu/ppc/frame_ppc.inline.hpp +++ b/src/hotspot/cpu/ppc/frame_ppc.inline.hpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2023 SAP SE. All rights reserved. + * Copyright (c) 2012, 2024 SAP SE. 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 diff --git a/src/hotspot/cpu/ppc/globals_ppc.hpp b/src/hotspot/cpu/ppc/globals_ppc.hpp index 50204d1ac8942..7fefc856a4735 100644 --- a/src/hotspot/cpu/ppc/globals_ppc.hpp +++ b/src/hotspot/cpu/ppc/globals_ppc.hpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2023 SAP SE. All rights reserved. + * Copyright (c) 2012, 2024 SAP SE. 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 diff --git a/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp b/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp index 632eb97e85206..67b9bdc04142f 100644 --- a/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp +++ b/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2023 SAP SE. All rights reserved. + * Copyright (c) 2012, 2024 SAP SE. 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 diff --git a/src/hotspot/cpu/ppc/nativeInst_ppc.cpp b/src/hotspot/cpu/ppc/nativeInst_ppc.cpp index 7577bdb9fdde9..78ed81be9cb75 100644 --- a/src/hotspot/cpu/ppc/nativeInst_ppc.cpp +++ b/src/hotspot/cpu/ppc/nativeInst_ppc.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2020 SAP SE. All rights reserved. + * Copyright (c) 2012, 2024 SAP SE. 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 diff --git a/src/hotspot/cpu/ppc/nativeInst_ppc.hpp b/src/hotspot/cpu/ppc/nativeInst_ppc.hpp index 29b8b1b891be8..f4d570116a8c1 100644 --- a/src/hotspot/cpu/ppc/nativeInst_ppc.hpp +++ b/src/hotspot/cpu/ppc/nativeInst_ppc.hpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2021 SAP SE. All rights reserved. + * Copyright (c) 2012, 2024 SAP SE. 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 diff --git a/src/hotspot/cpu/ppc/ppc.ad b/src/hotspot/cpu/ppc/ppc.ad index b023ccae86dca..808dd02273895 100644 --- a/src/hotspot/cpu/ppc/ppc.ad +++ b/src/hotspot/cpu/ppc/ppc.ad @@ -1,6 +1,6 @@ // // Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. -// Copyright (c) 2012, 2023 SAP SE. All rights reserved. +// Copyright (c) 2012, 2024 SAP SE. 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 diff --git a/src/hotspot/cpu/ppc/vm_version_ppc.cpp b/src/hotspot/cpu/ppc/vm_version_ppc.cpp index a09d718287f02..9a4f13e41a04d 100644 --- a/src/hotspot/cpu/ppc/vm_version_ppc.cpp +++ b/src/hotspot/cpu/ppc/vm_version_ppc.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2023 SAP SE. All rights reserved. + * Copyright (c) 2012, 2024 SAP SE. 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 diff --git a/src/hotspot/cpu/ppc/vm_version_ppc.hpp b/src/hotspot/cpu/ppc/vm_version_ppc.hpp index 4c0954ebdd2c4..6096f8e4fd113 100644 --- a/src/hotspot/cpu/ppc/vm_version_ppc.hpp +++ b/src/hotspot/cpu/ppc/vm_version_ppc.hpp @@ -1,6 +1,6 @@ /* * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2021 SAP SE. All rights reserved. + * Copyright (c) 2012, 2024 SAP SE. 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 diff --git a/src/hotspot/cpu/ppc/vtableStubs_ppc_64.cpp b/src/hotspot/cpu/ppc/vtableStubs_ppc_64.cpp index 6a8c146aa9a4a..567cfae8d0a5e 100644 --- a/src/hotspot/cpu/ppc/vtableStubs_ppc_64.cpp +++ b/src/hotspot/cpu/ppc/vtableStubs_ppc_64.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2021 SAP SE. All rights reserved. + * Copyright (c) 2012, 2024 SAP SE. 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 diff --git a/src/hotspot/cpu/s390/frame_s390.hpp b/src/hotspot/cpu/s390/frame_s390.hpp index b6e4726cd4526..3a6b3f33a5527 100644 --- a/src/hotspot/cpu/s390/frame_s390.hpp +++ b/src/hotspot/cpu/s390/frame_s390.hpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2016, 2023 SAP SE. All rights reserved. + * Copyright (c) 2016, 2024 SAP SE. 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 diff --git a/src/hotspot/cpu/s390/frame_s390.inline.hpp b/src/hotspot/cpu/s390/frame_s390.inline.hpp index 62e202337fef4..d29106cfc40d6 100644 --- a/src/hotspot/cpu/s390/frame_s390.inline.hpp +++ b/src/hotspot/cpu/s390/frame_s390.inline.hpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2016 SAP SE. All rights reserved. + * Copyright (c) 2016, 2024 SAP SE. 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 diff --git a/src/hotspot/cpu/s390/nativeInst_s390.hpp b/src/hotspot/cpu/s390/nativeInst_s390.hpp index 8003e1d42f267..fcae833769f74 100644 --- a/src/hotspot/cpu/s390/nativeInst_s390.hpp +++ b/src/hotspot/cpu/s390/nativeInst_s390.hpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2016 SAP SE. All rights reserved. + * Copyright (c) 2016, 2024 SAP SE. 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 diff --git a/src/hotspot/cpu/s390/templateInterpreterGenerator_s390.cpp b/src/hotspot/cpu/s390/templateInterpreterGenerator_s390.cpp index 4871706aadda2..1c4089d5beb07 100644 --- a/src/hotspot/cpu/s390/templateInterpreterGenerator_s390.cpp +++ b/src/hotspot/cpu/s390/templateInterpreterGenerator_s390.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2016, 2023 SAP SE. All rights reserved. + * Copyright (c) 2016, 2024 SAP SE. 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 diff --git a/src/hotspot/cpu/x86/c2_intelJccErratum_x86.cpp b/src/hotspot/cpu/x86/c2_intelJccErratum_x86.cpp index e03e04339a121..f726a831c9f15 100644 --- a/src/hotspot/cpu/x86/c2_intelJccErratum_x86.cpp +++ b/src/hotspot/cpu/x86/c2_intelJccErratum_x86.cpp @@ -25,7 +25,6 @@ #include "precompiled.hpp" #include "asm/macroAssembler.hpp" #include "c2_intelJccErratum_x86.hpp" -#include "opto/cfgnode.hpp" #include "opto/compile.hpp" #include "opto/machnode.hpp" #include "opto/node.hpp" diff --git a/src/hotspot/os/aix/attachListener_aix.cpp b/src/hotspot/os/aix/attachListener_aix.cpp index bf11d813e0694..721901bb0e244 100644 --- a/src/hotspot/os/aix/attachListener_aix.cpp +++ b/src/hotspot/os/aix/attachListener_aix.cpp @@ -39,7 +39,7 @@ #include #ifndef UNIX_PATH_MAX -#define UNIX_PATH_MAX sizeof(((struct sockaddr_un *)0)->sun_path) +#define UNIX_PATH_MAX sizeof(sockaddr_un::sun_path) #endif // The attach mechanism on AIX uses a UNIX domain socket. An attach listener diff --git a/src/hotspot/os/aix/osThread_aix.cpp b/src/hotspot/os/aix/osThread_aix.cpp index c424b044c09b9..86d9821e5a520 100644 --- a/src/hotspot/os/aix/osThread_aix.cpp +++ b/src/hotspot/os/aix/osThread_aix.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2015 SAP SE. All rights reserved. + * Copyright (c) 2012, 2024 SAP SE. 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 diff --git a/src/hotspot/os/aix/osThread_aix.hpp b/src/hotspot/os/aix/osThread_aix.hpp index 514e554101e88..771c2c19e4501 100644 --- a/src/hotspot/os/aix/osThread_aix.hpp +++ b/src/hotspot/os/aix/osThread_aix.hpp @@ -1,6 +1,6 @@ /* * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2013 SAP SE. All rights reserved. + * Copyright (c) 2012, 2024 SAP SE. 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 diff --git a/src/hotspot/os/aix/porting_aix.hpp b/src/hotspot/os/aix/porting_aix.hpp index 15f1e0afc549c..a1a22d81471bf 100644 --- a/src/hotspot/os/aix/porting_aix.hpp +++ b/src/hotspot/os/aix/porting_aix.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2023 SAP SE. All rights reserved. + * Copyright (c) 2012, 2024 SAP SE. 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 diff --git a/src/hotspot/os/posix/attachListener_posix.cpp b/src/hotspot/os/posix/attachListener_posix.cpp index bdd97afd47ee2..569c317caa7d8 100644 --- a/src/hotspot/os/posix/attachListener_posix.cpp +++ b/src/hotspot/os/posix/attachListener_posix.cpp @@ -43,7 +43,7 @@ #ifndef AIX #ifndef UNIX_PATH_MAX -#define UNIX_PATH_MAX sizeof(((struct sockaddr_un *)0)->sun_path) +#define UNIX_PATH_MAX sizeof(sockaddr_un::sun_path) #endif // The attach mechanism on Linux and BSD uses a UNIX domain socket. An attach diff --git a/src/hotspot/os/posix/perfMemory_posix.cpp b/src/hotspot/os/posix/perfMemory_posix.cpp index 4eb46169878cd..5fbd5e76c5aca 100644 --- a/src/hotspot/os/posix/perfMemory_posix.cpp +++ b/src/hotspot/os/posix/perfMemory_posix.cpp @@ -1053,7 +1053,7 @@ static char* mmap_create_shared(size_t size) { return nullptr; } - mapAddress = (char*)::mmap((char*)0, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); + mapAddress = (char*)::mmap(nullptr, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); result = ::close(fd); assert(result != OS_ERR, "could not close file"); @@ -1208,7 +1208,7 @@ static void mmap_attach_shared(int vmid, char** addr, size_t* sizep, TRAPS) { assert(size > 0, "unexpected size <= 0"); - char* mapAddress = (char*)::mmap((char*)0, size, mmap_prot, MAP_SHARED, fd, 0); + char* mapAddress = (char*)::mmap(nullptr, size, mmap_prot, MAP_SHARED, fd, 0); int result = ::close(fd); assert(result != OS_ERR, "could not close file"); diff --git a/src/hotspot/os_cpu/aix_ppc/javaThread_aix_ppc.cpp b/src/hotspot/os_cpu/aix_ppc/javaThread_aix_ppc.cpp index 3ec846460a1c8..94e0c387a81dc 100644 --- a/src/hotspot/os_cpu/aix_ppc/javaThread_aix_ppc.cpp +++ b/src/hotspot/os_cpu/aix_ppc/javaThread_aix_ppc.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2014 SAP SE. All rights reserved. + * Copyright (c) 2012, 2024 SAP SE. All rights reserved. * Copyright (c) 2022, IBM Corp. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/src/hotspot/os_cpu/linux_ppc/javaThread_linux_ppc.cpp b/src/hotspot/os_cpu/linux_ppc/javaThread_linux_ppc.cpp index 71d3aaddaece4..f9fc6cec7fac9 100644 --- a/src/hotspot/os_cpu/linux_ppc/javaThread_linux_ppc.cpp +++ b/src/hotspot/os_cpu/linux_ppc/javaThread_linux_ppc.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2022 SAP SE. All rights reserved. + * Copyright (c) 2012, 2024 SAP SE. 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 diff --git a/src/hotspot/os_cpu/linux_s390/os_linux_s390.cpp b/src/hotspot/os_cpu/linux_s390/os_linux_s390.cpp index bc8e3d104310a..d599359d52903 100644 --- a/src/hotspot/os_cpu/linux_s390/os_linux_s390.cpp +++ b/src/hotspot/os_cpu/linux_s390/os_linux_s390.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2016, 2023 SAP SE. All rights reserved. + * Copyright (c) 2016, 2024 SAP SE. 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 diff --git a/src/hotspot/share/c1/c1_Compilation.hpp b/src/hotspot/share/c1/c1_Compilation.hpp index 0ac0a4d4169ab..5f554496f932b 100644 --- a/src/hotspot/share/c1/c1_Compilation.hpp +++ b/src/hotspot/share/c1/c1_Compilation.hpp @@ -30,8 +30,6 @@ #include "code/exceptionHandlerTable.hpp" #include "compiler/compiler_globals.hpp" #include "compiler/compilerDefinitions.inline.hpp" -#include "compiler/compilerDirectives.hpp" -#include "memory/resourceArea.hpp" #include "runtime/deoptimization.hpp" class CompilationFailureInfo; diff --git a/src/hotspot/share/c1/c1_FrameMap.hpp b/src/hotspot/share/c1/c1_FrameMap.hpp index 2a7533e499f60..1fd7dd3edffe3 100644 --- a/src/hotspot/share/c1/c1_FrameMap.hpp +++ b/src/hotspot/share/c1/c1_FrameMap.hpp @@ -25,13 +25,11 @@ #ifndef SHARE_C1_C1_FRAMEMAP_HPP #define SHARE_C1_C1_FRAMEMAP_HPP -#include "asm/macroAssembler.hpp" #include "c1/c1_Defs.hpp" #include "c1/c1_LIR.hpp" #include "code/vmreg.hpp" #include "memory/allocation.hpp" #include "runtime/frame.hpp" -#include "runtime/synchronizer.hpp" #include "utilities/globalDefinitions.hpp" #include "utilities/macros.hpp" diff --git a/src/hotspot/share/c1/c1_GraphBuilder.cpp b/src/hotspot/share/c1/c1_GraphBuilder.cpp index 0179923bc306c..9925c592f6f10 100644 --- a/src/hotspot/share/c1/c1_GraphBuilder.cpp +++ b/src/hotspot/share/c1/c1_GraphBuilder.cpp @@ -41,12 +41,8 @@ #include "interpreter/bytecode.hpp" #include "jfr/jfrEvents.hpp" #include "memory/resourceArea.hpp" -#include "oops/oop.inline.hpp" #include "runtime/sharedRuntime.hpp" -#include "runtime/vm_version.hpp" -#include "utilities/bitMap.inline.hpp" #include "utilities/checkedCast.hpp" -#include "utilities/powerOfTwo.hpp" #include "utilities/macros.hpp" #if INCLUDE_JFR #include "jfr/jfr.hpp" diff --git a/src/hotspot/share/c1/c1_IR.hpp b/src/hotspot/share/c1/c1_IR.hpp index 48286315df833..9dfcb8419c3f1 100644 --- a/src/hotspot/share/c1/c1_IR.hpp +++ b/src/hotspot/share/c1/c1_IR.hpp @@ -27,8 +27,6 @@ #include "c1/c1_Instruction.hpp" #include "ci/ciExceptionHandler.hpp" -#include "ci/ciMethod.hpp" -#include "ci/ciStreams.hpp" #include "memory/allocation.hpp" // An XHandler is a C1 internal description for an exception handler diff --git a/src/hotspot/share/c1/c1_LIRAssembler.cpp b/src/hotspot/share/c1/c1_LIRAssembler.cpp index 51fb851d00c0e..0fa4b3a4c93d7 100644 --- a/src/hotspot/share/c1/c1_LIRAssembler.cpp +++ b/src/hotspot/share/c1/c1_LIRAssembler.cpp @@ -30,7 +30,6 @@ #include "c1/c1_LIRAssembler.hpp" #include "c1/c1_MacroAssembler.hpp" #include "c1/c1_ValueStack.hpp" -#include "ci/ciInstance.hpp" #include "compiler/compilerDefinitions.inline.hpp" #include "compiler/oopMap.hpp" #include "runtime/os.hpp" diff --git a/src/hotspot/share/c1/c1_LIRGenerator.hpp b/src/hotspot/share/c1/c1_LIRGenerator.hpp index 518cd5fa5e724..a66758054d7d4 100644 --- a/src/hotspot/share/c1/c1_LIRGenerator.hpp +++ b/src/hotspot/share/c1/c1_LIRGenerator.hpp @@ -28,9 +28,7 @@ #include "c1/c1_Decorators.hpp" #include "c1/c1_Instruction.hpp" #include "c1/c1_LIR.hpp" -#include "ci/ciMethodData.hpp" #include "gc/shared/barrierSet.hpp" -#include "jfr/support/jfrIntrinsics.hpp" #include "utilities/macros.hpp" #include "utilities/sizes.hpp" diff --git a/src/hotspot/share/c1/c1_Optimizer.cpp b/src/hotspot/share/c1/c1_Optimizer.cpp index dd428a5895bc4..d33e4d28bd0dd 100644 --- a/src/hotspot/share/c1/c1_Optimizer.cpp +++ b/src/hotspot/share/c1/c1_Optimizer.cpp @@ -23,9 +23,7 @@ */ #include "precompiled.hpp" -#include "c1/c1_Canonicalizer.hpp" #include "c1/c1_Optimizer.hpp" -#include "c1/c1_ValueMap.hpp" #include "c1/c1_ValueSet.hpp" #include "c1/c1_ValueStack.hpp" #include "memory/resourceArea.hpp" diff --git a/src/hotspot/share/c1/c1_RangeCheckElimination.cpp b/src/hotspot/share/c1/c1_RangeCheckElimination.cpp index c2397d4a399a6..a4c2976d26f13 100644 --- a/src/hotspot/share/c1/c1_RangeCheckElimination.cpp +++ b/src/hotspot/share/c1/c1_RangeCheckElimination.cpp @@ -26,13 +26,9 @@ #include "c1/c1_ValueStack.hpp" #include "c1/c1_RangeCheckElimination.hpp" #include "c1/c1_IR.hpp" -#include "c1/c1_Canonicalizer.hpp" -#include "c1/c1_ValueMap.hpp" #include "ci/ciMethodData.hpp" #include "runtime/deoptimization.hpp" -#ifdef ASSERT #include "utilities/bitMap.inline.hpp" -#endif // Macros for the Trace and the Assertion flag #ifdef ASSERT diff --git a/src/hotspot/share/c1/c1_Runtime1.cpp b/src/hotspot/share/c1/c1_Runtime1.cpp index 3ebd1f42f366d..4ef2f8f3b0a80 100644 --- a/src/hotspot/share/c1/c1_Runtime1.cpp +++ b/src/hotspot/share/c1/c1_Runtime1.cpp @@ -26,7 +26,6 @@ #include "asm/codeBuffer.hpp" #include "c1/c1_CodeStubs.hpp" #include "c1/c1_Defs.hpp" -#include "c1/c1_FrameMap.hpp" #include "c1/c1_LIRAssembler.hpp" #include "c1/c1_MacroAssembler.hpp" #include "c1/c1_Runtime1.hpp" @@ -35,7 +34,6 @@ #include "classfile/vmSymbols.hpp" #include "code/codeBlob.hpp" #include "code/compiledIC.hpp" -#include "code/pcDesc.hpp" #include "code/scopeDesc.hpp" #include "code/vtableStubs.hpp" #include "compiler/compilationPolicy.hpp" @@ -48,12 +46,10 @@ #include "interpreter/interpreter.hpp" #include "jfr/support/jfrIntrinsics.hpp" #include "logging/log.hpp" -#include "memory/allocation.inline.hpp" #include "memory/oopFactory.hpp" #include "memory/resourceArea.hpp" #include "memory/universe.hpp" #include "oops/access.inline.hpp" -#include "oops/klass.inline.hpp" #include "oops/objArrayOop.inline.hpp" #include "oops/objArrayKlass.hpp" #include "oops/oop.inline.hpp" @@ -67,7 +63,6 @@ #include "runtime/sharedRuntime.hpp" #include "runtime/stackWatermarkSet.hpp" #include "runtime/stubRoutines.hpp" -#include "runtime/threadCritical.hpp" #include "runtime/vframe.inline.hpp" #include "runtime/vframeArray.hpp" #include "runtime/vm_version.hpp" diff --git a/src/hotspot/share/c1/c1_Runtime1.hpp b/src/hotspot/share/c1/c1_Runtime1.hpp index 6aed71fdfe524..5f1ae4333bc15 100644 --- a/src/hotspot/share/c1/c1_Runtime1.hpp +++ b/src/hotspot/share/c1/c1_Runtime1.hpp @@ -29,7 +29,6 @@ #include "code/stubs.hpp" #include "interpreter/interpreter.hpp" #include "memory/allStatic.hpp" -#include "runtime/deoptimization.hpp" #include "runtime/stubDeclarations.hpp" class StubAssembler; diff --git a/src/hotspot/share/c1/c1_ValueMap.cpp b/src/hotspot/share/c1/c1_ValueMap.cpp index e7993a8db5bc0..d9e1e11a3b876 100644 --- a/src/hotspot/share/c1/c1_ValueMap.cpp +++ b/src/hotspot/share/c1/c1_ValueMap.cpp @@ -23,11 +23,11 @@ */ #include "precompiled.hpp" -#include "c1/c1_Canonicalizer.hpp" #include "c1/c1_IR.hpp" #include "c1/c1_ValueMap.hpp" #include "c1/c1_ValueSet.hpp" #include "c1/c1_ValueStack.hpp" +#include "utilities/bitMap.inline.hpp" #ifndef PRODUCT diff --git a/src/hotspot/share/c1/c1_ValueSet.hpp b/src/hotspot/share/c1/c1_ValueSet.hpp index afd8d081dc5d2..442261def0a71 100644 --- a/src/hotspot/share/c1/c1_ValueSet.hpp +++ b/src/hotspot/share/c1/c1_ValueSet.hpp @@ -26,9 +26,7 @@ #define SHARE_C1_C1_VALUESET_HPP #include "c1/c1_Instruction.hpp" -#include "memory/allocation.hpp" #include "utilities/bitMap.hpp" -#include "utilities/bitMap.inline.hpp" // A ValueSet is a simple abstraction on top of a BitMap representing // a set of Instructions. Currently it assumes that the number of diff --git a/src/hotspot/share/c1/c1_ValueType.hpp b/src/hotspot/share/c1/c1_ValueType.hpp index 488b337251884..62757ddc1a192 100644 --- a/src/hotspot/share/c1/c1_ValueType.hpp +++ b/src/hotspot/share/c1/c1_ValueType.hpp @@ -26,8 +26,6 @@ #define SHARE_C1_C1_VALUETYPE_HPP #include "c1/c1_Compilation.hpp" -#include "ci/ciConstant.hpp" -#include "ci/ciMethodData.hpp" // type hierarchy class ValueType; diff --git a/src/hotspot/share/ci/ciTypeFlow.cpp b/src/hotspot/share/ci/ciTypeFlow.cpp index 942b866eb5180..36b4a2991cc9e 100644 --- a/src/hotspot/share/ci/ciTypeFlow.cpp +++ b/src/hotspot/share/ci/ciTypeFlow.cpp @@ -38,7 +38,6 @@ #include "memory/resourceArea.hpp" #include "oops/oop.inline.hpp" #include "opto/compile.hpp" -#include "opto/node.hpp" #include "runtime/deoptimization.hpp" #include "utilities/growableArray.hpp" diff --git a/src/hotspot/share/classfile/vmIntrinsics.cpp b/src/hotspot/share/classfile/vmIntrinsics.cpp index 5e352e42efbc1..407cdafaf2017 100644 --- a/src/hotspot/share/classfile/vmIntrinsics.cpp +++ b/src/hotspot/share/classfile/vmIntrinsics.cpp @@ -28,10 +28,12 @@ #include "compiler/compilerDirectives.hpp" #include "jvm_constants.h" #include "jvm_io.h" +#ifdef COMPILER2 +#include "opto/c2_globals.hpp" +#endif #include "runtime/vm_version.hpp" #include "utilities/checkedCast.hpp" #include "utilities/tribool.hpp" -#include "utilities/xmlstream.hpp" // These are flag-matching functions: inline bool match_F_R(jshort flags) { diff --git a/src/hotspot/share/code/compiledIC.hpp b/src/hotspot/share/code/compiledIC.hpp index 22b93c1760aa5..37ca090fa9cc9 100644 --- a/src/hotspot/share/code/compiledIC.hpp +++ b/src/hotspot/share/code/compiledIC.hpp @@ -28,7 +28,6 @@ #include "code/nativeInst.hpp" #include "interpreter/linkResolver.hpp" #include "runtime/safepointVerifiers.hpp" -#include "opto/c2_MacroAssembler.hpp" //----------------------------------------------------------------------------- // The CompiledIC represents a compiled inline cache. diff --git a/src/hotspot/share/code/vtableStubs.cpp b/src/hotspot/share/code/vtableStubs.cpp index aa9319db63b50..6a0c52ae828c4 100644 --- a/src/hotspot/share/code/vtableStubs.cpp +++ b/src/hotspot/share/code/vtableStubs.cpp @@ -40,9 +40,6 @@ #include "runtime/sharedRuntime.hpp" #include "utilities/align.hpp" #include "utilities/powerOfTwo.hpp" -#ifdef COMPILER2 -#include "opto/matcher.hpp" -#endif // ----------------------------------------------------------------------------------------- // Implementation of VtableStub diff --git a/src/hotspot/share/compiler/compilerDefinitions.inline.hpp b/src/hotspot/share/compiler/compilerDefinitions.inline.hpp index 5557892669ddd..5d04ef307d0f7 100644 --- a/src/hotspot/share/compiler/compilerDefinitions.inline.hpp +++ b/src/hotspot/share/compiler/compilerDefinitions.inline.hpp @@ -32,9 +32,7 @@ #include "opto/c2compiler.hpp" #endif #include "compiler/compilerDefinitions.hpp" - #include "compiler/compiler_globals.hpp" -#include "compiler/compilerDefinitions.hpp" #include "runtime/arguments.hpp" inline bool CompilerConfig::is_interpreter_only() { diff --git a/src/hotspot/share/compiler/compilerDirectives.hpp b/src/hotspot/share/compiler/compilerDirectives.hpp index e960fdb1e53ce..620874508f483 100644 --- a/src/hotspot/share/compiler/compilerDirectives.hpp +++ b/src/hotspot/share/compiler/compilerDirectives.hpp @@ -26,9 +26,7 @@ #define SHARE_COMPILER_COMPILERDIRECTIVES_HPP #include "classfile/vmIntrinsics.hpp" -#include "ci/ciMetadata.hpp" #include "ci/ciMethod.hpp" -#include "compiler/compiler_globals.hpp" #include "compiler/methodMatcher.hpp" #include "opto/phasetype.hpp" #include "utilities/bitMap.hpp" diff --git a/src/hotspot/share/interpreter/interpreterRuntime.cpp b/src/hotspot/share/interpreter/interpreterRuntime.cpp index cb85513eed0ff..9d953d9db54fd 100644 --- a/src/hotspot/share/interpreter/interpreterRuntime.cpp +++ b/src/hotspot/share/interpreter/interpreterRuntime.cpp @@ -77,9 +77,6 @@ #include "utilities/checkedCast.hpp" #include "utilities/copy.hpp" #include "utilities/events.hpp" -#ifdef COMPILER2 -#include "opto/runtime.hpp" -#endif // Helper class to access current interpreter state class LastFrameAccessor : public StackObj { diff --git a/src/hotspot/share/oops/compressedKlass.cpp b/src/hotspot/share/oops/compressedKlass.cpp index 97415cf6e85a0..21c28af876686 100644 --- a/src/hotspot/share/oops/compressedKlass.cpp +++ b/src/hotspot/share/oops/compressedKlass.cpp @@ -278,7 +278,7 @@ void CompressedKlassPointers::initialize(address addr, size_t len) { if (!set_klass_decode_mode()) { // Give fatal error if this is a specified address - if ((address)CompressedClassSpaceBaseAddress == _base) { + if (CompressedClassSpaceBaseAddress == (size_t)_base) { vm_exit_during_initialization( err_msg("CompressedClassSpaceBaseAddress=" PTR_FORMAT " given with shift %d, cannot be used to encode class pointers", CompressedClassSpaceBaseAddress, _shift)); diff --git a/src/hotspot/share/opto/c2compiler.hpp b/src/hotspot/share/opto/c2compiler.hpp index 01c7de3a971b9..868372568af94 100644 --- a/src/hotspot/share/opto/c2compiler.hpp +++ b/src/hotspot/share/opto/c2compiler.hpp @@ -26,7 +26,12 @@ #define SHARE_OPTO_C2COMPILER_HPP #include "compiler/abstractCompiler.hpp" -#include "opto/output.hpp" + +// Define the initial sizes for allocation of the resizable code buffer +enum { + initial_const_capacity = 4 * 1024 +}; + class C2Compiler : public AbstractCompiler { private: diff --git a/src/hotspot/share/opto/compile.hpp b/src/hotspot/share/opto/compile.hpp index 7c251bd4bd934..223e703376103 100644 --- a/src/hotspot/share/opto/compile.hpp +++ b/src/hotspot/share/opto/compile.hpp @@ -946,11 +946,9 @@ class Compile : public Phase { Node_Notes* default_node_notes() const { return _default_node_notes; } void set_default_node_notes(Node_Notes* n) { _default_node_notes = n; } - Node_Notes* node_notes_at(int idx) { - return locate_node_notes(_node_note_array, idx, false); - } - inline bool set_node_notes_at(int idx, Node_Notes* value); + Node_Notes* node_notes_at(int idx); + inline bool set_node_notes_at(int idx, Node_Notes* value); // Copy notes from source to dest, if they exist. // Overwrite dest only if source provides something. // Return true if information was moved. diff --git a/src/hotspot/share/opto/library_call.cpp b/src/hotspot/share/opto/library_call.cpp index 096f0a20bd1af..40b19eecd9f65 100644 --- a/src/hotspot/share/opto/library_call.cpp +++ b/src/hotspot/share/opto/library_call.cpp @@ -50,6 +50,7 @@ #include "opto/runtime.hpp" #include "opto/rootnode.hpp" #include "opto/subnode.hpp" +#include "opto/vectornode.hpp" #include "prims/jvmtiExport.hpp" #include "prims/jvmtiThreadState.hpp" #include "prims/unsafe.hpp" diff --git a/src/hotspot/share/opto/loopTransform.cpp b/src/hotspot/share/opto/loopTransform.cpp index a33d89993addd..d8d7be5c89c1e 100644 --- a/src/hotspot/share/opto/loopTransform.cpp +++ b/src/hotspot/share/opto/loopTransform.cpp @@ -1748,20 +1748,11 @@ void PhaseIdealLoop::create_assertion_predicates_at_loop(CountedLoopNode* source CountedLoopNode* target_loop_head, const NodeInLoopBody& _node_in_loop_body, const bool clone_template) { - Node* init = target_loop_head->init_trip(); - Node* stride = target_loop_head->stride(); - LoopNode* target_outer_loop_head = target_loop_head->skip_strip_mined(); - Node* target_loop_entry = target_outer_loop_head->in(LoopNode::EntryControl); - CreateAssertionPredicatesVisitor create_assertion_predicates_visitor(init, stride, target_loop_entry, this, - _node_in_loop_body, clone_template); + CreateAssertionPredicatesVisitor create_assertion_predicates_visitor(target_loop_head, this, _node_in_loop_body, + clone_template); Node* source_loop_entry = source_loop_head->skip_strip_mined()->in(LoopNode::EntryControl); PredicateIterator predicate_iterator(source_loop_entry); predicate_iterator.for_each(create_assertion_predicates_visitor); - if (create_assertion_predicates_visitor.has_created_predicates()) { - IfTrueNode* last_created_predicate_success_proj = create_assertion_predicates_visitor.last_created_success_proj(); - _igvn.replace_input_of(target_outer_loop_head, LoopNode::EntryControl, last_created_predicate_success_proj); - set_idom(target_outer_loop_head, last_created_predicate_success_proj, dom_depth(target_outer_loop_head)); - } } //------------------------------do_unroll-------------------------------------- // Unroll the loop body one step - make each trip do 2 iterations. diff --git a/src/hotspot/share/opto/loopnode.hpp b/src/hotspot/share/opto/loopnode.hpp index da059f8c820f8..acafea3fce86e 100644 --- a/src/hotspot/share/opto/loopnode.hpp +++ b/src/hotspot/share/opto/loopnode.hpp @@ -1367,6 +1367,12 @@ class PhaseIdealLoop : public PhaseTransform { public: void register_control(Node* n, IdealLoopTree *loop, Node* pred, bool update_body = true); + // Replace the control input of 'node' with 'new_control' and set the dom depth to the one of 'new_control'. + void replace_control(Node* node, Node* new_control) { + _igvn.replace_input_of(node, 0, new_control); + set_idom(node, new_control, dom_depth(new_control)); + } + void replace_loop_entry(LoopNode* loop_head, Node* new_entry) { _igvn.replace_input_of(loop_head, LoopNode::EntryControl, new_entry); set_idom(loop_head, new_entry, dom_depth(new_entry)); diff --git a/src/hotspot/share/opto/mathexactnode.hpp b/src/hotspot/share/opto/mathexactnode.hpp index cc15b2ad98320..a324110c6f1fa 100644 --- a/src/hotspot/share/opto/mathexactnode.hpp +++ b/src/hotspot/share/opto/mathexactnode.hpp @@ -25,11 +25,8 @@ #ifndef SHARE_OPTO_MATHEXACTNODE_HPP #define SHARE_OPTO_MATHEXACTNODE_HPP -#include "opto/multnode.hpp" -#include "opto/node.hpp" #include "opto/addnode.hpp" #include "opto/subnode.hpp" -#include "opto/type.hpp" class PhaseGVN; diff --git a/src/hotspot/share/opto/node.hpp b/src/hotspot/share/opto/node.hpp index bb95601f9e7c4..8ff778ed49300 100644 --- a/src/hotspot/share/opto/node.hpp +++ b/src/hotspot/share/opto/node.hpp @@ -1999,6 +1999,10 @@ Compile::locate_node_notes(GrowableArray* arr, return arr->at(block_idx) + (idx & (_node_notes_block_size-1)); } +inline Node_Notes* Compile::node_notes_at(int idx) { + return locate_node_notes(_node_note_array, idx, false); +} + inline bool Compile::set_node_notes_at(int idx, Node_Notes* value) { if (value == nullptr || value->is_clear()) diff --git a/src/hotspot/share/opto/output.cpp b/src/hotspot/share/opto/output.cpp index 260aa7e635d2f..eb91ff7ea64aa 100644 --- a/src/hotspot/share/opto/output.cpp +++ b/src/hotspot/share/opto/output.cpp @@ -24,7 +24,6 @@ #include "precompiled.hpp" #include "asm/assembler.inline.hpp" -#include "asm/macroAssembler.inline.hpp" #include "code/compiledIC.hpp" #include "code/debugInfo.hpp" #include "code/debugInfoRec.hpp" @@ -34,7 +33,6 @@ #include "compiler/oopMap.hpp" #include "gc/shared/barrierSet.hpp" #include "gc/shared/c2/barrierSetC2.hpp" -#include "memory/allocation.inline.hpp" #include "memory/allocation.hpp" #include "opto/ad.hpp" #include "opto/block.hpp" @@ -48,10 +46,7 @@ #include "opto/optoreg.hpp" #include "opto/output.hpp" #include "opto/regalloc.hpp" -#include "opto/runtime.hpp" -#include "opto/subnode.hpp" #include "opto/type.hpp" -#include "runtime/handles.inline.hpp" #include "runtime/sharedRuntime.hpp" #include "utilities/macros.hpp" #include "utilities/powerOfTwo.hpp" diff --git a/src/hotspot/share/opto/output.hpp b/src/hotspot/share/opto/output.hpp index 503f5414dc4fd..432ad3638b230 100644 --- a/src/hotspot/share/opto/output.hpp +++ b/src/hotspot/share/opto/output.hpp @@ -54,11 +54,6 @@ class PhaseCFG; #define DEBUG_ARG(x) #endif -// Define the initial sizes for allocation of the resizable code buffer -enum { - initial_const_capacity = 4 * 1024 -}; - class BufferSizingData { public: int _stub; diff --git a/src/hotspot/share/opto/predicates.cpp b/src/hotspot/share/opto/predicates.cpp index 1a023d04b6855..a9cd1e638c180 100644 --- a/src/hotspot/share/opto/predicates.cpp +++ b/src/hotspot/share/opto/predicates.cpp @@ -878,6 +878,19 @@ void Predicates::dump_for_loop(LoopNode* loop_node) { } #endif // NOT PRODUCT +CreateAssertionPredicatesVisitor::CreateAssertionPredicatesVisitor(CountedLoopNode* target_loop_head, + PhaseIdealLoop* phase, + const NodeInLoopBody& node_in_loop_body, + const bool clone_template) + : _init(target_loop_head->init_trip()), + _stride(target_loop_head->stride()), + _old_target_loop_entry(target_loop_head->skip_strip_mined()->in(LoopNode::EntryControl)), + _current_predicate_chain_head(target_loop_head->skip_strip_mined()), // Initially no predicates, yet. + _phase(phase), + _has_hoisted_check_parse_predicates(false), + _node_in_loop_body(node_in_loop_body), + _clone_template(clone_template) {} + // Keep track of whether we are in the correct Predicate Block where Template Assertion Predicates can be found. // The PredicateIterator will always start at the loop entry and first visits the Loop Limit Check Predicate Block. void CreateAssertionPredicatesVisitor::visit(const ParsePredicate& parse_predicate) { @@ -894,22 +907,27 @@ void CreateAssertionPredicatesVisitor::visit(const TemplateAssertionPredicate& t return; } if (_clone_template) { - _new_control = clone_template_and_replace_init_input(template_assertion_predicate); + IfTrueNode* cloned_template_success_proj = clone_template_and_replace_init_input(template_assertion_predicate); + initialize_from_template(template_assertion_predicate, cloned_template_success_proj); + _current_predicate_chain_head = cloned_template_success_proj->in(0); + } else { + IfTrueNode* initialized_success_proj = initialize_from_template(template_assertion_predicate, _old_target_loop_entry); + _current_predicate_chain_head = initialized_success_proj->in(0); } - _new_control = initialize_from_template(template_assertion_predicate); } // Create an Initialized Assertion Predicate from the provided Template Assertion Predicate. IfTrueNode* CreateAssertionPredicatesVisitor::initialize_from_template( - const TemplateAssertionPredicate& template_assertion_predicate) const { + const TemplateAssertionPredicate& template_assertion_predicate, Node* new_control) const { DEBUG_ONLY(template_assertion_predicate.verify();) IfNode* template_head = template_assertion_predicate.head(); InitializedAssertionPredicateCreator initialized_assertion_predicate_creator(_phase); IfTrueNode* initialized_predicate = initialized_assertion_predicate_creator.create_from_template(template_head, - _new_control, + new_control, _init, _stride); DEBUG_ONLY(InitializedAssertionPredicate::verify(initialized_predicate);) template_assertion_predicate.rewire_loop_data_dependencies(initialized_predicate, _node_in_loop_body, _phase); + rewire_to_old_predicate_chain_head(initialized_predicate); return initialized_predicate; } @@ -917,8 +935,46 @@ IfTrueNode* CreateAssertionPredicatesVisitor::initialize_from_template( IfTrueNode* CreateAssertionPredicatesVisitor::clone_template_and_replace_init_input( const TemplateAssertionPredicate& template_assertion_predicate) { OpaqueLoopInitNode* opaque_init = new OpaqueLoopInitNode(_phase->C, _init); - _phase->register_new_node(opaque_init, _new_control); - return template_assertion_predicate.clone_and_replace_init(_new_control, opaque_init, _phase); + _phase->register_new_node(opaque_init, _old_target_loop_entry); + return template_assertion_predicate.clone_and_replace_init(_old_target_loop_entry, opaque_init, _phase); +} + +// Rewire the newly created predicates to the old predicate chain head (i.e. '_current_predicate_chain_head') by +// rewiring the current control input of '_current_predicate_chain_head' from '_old_target_loop_entry' to +// 'initialized_assertion_predicate_success_proj'. This is required because we walk the predicate chain from the loop +// up and clone Template Assertion Predicates on the fly: +// +// x +// | old target +// Template Assertion loop entry +// Predicate 1 old target clone | \ +// | loop entry TAP 2 | cloned Template Assertion +// Template Assertion | ======> | Predicate 2 +// Predicate 2 target loop | +// | target loop #_current_predicate_chain_head +// source loop +// +// +// old target old target +// loop entry loop entry +// | \ rewire | +// | cloned Template Assertion to old cloned Template Assertion #current_predicate +// initialize | Predicate 2 predicate Predicate 2 _chain_head (new) +// TAP 2 | | chain head | +// ======> | Initialized Assertion ======> Initialized Assertion +// | Predicate 2 Predicate 2 +// | | +// target loop #_current_predicate_chain_head target loop +// +void CreateAssertionPredicatesVisitor::rewire_to_old_predicate_chain_head( + Node* initialized_assertion_predicate_success_proj) const { + if (_current_predicate_chain_head->is_Loop()) { + assert(_current_predicate_chain_head->in(LoopNode::EntryControl) == _old_target_loop_entry, "must be old loop entry"); + _phase->replace_loop_entry(_current_predicate_chain_head->as_Loop(), initialized_assertion_predicate_success_proj); + } else { + assert(_current_predicate_chain_head->in(0) == _old_target_loop_entry, "must be old loop entry"); + _phase->replace_control(_current_predicate_chain_head, initialized_assertion_predicate_success_proj); + } } // Clone the Template Assertion Predicate and set a new input for the OpaqueLoopStrideNode. @@ -951,9 +1007,8 @@ IfTrueNode* UpdateStrideForAssertionPredicates::initialize_from_updated_template void UpdateStrideForAssertionPredicates::connect_initialized_assertion_predicate( Node* new_control_out, IfTrueNode* initialized_success_proj) const { if (new_control_out->is_Loop()) { - _phase->igvn().replace_input_of(new_control_out, LoopNode::EntryControl, initialized_success_proj); + _phase->replace_loop_entry(new_control_out->as_Loop(), initialized_success_proj); } else { - _phase->igvn().replace_input_of(new_control_out, 0, initialized_success_proj); + _phase->replace_control(new_control_out, initialized_success_proj); } - _phase->set_idom(new_control_out, initialized_success_proj, _phase->dom_depth(new_control_out)); } diff --git a/src/hotspot/share/opto/predicates.hpp b/src/hotspot/share/opto/predicates.hpp index ef27c093290b1..bc8c1a8ebdce8 100644 --- a/src/hotspot/share/opto/predicates.hpp +++ b/src/hotspot/share/opto/predicates.hpp @@ -984,46 +984,26 @@ class CreateAssertionPredicatesVisitor : public PredicateVisitor { Node* const _init; Node* const _stride; Node* const _old_target_loop_entry; - Node* _new_control; + Node* _current_predicate_chain_head; PhaseIdealLoop* const _phase; bool _has_hoisted_check_parse_predicates; const NodeInLoopBody& _node_in_loop_body; const bool _clone_template; IfTrueNode* clone_template_and_replace_init_input(const TemplateAssertionPredicate& template_assertion_predicate); - IfTrueNode* initialize_from_template(const TemplateAssertionPredicate& template_assertion_predicate) const; + IfTrueNode* initialize_from_template(const TemplateAssertionPredicate& template_assertion_predicate, + Node* new_control) const; + void rewire_to_old_predicate_chain_head(Node* initialized_assertion_predicate_success_proj) const; public: - CreateAssertionPredicatesVisitor(Node* init, Node* stride, Node* new_control, PhaseIdealLoop* phase, - const NodeInLoopBody& node_in_loop_body, const bool clone_template) - : _init(init), - _stride(stride), - _old_target_loop_entry(new_control), - _new_control(new_control), - _phase(phase), - _has_hoisted_check_parse_predicates(false), - _node_in_loop_body(node_in_loop_body), - _clone_template(clone_template) {} + CreateAssertionPredicatesVisitor(CountedLoopNode* target_loop_head, PhaseIdealLoop* phase, + const NodeInLoopBody& node_in_loop_body, bool clone_template); NONCOPYABLE(CreateAssertionPredicatesVisitor); using PredicateVisitor::visit; void visit(const ParsePredicate& parse_predicate) override; void visit(const TemplateAssertionPredicate& template_assertion_predicate) override; - - // Did we create any new Initialized Assertion Predicates? - bool has_created_predicates() const { - return _new_control != _old_target_loop_entry; - } - - // Return the last created node by this visitor or the originally provided 'new_control' to the visitor if there was - // no new node created (i.e. no Template Assertion Predicates found). - IfTrueNode* last_created_success_proj() const { - assert(has_created_predicates(), "should only be queried if new nodes have been created"); - assert(_new_control->unique_ctrl_out_or_null() == nullptr, "no control outputs, yet"); - assert(_new_control->is_IfTrue(), "Assertion Predicates only have IfTrue on success proj"); - return _new_control->as_IfTrue(); - } }; // This visitor collects all Template Assertion Predicates If nodes or the corresponding Opaque nodes, depending on the diff --git a/src/hotspot/share/opto/runtime.hpp b/src/hotspot/share/opto/runtime.hpp index da08fc0f38660..dc608cf746a73 100644 --- a/src/hotspot/share/opto/runtime.hpp +++ b/src/hotspot/share/opto/runtime.hpp @@ -28,8 +28,6 @@ #include "code/codeBlob.hpp" #include "opto/machnode.hpp" #include "opto/optoreg.hpp" -#include "opto/type.hpp" -#include "runtime/deoptimization.hpp" #include "runtime/stubDeclarations.hpp" #include "runtime/vframe.hpp" diff --git a/src/hotspot/share/runtime/vframeArray.cpp b/src/hotspot/share/runtime/vframeArray.cpp index 1b26abf740287..bf195311f487a 100644 --- a/src/hotspot/share/runtime/vframeArray.cpp +++ b/src/hotspot/share/runtime/vframeArray.cpp @@ -43,9 +43,6 @@ #include "runtime/vframe_hp.hpp" #include "utilities/copy.hpp" #include "utilities/events.hpp" -#ifdef COMPILER2 -#include "opto/runtime.hpp" -#endif int vframeArrayElement:: bci(void) const { return (_bci == SynchronizationEntryBCI ? 0 : _bci); } diff --git a/src/hotspot/share/runtime/vframe_hp.cpp b/src/hotspot/share/runtime/vframe_hp.cpp index 49ed47835d6a3..0c7e63d07fc82 100644 --- a/src/hotspot/share/runtime/vframe_hp.cpp +++ b/src/hotspot/share/runtime/vframe_hp.cpp @@ -45,10 +45,6 @@ #include "runtime/stubRoutines.hpp" #include "runtime/vframeArray.hpp" #include "runtime/vframe_hp.hpp" -#ifdef COMPILER2 -#include "opto/matcher.hpp" -#endif - // ------------- compiledVFrame -------------- diff --git a/src/hotspot/share/utilities/vmError.cpp b/src/hotspot/share/utilities/vmError.cpp index b0a9016ffc261..223d8ee88494a 100644 --- a/src/hotspot/share/utilities/vmError.cpp +++ b/src/hotspot/share/utilities/vmError.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2017, 2020 SAP SE. All rights reserved. + * Copyright (c) 2017, 2024 SAP SE. All rights reserved. * Copyright (c) 2023, Red Hat, Inc. and/or its affiliates. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -133,7 +133,7 @@ static const char* env_list[] = { // defined on Windows "OS", "PROCESSOR_IDENTIFIER", "_ALT_JAVA_HOME_DIR", "TMP", "TEMP", - (const char *)0 + nullptr // End marker. }; // A simple parser for -XX:OnError, usage: diff --git a/src/java.sql/share/classes/java/sql/SQLPermission.java b/src/java.sql/share/classes/java/sql/SQLPermission.java index 863037502e5f3..84e41c51a33a2 100644 --- a/src/java.sql/share/classes/java/sql/SQLPermission.java +++ b/src/java.sql/share/classes/java/sql/SQLPermission.java @@ -32,7 +32,7 @@ * A {@code SQLPermission} object contains * a name (also referred to as a "target name") but no actions * list; there is either a named permission or there is not. - * The target name is the name of the permission (see below). The + * The target name is the name of the permission. The * naming convention follows the hierarchical property naming convention. * In addition, an asterisk * may appear at the end of the name, following a ".", or by itself, to diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Lint.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Lint.java index 622c13d8b4797..c55830849c88a 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Lint.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Lint.java @@ -33,7 +33,10 @@ import com.sun.tools.javac.code.Symbol.*; import com.sun.tools.javac.main.Option; import com.sun.tools.javac.util.Context; +import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; +import com.sun.tools.javac.util.JCDiagnostic.LintWarning; import com.sun.tools.javac.util.List; +import com.sun.tools.javac.util.Log; import com.sun.tools.javac.util.Options; import com.sun.tools.javac.util.Pair; @@ -359,7 +362,7 @@ public enum LintCategory { map.put(option, this); } - static LintCategory get(String option) { + public static LintCategory get(String option) { return map.get(option); } @@ -385,6 +388,15 @@ public boolean isSuppressed(LintCategory lc) { return suppressedValues.contains(lc); } + /** + * Helper method. Log a lint warning if its lint category is enabled. + */ + public void logIfEnabled(Log log, DiagnosticPosition pos, LintWarning warning) { + if (isEnabled(warning.getLintCategory())) { + log.warning(pos, warning); + } + } + protected static class AugmentVisitor implements Attribute.Visitor { private final Context context; private Symtab syms; diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Preview.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Preview.java index c66e17586161e..5a684a1cc59bd 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Preview.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Preview.java @@ -30,11 +30,13 @@ import com.sun.tools.javac.code.Symbol.ModuleSymbol; import com.sun.tools.javac.jvm.Target; import com.sun.tools.javac.resources.CompilerProperties.Errors; +import com.sun.tools.javac.resources.CompilerProperties.LintWarnings; import com.sun.tools.javac.resources.CompilerProperties.Warnings; import com.sun.tools.javac.util.Assert; import com.sun.tools.javac.util.Context; import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; import com.sun.tools.javac.util.JCDiagnostic.Error; +import com.sun.tools.javac.util.JCDiagnostic.LintWarning; import com.sun.tools.javac.util.JCDiagnostic.SimpleDiagnosticPosition; import com.sun.tools.javac.util.JCDiagnostic.Warning; import com.sun.tools.javac.util.Log; @@ -175,8 +177,8 @@ public void warnPreview(DiagnosticPosition pos, Feature feature) { if (!lint.isSuppressed(LintCategory.PREVIEW)) { sourcesWithPreviewFeatures.add(log.currentSourceFile()); previewHandler.report(pos, feature.isPlural() ? - Warnings.PreviewFeatureUsePlural(feature.nameFragment()) : - Warnings.PreviewFeatureUse(feature.nameFragment())); + LintWarnings.PreviewFeatureUsePlural(feature.nameFragment()) : + LintWarnings.PreviewFeatureUse(feature.nameFragment())); } } @@ -188,8 +190,8 @@ public void warnPreview(DiagnosticPosition pos, Feature feature) { public void warnPreview(JavaFileObject classfile, int majorVersion) { Assert.check(isEnabled()); if (lint.isEnabled(LintCategory.PREVIEW)) { - log.mandatoryWarning(LintCategory.PREVIEW, null, - Warnings.PreviewFeatureUseClassfile(classfile, majorVersionToSource.get(majorVersion).name)); + log.mandatoryWarning(null, + LintWarnings.PreviewFeatureUseClassfile(classfile, majorVersionToSource.get(majorVersion).name)); } } @@ -197,7 +199,7 @@ public void markUsesPreview(DiagnosticPosition pos) { sourcesWithPreviewFeatures.add(log.currentSourceFile()); } - public void reportPreviewWarning(DiagnosticPosition pos, Warning warnKey) { + public void reportPreviewWarning(DiagnosticPosition pos, LintWarning warnKey) { previewHandler.report(pos, warnKey); } diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java index 2c3a79650b49c..193794806433b 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java @@ -58,6 +58,7 @@ import com.sun.tools.javac.resources.CompilerProperties.Errors; import com.sun.tools.javac.resources.CompilerProperties.Fragments; +import com.sun.tools.javac.resources.CompilerProperties.LintWarnings; import com.sun.tools.javac.resources.CompilerProperties.Warnings; import com.sun.tools.javac.tree.*; import com.sun.tools.javac.tree.JCTree.*; @@ -1938,8 +1939,8 @@ private Symbol enumConstant(JCTree tree, Type enumType) { public void visitSynchronized(JCSynchronized tree) { chk.checkRefType(tree.pos(), attribExpr(tree.lock, env)); - if (env.info.lint.isEnabled(LintCategory.SYNCHRONIZATION) && isValueBased(tree.lock.type)) { - log.warning(LintCategory.SYNCHRONIZATION, tree.pos(), Warnings.AttemptToSynchronizeOnInstanceOfValueBasedClass); + if (isValueBased(tree.lock.type)) { + env.info.lint.logIfEnabled(log, tree.pos(), LintWarnings.AttemptToSynchronizeOnInstanceOfValueBasedClass); } attribStat(tree.body, env); result = null; @@ -2045,9 +2046,8 @@ void checkAutoCloseable(DiagnosticPosition pos, Env env, Type resou } if (close.kind == MTH && close.overrides(syms.autoCloseableClose, resource.tsym, types, true) && - chk.isHandled(syms.interruptedExceptionType, types.memberType(resource, close).getThrownTypes()) && - env.info.lint.isEnabled(LintCategory.TRY)) { - log.warning(LintCategory.TRY, pos, Warnings.TryResourceThrowsInterruptedExc(resource)); + chk.isHandled(syms.interruptedExceptionType, types.memberType(resource, close).getThrownTypes())) { + env.info.lint.logIfEnabled(log, pos, LintWarnings.TryResourceThrowsInterruptedExc(resource)); } } } @@ -4446,9 +4446,8 @@ public void visitSelect(JCFieldAccess tree) { ((VarSymbol)sitesym).isResourceVariable() && sym.kind == MTH && sym.name.equals(names.close) && - sym.overrides(syms.autoCloseableClose, sitesym.type.tsym, types, true) && - env.info.lint.isEnabled(LintCategory.TRY)) { - log.warning(LintCategory.TRY, tree, Warnings.TryExplicitCloseCall); + sym.overrides(syms.autoCloseableClose, sitesym.type.tsym, types, true)) { + env.info.lint.logIfEnabled(log, tree, LintWarnings.TryExplicitCloseCall); } // Disallow selecting a type from an expression @@ -4475,9 +4474,9 @@ public void visitSelect(JCFieldAccess tree) { // If the qualified item is not a type and the selected item is static, report // a warning. Make allowance for the class of an array type e.g. Object[].class) if (!sym.owner.isAnonymous()) { - chk.warnStatic(tree, Warnings.StaticNotQualifiedByType(sym.kind.kindName(), sym.owner)); + chk.lint.logIfEnabled(log, tree, LintWarnings.StaticNotQualifiedByType(sym.kind.kindName(), sym.owner)); } else { - chk.warnStatic(tree, Warnings.StaticNotQualifiedByType2(sym.kind.kindName())); + chk.lint.logIfEnabled(log, tree, LintWarnings.StaticNotQualifiedByType2(sym.kind.kindName())); } } @@ -4690,7 +4689,7 @@ else if (ownOuter.hasTag(CLASS) && site != ownOuter) { if (s != null && s.isRaw() && !types.isSameType(v.type, v.erasure(types))) { - chk.warnUnchecked(tree.pos(), Warnings.UncheckedAssignToVar(v, s)); + chk.warnUnchecked(tree.pos(), LintWarnings.UncheckedAssignToVar(v, s)); } } // The computed type of a variable is the type of the @@ -4888,7 +4887,7 @@ public Type checkMethod(Type site, if (s != null && s.isRaw() && !types.isSameTypes(sym.type.getParameterTypes(), sym.erasure(types).getParameterTypes())) { - chk.warnUnchecked(env.tree.pos(), Warnings.UncheckedCallMbrOfRawType(sym, s)); + chk.warnUnchecked(env.tree.pos(), LintWarnings.UncheckedCallMbrOfRawType(sym, s)); } } @@ -4938,7 +4937,7 @@ public Type checkMethod(Type site, argtypes = argtypes.map(checkDeferredMap); if (noteWarner.hasNonSilentLint(LintCategory.UNCHECKED)) { - chk.warnUnchecked(env.tree.pos(), Warnings.UncheckedMethInvocationApplied(kindName(sym), + chk.warnUnchecked(env.tree.pos(), LintWarnings.UncheckedMethInvocationApplied(kindName(sym), sym.name, rs.methodArguments(sym.type.getParameterTypes()), rs.methodArguments(argtypes.map(checkDeferredMap)), diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java index 3f675cad65121..a5b4186659bf4 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java @@ -28,7 +28,6 @@ import java.util.*; import java.util.function.BiConsumer; import java.util.function.BiPredicate; -import java.util.function.Consumer; import java.util.function.Predicate; import java.util.function.Supplier; import java.util.function.ToIntBiFunction; @@ -50,13 +49,14 @@ import com.sun.tools.javac.resources.CompilerProperties.Errors; import com.sun.tools.javac.resources.CompilerProperties.Fragments; import com.sun.tools.javac.resources.CompilerProperties.Warnings; +import com.sun.tools.javac.resources.CompilerProperties.LintWarnings; import com.sun.tools.javac.tree.*; import com.sun.tools.javac.util.*; import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag; import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; import com.sun.tools.javac.util.JCDiagnostic.Error; import com.sun.tools.javac.util.JCDiagnostic.Fragment; -import com.sun.tools.javac.util.JCDiagnostic.Warning; +import com.sun.tools.javac.util.JCDiagnostic.LintWarning; import com.sun.tools.javac.util.List; import com.sun.tools.javac.code.Lint; @@ -79,11 +79,8 @@ import static com.sun.tools.javac.tree.JCTree.Tag.*; import javax.lang.model.element.Element; -import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.TypeElement; import javax.lang.model.type.DeclaredType; -import javax.lang.model.type.TypeMirror; -import javax.lang.model.util.ElementFilter; import javax.lang.model.util.ElementKindVisitor14; /** Type checking helper class for the attribution phase. @@ -122,7 +119,7 @@ public class Check { // The set of lint options currently in effect. It is initialized // from the context, and then is set/reset as needed by Attr as it // visits all the various parts of the trees during attribution. - private Lint lint; + Lint lint; // The method being analyzed in Attr - it is set/reset as needed by // Attr as it visits new method declarations. @@ -251,16 +248,16 @@ void warnDeprecated(DiagnosticPosition pos, Symbol sym) { if (sym.isDeprecatedForRemoval()) { if (!lint.isSuppressed(LintCategory.REMOVAL)) { if (sym.kind == MDL) { - removalHandler.report(pos, Warnings.HasBeenDeprecatedForRemovalModule(sym)); + removalHandler.report(pos, LintWarnings.HasBeenDeprecatedForRemovalModule(sym)); } else { - removalHandler.report(pos, Warnings.HasBeenDeprecatedForRemoval(sym, sym.location())); + removalHandler.report(pos, LintWarnings.HasBeenDeprecatedForRemoval(sym, sym.location())); } } } else if (!lint.isSuppressed(LintCategory.DEPRECATION)) { if (sym.kind == MDL) { - deprecationHandler.report(pos, Warnings.HasBeenDeprecatedModule(sym)); + deprecationHandler.report(pos, LintWarnings.HasBeenDeprecatedModule(sym)); } else { - deprecationHandler.report(pos, Warnings.HasBeenDeprecated(sym, sym.location())); + deprecationHandler.report(pos, LintWarnings.HasBeenDeprecated(sym, sym.location())); } } } @@ -269,7 +266,7 @@ void warnDeprecated(DiagnosticPosition pos, Symbol sym) { * @param pos Position to be used for error reporting. * @param msg A Warning describing the problem. */ - public void warnPreviewAPI(DiagnosticPosition pos, Warning warnKey) { + public void warnPreviewAPI(DiagnosticPosition pos, LintWarning warnKey) { if (!lint.isSuppressed(LintCategory.PREVIEW)) preview.reportPreviewWarning(pos, warnKey); } @@ -280,7 +277,7 @@ public void warnPreviewAPI(DiagnosticPosition pos, Warning warnKey) { */ public void warnDeclaredUsingPreview(DiagnosticPosition pos, Symbol sym) { if (!lint.isSuppressed(LintCategory.PREVIEW)) - preview.reportPreviewWarning(pos, Warnings.DeclaredUsingPreview(kindName(sym), sym)); + preview.reportPreviewWarning(pos, LintWarnings.DeclaredUsingPreview(kindName(sym), sym)); } /** Log a preview warning. @@ -288,40 +285,18 @@ public void warnDeclaredUsingPreview(DiagnosticPosition pos, Symbol sym) { * @param msg A Warning describing the problem. */ public void warnRestrictedAPI(DiagnosticPosition pos, Symbol sym) { - if (lint.isEnabled(LintCategory.RESTRICTED)) - log.warning(LintCategory.RESTRICTED, pos, Warnings.RestrictedMethod(sym.enclClass(), sym)); + lint.logIfEnabled(log, pos, LintWarnings.RestrictedMethod(sym.enclClass(), sym)); } /** Warn about unchecked operation. * @param pos Position to be used for error reporting. * @param msg A string describing the problem. */ - public void warnUnchecked(DiagnosticPosition pos, Warning warnKey) { + public void warnUnchecked(DiagnosticPosition pos, LintWarning warnKey) { if (!lint.isSuppressed(LintCategory.UNCHECKED)) uncheckedHandler.report(pos, warnKey); } - /** Warn about unsafe vararg method decl. - * @param pos Position to be used for error reporting. - */ - void warnUnsafeVararg(DiagnosticPosition pos, Warning warnKey) { - if (lint.isEnabled(LintCategory.VARARGS)) - log.warning(LintCategory.VARARGS, pos, warnKey); - } - - public void warnStatic(DiagnosticPosition pos, Warning warnKey) { - if (lint.isEnabled(LintCategory.STATIC)) - log.warning(LintCategory.STATIC, pos, warnKey); - } - - /** Warn about division by integer constant zero. - * @param pos Position to be used for error reporting. - */ - void warnDivZero(DiagnosticPosition pos) { - if (lint.isEnabled(LintCategory.DIVZERO)) - log.warning(LintCategory.DIVZERO, pos, Warnings.DivZero); - } - /** * Report any deferred diagnostics. */ @@ -674,9 +649,7 @@ public void checkRedundantCast(Env env, final JCTypeCast tree) { && !(ignoreAnnotatedCasts && TreeInfo.containsTypeAnnotation(tree.clazz)) && !is292targetTypeCast(tree)) { deferredLintHandler.report(_l -> { - if (lint.isEnabled(LintCategory.CAST)) - log.warning(LintCategory.CAST, - tree.pos(), Warnings.RedundantCast(tree.clazz.type)); + lint.logIfEnabled(log, tree.pos(), LintWarnings.RedundantCast(tree.clazz.type)); }); } } @@ -981,13 +954,13 @@ void checkVarargsMethodDecl(Env env, JCMethodDecl tree) { } } else if (hasTrustMeAnno && varargElemType != null && types.isReifiable(varargElemType)) { - warnUnsafeVararg(tree, Warnings.VarargsRedundantTrustmeAnno( + lint.logIfEnabled(log, tree, LintWarnings.VarargsRedundantTrustmeAnno( syms.trustMeType.tsym, diags.fragment(Fragments.VarargsTrustmeOnReifiableVarargs(varargElemType)))); } else if (!hasTrustMeAnno && varargElemType != null && !types.isReifiable(varargElemType)) { - warnUnchecked(tree.params.head.pos(), Warnings.UncheckedVarargsNonReifiableType(varargElemType)); + warnUnchecked(tree.params.head.pos(), LintWarnings.UncheckedVarargsNonReifiableType(varargElemType)); } } //where @@ -1074,7 +1047,7 @@ Type checkMethod(final Type mtype, if (!types.isReifiable(argtype) && (sym.baseSymbol().attribute(syms.trustMeType.tsym) == null || !isTrustMeAllowedOnMethod(sym))) { - warnUnchecked(env.tree.pos(), Warnings.UncheckedGenericArrayCreation(argtype)); + warnUnchecked(env.tree.pos(), LintWarnings.UncheckedGenericArrayCreation(argtype)); } TreeInfo.setVarargsElement(env.tree, types.elemtype(argtype)); } @@ -1350,11 +1323,7 @@ && checkDisjoint(pos, flags, private void warnOnExplicitStrictfp(DiagnosticPosition pos) { DiagnosticPosition prevLintPos = deferredLintHandler.setPos(pos); try { - deferredLintHandler.report(_l -> { - if (lint.isEnabled(LintCategory.STRICTFP)) { - log.warning(LintCategory.STRICTFP, - pos, Warnings.Strictfp); } - }); + deferredLintHandler.report(_ -> lint.logIfEnabled(log, pos, LintWarnings.Strictfp)); } finally { deferredLintHandler.setPos(prevLintPos); } @@ -1569,13 +1538,11 @@ public void validateTrees(List trees, boolean checkRaw, boolea } void checkRaw(JCTree tree, Env env) { - if (lint.isEnabled(LintCategory.RAW) && - tree.type.hasTag(CLASS) && + if (tree.type.hasTag(CLASS) && !TreeInfo.isDiamond(tree) && !withinAnonConstr(env) && tree.type.isRaw()) { - log.warning(LintCategory.RAW, - tree.pos(), Warnings.RawClassUse(tree.type, tree.type.tsym.type)); + lint.logIfEnabled(log, tree.pos(), LintWarnings.RawClassUse(tree.type, tree.type.tsym.type)); } } //where @@ -1877,7 +1844,7 @@ void checkOverride(JCTree tree, return; } else if (overrideWarner.hasNonSilentLint(LintCategory.UNCHECKED)) { warnUnchecked(TreeInfo.diagnosticPositionFor(m, tree), - Warnings.OverrideUncheckedRet(uncheckedOverrides(m, other), mtres, otres)); + LintWarnings.OverrideUncheckedRet(uncheckedOverrides(m, other), mtres, otres)); } // Error if overriding method throws an exception not reported @@ -1893,17 +1860,16 @@ void checkOverride(JCTree tree, } else if (unhandledUnerased.nonEmpty()) { warnUnchecked(TreeInfo.diagnosticPositionFor(m, tree), - Warnings.OverrideUncheckedThrown(cannotOverride(m, other), unhandledUnerased.head)); + LintWarnings.OverrideUncheckedThrown(cannotOverride(m, other), unhandledUnerased.head)); return; } // Optional warning if varargs don't agree - if ((((m.flags() ^ other.flags()) & Flags.VARARGS) != 0) - && lint.isEnabled(LintCategory.OVERRIDES)) { - log.warning(TreeInfo.diagnosticPositionFor(m, tree), + if ((((m.flags() ^ other.flags()) & Flags.VARARGS) != 0)) { + lint.logIfEnabled(log, TreeInfo.diagnosticPositionFor(m, tree), ((m.flags() & Flags.VARARGS) != 0) - ? Warnings.OverrideVarargsMissing(varargsOverrides(m, other)) - : Warnings.OverrideVarargsExtra(varargsOverrides(m, other))); + ? LintWarnings.OverrideVarargsMissing(varargsOverrides(m, other)) + : LintWarnings.OverrideVarargsExtra(varargsOverrides(m, other))); } // Warn if instance method overrides bridge method (compiler spec ??) @@ -2247,8 +2213,8 @@ private void checkClassOverrideEqualsAndHash(DiagnosticPosition pos, someClass, false, equalsHasCodeFilter) != hashCodeAtObject; if (overridesEquals && !overridesHashCode) { - log.warning(LintCategory.OVERRIDES, pos, - Warnings.OverrideEqualsButNotHashcode(someClass)); + log.warning(pos, + LintWarnings.OverrideEqualsButNotHashcode(someClass)); } } } @@ -2310,7 +2276,7 @@ public void checkModuleName (JCModuleDecl tree) { String moduleNameComponentString = componentName.toString(); int nameLength = moduleNameComponentString.length(); if (nameLength > 0 && Character.isDigit(moduleNameComponentString.charAt(nameLength - 1))) { - log.warning(Lint.LintCategory.MODULE, pos, Warnings.PoorChoiceForModuleName(componentName)); + log.warning(pos, LintWarnings.PoorChoiceForModuleName(componentName)); } } } @@ -2781,8 +2747,8 @@ void checkPotentiallyAmbiguousOverloads(JCClassDecl tree, Type site) { tree.pos(); // Log the warning - log.warning(LintCategory.OVERLOADS, pos, - Warnings.PotentiallyAmbiguousOverload( + log.warning(pos, + LintWarnings.PotentiallyAmbiguousOverload( m1.asMemberOf(site, types), m1.location(), m2.asMemberOf(site, types), m2.location())); @@ -3002,12 +2968,12 @@ void checkAccessFromSerializableElement(final JCTree tree, boolean isLambda) { isEffectivelyNonPublic(sym)) { if (isLambda) { if (belongsToRestrictedPackage(sym)) { - log.warning(LintCategory.SERIAL, tree.pos(), - Warnings.AccessToMemberFromSerializableLambda(sym)); + log.warning(tree.pos(), + LintWarnings.AccessToMemberFromSerializableLambda(sym)); } } else { log.warning(tree.pos(), - Warnings.AccessToMemberFromSerializableElement(sym)); + LintWarnings.AccessToMemberFromSerializableElement(sym)); } } } @@ -3790,14 +3756,13 @@ void checkDeprecatedAnnotation(DiagnosticPosition pos, Symbol s) { (s.flags() & DEPRECATED) != 0 && !syms.deprecatedType.isErroneous() && s.attribute(syms.deprecatedType.tsym) == null) { - log.warning(LintCategory.DEP_ANN, - pos, Warnings.MissingDeprecatedAnnotation); + log.warning(pos, LintWarnings.MissingDeprecatedAnnotation); } // Note: @Deprecated has no effect on local variables, parameters and package decls. if (lint.isEnabled(LintCategory.DEPRECATION) && !s.isDeprecatableViaAnnotation()) { if (!syms.deprecatedType.isErroneous() && s.attribute(syms.deprecatedType.tsym) != null) { - log.warning(LintCategory.DEPRECATION, pos, - Warnings.DeprecatedAnnotationHasNoEffect(Kinds.kindName(s))); + log.warning(pos, + LintWarnings.DeprecatedAnnotationHasNoEffect(Kinds.kindName(s))); } } } @@ -3857,10 +3822,10 @@ void checkPreview(DiagnosticPosition pos, Symbol other, Type site, Symbol s) { log.error(pos, Errors.IsPreview(s)); } else { preview.markUsesPreview(pos); - deferredLintHandler.report(_l -> warnPreviewAPI(pos, Warnings.IsPreview(s))); + deferredLintHandler.report(_l -> warnPreviewAPI(pos, LintWarnings.IsPreview(s))); } } else { - deferredLintHandler.report(_l -> warnPreviewAPI(pos, Warnings.IsPreviewReflective(s))); + deferredLintHandler.report(_l -> warnPreviewAPI(pos, LintWarnings.IsPreviewReflective(s))); } } if (preview.declaredUsingPreviewFeature(s)) { @@ -4148,7 +4113,7 @@ void checkDivZero(final DiagnosticPosition pos, Symbol operator, Type operand) { int opc = ((OperatorSymbol)operator).opcode; if (opc == ByteCodes.idiv || opc == ByteCodes.imod || opc == ByteCodes.ldiv || opc == ByteCodes.lmod) { - deferredLintHandler.report(_l -> warnDivZero(pos)); + deferredLintHandler.report(_ -> lint.logIfEnabled(log, pos, LintWarnings.DivZero)); } } } @@ -4161,11 +4126,8 @@ void checkDivZero(final DiagnosticPosition pos, Symbol operator, Type operand) { */ void checkLossOfPrecision(final DiagnosticPosition pos, Type found, Type req) { if (found.isNumeric() && req.isNumeric() && !types.isAssignable(found, req)) { - deferredLintHandler.report(_l -> { - if (lint.isEnabled(LintCategory.LOSSY_CONVERSIONS)) - log.warning(LintCategory.LOSSY_CONVERSIONS, - pos, Warnings.PossibleLossOfPrecision(found, req)); - }); + deferredLintHandler.report(_ -> + lint.logIfEnabled(log, pos, LintWarnings.PossibleLossOfPrecision(found, req))); } } @@ -4173,9 +4135,9 @@ void checkLossOfPrecision(final DiagnosticPosition pos, Type found, Type req) { * Check for empty statements after if */ void checkEmptyIf(JCIf tree) { - if (tree.thenpart.hasTag(SKIP) && tree.elsepart == null && - lint.isEnabled(LintCategory.EMPTY)) - log.warning(LintCategory.EMPTY, tree.thenpart.pos(), Warnings.EmptyIf); + if (tree.thenpart.hasTag(SKIP) && tree.elsepart == null) { + lint.logIfEnabled(log, tree.thenpart.pos(), LintWarnings.EmptyIf); + } } /** Check that symbol is unique in given scope. @@ -4317,13 +4279,12 @@ private boolean isCanonical(JCTree tree) { /** Check that an auxiliary class is not accessed from any other file than its own. */ void checkForBadAuxiliaryClassAccess(DiagnosticPosition pos, Env env, ClassSymbol c) { - if (lint.isEnabled(Lint.LintCategory.AUXILIARYCLASS) && - (c.flags() & AUXILIARY) != 0 && + if ((c.flags() & AUXILIARY) != 0 && rs.isAccessible(env, c) && !fileManager.isSameFile(c.sourcefile, env.toplevel.sourcefile)) { - log.warning(pos, - Warnings.AuxiliaryClassAccessedFromOutsideOfItsSourceFile(c, c.sourcefile)); + lint.logIfEnabled(log, pos, + LintWarnings.AuxiliaryClassAccessedFromOutsideOfItsSourceFile(c, c.sourcefile)); } } @@ -4365,11 +4326,8 @@ void checkDefaultConstructor(ClassSymbol c, DiagnosticPosition pos) { // Warning may be suppressed by // annotations; check again for being // enabled in the deferred context. - deferredLintHandler.report(_l -> { - if (lint.isEnabled(LintCategory.MISSING_EXPLICIT_CTOR)) - log.warning(LintCategory.MISSING_EXPLICIT_CTOR, - pos, Warnings.MissingExplicitCtor(c, pkg, modle)); - }); + deferredLintHandler.report(_ -> + lint.logIfEnabled(log, pos, LintWarnings.MissingExplicitCtor(c, pkg, modle))); } else { return; } @@ -4398,14 +4356,14 @@ public void warn(LintCategory lint) { if (warned) return; // suppress redundant diagnostics switch (lint) { case UNCHECKED: - Check.this.warnUnchecked(pos(), Warnings.ProbFoundReq(diags.fragment(uncheckedKey), found, expected)); + Check.this.warnUnchecked(pos(), LintWarnings.ProbFoundReq(diags.fragment(uncheckedKey), found, expected)); break; case VARARGS: if (method != null && method.attribute(syms.trustMeType.tsym) != null && isTrustMeAllowedOnMethod(method) && !types.isReifiable(method.type.getParameterTypes().last())) { - Check.this.warnUnsafeVararg(pos(), Warnings.VarargsUnsafeUseVarargsParam(method.params.last())); + Check.this.lint.logIfEnabled(log, pos(), LintWarnings.VarargsUnsafeUseVarargsParam(method.params.last())); } break; default: @@ -4660,7 +4618,7 @@ private boolean isAPISymbol(Symbol sym) { } private void checkVisible(DiagnosticPosition pos, Symbol what, PackageSymbol inPackage, boolean inSuperType) { if (!isAPISymbol(what) && !inSuperType) { //package private/private element - log.warning(LintCategory.EXPORTS, pos, Warnings.LeaksNotAccessible(kindName(what), what, what.packge().modle)); + log.warning(pos, LintWarnings.LeaksNotAccessible(kindName(what), what, what.packge().modle)); return ; } @@ -4669,13 +4627,13 @@ private void checkVisible(DiagnosticPosition pos, Symbol what, PackageSymbol inP ExportsDirective inExport = findExport(inPackage); if (whatExport == null) { //package not exported: - log.warning(LintCategory.EXPORTS, pos, Warnings.LeaksNotAccessibleUnexported(kindName(what), what, what.packge().modle)); + log.warning(pos, LintWarnings.LeaksNotAccessibleUnexported(kindName(what), what, what.packge().modle)); return ; } if (whatExport.modules != null) { if (inExport.modules == null || !whatExport.modules.containsAll(inExport.modules)) { - log.warning(LintCategory.EXPORTS, pos, Warnings.LeaksNotAccessibleUnexportedQualified(kindName(what), what, what.packge().modle)); + log.warning(pos, LintWarnings.LeaksNotAccessibleUnexportedQualified(kindName(what), what, what.packge().modle)); } } @@ -4697,36 +4655,32 @@ private void checkVisible(DiagnosticPosition pos, Symbol what, PackageSymbol inP } } - log.warning(LintCategory.EXPORTS, pos, Warnings.LeaksNotAccessibleNotRequiredTransitive(kindName(what), what, what.packge().modle)); + log.warning(pos, LintWarnings.LeaksNotAccessibleNotRequiredTransitive(kindName(what), what, what.packge().modle)); } } void checkModuleExists(final DiagnosticPosition pos, ModuleSymbol msym) { if (msym.kind != MDL) { - deferredLintHandler.report(_l -> { - if (lint.isEnabled(LintCategory.MODULE)) - log.warning(LintCategory.MODULE, pos, Warnings.ModuleNotFound(msym)); - }); + deferredLintHandler.report(_ -> + lint.logIfEnabled(log, pos, LintWarnings.ModuleNotFound(msym))); } } void checkPackageExistsForOpens(final DiagnosticPosition pos, PackageSymbol packge) { if (packge.members().isEmpty() && ((packge.flags() & Flags.HAS_RESOURCE) == 0)) { - deferredLintHandler.report(_l -> { - if (lint.isEnabled(LintCategory.OPENS)) - log.warning(pos, Warnings.PackageEmptyOrNotFound(packge)); - }); + deferredLintHandler.report(_ -> + lint.logIfEnabled(log, pos, LintWarnings.PackageEmptyOrNotFound(packge))); } } void checkModuleRequires(final DiagnosticPosition pos, final RequiresDirective rd) { if ((rd.module.flags() & Flags.AUTOMATIC_MODULE) != 0) { - deferredLintHandler.report(_l -> { + deferredLintHandler.report(_ -> { if (rd.isTransitive() && lint.isEnabled(LintCategory.REQUIRES_TRANSITIVE_AUTOMATIC)) { - log.warning(pos, Warnings.RequiresTransitiveAutomatic); - } else if (lint.isEnabled(LintCategory.REQUIRES_AUTOMATIC)) { - log.warning(pos, Warnings.RequiresAutomatic); + log.warning(pos, LintWarnings.RequiresTransitiveAutomatic); + } else { + lint.logIfEnabled(log, pos, LintWarnings.RequiresAutomatic); } }); } @@ -5024,7 +4978,7 @@ public Void visitTypeAsClass(TypeElement e, } if (svuidSym == null) { - log.warning(LintCategory.SERIAL, p.pos(), Warnings.MissingSVUID(c)); + log.warning(p.pos(), LintWarnings.MissingSVUID(c)); } // Check for serialPersistentFields to gate checks for @@ -5051,9 +5005,9 @@ public Void visitTypeAsClass(TypeElement e, // Note per JLS arrays are // serializable even if the // component type is not. - log.warning(LintCategory.SERIAL, - TreeInfo.diagnosticPositionFor(enclosed, tree), - Warnings.NonSerializableInstanceField); + log.warning( + TreeInfo.diagnosticPositionFor(enclosed, tree), + LintWarnings.NonSerializableInstanceField); } else if (varType.hasTag(ARRAY)) { ArrayType arrayType = (ArrayType)varType; Type elementType = arrayType.elemtype; @@ -5062,9 +5016,9 @@ public Void visitTypeAsClass(TypeElement e, elementType = arrayType.elemtype; } if (!canBeSerialized(elementType)) { - log.warning(LintCategory.SERIAL, - TreeInfo.diagnosticPositionFor(enclosed, tree), - Warnings.NonSerializableInstanceFieldArray(elementType)); + log.warning( + TreeInfo.diagnosticPositionFor(enclosed, tree), + LintWarnings.NonSerializableInstanceFieldArray(elementType)); } } } @@ -5147,8 +5101,8 @@ private void checkCtorAccess(JCClassDecl tree, ClassSymbol c) { } } } - log.warning(LintCategory.SERIAL, tree.pos(), - Warnings.ExternalizableMissingPublicNoArgCtor); + log.warning(tree.pos(), + LintWarnings.ExternalizableMissingPublicNoArgCtor); } else { // Approximate access to the no-arg constructor up in // the superclass chain by checking that the @@ -5175,8 +5129,8 @@ private void checkCtorAccess(JCClassDecl tree, ClassSymbol c) { // Handle nested classes and implicit this$0 (supertype.getNestingKind() == NestingKind.MEMBER && ((supertype.flags() & STATIC) == 0))) - log.warning(LintCategory.SERIAL, tree.pos(), - Warnings.SerializableMissingAccessNoArgCtor(supertype.getQualifiedName())); + log.warning(tree.pos(), + LintWarnings.SerializableMissingAccessNoArgCtor(supertype.getQualifiedName())); } } } @@ -5194,43 +5148,43 @@ private void checkSerialVersionUID(JCClassDecl tree, Element e, VarSymbol svuid) // fields. if ((svuid.flags() & (STATIC | FINAL)) != (STATIC | FINAL)) { - log.warning(LintCategory.SERIAL, - TreeInfo.diagnosticPositionFor(svuid, tree), - Warnings.ImproperSVUID((Symbol)e)); + log.warning( + TreeInfo.diagnosticPositionFor(svuid, tree), + LintWarnings.ImproperSVUID((Symbol)e)); } // check svuid has type long if (!svuid.type.hasTag(LONG)) { - log.warning(LintCategory.SERIAL, - TreeInfo.diagnosticPositionFor(svuid, tree), - Warnings.LongSVUID((Symbol)e)); + log.warning( + TreeInfo.diagnosticPositionFor(svuid, tree), + LintWarnings.LongSVUID((Symbol)e)); } if (svuid.getConstValue() == null) - log.warning(LintCategory.SERIAL, - TreeInfo.diagnosticPositionFor(svuid, tree), - Warnings.ConstantSVUID((Symbol)e)); + log.warning( + TreeInfo.diagnosticPositionFor(svuid, tree), + LintWarnings.ConstantSVUID((Symbol)e)); } private void checkSerialPersistentFields(JCClassDecl tree, Element e, VarSymbol spf) { // To be effective, serialPersisentFields must be private, static, and final. if ((spf.flags() & (PRIVATE | STATIC | FINAL)) != (PRIVATE | STATIC | FINAL)) { - log.warning(LintCategory.SERIAL, - TreeInfo.diagnosticPositionFor(spf, tree), - Warnings.ImproperSPF); + log.warning( + TreeInfo.diagnosticPositionFor(spf, tree), + LintWarnings.ImproperSPF); } if (!types.isSameType(spf.type, OSF_TYPE)) { - log.warning(LintCategory.SERIAL, - TreeInfo.diagnosticPositionFor(spf, tree), - Warnings.OSFArraySPF); + log.warning( + TreeInfo.diagnosticPositionFor(spf, tree), + LintWarnings.OSFArraySPF); } if (isExternalizable((Type)(e.asType()))) { - log.warning(LintCategory.SERIAL, - TreeInfo.diagnosticPositionFor(spf, tree), - Warnings.IneffectualSerialFieldExternalizable); + log.warning( + TreeInfo.diagnosticPositionFor(spf, tree), + LintWarnings.IneffectualSerialFieldExternalizable); } // Warn if serialPersistentFields is initialized to a @@ -5240,8 +5194,8 @@ private void checkSerialPersistentFields(JCClassDecl tree, Element e, VarSymbol JCVariableDecl variableDef = (JCVariableDecl) spfDecl; JCExpression initExpr = variableDef.init; if (initExpr != null && TreeInfo.isNull(initExpr)) { - log.warning(LintCategory.SERIAL, initExpr.pos(), - Warnings.SPFNullInit); + log.warning(initExpr.pos(), + LintWarnings.SPFNullInit); } } } @@ -5319,24 +5273,24 @@ private void checkReadExternalRecord(JCClassDecl tree, Element e, MethodSymbol m private void checkExternMethodRecord(JCClassDecl tree, Element e, MethodSymbol method, Type argType, boolean isExtern) { if (isExtern && isExternMethod(tree, e, method, argType)) { - log.warning(LintCategory.SERIAL, - TreeInfo.diagnosticPositionFor(method, tree), - Warnings.IneffectualExternalizableMethodRecord(method.getSimpleName().toString())); + log.warning( + TreeInfo.diagnosticPositionFor(method, tree), + LintWarnings.IneffectualExternalizableMethodRecord(method.getSimpleName().toString())); } } void checkPrivateNonStaticMethod(JCClassDecl tree, MethodSymbol method) { var flags = method.flags(); if ((flags & PRIVATE) == 0) { - log.warning(LintCategory.SERIAL, - TreeInfo.diagnosticPositionFor(method, tree), - Warnings.SerialMethodNotPrivate(method.getSimpleName())); + log.warning( + TreeInfo.diagnosticPositionFor(method, tree), + LintWarnings.SerialMethodNotPrivate(method.getSimpleName())); } if ((flags & STATIC) != 0) { - log.warning(LintCategory.SERIAL, - TreeInfo.diagnosticPositionFor(method, tree), - Warnings.SerialMethodStatic(method.getSimpleName())); + log.warning( + TreeInfo.diagnosticPositionFor(method, tree), + LintWarnings.SerialMethodStatic(method.getSimpleName())); } } @@ -5359,18 +5313,18 @@ public Void visitTypeAsEnum(TypeElement e, case FIELD -> { var field = (VarSymbol)enclosed; if (serialFieldNames.contains(name)) { - log.warning(LintCategory.SERIAL, - TreeInfo.diagnosticPositionFor(field, tree), - Warnings.IneffectualSerialFieldEnum(name)); + log.warning( + TreeInfo.diagnosticPositionFor(field, tree), + LintWarnings.IneffectualSerialFieldEnum(name)); } } case METHOD -> { var method = (MethodSymbol)enclosed; if (serialMethodNames.contains(name)) { - log.warning(LintCategory.SERIAL, - TreeInfo.diagnosticPositionFor(method, tree), - Warnings.IneffectualSerialMethodEnum(name)); + log.warning( + TreeInfo.diagnosticPositionFor(method, tree), + LintWarnings.IneffectualSerialMethodEnum(name)); } if (isExtern) { @@ -5408,9 +5362,9 @@ private void checkReadExternalEnum(JCClassDecl tree, Element e, MethodSymbol met private void checkExternMethodEnum(JCClassDecl tree, Element e, MethodSymbol method, Type argType) { if (isExternMethod(tree, e, method, argType)) { - log.warning(LintCategory.SERIAL, - TreeInfo.diagnosticPositionFor(method, tree), - Warnings.IneffectualExternMethodEnum(method.getSimpleName().toString())); + log.warning( + TreeInfo.diagnosticPositionFor(method, tree), + LintWarnings.IneffectualExternMethodEnum(method.getSimpleName().toString())); } } @@ -5440,9 +5394,9 @@ public Void visitTypeAsInterface(TypeElement e, name = field.getSimpleName().toString(); switch(name) { case "serialPersistentFields" -> { - log.warning(LintCategory.SERIAL, - TreeInfo.diagnosticPositionFor(field, tree), - Warnings.IneffectualSerialFieldInterface); + log.warning( + TreeInfo.diagnosticPositionFor(field, tree), + LintWarnings.IneffectualSerialFieldInterface); } case "serialVersionUID" -> { @@ -5480,9 +5434,9 @@ private void checkPrivateMethod(JCClassDecl tree, Element e, MethodSymbol method) { if ((method.flags() & PRIVATE) == 0) { - log.warning(LintCategory.SERIAL, - TreeInfo.diagnosticPositionFor(method, tree), - Warnings.NonPrivateMethodWeakerAccess); + log.warning( + TreeInfo.diagnosticPositionFor(method, tree), + LintWarnings.NonPrivateMethodWeakerAccess); } } @@ -5490,9 +5444,9 @@ private void checkDefaultIneffective(JCClassDecl tree, Element e, MethodSymbol method) { if ((method.flags() & DEFAULT) == DEFAULT) { - log.warning(LintCategory.SERIAL, - TreeInfo.diagnosticPositionFor(method, tree), - Warnings.DefaultIneffective); + log.warning( + TreeInfo.diagnosticPositionFor(method, tree), + LintWarnings.DefaultIneffective); } } @@ -5537,9 +5491,9 @@ public Void visitTypeAsRecord(TypeElement e, var field = (VarSymbol)enclosed; switch(name) { case "serialPersistentFields" -> { - log.warning(LintCategory.SERIAL, - TreeInfo.diagnosticPositionFor(field, tree), - Warnings.IneffectualSerialFieldRecord); + log.warning( + TreeInfo.diagnosticPositionFor(field, tree), + LintWarnings.IneffectualSerialFieldRecord); } case "serialVersionUID" -> { @@ -5561,9 +5515,9 @@ public Void visitTypeAsRecord(TypeElement e, default -> { if (serialMethodNames.contains(name)) { - log.warning(LintCategory.SERIAL, - TreeInfo.diagnosticPositionFor(method, tree), - Warnings.IneffectualSerialMethodRecord(name)); + log.warning( + TreeInfo.diagnosticPositionFor(method, tree), + LintWarnings.IneffectualSerialMethodRecord(name)); } }} }}}); @@ -5575,9 +5529,9 @@ void checkConcreteInstanceMethod(JCClassDecl tree, Element enclosing, MethodSymbol method) { if ((method.flags() & (STATIC | ABSTRACT)) != 0) { - log.warning(LintCategory.SERIAL, - TreeInfo.diagnosticPositionFor(method, tree), - Warnings.SerialConcreteInstanceMethod(method.getSimpleName())); + log.warning( + TreeInfo.diagnosticPositionFor(method, tree), + LintWarnings.SerialConcreteInstanceMethod(method.getSimpleName())); } } @@ -5592,9 +5546,9 @@ private void checkReturnType(JCClassDecl tree, // checking. Type rtype = method.getReturnType(); if (!types.isSameType(expectedReturnType, rtype)) { - log.warning(LintCategory.SERIAL, - TreeInfo.diagnosticPositionFor(method, tree), - Warnings.SerialMethodUnexpectedReturnType(method.getSimpleName(), + log.warning( + TreeInfo.diagnosticPositionFor(method, tree), + LintWarnings.SerialMethodUnexpectedReturnType(method.getSimpleName(), rtype, expectedReturnType)); } } @@ -5608,17 +5562,17 @@ private void checkOneArg(JCClassDecl tree, var parameters= method.getParameters(); if (parameters.size() != 1) { - log.warning(LintCategory.SERIAL, - TreeInfo.diagnosticPositionFor(method, tree), - Warnings.SerialMethodOneArg(method.getSimpleName(), parameters.size())); + log.warning( + TreeInfo.diagnosticPositionFor(method, tree), + LintWarnings.SerialMethodOneArg(method.getSimpleName(), parameters.size())); return; } Type parameterType = parameters.get(0).asType(); if (!types.isSameType(parameterType, expectedType)) { - log.warning(LintCategory.SERIAL, - TreeInfo.diagnosticPositionFor(method, tree), - Warnings.SerialMethodParameterType(method.getSimpleName(), + log.warning( + TreeInfo.diagnosticPositionFor(method, tree), + LintWarnings.SerialMethodParameterType(method.getSimpleName(), expectedType, parameterType)); } @@ -5637,18 +5591,18 @@ private boolean hasExactlyOneArgWithType(JCClassDecl tree, private void checkNoArgs(JCClassDecl tree, Element enclosing, MethodSymbol method) { var parameters = method.getParameters(); if (!parameters.isEmpty()) { - log.warning(LintCategory.SERIAL, - TreeInfo.diagnosticPositionFor(parameters.get(0), tree), - Warnings.SerialMethodNoArgs(method.getSimpleName())); + log.warning( + TreeInfo.diagnosticPositionFor(parameters.get(0), tree), + LintWarnings.SerialMethodNoArgs(method.getSimpleName())); } } private void checkExternalizable(JCClassDecl tree, Element enclosing, MethodSymbol method) { // If the enclosing class is externalizable, warn for the method if (isExternalizable((Type)enclosing.asType())) { - log.warning(LintCategory.SERIAL, - TreeInfo.diagnosticPositionFor(method, tree), - Warnings.IneffectualSerialMethodExternalizable(method.getSimpleName())); + log.warning( + TreeInfo.diagnosticPositionFor(method, tree), + LintWarnings.IneffectualSerialMethodExternalizable(method.getSimpleName())); } return; } @@ -5675,9 +5629,9 @@ private void checkExceptions(JCClassDecl tree, } } if (!declared) { - log.warning(LintCategory.SERIAL, - TreeInfo.diagnosticPositionFor(method, tree), - Warnings.SerialMethodUnexpectedException(method.getSimpleName(), + log.warning( + TreeInfo.diagnosticPositionFor(method, tree), + LintWarnings.SerialMethodUnexpectedException(method.getSimpleName(), thrownType)); } } diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java index df28548152aec..e167b81272b70 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java @@ -34,11 +34,11 @@ import java.util.Set; import java.util.function.Consumer; -import com.sun.source.tree.CaseTree; import com.sun.source.tree.LambdaExpressionTree.BodyKind; import com.sun.tools.javac.code.*; import com.sun.tools.javac.code.Scope.WriteableScope; import com.sun.tools.javac.resources.CompilerProperties.Errors; +import com.sun.tools.javac.resources.CompilerProperties.LintWarnings; import com.sun.tools.javac.resources.CompilerProperties.Warnings; import com.sun.tools.javac.tree.*; import com.sun.tools.javac.util.*; @@ -60,8 +60,6 @@ import static com.sun.tools.javac.tree.JCTree.Tag.*; import com.sun.tools.javac.util.JCDiagnostic.Fragment; import java.util.Arrays; -import java.util.Collections; -import java.util.IdentityHashMap; import java.util.Iterator; import java.util.function.Predicate; import java.util.stream.Collectors; @@ -726,11 +724,9 @@ public void visitSwitch(JCSwitch tree) { } // Warn about fall-through if lint switch fallthrough enabled. if (alive == Liveness.ALIVE && - lint.isEnabled(Lint.LintCategory.FALLTHROUGH) && c.stats.nonEmpty() && l.tail.nonEmpty()) - log.warning(Lint.LintCategory.FALLTHROUGH, - l.tail.head.pos(), - Warnings.PossibleFallThroughIntoCase); + lint.logIfEnabled(log, l.tail.head.pos(), + LintWarnings.PossibleFallThroughIntoCase); } tree.isExhaustive = tree.hasUnconditionalPattern || TreeInfo.isErrorEnumSwitch(tree.selector, tree.cases); @@ -1237,11 +1233,8 @@ public void visitTry(JCTry tree) { scanStat(tree.finalizer); tree.finallyCanCompleteNormally = alive != Liveness.DEAD; if (alive == Liveness.DEAD) { - if (lint.isEnabled(Lint.LintCategory.FINALLY)) { - log.warning(Lint.LintCategory.FINALLY, - TreeInfo.diagEndPos(tree.finalizer), - Warnings.FinallyCannotComplete); - } + lint.logIfEnabled(log, TreeInfo.diagEndPos(tree.finalizer), + LintWarnings.FinallyCannotComplete); } else { while (exits.nonEmpty()) { pendingExits.append(exits.next()); @@ -2863,8 +2856,8 @@ public void visitTry(JCTry tree) { lint.isEnabled(Lint.LintCategory.TRY)) { for (JCVariableDecl resVar : resourceVarDecls) { if (unrefdResources.includes(resVar.sym) && !resVar.sym.isUnnamedVariable()) { - log.warning(Lint.LintCategory.TRY, resVar.pos(), - Warnings.TryResourceNotReferenced(resVar.sym)); + log.warning(resVar.pos(), + LintWarnings.TryResourceNotReferenced(resVar.sym)); unrefdResources.remove(resVar.sym); } } diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java index bfad334d1942f..97f961f09bf48 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java @@ -52,7 +52,6 @@ import javax.tools.StandardLocation; import com.sun.source.tree.ModuleTree.ModuleKind; -import com.sun.tools.javac.code.ClassFinder; import com.sun.tools.javac.code.DeferredLintHandler; import com.sun.tools.javac.code.Directive; import com.sun.tools.javac.code.Directive.ExportsDirective; @@ -88,6 +87,7 @@ import com.sun.tools.javac.jvm.Target; import com.sun.tools.javac.main.Option; import com.sun.tools.javac.resources.CompilerProperties.Errors; +import com.sun.tools.javac.resources.CompilerProperties.LintWarnings; import com.sun.tools.javac.resources.CompilerProperties.Warnings; import com.sun.tools.javac.tree.JCTree; import com.sun.tools.javac.tree.JCTree.JCCompilationUnit; @@ -1275,8 +1275,8 @@ private void setupAllModules() { if (lintOptions) { for (ModuleSymbol msym : limitMods) { if (!observable.contains(msym)) { - log.warning(LintCategory.OPTIONS, - Warnings.ModuleForOptionNotFound(Option.LIMIT_MODULES, msym)); + log.warning( + LintWarnings.ModuleForOptionNotFound(Option.LIMIT_MODULES, msym)); } } } @@ -1381,7 +1381,7 @@ private void setupAllModules() { .collect(Collectors.joining(",")); if (!incubatingModules.isEmpty()) { - log.warning(Warnings.IncubatingModules(incubatingModules)); + log.warning(LintWarnings.IncubatingModules(incubatingModules)); } } @@ -1731,8 +1731,8 @@ private boolean isKnownModule(ModuleSymbol msym, Set unknownModule if (!unknownModules.contains(msym)) { if (lintOptions) { - log.warning(LintCategory.OPTIONS, - Warnings.ModuleForOptionNotFound(Option.ADD_EXPORTS, msym)); + log.warning( + LintWarnings.ModuleForOptionNotFound(Option.ADD_EXPORTS, msym)); } unknownModules.add(msym); } @@ -1770,7 +1770,7 @@ private void initAddReads() { ModuleSymbol msym = syms.enterModule(names.fromString(sourceName)); if (!allModules.contains(msym)) { if (lintOptions) { - log.warning(Warnings.ModuleForOptionNotFound(Option.ADD_READS, msym)); + log.warning(LintWarnings.ModuleForOptionNotFound(Option.ADD_READS, msym)); } continue; } @@ -1790,7 +1790,7 @@ private void initAddReads() { targetModule = syms.enterModule(names.fromString(targetName)); if (!allModules.contains(targetModule)) { if (lintOptions) { - log.warning(LintCategory.OPTIONS, Warnings.ModuleForOptionNotFound(Option.ADD_READS, targetModule)); + log.warning(LintWarnings.ModuleForOptionNotFound(Option.ADD_READS, targetModule)); } continue; } diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ThisEscapeAnalyzer.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ThisEscapeAnalyzer.java index 0876aa0d5a0dc..e1bf92a7f7ba7 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ThisEscapeAnalyzer.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ThisEscapeAnalyzer.java @@ -31,12 +31,10 @@ import java.util.LinkedHashMap; import java.util.EnumSet; import java.util.HashSet; -import java.util.Map.Entry; import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.Set; -import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.BiPredicate; import java.util.function.Consumer; import java.util.function.Function; @@ -53,6 +51,7 @@ import com.sun.tools.javac.code.Symtab; import com.sun.tools.javac.code.Type; import com.sun.tools.javac.code.Types; +import com.sun.tools.javac.resources.CompilerProperties.LintWarnings; import com.sun.tools.javac.resources.CompilerProperties.Warnings; import com.sun.tools.javac.tree.JCTree; import com.sun.tools.javac.tree.JCTree.*; @@ -63,7 +62,6 @@ import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; import com.sun.tools.javac.util.List; import com.sun.tools.javac.util.Log; -import com.sun.tools.javac.util.Name; import com.sun.tools.javac.util.Names; import com.sun.tools.javac.util.Pair; @@ -424,12 +422,12 @@ private boolean currentClassIsExternallyExtendable() { previous = warning; // Emit warnings showing the entire stack trace - JCDiagnostic.Warning key = Warnings.PossibleThisEscape; + JCDiagnostic.Warning key = LintWarnings.PossibleThisEscape; int remain = warning.length; do { DiagnosticPosition pos = warning[--remain]; - log.warning(Lint.LintCategory.THIS_ESCAPE, pos, key); - key = Warnings.PossibleThisEscapeLocation; + log.warning(pos, key); + key = LintWarnings.PossibleThisEscapeLocation; } while (remain > 0); } warningList.clear(); diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileManager.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileManager.java index 3999cf0c36bb9..646db6a6bf333 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileManager.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileManager.java @@ -29,8 +29,6 @@ import java.io.InputStream; import java.lang.ref.SoftReference; import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import java.net.URL; import java.net.URLClassLoader; import java.nio.ByteBuffer; @@ -41,7 +39,6 @@ import java.nio.charset.CodingErrorAction; import java.nio.charset.IllegalCharsetNameException; import java.nio.charset.UnsupportedCharsetException; -import java.nio.file.Files; import java.nio.file.NoSuchFileException; import java.nio.file.Path; import java.util.Collection; @@ -56,13 +53,12 @@ import javax.tools.JavaFileObject; import javax.tools.JavaFileObject.Kind; -import com.sun.tools.javac.code.Lint.LintCategory; import com.sun.tools.javac.main.Option; import com.sun.tools.javac.main.OptionHelper; import com.sun.tools.javac.main.OptionHelper.GrumpyHelper; import com.sun.tools.javac.resources.CompilerProperties.Errors; +import com.sun.tools.javac.resources.CompilerProperties.LintWarnings; import com.sun.tools.javac.resources.CompilerProperties.Warnings; -import com.sun.tools.javac.util.Abort; import com.sun.tools.javac.util.Context; import com.sun.tools.javac.util.DefinedBy; import com.sun.tools.javac.util.DefinedBy.Api; @@ -529,6 +525,6 @@ synchronized void newOutputToPath(Path path) throws IOException { // Check whether we've already opened this file for output if (!outputFilesWritten.add(realPath)) - log.warning(LintCategory.OUTPUT_FILE_CLASH, Warnings.OutputFileClash(path)); + log.warning(LintWarnings.OutputFileClash(path)); } } diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java index 9da2052b9f3bf..3a6ed52cc79e7 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java @@ -77,10 +77,10 @@ import javax.tools.StandardJavaFileManager.PathFactory; import javax.tools.StandardLocation; +import com.sun.tools.javac.code.Lint; +import com.sun.tools.javac.resources.CompilerProperties.LintWarnings; import jdk.internal.jmod.JmodFile; -import com.sun.tools.javac.code.Lint; -import com.sun.tools.javac.code.Lint.LintCategory; import com.sun.tools.javac.main.Option; import com.sun.tools.javac.resources.CompilerProperties.Errors; import com.sun.tools.javac.resources.CompilerProperties.Warnings; @@ -224,7 +224,7 @@ private Iterable getPathEntries(String searchPath, Path emptyPathDefault) entries.add(getPath(s)); } catch (IllegalArgumentException e) { if (warn) { - log.warning(LintCategory.PATH, Warnings.InvalidPath(s)); + log.warning(LintWarnings.InvalidPath(s)); } } } @@ -319,8 +319,8 @@ public SearchPath addDirectories(String dirs) { private void addDirectory(Path dir, boolean warn) { if (!Files.isDirectory(dir)) { if (warn) { - log.warning(Lint.LintCategory.PATH, - Warnings.DirPathElementNotFound(dir)); + log.warning( + LintWarnings.DirPathElementNotFound(dir)); } return; } @@ -365,8 +365,8 @@ public void addFile(Path file, boolean warn) { if (!fsInfo.exists(file)) { /* No such file or directory exists */ if (warn) { - log.warning(Lint.LintCategory.PATH, - Warnings.PathElementNotFound(file)); + log.warning( + LintWarnings.PathElementNotFound(file)); } super.add(file); return; @@ -388,14 +388,14 @@ public void addFile(Path file, boolean warn) { try { FileSystems.newFileSystem(file, (ClassLoader)null).close(); if (warn) { - log.warning(Lint.LintCategory.PATH, - Warnings.UnexpectedArchiveFile(file)); + log.warning( + LintWarnings.UnexpectedArchiveFile(file)); } } catch (IOException | ProviderNotFoundException e) { // FIXME: include e.getLocalizedMessage in warning if (warn) { - log.warning(Lint.LintCategory.PATH, - Warnings.InvalidArchiveFile(file)); + log.warning( + LintWarnings.InvalidArchiveFile(file)); } return; } @@ -1660,9 +1660,9 @@ void add(Map> map, Path prefix, Path suffix) { if (!Files.isDirectory(prefix)) { if (warn) { Warning key = Files.exists(prefix) - ? Warnings.DirPathElementNotDirectory(prefix) - : Warnings.DirPathElementNotFound(prefix); - log.warning(Lint.LintCategory.PATH, key); + ? LintWarnings.DirPathElementNotDirectory(prefix) + : LintWarnings.DirPathElementNotFound(prefix); + log.warning(key); } return; } diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java index f70b96697b37b..7147e97289853 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java @@ -64,6 +64,7 @@ import com.sun.tools.javac.main.Option; import com.sun.tools.javac.resources.CompilerProperties.Errors; import com.sun.tools.javac.resources.CompilerProperties.Fragments; +import com.sun.tools.javac.resources.CompilerProperties.LintWarnings; import com.sun.tools.javac.resources.CompilerProperties.Warnings; import com.sun.tools.javac.util.*; import com.sun.tools.javac.util.ByteBuffer.UnderflowException; @@ -855,8 +856,8 @@ protected boolean accepts(AttributeKind kind) { if (lintClassfile && !warnedAttrs.contains(name)) { JavaFileObject prev = log.useSource(currentClassFile); try { - log.warning(LintCategory.CLASSFILE, (DiagnosticPosition) null, - Warnings.FutureAttr(name, version.major, version.minor, majorVersion, minorVersion)); + log.warning((DiagnosticPosition) null, + LintWarnings.FutureAttr(name, version.major, version.minor, majorVersion, minorVersion)); } finally { log.useSource(prev); } @@ -1610,7 +1611,7 @@ void readParameterAnnotations(Symbol meth) { //the RuntimeVisibleParameterAnnotations and RuntimeInvisibleParameterAnnotations //provide annotations for a different number of parameters, ignore: if (lintClassfile) { - log.warning(LintCategory.CLASSFILE, Warnings.RuntimeVisibleInvisibleParamAnnotationsMismatch(currentClassFile)); + log.warning(LintWarnings.RuntimeVisibleInvisibleParamAnnotationsMismatch(currentClassFile)); } for (int pnum = 0; pnum < numParameters; pnum++) { readAnnotations(); @@ -2078,9 +2079,9 @@ MethodSymbol findAccessMethod(Type container, Name name) { try { if (lintClassfile) { if (failure == null) { - log.warning(Warnings.AnnotationMethodNotFound(container, name)); + log.warning(LintWarnings.AnnotationMethodNotFound(container, name)); } else { - log.warning(Warnings.AnnotationMethodNotFoundReason(container, + log.warning(LintWarnings.AnnotationMethodNotFoundReason(container, name, failure.getDetailValue()));//diagnostic, if present } @@ -2960,7 +2961,7 @@ void adjustParameterAnnotations(MethodSymbol sym, Type methodDescriptor, private void dropParameterAnnotations() { parameterAnnotations = null; if (lintClassfile) { - log.warning(LintCategory.CLASSFILE, Warnings.RuntimeInvisibleParameterAnnotations(currentClassFile)); + log.warning(LintWarnings.RuntimeInvisibleParameterAnnotations(currentClassFile)); } } /** diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Arguments.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Arguments.java index 2af50832f96fc..1e8b85eb1437f 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Arguments.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Arguments.java @@ -63,6 +63,7 @@ import com.sun.tools.javac.platform.PlatformUtils; import com.sun.tools.javac.resources.CompilerProperties.Errors; import com.sun.tools.javac.resources.CompilerProperties.Fragments; +import com.sun.tools.javac.resources.CompilerProperties.LintWarnings; import com.sun.tools.javac.resources.CompilerProperties.Warnings; import com.sun.tools.javac.util.Context; import com.sun.tools.javac.util.JCDiagnostic; @@ -497,7 +498,7 @@ public boolean validate() { if (lintPaths) { Path outDirParent = outDir.getParent(); if (outDirParent != null && Files.exists(outDirParent.resolve("module-info.class"))) { - log.warning(LintCategory.PATH, Warnings.OutdirIsInExplodedModule(outDir)); + log.warning(LintWarnings.OutdirIsInExplodedModule(outDir)); } } } @@ -571,10 +572,10 @@ public boolean validate() { if (fm instanceof BaseFileManager baseFileManager) { if (source.compareTo(Source.JDK8) <= 0) { if (baseFileManager.isDefaultBootClassPath()) - log.warning(LintCategory.OPTIONS, Warnings.SourceNoBootclasspath(source.name, releaseNote(source, targetString))); + log.warning(LintWarnings.SourceNoBootclasspath(source.name, releaseNote(source, targetString))); } else { if (baseFileManager.isDefaultSystemModulesPath()) - log.warning(LintCategory.OPTIONS, Warnings.SourceNoSystemModulesPath(source.name, releaseNote(source, targetString))); + log.warning(LintWarnings.SourceNoSystemModulesPath(source.name, releaseNote(source, targetString))); } } } @@ -584,14 +585,14 @@ public boolean validate() { if (source.compareTo(Source.MIN) < 0) { log.error(Errors.OptionRemovedSource(source.name, Source.MIN.name)); } else if (source == Source.MIN && lintOptions) { - log.warning(LintCategory.OPTIONS, Warnings.OptionObsoleteSource(source.name)); + log.warning(LintWarnings.OptionObsoleteSource(source.name)); obsoleteOptionFound = true; } if (target.compareTo(Target.MIN) < 0) { log.error(Errors.OptionRemovedTarget(target, Target.MIN)); } else if (target == Target.MIN && lintOptions) { - log.warning(LintCategory.OPTIONS, Warnings.OptionObsoleteTarget(target)); + log.warning(LintWarnings.OptionObsoleteTarget(target)); obsoleteOptionFound = true; } @@ -625,7 +626,7 @@ public boolean validate() { } if (obsoleteOptionFound && lintOptions) { - log.warning(LintCategory.OPTIONS, Warnings.OptionObsoleteSuppression); + log.warning(LintWarnings.OptionObsoleteSuppression); } SourceVersion sv = Source.toSourceVersion(source); @@ -636,7 +637,7 @@ public boolean validate() { validateDefaultModuleForCreatedFiles(sv); if (lintOptions && options.isSet(Option.ADD_OPENS)) { - log.warning(LintCategory.OPTIONS, Warnings.AddopensIgnored); + log.warning(LintWarnings.AddopensIgnored); } return !errors && (log.nerrors == 0); diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java index a38658a315e2d..b25ca99eb88f7 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java @@ -33,14 +33,13 @@ import com.sun.tools.javac.file.JavacFileManager; import com.sun.tools.javac.parser.Tokens.Comment.CommentStyle; import com.sun.tools.javac.resources.CompilerProperties.Errors; +import com.sun.tools.javac.resources.CompilerProperties.LintWarnings; import com.sun.tools.javac.resources.CompilerProperties.Warnings; import com.sun.tools.javac.tree.EndPosTable; -import com.sun.tools.javac.tree.JCTree; import com.sun.tools.javac.util.*; import com.sun.tools.javac.util.JCDiagnostic.*; import java.nio.CharBuffer; -import java.util.Iterator; import java.util.Set; import static com.sun.tools.javac.parser.Tokens.*; @@ -222,13 +221,12 @@ protected void lexError(DiagnosticFlag flags, int pos, JCDiagnostic.Error key) { /** * Report an error at the given position using the provided arguments. * - * @param lc lint category. * @param pos position in input buffer. * @param key error key to report. */ - protected void lexWarning(LintCategory lc, int pos, JCDiagnostic.Warning key) { + protected void lexWarning(int pos, JCDiagnostic.Warning key) { DiagnosticPosition dp = new SimpleDiagnosticPosition(pos) ; - log.warning(lc, dp, key); + log.warning(dp, key); } /** @@ -1075,12 +1073,12 @@ public Token readToken() { Set checks = TextBlockSupport.checkWhitespace(string); if (checks.contains(TextBlockSupport.WhitespaceChecks.INCONSISTENT)) { - lexWarning(LintCategory.TEXT_BLOCKS, pos, - Warnings.InconsistentWhiteSpaceIndentation); + lexWarning(pos, + LintWarnings.InconsistentWhiteSpaceIndentation); } if (checks.contains(TextBlockSupport.WhitespaceChecks.TRAILING)) { - lexWarning(LintCategory.TEXT_BLOCKS, pos, - Warnings.TrailingWhiteSpaceWillBeRemoved); + lexWarning(pos, + LintWarnings.TrailingWhiteSpaceWillBeRemoved); } } // Remove incidental indentation. diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java index d975a6c927a10..1413c51191378 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java @@ -42,6 +42,7 @@ import com.sun.tools.javac.parser.Tokens.*; import com.sun.tools.javac.resources.CompilerProperties.Errors; import com.sun.tools.javac.resources.CompilerProperties.Fragments; +import com.sun.tools.javac.resources.CompilerProperties.LintWarnings; import com.sun.tools.javac.resources.CompilerProperties.Warnings; import com.sun.tools.javac.tree.*; import com.sun.tools.javac.tree.JCTree.*; @@ -669,8 +670,8 @@ void reportDanglingDocComment(Comment c) { deferredLintHandler.report(lint -> { if (lint.isEnabled(Lint.LintCategory.DANGLING_DOC_COMMENTS) && !shebang(c, pos)) { - log.warning(Lint.LintCategory.DANGLING_DOC_COMMENTS, - pos, Warnings.DanglingDocComment); + log.warning( + pos, LintWarnings.DanglingDocComment); } }); } diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacFiler.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacFiler.java index 1c3f8ba96f882..3f30bee31f935 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacFiler.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacFiler.java @@ -57,6 +57,7 @@ import com.sun.tools.javac.code.Symtab; import com.sun.tools.javac.comp.Modules; import com.sun.tools.javac.model.JavacElements; +import com.sun.tools.javac.resources.CompilerProperties.LintWarnings; import com.sun.tools.javac.resources.CompilerProperties.Warnings; import com.sun.tools.javac.util.*; import com.sun.tools.javac.util.DefinedBy.Api; @@ -492,7 +493,7 @@ private JavaFileObject createSourceOrClassFile(ModuleSymbol mod, boolean isSourc String base = name.substring(periodIndex); String extn = (isSourceFile ? ".java" : ".class"); if (base.equals(extn)) - log.warning(Warnings.ProcSuspiciousClassName(name, extn)); + log.warning(LintWarnings.ProcSuspiciousClassName(name, extn)); } } checkNameAndExistence(mod, name, isSourceFile); @@ -708,7 +709,7 @@ private void checkName(String name) throws FilerException { private void checkName(String name, boolean allowUnnamedPackageInfo) throws FilerException { if (!SourceVersion.isName(name) && !isPackageInfo(name, allowUnnamedPackageInfo)) { if (lint) - log.warning(Warnings.ProcIllegalFileName(name)); + log.warning(LintWarnings.ProcIllegalFileName(name)); throw new FilerException("Illegal name " + name); } } @@ -737,11 +738,11 @@ private void checkNameAndExistence(ModuleSymbol mod, String typename, boolean al containedInInitialInputs(typename); if (alreadySeen) { if (lint) - log.warning(Warnings.ProcTypeRecreate(typename)); + log.warning(LintWarnings.ProcTypeRecreate(typename)); throw new FilerException("Attempt to recreate a file for type " + typename); } if (lint && existing != null) { - log.warning(Warnings.ProcTypeAlreadyExists(typename)); + log.warning(LintWarnings.ProcTypeAlreadyExists(typename)); } if (!mod.isUnnamed() && !typename.contains(".")) { throw new FilerException("Attempt to create a type in unnamed package of a named module: " + typename); @@ -771,7 +772,7 @@ private boolean containedInInitialInputs(String typename) { private void checkFileReopening(FileObject fileObject, boolean forWriting) throws FilerException { if (isInFileObjectHistory(fileObject, forWriting)) { if (lint) - log.warning(Warnings.ProcFileReopening(fileObject.getName())); + log.warning(LintWarnings.ProcFileReopening(fileObject.getName())); throw new FilerException("Attempt to reopen a file for path " + fileObject.getName()); } if (forWriting) diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java index 4ea1c488875c9..23e1e348cf91f 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java @@ -66,6 +66,7 @@ import com.sun.tools.javac.platform.PlatformDescription; import com.sun.tools.javac.platform.PlatformDescription.PluginInfo; import com.sun.tools.javac.resources.CompilerProperties.Errors; +import com.sun.tools.javac.resources.CompilerProperties.LintWarnings; import com.sun.tools.javac.resources.CompilerProperties.Warnings; import com.sun.tools.javac.tree.*; import com.sun.tools.javac.tree.JCTree.*; @@ -648,7 +649,7 @@ static class ProcessorState { add(importStringToPattern(allowModules, annotationPattern, processor, log, lint)); if (lint && !patternAdded) { - log.warning(Warnings.ProcDuplicateSupportedAnnotation(annotationPattern, + log.warning(LintWarnings.ProcDuplicateSupportedAnnotation(annotationPattern, p.getClass().getName())); } } @@ -662,7 +663,7 @@ static class ProcessorState { if (lint && supportedAnnotationPatterns.contains(MatchingUtils.validImportStringToPattern("*")) && supportedAnnotationPatterns.size() > 1) { - log.warning(Warnings.ProcRedundantTypesWithWildcard(p.getClass().getName())); + log.warning(LintWarnings.ProcRedundantTypesWithWildcard(p.getClass().getName())); } supportedOptionNames = new LinkedHashSet<>(); @@ -670,7 +671,7 @@ static class ProcessorState { if (checkOptionName(optionName, log)) { boolean optionAdded = supportedOptionNames.add(optionName); if (lint && !optionAdded) { - log.warning(Warnings.ProcDuplicateOptionName(optionName, + log.warning(LintWarnings.ProcDuplicateOptionName(optionName, p.getClass().getName())); } } @@ -891,7 +892,7 @@ private void discoverAndRunProcs(Set annotationsPresent, // Remove annotations processed by javac unmatchedAnnotations.keySet().removeAll(platformAnnotations); if (unmatchedAnnotations.size() > 0) { - log.warning(Warnings.ProcAnnotationsWithoutProcessors(unmatchedAnnotations.keySet())); + log.warning(LintWarnings.ProcAnnotationsWithoutProcessors(unmatchedAnnotations.keySet())); } } @@ -1688,7 +1689,7 @@ private static Pattern importStringToPattern(boolean allowModules, String s, Pro private static Pattern warnAndNoMatches(String s, Processor p, Log log, boolean lint) { if (lint) { - log.warning(Warnings.ProcMalformedSupportedString(s, p.getClass().getName())); + log.warning(LintWarnings.ProcMalformedSupportedString(s, p.getClass().getName())); } return noMatches; // won't match any valid identifier } diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties index 96944f698ddb0..13041b44ac0a4 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties @@ -708,9 +708,11 @@ compiler.err.not.in.profile=\ compiler.warn.forward.ref=\ reference to variable ''{0}'' before it has been initialized +# lint: this-escape compiler.warn.possible.this.escape=\ possible ''this'' escape before subclass is fully initialized +# lint: this-escape compiler.warn.possible.this.escape.location=\ previous possible ''this'' escape happens here via invocation @@ -731,9 +733,11 @@ compiler.err.illegal.line.end.in.char.lit=\ compiler.err.illegal.text.block.open=\ illegal text block open delimiter sequence, missing line terminator +# lint: text-blocks compiler.warn.inconsistent.white.space.indentation=\ inconsistent white space indentation +# lint: text-blocks compiler.warn.trailing.white.space.will.be.removed=\ trailing white space will be removed @@ -1591,6 +1595,7 @@ compiler.err.multi-module.outdir.cannot.be.exploded.module=\ in multi-module mode, the output directory cannot be an exploded module: {0} # 0: path +# lint: path compiler.warn.outdir.is.in.exploded.module=\ the output directory is within an exploded module: {0} @@ -1658,6 +1663,7 @@ compiler.warn.file.from.future=\ Modification date is in the future for file {0} # 0: path +# lint: output-file-clash compiler.warn.output.file.clash=\ output file written more than once: {0} @@ -1870,47 +1876,59 @@ compiler.warn.lintOption=\ [{0}]\u0020 # 0: symbol +# lint: serial compiler.warn.constant.SVUID=\ serialVersionUID must be constant in class {0} +# lint: dangling compiler.warn.dangling.doc.comment=\ documentation comment is not attached to any declaration # 0: path +# lint: path compiler.warn.dir.path.element.not.found=\ bad path element "{0}": no such directory # 0: file name +# lint: path compiler.warn.dir.path.element.not.directory=\ bad path element "{0}": not a directory # 0: symbol, 1: symbol, 2: symbol +# lint: missing-explicit-ctor compiler.warn.missing-explicit-ctor=\ class {0} in exported package {1} declares no explicit constructors, thereby exposing a default constructor to clients of module {2} +# lint: strictfp compiler.warn.strictfp=\ as of release 17, all floating-point expressions are evaluated strictly and ''strictfp'' is not required +# lint: finally compiler.warn.finally.cannot.complete=\ finally clause cannot complete normally # 0: name +# lint: module compiler.warn.poor.choice.for.module.name=\ module name component {0} should avoid terminal digits # 0: string +# lint: incubating compiler.warn.incubating.modules=\ using incubating module(s): {0} # 0: symbol, 1: symbol +# lint: deprecation compiler.warn.has.been.deprecated=\ {0} in {1} has been deprecated # 0: symbol, 1: symbol +# lint: removal compiler.warn.has.been.deprecated.for.removal=\ {0} in {1} has been deprecated and marked for removal # 0: symbol +# lint: preview compiler.warn.is.preview=\ {0} is a preview API and may be removed in a future release. @@ -1920,19 +1938,23 @@ compiler.err.is.preview=\ (use --enable-preview to enable preview APIs) # 0: symbol +# lint: preview compiler.warn.is.preview.reflective=\ {0} is a reflective preview API and may be removed in a future release. # 0: symbol, 1: symbol +# lint: restricted compiler.warn.restricted.method=\ {0}.{1} is a restricted method.\n\ (Restricted methods are unsafe and, if used incorrectly, might crash the Java runtime or corrupt memory) # 0: symbol +# lint: deprecation compiler.warn.has.been.deprecated.module=\ module {0} has been deprecated # 0: symbol +# lint: removal compiler.warn.has.been.deprecated.for.removal.module=\ module {0} has been deprecated and marked for removal @@ -1944,12 +1966,15 @@ compiler.warn.illegal.char.for.encoding=\ unmappable character for encoding {0} # 0: symbol +# lint: serial compiler.warn.improper.SVUID=\ serialVersionUID must be declared static final in class {0} +# lint: serial compiler.warn.improper.SPF=\ serialPersistentFields must be declared private static final to be effective +# lint: serial compiler.warn.SPF.null.init=\ serialPersistentFields ineffective if initialized to null.\n\ Initialize to an empty array to indicate no fields @@ -1972,112 +1997,141 @@ compiler.warn.unreachable.catch.1=\ thrown types {0} have already been caught # 0: symbol +# lint: serial compiler.warn.long.SVUID=\ serialVersionUID must be of type long in class {0} +# lint: serial compiler.warn.OSF.array.SPF=\ serialPersistentFields must be of type java.io.ObjectStreamField[] to be effective # 0: symbol +# lint: serial compiler.warn.missing.SVUID=\ serializable class {0} has no definition of serialVersionUID # 0: name +# lint: serial compiler.warn.serializable.missing.access.no.arg.ctor=\ cannot access a no-arg constructor in first non-serializable superclass {0} # 0: name +# lint: serial compiler.warn.serial.method.not.private=\ serialization-related method {0} not declared private # 0: name +# lint: serial compiler.warn.serial.concrete.instance.method=\ serialization-related method {0} must be a concrete instance method to be effective, neither abstract nor static # 0: name +# lint: serial compiler.warn.serial.method.static=\ serialization-related method {0} declared static; must instead be an instance method to be effective # 0: name +# lint: serial compiler.warn.serial.method.no.args=\ to be effective serialization-related method {0} must have no parameters # 0: name, 1: number +# lint: serial compiler.warn.serial.method.one.arg=\ to be effective serialization-related method {0} must have exactly one parameter rather than {1} parameters # 0: name, 1: type, 2: type +# lint: serial compiler.warn.serial.method.parameter.type=\ sole parameter of serialization-related method {0} must have type {1} to be effective rather than type {2} # 0: name, 1: type, 2: type +# lint: serial compiler.warn.serial.method.unexpected.return.type=\ serialization-related method {0} declared with a return type of {1} rather than expected type {2}.\n\ As declared, the method will be ineffective for serialization # 0: name, 1: type +# lint: serial compiler.warn.serial.method.unexpected.exception=\ serialization-related method {0} declared to throw an unexpected type {1} +# lint: serial compiler.warn.ineffectual.serial.field.interface=\ serialPersistentFields is not effective in an interface # 0: string +# lint: serial compiler.warn.ineffectual.serial.field.enum=\ serialization-related field {0} is not effective in an enum class # 0: string +# lint: serial compiler.warn.ineffectual.serial.method.enum=\ serialization-related method {0} is not effective in an enum class # 0: string +# lint: serial compiler.warn.ineffectual.extern.method.enum=\ externalization-related method {0} is not effective in an enum class +# lint: serial compiler.warn.ineffectual.serial.field.record=\ serialPersistentFields is not effective in a record class # 0: string +# lint: serial compiler.warn.ineffectual.serial.method.record=\ serialization-related method {0} is not effective in a record class # 0: string +# lint: serial compiler.warn.ineffectual.externalizable.method.record=\ externalization-related method {0} is not effective in a record class # 0: name +# lint: serial compiler.warn.ineffectual.serial.method.externalizable=\ serialization-related method {0} is not effective in an Externalizable class +# lint: serial compiler.warn.ineffectual.serial.field.externalizable=\ serialPersistentFields is not effective in an Externalizable class +# lint: serial compiler.warn.externalizable.missing.public.no.arg.ctor=\ an Externalizable class needs a public no-arg constructor +# lint: serial compiler.warn.non.serializable.instance.field=\ non-transient instance field of a serializable class declared with a non-serializable type # 0: type +# lint: serial compiler.warn.non.serializable.instance.field.array=\ non-transient instance field of a serializable class declared with an array having a non-serializable base component type {0} +# lint: serial compiler.warn.non.private.method.weaker.access=\ serialization-related method declared non-private in an interface will prevent\n\ classes implementing the interface from declaring the method as private +# lint: serial compiler.warn.default.ineffective=\ serialization-related default method from an interface will not be run by serialization for an implementing class # 0: symbol, 1: symbol, 2: symbol, 3: symbol +# lint: overloads compiler.warn.potentially.ambiguous.overload=\ {0} in {1} is potentially ambiguous with {2} in {3} # 0: message segment +# lint: overrides compiler.warn.override.varargs.missing=\ {0}; overridden method has no ''...'' # 0: message segment +# lint: overrides compiler.warn.override.varargs.extra=\ {0}; overriding method is missing ''...'' @@ -2090,13 +2144,16 @@ compiler.warn.pkg-info.already.seen=\ a package-info.java file has already been seen for package {0} # 0: path +# lint: path compiler.warn.path.element.not.found=\ bad path element "{0}": no such file or directory +# lint: fallthrough compiler.warn.possible.fall-through.into.case=\ possible fall-through into case # 0: type +# lint: cast compiler.warn.redundant.cast=\ redundant cast to {0} @@ -2114,18 +2171,22 @@ compiler.warn.invalid.utf8.in.classfile=\ {0}: classfile contains invalid UTF-8: {1} # 0: kind name, 1: symbol +# lint: static compiler.warn.static.not.qualified.by.type=\ static {0} should be qualified by type name, {1}, instead of by an expression # 0: kind name +# lint: static compiler.warn.static.not.qualified.by.type2=\ static {0} should not be used as a member of an anonymous class # 0: string, 1: fragment +# lint: options compiler.warn.source.no.bootclasspath=\ bootstrap class path is not set in conjunction with -source {0}\n{1} # 0: string, 1: fragment +# lint: options compiler.warn.source.no.system.modules.path=\ location of system modules is not set in conjunction with -source {0}\n{1} @@ -2150,10 +2211,12 @@ compiler.misc.source.no.system.modules.path.with.target=\ --release {0} is recommended instead of -source {0} -target {1} because it sets the location of system modules automatically # 0: string +# lint: options compiler.warn.option.obsolete.source=\ source value {0} is obsolete and will be removed in a future release # 0: target +# lint: options compiler.warn.option.obsolete.target=\ target value {0} is obsolete and will be removed in a future release @@ -2165,16 +2228,20 @@ compiler.err.option.removed.source=\ compiler.err.option.removed.target=\ Target option {0} is no longer supported. Use {1} or later. +# lint: options compiler.warn.option.obsolete.suppression=\ To suppress warnings about obsolete options, use -Xlint:-options. # 0: name, 1: number, 2: number, 3: number, 4: number +# lint: classfile compiler.warn.future.attr=\ {0} attribute introduced in version {1}.{2} class files is ignored in version {3}.{4} class files +# lint: requires-automatic compiler.warn.requires.automatic=\ requires directive for an automatic module +# lint: requires-transitive-automatic compiler.warn.requires.transitive.automatic=\ requires transitive directive for an automatic module @@ -2184,22 +2251,27 @@ compiler.warn.proc.package.does.not.exist=\ package {0} does not exist # 0: string +# lint: processing compiler.warn.proc.file.reopening=\ Attempt to create a file for ''{0}'' multiple times # 0: string +# lint: processing compiler.warn.proc.type.already.exists=\ A file for type ''{0}'' already exists on the sourcepath or classpath # 0: string +# lint: processing compiler.warn.proc.type.recreate=\ Attempt to create a file for type ''{0}'' multiple times # 0: string +# lint: processing compiler.warn.proc.illegal.file.name=\ Cannot create file for illegal name ''{0}''. # 0: string, 1: string +# lint: processing compiler.warn.proc.suspicious.class.name=\ Creating file for a type whose name ends in {1}: ''{0}'' @@ -2208,10 +2280,12 @@ compiler.warn.proc.file.create.last.round=\ File for type ''{0}'' created in the last round will not be subject to annotation processing. # 0: string, 1: string +# lint: processing compiler.warn.proc.malformed.supported.string=\ Malformed string ''{0}'' for a supported annotation interface returned by processor ''{1}'' # 0: set of string +# lint: processing compiler.warn.proc.annotations.without.processors=\ No processor claimed any of these annotations: {0} @@ -2220,15 +2294,18 @@ compiler.warn.proc.processor.incompatible.source.version=\ Supported source version ''{0}'' from annotation processor ''{1}'' less than -source ''{2}'' # 0: string, 1: string +# lint: processing compiler.warn.proc.duplicate.option.name=\ Duplicate supported option ''{0}'' returned by annotation processor ''{1}'' # 0: string, 1: string +# lint: processing compiler.warn.proc.duplicate.supported.annotation=\ Duplicate supported annotation interface ''{0}'' returned by annotation processor ''{1}'' # 0: string +# lint: processing compiler.warn.proc.redundant.types.with.wildcard=\ Annotation processor ''{0}'' redundantly supports both ''*'' and other annotation interfaces @@ -2256,57 +2333,71 @@ compiler.warn.proc.unclosed.type.files=\ compiler.warn.proc.unmatched.processor.options=\ The following options were not recognized by any processor: ''{0}'' +# lint: try compiler.warn.try.explicit.close.call=\ explicit call to close() on an auto-closeable resource # 0: symbol +# lint: try compiler.warn.try.resource.not.referenced=\ auto-closeable resource {0} is never referenced in body of corresponding try statement # 0: type +# lint: try compiler.warn.try.resource.throws.interrupted.exc=\ auto-closeable resource {0} has a member method close() that could throw InterruptedException +# lint: unchecked compiler.warn.unchecked.assign=\ unchecked assignment: {0} to {1} # 0: symbol, 1: type +# lint: unchecked compiler.warn.unchecked.assign.to.var=\ unchecked assignment to variable {0} as member of raw type {1} # 0: symbol, 1: type +# lint: unchecked compiler.warn.unchecked.call.mbr.of.raw.type=\ unchecked call to {0} as a member of the raw type {1} +# lint: unchecked compiler.warn.unchecked.cast.to.type=\ unchecked cast to type {0} # 0: kind name, 1: name, 2: object, 3: object, 4: kind name, 5: symbol +# lint: unchecked compiler.warn.unchecked.meth.invocation.applied=\ unchecked method invocation: {0} {1} in {4} {5} is applied to given types\n\ required: {2}\n\ found: {3} # 0: type +# lint: unchecked compiler.warn.unchecked.generic.array.creation=\ unchecked generic array creation for varargs parameter of type {0} # 0: type +# lint: unchecked compiler.warn.unchecked.varargs.non.reifiable.type=\ Possible heap pollution from parameterized vararg type {0} # 0: symbol +# lint: varargs compiler.warn.varargs.unsafe.use.varargs.param=\ Varargs method could cause heap pollution from non-reifiable varargs parameter {0} +# lint: dep-ann compiler.warn.missing.deprecated.annotation=\ deprecated item is not annotated with @Deprecated # 0: kind name +# lint: deprecation compiler.warn.deprecated.annotation.has.no.effect=\ @Deprecated annotation has no effect on this {0} declaration # 0: string +# lint: path compiler.warn.invalid.path=\ Invalid filename: {0} @@ -2319,10 +2410,12 @@ compiler.err.invalid.path=\ # 0: path +# lint: path compiler.warn.invalid.archive.file=\ Unexpected file on path: {0} # 0: path +# lint: path compiler.warn.unexpected.archive.file=\ Unexpected extension for archive file: {0} @@ -2330,17 +2423,21 @@ compiler.warn.unexpected.archive.file=\ compiler.err.no.zipfs.for.archive=\ No file system provider is available to handle this file: {0} +# lint: divzero compiler.warn.div.zero=\ division by zero +# lint: empty compiler.warn.empty.if=\ empty statement after if # 0: type, 1: name +# lint: classfile compiler.warn.annotation.method.not.found=\ Cannot find annotation method ''{1}()'' in type ''{0}'' # 0: type, 1: name, 2: message segment +# lint: classfile compiler.warn.annotation.method.not.found.reason=\ Cannot find annotation method ''{1}()'' in type ''{0}'': {2} @@ -2359,6 +2456,7 @@ compiler.warn.unknown.enum.constant.reason=\ reason: {3} # 0: type, 1: type +# lint: rawtypes compiler.warn.raw.class.use=\ found raw type: {0}\n\ missing type arguments for generic class {1} @@ -2376,14 +2474,17 @@ compiler.warn.method.redundant.typeargs=\ Redundant type arguments in method call. # 0: symbol, 1: message segment +# lint: varargs compiler.warn.varargs.redundant.trustme.anno=\ Redundant {0} annotation. {1} # 0: symbol +# lint: serial compiler.warn.access.to.member.from.serializable.element=\ access to member {0} from serializable element can be publicly accessible to untrusted code # 0: symbol +# lint: serial compiler.warn.access.to.member.from.serializable.lambda=\ access to member {0} from serializable lambda can be publicly accessible to untrusted code @@ -2541,12 +2642,14 @@ compiler.misc.bad.enclosing.method=\ bad enclosing method attribute for class {0} # 0: file name +# lint: classfile compiler.warn.runtime.visible.invisible.param.annotations.mismatch=\ the length of parameters in RuntimeVisibleParameterAnnotations attribute and \ RuntimeInvisibleParameterAnnotations attribute in: {0} \ do not match, ignoring both attributes # 0: file name +# lint: classfile compiler.warn.runtime.invisible.parameter.annotations=\ the RuntimeVisibleParameterAnnotations and RuntimeInvisibleParameterAnnotations attributes \ in: {0} \ @@ -2673,6 +2776,7 @@ compiler.misc.prob.found.req=\ incompatible types: {0} # 0: message segment, 1: type, 2: type +# lint: unchecked compiler.warn.prob.found.req=\ {0}\n\ required: {2}\n\ @@ -2687,6 +2791,7 @@ compiler.misc.possible.loss.of.precision=\ possible lossy conversion from {0} to {1} # 0: type, 1: type +# lint: lossy-conversions compiler.warn.possible.loss.of.precision=\ implicit cast from {0} to {1} in compound assignment is possibly lossy @@ -2862,6 +2967,7 @@ compiler.misc.varargs.argument.mismatch=\ ##### # 0: symbol or type, 1: file name +# lint: auxiliaryclass compiler.warn.auxiliary.class.accessed.from.outside.of.its.source.file=\ auxiliary class {0} in {1} should not be accessed from outside its own source file @@ -3066,16 +3172,19 @@ compiler.err.override.incompatible.ret=\ return type {1} is not compatible with {2} # 0: message segment, 1: type, 2: type +# lint: unchecked compiler.warn.override.unchecked.ret=\ {0}\n\ return type requires unchecked conversion from {1} to {2} # 0: message segment, 1: type +# lint: unchecked compiler.warn.override.unchecked.thrown=\ {0}\n\ overridden method does not throw {1} # 0: symbol +# lint: overrides compiler.warn.override.equals.but.not.hashcode=\ Class {0} overrides equals, but neither it nor any superclass overrides hashCode method @@ -3168,14 +3277,17 @@ compiler.err.preview.feature.disabled.classfile=\ (use --enable-preview to allow loading of class files which contain preview features) # 0: message segment (feature) +# lint: preview compiler.warn.preview.feature.use=\ {0} is a preview feature and may be removed in a future release. # 0: message segment (feature) +# lint: preview compiler.warn.preview.feature.use.plural=\ {0} are a preview feature and may be removed in a future release. # 0: file object (classfile), 1: string (expected version) +# lint: preview compiler.warn.preview.feature.use.classfile=\ class file for {0} uses preview features of Java SE {1}. @@ -3558,6 +3670,7 @@ compiler.err.module.not.found=\ module not found: {0} # 0: symbol +# lint: module compiler.warn.module.not.found=\ module not found: {0} @@ -3653,6 +3766,7 @@ compiler.err.package.empty.or.not.found=\ package is empty or does not exist: {0} # 0: symbol +# lint: opens compiler.warn.package.empty.or.not.found=\ package is empty or does not exist: {0} @@ -3736,6 +3850,7 @@ compiler.err.bad.name.for.option=\ bad name in value for {0} option: ''{1}'' # 0: option name, 1: symbol +# lint: options compiler.warn.module.for.option.not.found=\ module name in {0} option not found: {1} @@ -3751,6 +3866,7 @@ compiler.err.add.exports.with.release=\ compiler.err.add.reads.with.release=\ adding read edges for system module {0} is not allowed with --release +# lint: options compiler.warn.addopens.ignored=\ --add-opens has no effect at compile time @@ -3781,15 +3897,19 @@ compiler.warn.service.provided.but.not.exported.or.used=\ service interface provided but not exported or used # 0: kind name, 1: symbol, 2: symbol +# lint: exports compiler.warn.leaks.not.accessible=\ {0} {1} in module {2} is not accessible to clients that require this module # 0: kind name, 1: symbol, 2: symbol +# lint: exports compiler.warn.leaks.not.accessible.unexported=\ {0} {1} in module {2} is not exported # 0: kind name, 1: symbol, 2: symbol +# lint: exports compiler.warn.leaks.not.accessible.not.required.transitive=\ {0} {1} in module {2} is not indirectly exported using ''requires transitive'' # 0: kind name, 1: symbol, 2: symbol +# lint: exports compiler.warn.leaks.not.accessible.unexported.qualified=\ {0} {1} in module {2} may not be visible to all clients that require this module @@ -4119,9 +4239,11 @@ compiler.err.incorrect.number.of.nested.patterns=\ found: {1} # 0: kind name, 1: symbol +# lint: preview compiler.warn.declared.using.preview=\ {0} {1} is declared using a preview feature, which may be removed in a future release. +# lint: synchronization compiler.warn.attempt.to.synchronize.on.instance.of.value.based.class=\ attempt to synchronize on an instance of a value-based class diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/util/AbstractLog.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/util/AbstractLog.java index d303b5f710f05..59730448bf53a 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/util/AbstractLog.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/util/AbstractLog.java @@ -29,7 +29,6 @@ import java.util.Map; import javax.tools.JavaFileObject; -import com.sun.tools.javac.code.Lint.LintCategory; import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag; import com.sun.tools.javac.util.JCDiagnostic.Error; import com.sun.tools.javac.util.JCDiagnostic.Note; @@ -155,21 +154,14 @@ public void error(DiagnosticFlag flag, int pos, Error errorKey) { report(diags.error(flag, source, wrap(pos), errorKey)); } - /** Report a warning, unless suppressed by the -nowarn option or the - * maximum number of warnings has been reached. - * @param warningKey The key for the localized warning message. + /** + * Report a lint warning, unless suppressed by the -nowarn option or the + * maximum number of warnings has been reached. + * + * @param warningKey The key for the localized warning message. */ public void warning(Warning warningKey) { - report(diags.warning(null, source, null, warningKey)); - } - - /** Report a lint warning, unless suppressed by the -nowarn option or the - * maximum number of warnings has been reached. - * @param lc The lint category for the diagnostic - * @param warningKey The key for the localized warning message. - */ - public void warning(LintCategory lc, Warning warningKey) { - report(diags.warning(lc, null, null, warningKey)); + report(diags.warning(source, null, warningKey)); } /** Report a warning, unless suppressed by the -nowarn option or the @@ -178,17 +170,7 @@ public void warning(LintCategory lc, Warning warningKey) { * @param warningKey The key for the localized warning message. */ public void warning(DiagnosticPosition pos, Warning warningKey) { - report(diags.warning(null, source, pos, warningKey)); - } - - /** Report a lint warning, unless suppressed by the -nowarn option or the - * maximum number of warnings has been reached. - * @param lc The lint category for the diagnostic - * @param pos The source position at which to report the warning. - * @param warningKey The key for the localized warning message. - */ - public void warning(LintCategory lc, DiagnosticPosition pos, Warning warningKey) { - report(diags.warning(lc, source, pos, warningKey)); + report(diags.warning(source, pos, warningKey)); } /** Report a warning, unless suppressed by the -nowarn option or the @@ -197,7 +179,7 @@ public void warning(LintCategory lc, DiagnosticPosition pos, Warning warningKey) * @param warningKey The key for the localized warning message. */ public void warning(int pos, Warning warningKey) { - report(diags.warning(null, source, wrap(pos), warningKey)); + report(diags.warning(source, wrap(pos), warningKey)); } /** Report a warning. @@ -205,16 +187,7 @@ public void warning(int pos, Warning warningKey) { * @param warningKey The key for the localized warning message. */ public void mandatoryWarning(DiagnosticPosition pos, Warning warningKey) { - report(diags.mandatoryWarning(null, source, pos, warningKey)); - } - - /** Report a warning. - * @param lc The lint category for the diagnostic - * @param pos The source position at which to report the warning. - * @param warningKey The key for the localized warning message. - */ - public void mandatoryWarning(LintCategory lc, DiagnosticPosition pos, Warning warningKey) { - report(diags.mandatoryWarning(lc, source, pos, warningKey)); + report(diags.mandatoryWarning(source, pos, warningKey)); } /** Provide a non-fatal notification, unless suppressed by the -nowarn option. diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/util/JCDiagnostic.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/util/JCDiagnostic.java index 907539d540ecb..053a24e39ce0e 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/util/JCDiagnostic.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/util/JCDiagnostic.java @@ -111,7 +111,7 @@ public JCDiagnostic error( */ public JCDiagnostic error( DiagnosticFlag flag, DiagnosticSource source, DiagnosticPosition pos, Error errorKey) { - JCDiagnostic diag = create(null, EnumSet.copyOf(defaultErrorFlags), source, pos, errorKey); + JCDiagnostic diag = create(EnumSet.copyOf(defaultErrorFlags), source, pos, errorKey); if (flag != null) { diag.setFlag(flag); } @@ -130,21 +130,19 @@ public JCDiagnostic error( public JCDiagnostic mandatoryWarning( LintCategory lc, DiagnosticSource source, DiagnosticPosition pos, String key, Object... args) { - return mandatoryWarning(lc, source, pos, warningKey(key, args)); + return mandatoryWarning(source, pos, warningKey(lc, key, args)); } /** * Create a warning diagnostic that will not be hidden by the -nowarn or -Xlint:none options. - * @param lc The lint category for the diagnostic * @param source The source of the compilation unit, if any, in which to report the warning. * @param pos The source position at which to report the warning. * @param warningKey The key for the localized warning message. * @see MandatoryWarningHandler */ public JCDiagnostic mandatoryWarning( - LintCategory lc, DiagnosticSource source, DiagnosticPosition pos, Warning warningKey) { - return create(lc, EnumSet.of(DiagnosticFlag.MANDATORY), source, pos, warningKey); + return create(EnumSet.of(DiagnosticFlag.MANDATORY), source, pos, warningKey); } /** @@ -158,20 +156,19 @@ public JCDiagnostic mandatoryWarning( */ public JCDiagnostic warning( LintCategory lc, DiagnosticSource source, DiagnosticPosition pos, String key, Object... args) { - return warning(lc, source, pos, warningKey(key, args)); + return warning(source, pos, warningKey(lc, key, args)); } /** * Create a warning diagnostic. - * @param lc The lint category for the diagnostic * @param source The source of the compilation unit, if any, in which to report the warning. * @param pos The source position at which to report the warning. * @param warningKey The key for the localized warning message. * @see MandatoryWarningHandler */ public JCDiagnostic warning( - LintCategory lc, DiagnosticSource source, DiagnosticPosition pos, Warning warningKey) { - return create(lc, EnumSet.noneOf(DiagnosticFlag.class), source, pos, warningKey); + DiagnosticSource source, DiagnosticPosition pos, Warning warningKey) { + return create(EnumSet.noneOf(DiagnosticFlag.class), source, pos, warningKey); } /** @@ -191,7 +188,7 @@ public JCDiagnostic mandatoryNote(DiagnosticSource source, String key, Object... * @see MandatoryWarningHandler */ public JCDiagnostic mandatoryNote(DiagnosticSource source, Note noteKey) { - return create(null, EnumSet.of(DiagnosticFlag.MANDATORY), source, null, noteKey); + return create(EnumSet.of(DiagnosticFlag.MANDATORY), source, null, noteKey); } /** @@ -212,7 +209,7 @@ public JCDiagnostic note( */ public JCDiagnostic note( DiagnosticSource source, DiagnosticPosition pos, Note noteKey) { - return create(null, EnumSet.noneOf(DiagnosticFlag.class), source, pos, noteKey); + return create(EnumSet.noneOf(DiagnosticFlag.class), source, pos, noteKey); } /** @@ -229,7 +226,7 @@ public JCDiagnostic fragment(String key, Object... args) { * @param fragmentKey The key for the localized subdiagnostic message. */ public JCDiagnostic fragment(Fragment fragmentKey) { - return create(null, EnumSet.noneOf(DiagnosticFlag.class), null, null, fragmentKey); + return create(EnumSet.noneOf(DiagnosticFlag.class), null, null, fragmentKey); } /** @@ -243,7 +240,7 @@ public JCDiagnostic fragment(Fragment fragmentKey) { */ public JCDiagnostic create( DiagnosticType kind, DiagnosticSource source, DiagnosticPosition pos, String key, Object... args) { - return create(null, EnumSet.noneOf(DiagnosticFlag.class), source, pos, DiagnosticInfo.of(kind, prefix, key, args)); + return create(EnumSet.noneOf(DiagnosticFlag.class), source, pos, DiagnosticInfo.of(kind, prefix, key, args)); } /** @@ -258,7 +255,7 @@ public JCDiagnostic create( */ public JCDiagnostic create( DiagnosticType kind, DiagnosticSource source, DiagnosticPosition pos, String key, UnaryOperator rewriter, Object... args) { - return create(null, EnumSet.noneOf(DiagnosticFlag.class), source, pos, DiagnosticInfo.of(kind, prefix, key, args), rewriter); + return create(EnumSet.noneOf(DiagnosticFlag.class), source, pos, DiagnosticInfo.of(kind, prefix, key, args), rewriter); } /** @@ -270,7 +267,7 @@ public JCDiagnostic create( */ public JCDiagnostic create( DiagnosticSource source, DiagnosticPosition pos, DiagnosticInfo diagnosticInfo) { - return create(null, EnumSet.noneOf(DiagnosticFlag.class), source, pos, diagnosticInfo); + return create(EnumSet.noneOf(DiagnosticFlag.class), source, pos, diagnosticInfo); } /** @@ -285,30 +282,31 @@ public JCDiagnostic create( */ public JCDiagnostic create(DiagnosticType kind, LintCategory lc, Set flags, DiagnosticSource source, DiagnosticPosition pos, String key, Object... args) { - return create(lc, flags, source, pos, DiagnosticInfo.of(kind, prefix, key, args)); + return create(flags, source, pos, DiagnosticInfo.of(kind, lc, prefix, key, args)); } /** * Create a new diagnostic with given key. - * @param lc The lint category, if applicable, or null * @param flags The set of flags for the diagnostic * @param source The source of the compilation unit, if any, in which to report the message. * @param pos The source position at which to report the message. * @param diagnosticInfo The key for the localized message. */ public JCDiagnostic create( - LintCategory lc, Set flags, DiagnosticSource source, DiagnosticPosition pos, DiagnosticInfo diagnosticInfo) { - return new JCDiagnostic(formatter, normalize(diagnosticInfo), lc, flags, source, pos); + Set flags, DiagnosticSource source, DiagnosticPosition pos, DiagnosticInfo diagnosticInfo) { + return new JCDiagnostic(formatter, normalize(diagnosticInfo), flags, source, pos); } public JCDiagnostic create( - LintCategory lc, Set flags, DiagnosticSource source, DiagnosticPosition pos, DiagnosticInfo diagnosticInfo, UnaryOperator rewriter) { - return new JCDiagnostic(formatter, normalize(diagnosticInfo), lc, flags, source, pos, rewriter); + Set flags, DiagnosticSource source, DiagnosticPosition pos, DiagnosticInfo diagnosticInfo, UnaryOperator rewriter) { + return new JCDiagnostic(formatter, normalize(diagnosticInfo), flags, source, pos, rewriter); } //where DiagnosticInfo normalize(DiagnosticInfo diagnosticInfo) { //replace all nested FragmentKey with full-blown JCDiagnostic objects - return DiagnosticInfo.of(diagnosticInfo.type, diagnosticInfo.prefix, diagnosticInfo.code, + LintCategory category = diagnosticInfo instanceof LintWarning lintWarning ? + lintWarning.category : null; + return DiagnosticInfo.of(diagnosticInfo.type, category, diagnosticInfo.prefix, diagnosticInfo.code, Stream.of(diagnosticInfo.args).map(o -> { return (o instanceof Fragment frag) ? fragment(frag) : o; @@ -325,8 +323,8 @@ public Error errorKey(String code, Object... args) { /** * Create a new warning key. */ - Warning warningKey(String code, Object... args) { - return (Warning)DiagnosticInfo.of(WARNING, prefix, code, args); + Warning warningKey(LintCategory lintCategory, String code, Object... args) { + return (Warning)DiagnosticInfo.of(WARNING, lintCategory, prefix, code, args); } /** @@ -356,10 +354,10 @@ Fragment fragmentKey(String code, Object... args) { public static JCDiagnostic fragment(String key, Object... args) { return new JCDiagnostic(getFragmentFormatter(), DiagnosticInfo.of(FRAGMENT, + null, "compiler", key, args), - null, EnumSet.noneOf(DiagnosticFlag.class), null, null); @@ -464,7 +462,6 @@ public enum DiagnosticFlag { private final DiagnosticPosition position; private final DiagnosticInfo diagnosticInfo; private final Set flags; - private final LintCategory lintCategory; /** source line position (set lazily) */ private SourcePosition sourcePosition; @@ -537,11 +534,17 @@ public String key() { * Static factory method; build a custom diagnostic key using given kind, prefix, code and args. */ public static DiagnosticInfo of(DiagnosticType type, String prefix, String code, Object... args) { + return of(type, null, prefix, code, args); + } + + public static DiagnosticInfo of(DiagnosticType type, LintCategory lc, String prefix, String code, Object... args) { switch (type) { case ERROR: return new Error(prefix, code, args); case WARNING: - return new Warning(prefix, code, args); + return lc == null ? + new Warning(prefix, code, args) : + new LintWarning(lc, prefix, code, args); case NOTE: return new Note(prefix, code, args); case FRAGMENT: @@ -583,12 +586,28 @@ public Error(String prefix, String key, Object... args) { /** * Class representing warning diagnostic keys. */ - public static final class Warning extends DiagnosticInfo { + public static sealed class Warning extends DiagnosticInfo { public Warning(String prefix, String key, Object... args) { super(DiagnosticType.WARNING, prefix, key, args); } } + /** + * Class representing lint warning diagnostic keys. + */ + public static final class LintWarning extends Warning { + final LintCategory category; + + public LintWarning(LintCategory category, String prefix, String key, Object... args) { + super(prefix, key, args); + this.category = category; + } + + public LintCategory getLintCategory() { + return category; + } + } + /** * Class representing note diagnostic keys. */ @@ -614,31 +633,27 @@ public record AnnotatedType(Type type) {} * Create a diagnostic object. * @param formatter the formatter to use for the diagnostic * @param diagnosticInfo the diagnostic key - * @param lc the lint category for the diagnostic * @param source the name of the source file, or null if none. * @param pos the character offset within the source file, if given. */ protected JCDiagnostic(DiagnosticFormatter formatter, DiagnosticInfo diagnosticInfo, - LintCategory lc, Set flags, DiagnosticSource source, DiagnosticPosition pos) { - this(formatter, diagnosticInfo, lc, flags, source, pos, null); + this(formatter, diagnosticInfo, flags, source, pos, null); } /** * Create a diagnostic object. * @param formatter the formatter to use for the diagnostic * @param diagnosticInfo the diagnostic key - * @param lc the lint category for the diagnostic * @param source the name of the source file, or null if none. * @param pos the character offset within the source file, if given. * @param rewriter the rewriter function used if this diagnostic needs to be rewritten */ protected JCDiagnostic(DiagnosticFormatter formatter, DiagnosticInfo diagnosticInfo, - LintCategory lc, Set flags, DiagnosticSource source, DiagnosticPosition pos, @@ -648,7 +663,6 @@ protected JCDiagnostic(DiagnosticFormatter formatter, this.defaultFormatter = formatter; this.diagnosticInfo = diagnosticInfo; - this.lintCategory = lc; this.flags = flags; this.source = source; this.position = pos; @@ -687,14 +701,15 @@ public boolean isMandatory() { * Check whether this diagnostic has an associated lint category. */ public boolean hasLintCategory() { - return (lintCategory != null); + return getLintCategory() != null; } /** * Get the associated lint category, or null if none. */ public LintCategory getLintCategory() { - return lintCategory; + return diagnosticInfo instanceof LintWarning lintWarning ? + lintWarning.category : null; } /** @@ -870,7 +885,6 @@ public static class MultilineDiagnostic extends JCDiagnostic { public MultilineDiagnostic(JCDiagnostic other, List subdiagnostics) { super(other.defaultFormatter, other.diagnosticInfo, - other.getLintCategory(), other.flags, other.getDiagnosticSource(), other.position); diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/util/MandatoryWarningHandler.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/util/MandatoryWarningHandler.java index 9fe9590ef35b1..636563621a4a6 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/util/MandatoryWarningHandler.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/util/MandatoryWarningHandler.java @@ -33,6 +33,7 @@ import com.sun.tools.javac.code.Lint.LintCategory; import com.sun.tools.javac.code.Source; import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; +import com.sun.tools.javac.util.JCDiagnostic.LintWarning; import com.sun.tools.javac.util.JCDiagnostic.Note; import com.sun.tools.javac.util.JCDiagnostic.Warning; @@ -126,8 +127,9 @@ public MandatoryWarningHandler(Log log, Source source, boolean verbose, /** * Report a mandatory warning. */ - public void report(DiagnosticPosition pos, Warning warnKey) { + public void report(DiagnosticPosition pos, LintWarning warnKey) { JavaFileObject currentSource = log.currentSourceFile(); + Assert.check(warnKey.getLintCategory() == lintCategory); if (verbose) { if (sourcesWithReportedWarnings == null) @@ -259,9 +261,9 @@ public void reportDeferredDiagnostic() { private void logMandatoryWarning(DiagnosticPosition pos, Warning warnKey) { // Note: the following log methods are safe if lintCategory is null. if (enforceMandatory) - log.mandatoryWarning(lintCategory, pos, warnKey); + log.mandatoryWarning(pos, warnKey); else - log.warning(lintCategory, pos, warnKey); + log.warning(pos, warnKey); } /** diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java index d10478fb3bad5..c2a63be654d3b 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java @@ -106,7 +106,6 @@ public ClassUseWriter(HtmlConfiguration configuration, pkgToPackageAnnotations = new TreeSet<>(comparators.classUseComparator()); pkgToPackageAnnotations.addAll(mapper.classToPackageAnnotations.get(typeElement)); } - configuration.currentTypeElement = typeElement; this.pkgSet = new TreeSet<>(comparators.packageComparator()); this.pkgToClassTypeParameter = pkgDivide(mapper.classToClassTypeParam); this.pkgToSubclassTypeParameter = pkgDivide(mapper.classToSubclassTypeParam); diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriter.java index bef634b0ddb9f..d56616dfc91b5 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriter.java @@ -94,7 +94,6 @@ public ClassWriter(HtmlConfiguration configuration, TypeElement typeElement, ClassTree classTree) { super(configuration, configuration.docPaths.forClass(typeElement)); this.typeElement = typeElement; - configuration.currentTypeElement = typeElement; this.classTree = classTree; pHelper = new PropertyUtils.PropertyHelper(configuration, typeElement); @@ -506,7 +505,7 @@ protected Content getClassInfo(Content classInfo) { } @Override - public TypeElement getCurrentPageElement() { + public TypeElement getCurrentTypeElement() { return typeElement; } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlConfiguration.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlConfiguration.java index 2794a13f9dad0..97c9e2669e005 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlConfiguration.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlConfiguration.java @@ -104,11 +104,6 @@ public class HtmlConfiguration extends BaseConfiguration { */ public DocPath topFile = DocPath.empty; - /** - * The TypeElement for the class file getting generated. - */ - public TypeElement currentTypeElement = null; // Set this TypeElement in the ClassWriter. - /** * The collections of items for the main index. * This field is only initialized if {@code options.createIndex()} diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java index 3f20c7dfd76ad..c2b048b54e029 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java @@ -1024,11 +1024,10 @@ public String getEnclosingPackageName(TypeElement te) { } /** - * Return the main type element of the current page or null for pages that don't have one. - * - * @return the type element of the current page. + * {@return the type element documented by this writer if it is a {@code ClassWriter}, + * or null for any other kind of writer} */ - public TypeElement getCurrentPageElement() { + public TypeElement getCurrentTypeElement() { return null; } @@ -1912,7 +1911,7 @@ private boolean shouldRedirectRelativeLinks(Element element) { // Retrieve the element of this writer if it is a "primary" writer for an element. // Note: It would be nice to have getCurrentPageElement() return package and module elements // in their respective writers, but other uses of the method are only interested in TypeElements. - Element currentPageElement = getCurrentPageElement(); + Element currentPageElement = getCurrentTypeElement(); if (currentPageElement == null) { if (this instanceof PackageWriter packageWriter) { currentPageElement = packageWriter.packageElement; @@ -1951,7 +1950,7 @@ public Content invalidTagOutput(String summary, Optional detail) { */ private boolean inSamePackage(Element element) { Element currentPageElement = (this instanceof PackageWriter packageWriter) - ? packageWriter.packageElement : getCurrentPageElement(); + ? packageWriter.packageElement : getCurrentTypeElement(); return currentPageElement != null && !utils.isModule(element) && Objects.equals(utils.containingPackage(currentPageElement), utils.containingPackage(element)); diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlLinkFactory.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlLinkFactory.java index 3dce7920db975..d404fdaab94a9 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlLinkFactory.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlLinkFactory.java @@ -270,7 +270,7 @@ protected Content getClassLink(HtmlLinkInfo linkInfo) { TypeElement enclosing = utils.getEnclosingTypeElement(linkInfo.getTargetMember()); Set enclosingFlags = utils.elementFlags(enclosing); if (flags.contains(ElementFlag.PREVIEW) && enclosingFlags.contains(ElementFlag.PREVIEW)) { - if (enclosing.equals(m_writer.getCurrentPageElement())) { + if (enclosing.equals(m_writer.getCurrentTypeElement())) { //skip the PREVIEW tag: flags = EnumSet.copyOf(flags); flags.remove(ElementFlag.PREVIEW); @@ -294,7 +294,7 @@ protected Content getClassLink(HtmlLinkInfo linkInfo) { if (utils.isIncluded(typeElement)) { if (configuration.isGeneratedDoc(typeElement) && !utils.hasHiddenTag(typeElement)) { DocPath fileName = getPath(linkInfo); - if (linkInfo.linkToSelf() || typeElement != m_writer.getCurrentPageElement()) { + if (linkInfo.linkToSelf() || typeElement != m_writer.getCurrentTypeElement()) { link.add(m_writer.links.createLink( fileName.fragment(linkInfo.getFragment()), label, linkInfo.getStyle(), linkInfo.getTitle())); diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/taglets/InheritDocTaglet.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/taglets/InheritDocTaglet.java index 4ba730cca9c3d..7f8fd7ff74150 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/taglets/InheritDocTaglet.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/taglets/InheritDocTaglet.java @@ -133,7 +133,7 @@ private Content retrieveInheritedDocumentation(TagletWriter writer, } } catch (DocFinder.NoOverriddenMethodFound e) { String signature = utils.getSimpleName(method) - + utils.flatSignature(method, writer.getCurrentPageElement()); + + utils.flatSignature(method, writer.getCurrentTypeElement()); messages.warning(method, "doclet.noInheritedDoc", signature); } return replacement; @@ -157,7 +157,7 @@ private Content retrieveInheritedDocumentation(TagletWriter writer, } } else { String signature = utils.getSimpleName(method) - + utils.flatSignature(method, writer.getCurrentPageElement()); + + utils.flatSignature(method, writer.getCurrentTypeElement()); messages.warning(method, "doclet.noInheritedDoc", signature); } return replacement; diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/taglets/LinkTaglet.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/taglets/LinkTaglet.java index 69cabd5427d41..1f34a466f0d9d 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/taglets/LinkTaglet.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/taglets/LinkTaglet.java @@ -264,7 +264,7 @@ Content linkSeeReferenceOutput(Element holder, } } String refMemName = refFragment; - if (config.currentTypeElement != containing) { + if (htmlWriter.getCurrentTypeElement() != containing) { refMemName = (utils.isConstructor(refMem)) ? refMemName : utils.getSimpleName(containing) + "." + refMemName; diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/taglets/ReturnTaglet.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/taglets/ReturnTaglet.java index 38ab48bb61f05..994d45b8914fb 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/taglets/ReturnTaglet.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/taglets/ReturnTaglet.java @@ -94,7 +94,7 @@ public Content getAllBlockTagOutput(Element holder, TagletWriter tagletWriter) { List tags = utils.getReturnTrees(holder); // make sure we are not using @return on a method with the void return type - TypeMirror returnType = utils.getReturnType(tagletWriter.getCurrentPageElement(), method); + TypeMirror returnType = utils.getReturnType(tagletWriter.getCurrentTypeElement(), method); if (returnType != null && utils.isVoid(returnType)) { if (!tags.isEmpty() && !config.isDocLintReferenceGroupEnabled()) { messages.warning(holder, "doclet.Return_tag_on_void_method"); diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/taglets/TagletWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/taglets/TagletWriter.java index 7b6c7060a6f76..e0712e2f77151 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/taglets/TagletWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/taglets/TagletWriter.java @@ -201,12 +201,10 @@ public Content invalidTagOutput(String summary, Optional detail) { } /** - * Returns the main type element of the current page or null for pages that don't have one. - * - * @return the type element of the current page or null. + * {@return the type element documented by the current {@code HtmlDocletWriter} (may be null)} */ - public TypeElement getCurrentPageElement() { - return htmlWriter.getCurrentPageElement(); + public TypeElement getCurrentTypeElement() { + return htmlWriter.getCurrentTypeElement(); } /** @@ -411,7 +409,7 @@ public String visitType(TypeElement e, Void p) { public String visitExecutable(ExecutableElement e, Void p) { return utils.getFullyQualifiedName(utils.getEnclosingTypeElement(e)) + "." + utils.getSimpleName(e) - + utils.flatSignature(e, htmlWriter.getCurrentPageElement()); + + utils.flatSignature(e, htmlWriter.getCurrentTypeElement()); } @Override @@ -476,11 +474,11 @@ private boolean isLongOrHasComma(Content c) { // Test if element is the same as or belongs to the current page element private boolean isDifferentTypeElement(Element element) { if (element.getKind().isDeclaredType()) { - return element != getCurrentPageElement(); + return element != getCurrentTypeElement(); } else if (element.getKind() == ElementKind.OTHER) { return false; } else { - return utils.getEnclosingTypeElement(element) != getCurrentPageElement(); + return utils.getEnclosingTypeElement(element) != getCurrentTypeElement(); } } } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/taglets/ThrowsTaglet.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/taglets/ThrowsTaglet.java index 5a92bf42a04bd..8c60903d48cb5 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/taglets/ThrowsTaglet.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/taglets/ThrowsTaglet.java @@ -211,7 +211,7 @@ public Content getAllBlockTagOutput(Element holder, TagletWriter tagletWriter) { // since {@inheritDoc} in @throws is processed by ThrowsTaglet (this taglet) rather than // InheritDocTaglet, we have to duplicate some of the behavior of the latter taglet String signature = utils.getSimpleName(holder) - + utils.flatSignature((ExecutableElement) holder, tagletWriter.getCurrentPageElement()); + + utils.flatSignature((ExecutableElement) holder, tagletWriter.getCurrentTypeElement()); messages.warning(holder, "doclet.noInheritedDoc", signature); } return tagletWriter.getOutputInstance(); // TODO: consider invalid rather than empty output @@ -235,7 +235,7 @@ private Content getAllBlockTagOutput0(Element holder) } var executable = (ExecutableElement) holder; ExecutableType instantiatedType = utils.asInstantiatedMethodType( - tagletWriter.getCurrentPageElement(), executable); + tagletWriter.getCurrentTypeElement(), executable); List substitutedExceptionTypes = instantiatedType.getThrownTypes(); List originalExceptionTypes = executable.getThrownTypes(); Map typeSubstitutions = getSubstitutedThrownTypes( diff --git a/test/hotspot/gtest/riscv/test_assembler_riscv.cpp b/test/hotspot/gtest/riscv/test_assembler_riscv.cpp index 0192e77da9400..41ca565b23df4 100644 --- a/test/hotspot/gtest/riscv/test_assembler_riscv.cpp +++ b/test/hotspot/gtest/riscv/test_assembler_riscv.cpp @@ -29,9 +29,13 @@ #include "asm/assembler.inline.hpp" #include "asm/macroAssembler.hpp" #include "memory/resourceArea.hpp" +#include "metaprogramming/enableIf.hpp" #include "runtime/orderAccess.hpp" +#include "threadHelper.inline.hpp" #include "unittest.hpp" +#include + typedef int64_t (*zicond_func)(int64_t cmp1, int64_t cmp2, int64_t dst, int64_t src); typedef void (MacroAssembler::*cmov_func)(Register cmp1, Register cmp2, Register dst, Register src); @@ -54,7 +58,7 @@ class CmovTester { } }; -void run_cmov_tests() { +static void run_cmov_tests() { // If 42(a0) eq 42(a1): assign dest(a2/66) the src(a3/77), expect result: 77 CmovTester::test(&MacroAssembler::cmov_eq, 42, 42, 66, 77, 77); // If 41(a0) eq 42(a1): assign dest(a2/66) the src(a3/77), expect result: 66 @@ -107,211 +111,239 @@ TEST_VM(RiscV, cmov) { template class CmpxchgTester { - public: - typedef TESTSIZE (*cmpxchg_func)(intptr_t addr, TESTSIZE expected, TESTSIZE new_value, TESTSIZE result); + // The functions expect arguments to be type represented, not C-ABI argument representation. + // Hence an unsigned should be zero-extended, and the same goes for the return value. + typedef int64_t (*cmpxchg_func)(intptr_t addr, int64_t expected, int64_t new_value, int64_t result); - static TESTSIZE base_cmpxchg(int variant, intptr_t addr, TESTSIZE expected, TESTSIZE new_value, TESTSIZE result, bool boolean_result = false) { - BufferBlob* bb = BufferBlob::create("riscvTest", 128); - CodeBuffer code(bb); + typedef int64_t (*cmpxchg_narrow_func)(intptr_t addr, int64_t expected, int64_t new_value, int64_t result, + int64_t scratch0, int64_t scratch1, int64_t scratch2); + + BufferBlob* _bb; + cmpxchg_func _func; + cmpxchg_narrow_func _narrow; + + public: + CmpxchgTester(int variant, bool boolean_result) { + _bb = BufferBlob::create("riscvTest", 128); + CodeBuffer code(_bb); MacroAssembler _masm(&code); address entry = _masm.pc(); - { + if (ASMSIZE == Assembler::int8 || ASMSIZE == Assembler::int16) { + address entry = _masm.pc(); + _masm.cmpxchg_narrow_value(/*addr*/ c_rarg0, /*expected*/ c_rarg1, /*new_value*/c_rarg2, + ASMSIZE, Assembler::relaxed, Assembler::relaxed, + /*result*/ c_rarg3, boolean_result, c_rarg4, c_rarg5, c_rarg6); /* Uses also t0-t1, caller saved */ + _masm.mv(c_rarg0, c_rarg3); + _masm.ret(); + _narrow = ((cmpxchg_narrow_func)entry); + } else { switch(variant) { default: _masm.cmpxchg(/*addr*/ c_rarg0, /*expected*/ c_rarg1, /*new_value*/c_rarg2, - ASMSIZE, Assembler::relaxed, Assembler::relaxed, + ASMSIZE, Assembler::aq, Assembler::rl, /*result*/ c_rarg3, boolean_result); _masm.mv(c_rarg0, c_rarg3); break; case 1: // expected == result _masm.cmpxchg(/*addr*/ c_rarg0, /*expected*/ c_rarg1, /*new_value*/c_rarg2, - ASMSIZE, Assembler::relaxed, Assembler::relaxed, + ASMSIZE, Assembler::aq, Assembler::rl, /*result*/ c_rarg1, boolean_result); _masm.mv(c_rarg0, c_rarg1); break; case 2: // new_value == result _masm.cmpxchg(/*addr*/ c_rarg0, /*expected*/ c_rarg1, /*new_value*/c_rarg2, - ASMSIZE, Assembler::relaxed, Assembler::relaxed, + ASMSIZE, Assembler::aq, Assembler::rl, /*result*/ c_rarg2, boolean_result); _masm.mv(c_rarg0, c_rarg2); break; case 3: // expected == new_value _masm.cmpxchg(/*addr*/ c_rarg0, /*expected*/ c_rarg1, /*new_value*/ c_rarg1, - ASMSIZE, Assembler::relaxed, Assembler::relaxed, + ASMSIZE, Assembler::aq, Assembler::rl, /*result*/ c_rarg2, boolean_result); _masm.mv(c_rarg0, c_rarg2); break; } _masm.ret(); + _func = ((cmpxchg_func)entry); } _masm.flush(); // icache invalidate - TESTSIZE ret = ((cmpxchg_func)entry)(addr, expected, new_value, result); - BufferBlob::free(bb); - return ret; + } + + ~CmpxchgTester() { + BufferBlob::free(_bb); + } + + TESTSIZE cmpxchg(intptr_t addr, TESTSIZE expected, TESTSIZE new_value) { + if (ASMSIZE == Assembler::int8 || ASMSIZE == Assembler::int16) { + return _narrow(addr, expected, new_value, /* dummy result */ 67, -1, -1, -1); + } else { + return _func(addr, expected, new_value, /* dummy result */ 67); + } } }; template -void plain_cmpxchg_test(int variant, TESTSIZE dv, TESTSIZE ex, TESTSIZE nv, TESTSIZE eret, TESTSIZE edata, bool bv) { +static void plain_cmpxchg_test(int variant, TESTSIZE dv, TESTSIZE ex, TESTSIZE nv, TESTSIZE eret, TESTSIZE edata, bool bv) { + CmpxchgTester cmpxchg(variant, bv); TESTSIZE data = dv; - TESTSIZE ret = CmpxchgTester::base_cmpxchg(variant, (intptr_t)&data, ex, nv, /* dummy */ 67, bv); + TESTSIZE ret = cmpxchg.cmpxchg((intptr_t)&data, ex, nv); ASSERT_EQ(ret, eret); ASSERT_EQ(data, edata); } template -void run_plain_cmpxchg_tests() { - // Normal - plain_cmpxchg_test( 0 /* variant */ , 1337 /* start value*/, - 1337 /* expected */, 42 /* new value */, - 1337 /* return */ , 42 /* end value*/, false /* boolean ret*/); - - plain_cmpxchg_test( 0 /* variant */ , 1337 /* start value*/, - 1336 /* expected */, 42 /* new value */, - 1337 /* return */ , 1337 /* end value*/, false /* boolean ret*/); - - plain_cmpxchg_test( 0 /* variant */ , 1337 /* start value*/, - 1337 /* expected */, 42 /* new value */, - 1 /* return */ , 42 /* end value*/, true /* boolean ret*/); - - plain_cmpxchg_test( 0 /* variant */ , 1337 /* start value*/, - 1336 /* expected */, 42 /* new value */, - 0 /* return */ , 1337 /* end value*/, true /* boolean ret*/); - - // result == expected register - plain_cmpxchg_test( 1 /* variant */ , 1337 /* start value*/, - 1337 /* expected */, 42 /* new value */, - 1337 /* return */ , 42 /* end value*/, false /* boolean ret*/); - - plain_cmpxchg_test( 1 /* variant */ , 1337 /* start value*/, - 1336 /* expected */, 42 /* new value */, - 1337 /* return */ , 1337 /* end value*/, false /* boolean ret*/); - - plain_cmpxchg_test( 1 /* variant */ , 1337 /* start value*/, - 1337 /* expected */, 42 /* new value */, - 1 /* return */ , 42 /* end value*/, true /* boolean ret*/); - - plain_cmpxchg_test( 1 /* variant */ , 1337 /* start value*/, - 1336 /* expected */, 42 /* new value */, - 0 /* return */ , 1337 /* end value*/, true /* boolean ret*/); - - // new_value == result register - plain_cmpxchg_test( 2 /* variant */ , 1337 /* start value*/, - 1337 /* expected */, 42 /* new value */, - 1337 /* return */ , 42 /* end value*/, false /* boolean ret*/); - - plain_cmpxchg_test( 2 /* variant */ , 1337 /* start value*/, - 1336 /* expected */, 42 /* new value */, - 1337 /* return */ , 1337 /* end value*/, false /* boolean ret*/); - - plain_cmpxchg_test( 2 /* variant */ , 1337 /* start value*/, - 1337 /* expected */, 42 /* new value */, - 1 /* return */ , 42 /* end value*/, true /* boolean ret*/); - - plain_cmpxchg_test( 2 /* variant */ , 1337 /* start value*/, - 1336 /* expected */, 42 /* new value */, - 0 /* return */ , 1337 /* end value*/, true /* boolean ret*/); - - // expected == new_value register - plain_cmpxchg_test( 3 /* variant */ , 1337 /* start value*/, - 1337 /* expected */, 42 /* new value */, - 1337 /* return */ , 1337 /* end value*/, false /* boolean ret*/); - - plain_cmpxchg_test( 3 /* variant */ , 1337 /* start value*/, - 1336 /* expected */, 42 /* new value */, - 1337 /* return */ , 1337 /* end value*/, false /* boolean ret*/); - - plain_cmpxchg_test( 3 /* variant */ , 1337 /* start value*/, - 1337 /* expected */, 42 /* new value */, - 1 /* return */ , 1337 /* end value*/, true /* boolean ret*/); - - plain_cmpxchg_test( 3 /* variant */ , 1337 /* start value*/, - 1336 /* expected */, 42 /* new value */, - 0 /* return */ , 1337 /* end value*/, true /* boolean ret*/); +static void run_plain_cmpxchg_tests() { + TESTSIZE max = std::numeric_limits::max(); + TESTSIZE min = std::numeric_limits::min(); + TESTSIZE val[] = {1337, min, max}; + for (int i = 0; i < 3; i++) { + // Normal + plain_cmpxchg_test( 0 /* variant */ , val[i] /* start value */, + val[i] /* expected */, 42 /* new value */, + val[i] /* return */ , 42 /* end value*/, false /* boolean ret*/); + + plain_cmpxchg_test( 0 /* variant */ , val[i] /* start value */, + 1336 /* expected */, 42 /* new value */, + val[i] /* return */ , val[i] /* end value */, false /* boolean ret*/); + + plain_cmpxchg_test( 0 /* variant */ , val[i] /* start value */, + val[i] /* expected */, 42 /* new value */, + 1 /* return */ , 42 /* end value*/, true /* boolean ret*/); + + plain_cmpxchg_test( 0 /* variant */ , val[i] /* start value */, + 1336 /* expected */, 42 /* new value */, + 0 /* return */ , val[i] /* end value */, true /* boolean ret*/); + + // result == expected register + plain_cmpxchg_test( 1 /* variant */ , val[i] /* start value */, + val[i] /* expected */, 42 /* new value */, + val[i] /* return */ , 42 /* end value*/, false /* boolean ret*/); + + plain_cmpxchg_test( 1 /* variant */ , val[i] /* start value */, + 1336 /* expected */, 42 /* new value */, + val[i] /* return */ , val[i] /* end value */, false /* boolean ret*/); + + plain_cmpxchg_test( 1 /* variant */ , val[i] /* start value */, + val[i] /* expected */, 42 /* new value */, + 1 /* return */ , 42 /* end value*/, true /* boolean ret*/); + + plain_cmpxchg_test( 1 /* variant */ , val[i] /* start value */, + 1336 /* expected */, 42 /* new value */, + 0 /* return */ , val[i] /* end value */, true /* boolean ret*/); + + // new_value == result register + plain_cmpxchg_test( 2 /* variant */ , val[i] /* start value */, + val[i] /* expected */, 42 /* new value */, + val[i] /* return */ , 42 /* end value*/, false /* boolean ret*/); + + plain_cmpxchg_test( 2 /* variant */ , val[i] /* start value */, + 1336 /* expected */, 42 /* new value */, + val[i] /* return */ , val[i] /* end value */, false /* boolean ret*/); + + plain_cmpxchg_test( 2 /* variant */ , val[i] /* start value */, + val[i] /* expected */, 42 /* new value */, + 1 /* return */ , 42 /* end value*/, true /* boolean ret*/); + + plain_cmpxchg_test( 2 /* variant */ , val[i] /* start value */, + 1336 /* expected */, 42 /* new value */, + 0 /* return */ , val[i] /* end value */, true /* boolean ret*/); + + // expected == new_value register + plain_cmpxchg_test( 3 /* variant */ , val[i] /* start value */, + val[i] /* expected */, 42 /* new value */, + val[i] /* return */ , val[i] /* end value */, false /* boolean ret*/); + + plain_cmpxchg_test( 3 /* variant */ , val[i] /* start value */, + 1336 /* expected */, 42 /* new value */, + val[i] /* return */ , val[i] /* end value */, false /* boolean ret*/); + + plain_cmpxchg_test( 3 /* variant */ , val[i] /* start value */, + val[i] /* expected */, 42 /* new value */, + 1 /* return */ , val[i] /* end value */, true /* boolean ret*/); + + plain_cmpxchg_test( 3 /* variant */ , val[i] /* start value */, + 1336 /* expected */, 42 /* new value */, + 0 /* return */ , val[i] /* end value */, true /* boolean ret*/); + } } -TEST_VM(RiscV, cmpxchg_int64_plain_lr_sc) { +TEST_VM(RiscV, cmpxchg_int64_lr_sc) { bool zacas = UseZacas; UseZacas = false; run_plain_cmpxchg_tests(); UseZacas = zacas; } -TEST_VM(RiscV, cmpxchg_int64_plain_maybe_zacas) { +TEST_VM(RiscV, cmpxchg_int64_maybe_zacas) { if (UseZacas) { run_plain_cmpxchg_tests(); } } -TEST_VM(RiscV, cmpxchg_int32_plain_lr_sc) { +TEST_VM(RiscV, cmpxchg_int32_lr_sc) { bool zacas = UseZacas; UseZacas = false; run_plain_cmpxchg_tests(); UseZacas = zacas; } -TEST_VM(RiscV, cmpxchg_int32_plain_maybe_zacas) { +TEST_VM(RiscV, cmpxchg_int32_maybe_zacas) { if (UseZacas) { run_plain_cmpxchg_tests(); } } -template -class NarrowCmpxchgTester { - public: - typedef TESTSIZE (*cmpxchg_func)(intptr_t addr, TESTSIZE expected, TESTSIZE new_value, TESTSIZE result, - int64_t scratch0, int64_t scratch1, int64_t scratch2); +TEST_VM(RiscV, cmpxchg_uint32_lr_sc) { + bool zacas = UseZacas; + UseZacas = false; + run_plain_cmpxchg_tests(); + UseZacas = zacas; +} - static TESTSIZE narrow_cmpxchg(intptr_t addr, TESTSIZE expected, TESTSIZE new_value, TESTSIZE result, bool boolean_result = false) { - BufferBlob* bb = BufferBlob::create("riscvTest", 128); - CodeBuffer code(bb); - MacroAssembler _masm(&code); - address entry = _masm.pc(); - { - _masm.cmpxchg_narrow_value(/*addr*/ c_rarg0, /*expected*/ c_rarg1, /*new_value*/c_rarg2, - ASMSIZE, Assembler::relaxed, Assembler::relaxed, - /*result*/ c_rarg3, boolean_result, c_rarg4, c_rarg5, c_rarg6); /* Uses also t0-t1, caller saved */ - _masm.mv(c_rarg0, c_rarg3); - _masm.ret(); - } - _masm.flush(); // icache invalidate - TESTSIZE ret = ((cmpxchg_func)entry)(addr, expected, new_value, result, -1, -1, -1); - BufferBlob::free(bb); - return ret; +TEST_VM(RiscV, cmpxchg_uint32_maybe_zacas) { + if (UseZacas) { + run_plain_cmpxchg_tests(); } -}; +} template -void run_narrow_cmpxchg_tests() { +static void run_narrow_cmpxchg_tests() { + CmpxchgTester cmpxchg(0, false); + CmpxchgTester cmpxchg_bool(0, true); // Assume natural aligned TESTSIZE data[8]; TESTSIZE ret; - for (int i = 0; i < 7; i++) { - memset(data, -1, sizeof(data)); - - data[i] = 121; - ret = NarrowCmpxchgTester::narrow_cmpxchg((intptr_t)&data[i], 121, 42, /* result */ 67, false); - ASSERT_EQ(ret, 121); - ASSERT_EQ(data[i], 42); - - data[i] = 121; - ret = NarrowCmpxchgTester::narrow_cmpxchg((intptr_t)&data[i], 120, 42, /* result */ 67, false); - ASSERT_EQ(ret, 121); - ASSERT_EQ(data[i], 121); - - data[i] = 121; - ret = NarrowCmpxchgTester::narrow_cmpxchg((intptr_t)&data[i], 121, 42, /* result */ 67, true); - ASSERT_EQ(ret, 1); - ASSERT_EQ(data[i], 42); - - data[i] = 121; - ret = NarrowCmpxchgTester::narrow_cmpxchg((intptr_t)&data[i], 120, 42, /* result */ 67, true); - ASSERT_EQ(ret, 0); - ASSERT_EQ(data[i], 121); + TESTSIZE max = std::numeric_limits::max(); + TESTSIZE min = std::numeric_limits::min(); + TESTSIZE val[] = {121, min, max}; + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 7; j++) { + // printf("%lu %lX\n", (uint64_t)val[i], (uint64_t)val[i]); + memset(data, -1, sizeof(data)); + data[i] = val[i]; + ret = cmpxchg.cmpxchg((intptr_t)&data[i], val[i], 42); + ASSERT_EQ(ret, val[i]); + ASSERT_EQ(data[i], 42); + + data[i] = val[i]; + ret = cmpxchg.cmpxchg((intptr_t)&data[i], 120, 42); + ASSERT_EQ(ret, val[i]); + ASSERT_EQ(data[i], val[i]); + + data[i] = val[i]; + ret = cmpxchg_bool.cmpxchg((intptr_t)&data[i], val[i], 42); + ASSERT_EQ(ret, 1); + ASSERT_EQ(data[i], 42); + + data[i] = val[i]; + ret = cmpxchg_bool.cmpxchg((intptr_t)&data[i], 120, 42); + ASSERT_EQ(ret, 0); + ASSERT_EQ(data[i], val[i]); + } } } @@ -322,6 +354,12 @@ TEST_VM(RiscV, cmpxchg_int16_lr_sc) { UseZacas = zacas; } +TEST_VM(RiscV, cmpxchg_int16_maybe_zacas) { + if (UseZacas) { + run_narrow_cmpxchg_tests(); + } +} + TEST_VM(RiscV, cmpxchg_int8_lr_sc) { bool zacas = UseZacas; UseZacas = false; @@ -329,144 +367,392 @@ TEST_VM(RiscV, cmpxchg_int8_lr_sc) { UseZacas = zacas; } -TEST_VM(RiscV, cmpxchg_int16_maybe_zacas) { +TEST_VM(RiscV, cmpxchg_int8_maybe_zacas) { if (UseZacas) { - run_narrow_cmpxchg_tests(); + run_narrow_cmpxchg_tests(); } } -TEST_VM(RiscV, cmpxchg_int8_maybe_zacas) { +template +TESTSIZE next_count(TESTSIZE now, TESTSIZE add) { + if ((std::numeric_limits::max() - add) >= now) { + return now + add; + } + TESTSIZE diff = std::numeric_limits::max() - now; + add -= diff + 1; // add one to the diff for the wrap around. + return std::numeric_limits::min() + add; +} + +constexpr int64_t PAR_IT_END = 10000; +constexpr int64_t NUMBER_THREADS = 4; +constexpr int64_t TOTAL_ITERATIONS = NUMBER_THREADS * PAR_IT_END; + +template ::max() <= (std::numeric_limits::min() + TOTAL_ITERATIONS))> +constexpr TESTSIZE result_count() { + int64_t range = std::numeric_limits::max() - std::numeric_limits::min() + 1; + int64_t rest = TOTAL_ITERATIONS % range; + return std::numeric_limits::min() + rest; +} + +template ::max() > (std::numeric_limits::min() + TOTAL_ITERATIONS))> +constexpr TESTSIZE result_count() { + return std::numeric_limits::min() + TOTAL_ITERATIONS; +} + +template +static void run_concurrent_cmpxchg_tests() { + volatile TESTSIZE data = std::numeric_limits::min(); + int num_threads = NUMBER_THREADS; + CmpxchgTester cmpxchg(0, false); // variant 0, not bool ret + auto incThread = [&](Thread* _current, int _id) { // _id starts from 0..(CTHREAD-1) + TESTSIZE my_oldvalue = std::numeric_limits::min() + _id; + for (int64_t i = 0; i < PAR_IT_END ; i++) { + TESTSIZE newvalue = next_count(my_oldvalue, 1); + TESTSIZE ret; + do { + ret = cmpxchg.cmpxchg((intptr_t)&data, my_oldvalue, newvalue); + } while (ret != my_oldvalue); + my_oldvalue = next_count(my_oldvalue, num_threads); + } + }; + TestThreadGroup ttg(incThread, num_threads); + ttg.doit(); + ttg.join(); + ASSERT_EQ(data, result_count()); +} + +template +static void run_concurrent_alt_cmpxchg_tests() { + volatile TESTSIZE data = std::numeric_limits::min(); + int num_threads = NUMBER_THREADS; + CmpxchgTester cmpxchg(0, false); // variant 0, not bool ret + auto incThread = [&](Thread* _current, int _id) { // _id starts from 0..(CTHREAD-1) + for (int i = 0; i < PAR_IT_END; i++) { + TESTSIZE oldvalue; + TESTSIZE ret = 0; + do { + oldvalue = ret; + TESTSIZE newvalue = next_count(oldvalue, 1); + ret = cmpxchg.cmpxchg((intptr_t)&data, oldvalue, newvalue); + } while (ret != oldvalue); + } + }; + TestThreadGroup ttg(incThread, num_threads); + ttg.doit(); + ttg.join(); + ASSERT_EQ(data, result_count()); +} + +TEST_VM(RiscV, cmpxchg_int64_concurrent_lr_sc) { + bool zacas = UseZacas; + UseZacas = false; + run_concurrent_cmpxchg_tests(); + run_concurrent_alt_cmpxchg_tests(); + UseZacas = zacas; +} + +TEST_VM(RiscV, cmpxchg_int64_concurrent_maybe_zacas) { if (UseZacas) { - run_narrow_cmpxchg_tests(); + run_concurrent_cmpxchg_tests(); + run_concurrent_alt_cmpxchg_tests(); + } +} + +TEST_VM(RiscV, cmpxchg_int32_concurrent_lr_sc) { + bool zacas = UseZacas; + UseZacas = false; + run_concurrent_cmpxchg_tests(); + run_concurrent_alt_cmpxchg_tests(); + UseZacas = zacas; +} + +TEST_VM(RiscV, cmpxchg_int32_concurrent_maybe_zacas) { + if (UseZacas) { + run_concurrent_cmpxchg_tests(); + run_concurrent_alt_cmpxchg_tests(); + } +} + +TEST_VM(RiscV, cmpxchg_uint32_concurrent_lr_sc) { + bool zacas = UseZacas; + UseZacas = false; + run_concurrent_cmpxchg_tests(); + run_concurrent_alt_cmpxchg_tests(); + UseZacas = zacas; +} + +TEST_VM(RiscV, cmpxchg_uint32_concurrent_maybe_zacas) { + if (UseZacas) { + run_concurrent_cmpxchg_tests(); + run_concurrent_alt_cmpxchg_tests(); + } +} + +TEST_VM(RiscV, cmpxchg_int16_concurrent_lr_sc) { + bool zacas = UseZacas; + UseZacas = false; + run_concurrent_cmpxchg_tests(); + run_concurrent_alt_cmpxchg_tests(); + UseZacas = zacas; +} + +TEST_VM(RiscV, cmpxchg_int16_concurrent_maybe_zacas) { + if (UseZacas) { + run_concurrent_cmpxchg_tests(); + run_concurrent_alt_cmpxchg_tests(); + } +} + +TEST_VM(RiscV, cmpxchg_int8_concurrent_lr_sc) { + bool zacas = UseZacas; + UseZacas = false; + run_concurrent_cmpxchg_tests(); + run_concurrent_alt_cmpxchg_tests(); + UseZacas = zacas; +} + +TEST_VM(RiscV, cmpxchg_int8_concurrent_maybe_zacas) { + if (UseZacas) { + run_concurrent_cmpxchg_tests(); + run_concurrent_alt_cmpxchg_tests(); } } template class WeakCmpxchgTester { - public: - typedef TESTSIZE (*cmpxchg_narrow)(intptr_t addr, TESTSIZE expected, TESTSIZE new_value, TESTSIZE result, + // The functions expect arguments to be type represented, not C-ABI argument representation. + // Hence an unsigned should be zero-extended, and the same goes for the return value. + typedef int64_t (*weak_cmpxchg_narrow_func)(intptr_t addr, int64_t expected, int64_t new_value, int64_t result, int64_t scratch0, int64_t scratch1, int64_t scratch2); - typedef TESTSIZE (*cmpxchg_func)(intptr_t addr, TESTSIZE expected, TESTSIZE new_value, TESTSIZE result); + typedef int64_t (*weak_cmpxchg_func)(intptr_t addr, int64_t expected, int64_t new_value, int64_t result); - static TESTSIZE weak_narrow_cmpxchg(intptr_t addr, TESTSIZE expected, TESTSIZE new_value) { - BufferBlob* bb = BufferBlob::create("riscvTest", 128); - CodeBuffer code(bb); + BufferBlob* _bb; + weak_cmpxchg_narrow_func _narrow_weak; + weak_cmpxchg_func _weak; + + public: + WeakCmpxchgTester() : _bb(nullptr), _narrow_weak(nullptr), _weak(nullptr) { + _bb = BufferBlob::create("riscvTest", 128); + CodeBuffer code(_bb); MacroAssembler _masm(&code); - address entry = _masm.pc(); - { + if (ASMSIZE == Assembler::int8 || ASMSIZE == Assembler::int16) { + address entry = _masm.pc(); _masm.weak_cmpxchg_narrow_value(/*addr*/ c_rarg0, /*expected*/ c_rarg1, /*new_value*/ c_rarg2, ASMSIZE, Assembler::relaxed, Assembler::relaxed, /*result*/ c_rarg3, c_rarg4, c_rarg5, c_rarg6); /* Uses also t0-t1, caller saved */ _masm.mv(c_rarg0, c_rarg3); _masm.ret(); - } - _masm.flush(); // icache invalidate - TESTSIZE ret = ((cmpxchg_narrow)entry)(addr, expected, new_value, /*result*/ 67, -1, -1, -1); - BufferBlob::free(bb); - return ret; - } - - static TESTSIZE weak_cmpxchg(intptr_t addr, TESTSIZE expected, TESTSIZE new_value) { - BufferBlob* bb = BufferBlob::create("riscvTest", 128); - CodeBuffer code(bb); - MacroAssembler _masm(&code); - address entry = _masm.pc(); - { + _narrow_weak = ((weak_cmpxchg_narrow_func)entry); + } else { + address entry = _masm.pc(); _masm.weak_cmpxchg(/*addr*/ c_rarg0, /*expected*/ c_rarg1, /*new_value*/ c_rarg2, ASMSIZE, Assembler::relaxed, Assembler::relaxed, /*result*/ c_rarg3); _masm.mv(c_rarg0, c_rarg3); _masm.ret(); + _weak = ((weak_cmpxchg_func)entry); } _masm.flush(); // icache invalidate - TESTSIZE ret = ((cmpxchg_func)entry)(addr, expected, new_value, /*result*/ 67); - BufferBlob::free(bb); - return ret; + } + + TESTSIZE weak_cmpxchg(intptr_t addr, TESTSIZE expected, TESTSIZE new_value) { + if (ASMSIZE == Assembler::int8 || ASMSIZE == Assembler::int16) { + return _narrow_weak(addr, expected, new_value, /* dummy result */ 67, -1, -1, -1); + } else { + return _weak(addr, expected, new_value, /* dummy result */ 67); + } + } + + ~WeakCmpxchgTester() { + BufferBlob::free(_bb); } }; template -void run_weak_cmpxchg_narrow_value_tests() { - // Assume natural aligned - TESTSIZE data[8]; - TESTSIZE ret; - for (int i = 0; i < 7; i++) { - memset(data, -1, sizeof(data)); - - data[i] = 121; - ret = WeakCmpxchgTester::weak_narrow_cmpxchg((intptr_t)&data[i], 121, 42); - ASSERT_EQ(ret, 1); - ASSERT_EQ(data[i], 42); - - data[i] = 121; - ret = WeakCmpxchgTester::weak_narrow_cmpxchg((intptr_t)&data[i], 120, 42); - ASSERT_EQ(ret, 0); - ASSERT_EQ(data[i], 121); +void run_weak_cmpxchg_tests() { + TESTSIZE max = std::numeric_limits::max(); + TESTSIZE min = std::numeric_limits::min(); + TESTSIZE val[] = {121, min, max}; + for (int i = 0; i < 3; i++) { + WeakCmpxchgTester cmpxchg; + TESTSIZE data = val[i]; + TESTSIZE ret = cmpxchg.weak_cmpxchg((intptr_t)&data, val[i], 42); + ASSERT_EQ(ret, (TESTSIZE)1); + ASSERT_EQ(data, (TESTSIZE)42); + + data = val[i]; + ret = cmpxchg.weak_cmpxchg((intptr_t)&data, 120, 42); + ASSERT_EQ(ret, (TESTSIZE)0); + ASSERT_EQ(data, (TESTSIZE)val[i]); + } +} + +TEST_VM(RiscV, weak_cmpxchg_int64_lr_sc) { + bool zacas = UseZacas; + UseZacas = false; + run_weak_cmpxchg_tests(); + UseZacas = zacas; +} + +TEST_VM(RiscV, weak_cmpxchg_int64_maybe_zacas) { + if (UseZacas) { + run_weak_cmpxchg_tests(); + } +} + +TEST_VM(RiscV, weak_cmpxchg_int32_lr_sc) { + bool zacas = UseZacas; + UseZacas = false; + run_weak_cmpxchg_tests(); + UseZacas = zacas; +} + +TEST_VM(RiscV, weak_cmpxchg_int32_maybe_zacas) { + if (UseZacas) { + run_weak_cmpxchg_tests(); + } +} + +TEST_VM(RiscV, weak_cmpxchg_uint32_lr_sc) { + bool zacas = UseZacas; + UseZacas = false; + run_weak_cmpxchg_tests(); + UseZacas = zacas; +} + +TEST_VM(RiscV, weak_cmpxchg_uint32_maybe_zacas) { + if (UseZacas) { + run_weak_cmpxchg_tests(); } } TEST_VM(RiscV, weak_cmpxchg_int16_lr_sc) { bool zacas = UseZacas; UseZacas = false; - run_weak_cmpxchg_narrow_value_tests(); + run_weak_cmpxchg_tests(); UseZacas = zacas; } TEST_VM(RiscV, weak_cmpxchg_int8_lr_sc) { bool zacas = UseZacas; UseZacas = false; - run_weak_cmpxchg_narrow_value_tests(); + run_weak_cmpxchg_tests(); UseZacas = zacas; } TEST_VM(RiscV, weak_cmpxchg_int16_maybe_zacas) { if (UseZacas) { - run_weak_cmpxchg_narrow_value_tests(); + run_weak_cmpxchg_tests(); } } TEST_VM(RiscV, weak_cmpxchg_int8_maybe_zacas) { if (UseZacas) { - run_weak_cmpxchg_narrow_value_tests(); + run_weak_cmpxchg_tests(); } } template -void run_weak_cmpxchg_tests() { - TESTSIZE data = 121; - TESTSIZE ret = WeakCmpxchgTester::weak_cmpxchg((intptr_t)&data, 121, 42); - ASSERT_EQ(ret, 1); - ASSERT_EQ(data, 42); +static void run_concurrent_weak_cmpxchg_tests() { + volatile TESTSIZE data = std::numeric_limits::min(); + int num_threads = NUMBER_THREADS; + WeakCmpxchgTester cmpxchg; // not bool ret + auto incThread = [&](Thread* _current, int _id) { // _id starts from 0..(CTHREAD-1) + TESTSIZE my_oldvalue = std::numeric_limits::min() + _id; + for (int64_t i = 0; i < PAR_IT_END; i++) { + TESTSIZE newvalue = next_count(my_oldvalue, 1); + TESTSIZE ret; + do { + ret = cmpxchg.weak_cmpxchg((intptr_t)&data, my_oldvalue, newvalue); + } while (ret != 1); + my_oldvalue = next_count(my_oldvalue, num_threads); + } + }; + TestThreadGroup ttg(incThread, num_threads); + ttg.doit(); + ttg.join(); + ASSERT_EQ(data, result_count()); +} - data = 121; - ret = WeakCmpxchgTester::weak_cmpxchg((intptr_t)&data, 120, 42); - ASSERT_EQ(ret, 0); - ASSERT_EQ(data, 121); +template +static void run_concurrent_alt_weak_cmpxchg_tests() { + volatile TESTSIZE data = std::numeric_limits::min(); + int num_threads = NUMBER_THREADS; + WeakCmpxchgTester cmpxchg; // not bool ret + auto incThread = [&](Thread* _current, int _id) { // _id starts from 0..(CTHREAD-1) + for (int i = 0; i < PAR_IT_END; i++) { + TESTSIZE oldvalue; + TESTSIZE ret = 0; + do { + oldvalue = data; + TESTSIZE newvalue = next_count(oldvalue, 1); + ret = cmpxchg.weak_cmpxchg((intptr_t)&data, oldvalue, newvalue); + } while (ret != 1); + } + }; + TestThreadGroup ttg(incThread, num_threads); + ttg.doit(); + ttg.join(); + ASSERT_EQ(data, result_count()); } -TEST_VM(RiscV, weak_cmpxchg_int64_lr_sc) { +TEST_VM(RiscV, weak_cmpxchg_int64_concurrent_lr_sc) { bool zacas = UseZacas; UseZacas = false; - run_weak_cmpxchg_tests(); + run_concurrent_weak_cmpxchg_tests(); + run_concurrent_alt_weak_cmpxchg_tests(); UseZacas = zacas; } -TEST_VM(RiscV, weak_cmpxchg_int64_maybe_zacas) { +TEST_VM(RiscV, weak_cmpxchg_int64_concurrent_maybe_zacas) { if (UseZacas) { - run_weak_cmpxchg_tests(); + run_concurrent_weak_cmpxchg_tests(); + run_concurrent_alt_weak_cmpxchg_tests(); } } -TEST_VM(RiscV, weak_cmpxchg_int32_lr_sc) { +TEST_VM(RiscV, weak_cmpxchg_int32_concurrent_lr_sc) { bool zacas = UseZacas; UseZacas = false; - run_weak_cmpxchg_tests(); + run_concurrent_weak_cmpxchg_tests(); + run_concurrent_alt_weak_cmpxchg_tests(); UseZacas = zacas; } -TEST_VM(RiscV, weak_cmpxchg_int32_maybe_zacas) { +TEST_VM(RiscV, weak_cmpxchg_int32_concurrent_maybe_zacas) { if (UseZacas) { - run_weak_cmpxchg_tests(); + run_concurrent_weak_cmpxchg_tests(); + run_concurrent_alt_weak_cmpxchg_tests(); + } +} + +TEST_VM(RiscV, weak_cmpxchg_int16_concurrent_lr_sc) { + bool zacas = UseZacas; + UseZacas = false; + run_concurrent_weak_cmpxchg_tests(); + run_concurrent_alt_weak_cmpxchg_tests(); + UseZacas = zacas; +} + +TEST_VM(RiscV, weak_cmpxchg_int16_concurrent_maybe_zacas) { + if (UseZacas) { + run_concurrent_weak_cmpxchg_tests(); + run_concurrent_alt_weak_cmpxchg_tests(); + } +} + +TEST_VM(RiscV, weak_cmpxchg_int8_concurrent_lr_sc) { + bool zacas = UseZacas; + UseZacas = false; + run_concurrent_weak_cmpxchg_tests(); + run_concurrent_alt_weak_cmpxchg_tests(); + UseZacas = zacas; +} + +TEST_VM(RiscV, weak_cmpxchg_int8_concurrent_maybe_zacas) { + if (UseZacas) { + run_concurrent_weak_cmpxchg_tests(); + run_concurrent_alt_weak_cmpxchg_tests(); } } diff --git a/test/hotspot/jtreg/serviceability/dcmd/vm/SystemMapTestBase.java b/test/hotspot/jtreg/serviceability/dcmd/vm/SystemMapTestBase.java index dbd82f0f20863..dbaa5b18e2e50 100644 --- a/test/hotspot/jtreg/serviceability/dcmd/vm/SystemMapTestBase.java +++ b/test/hotspot/jtreg/serviceability/dcmd/vm/SystemMapTestBase.java @@ -157,7 +157,7 @@ private static class MacOSPatterns implements MapPatterns { static final String macow = "cow"; static final String macprivate = "pvt"; - static final String macprivate_or_shared = "(pvt|tsh-shared)"; + static final String macprivate_or_shared = "(pvt|tsh)"; static final String macprivatealiased = "p/a"; static final String macOSbase = range + space + someSize + space + macprot + space; diff --git a/test/langtools/jdk/javadoc/doclet/testModules/TestModules.java b/test/langtools/jdk/javadoc/doclet/testModules/TestModules.java index 4d3628544f81e..88ccac315804c 100644 --- a/test/langtools/jdk/javadoc/doclet/testModules/TestModules.java +++ b/test/langtools/jdk/javadoc/doclet/testModules/TestModules.java @@ -621,7 +621,7 @@ void checkModuleTags() { estpkgmdltags">TestClassInModuleTags.""", """ Member Link: testMethod(String).""", + lang.String)">TestClassInModuleTags.testMethod(String).""", """ Package Link: testpkgmdltags.""", """ @@ -892,7 +892,7 @@ void checkModuleModeCommon() { Type Link: TestClassInModuleTags.
Member Link: testMethod(String).
+ Method(java.lang.String)">TestClassInModuleTags.testMethod(String).
Package Link: testpkgmdltags.
"""); checkOutput("moduleA/module-summary.html", true, diff --git a/test/langtools/jdk/javadoc/doclet/testUseOption/TestUseOption.java b/test/langtools/jdk/javadoc/doclet/testUseOption/TestUseOption.java index f5f6ff213a04a..d59aed41798c6 100644 --- a/test/langtools/jdk/javadoc/doclet/testUseOption/TestUseOption.java +++ b/test/langtools/jdk/javadoc/doclet/testUseOption/TestUseOption.java @@ -24,7 +24,7 @@ /* * @test * @bug 4496290 4985072 7006178 7068595 8016328 8050031 8048351 8081854 8071982 8162363 8175200 8186332 - * 8182765 8196202 8202626 8261976 8323698 + * 8182765 8196202 8202626 8261976 8323698 8345770 * @summary A simple test to ensure class-use files are correct. * @library /tools/lib ../../lib * @modules jdk.javadoc/jdk.javadoc.internal.tool @@ -107,7 +107,10 @@ public void test1() { ); checkOutput("pkg1/class-use/UsedInterface.html", true, """ - AnAbstract""" + AnAbstract""", + """ + Link to interface method: Use\ + dInterface.doNothing().""" ); checkOutput("pkg1/class-use/UsedInterface.html", true, "../C10.html#withReturningTypeParameters()" diff --git a/test/langtools/jdk/javadoc/doclet/testUseOption/pkg1/AnAbstract.java b/test/langtools/jdk/javadoc/doclet/testUseOption/pkg1/AnAbstract.java index 4d31c6f36bdca..ad7d8f3e719a3 100644 --- a/test/langtools/jdk/javadoc/doclet/testUseOption/pkg1/AnAbstract.java +++ b/test/langtools/jdk/javadoc/doclet/testUseOption/pkg1/AnAbstract.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2024, 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 @@ -22,4 +22,8 @@ */ package pkg1; + +/** + * Link to interface method: {@link #doNothing}. + */ public abstract class AnAbstract implements UsedInterface {} diff --git a/test/langtools/tools/javac/6304921/TestLog.java b/test/langtools/tools/javac/6304921/TestLog.java index 3d88aa6fdfd65..41695554a8800 100644 --- a/test/langtools/tools/javac/6304921/TestLog.java +++ b/test/langtools/tools/javac/6304921/TestLog.java @@ -41,6 +41,7 @@ import com.sun.tools.javac.file.JavacFileManager; import com.sun.tools.javac.parser.Parser; import com.sun.tools.javac.parser.ParserFactory; +import com.sun.tools.javac.resources.CompilerProperties.LintWarnings; import com.sun.tools.javac.tree.EndPosTable; import com.sun.tools.javac.tree.JCTree; import com.sun.tools.javac.tree.TreeScanner; @@ -51,7 +52,6 @@ import com.sun.tools.javac.util.JCDiagnostic.Factory; import com.sun.tools.javac.util.Options; import com.sun.tools.javac.resources.CompilerProperties.Errors; -import com.sun.tools.javac.resources.CompilerProperties.Warnings; public class TestLog { @@ -130,10 +130,10 @@ public void visitIf(JCTree.JCIf tree) { log.error(tree.pos(), Errors.NotStmt); log.error(nil, Errors.NotStmt); - log.warning(Warnings.DivZero); - log.warning(tree.pos, Warnings.DivZero); - log.warning(tree.pos(), Warnings.DivZero); - log.warning(nil, Warnings.DivZero); + log.warning(LintWarnings.DivZero); + log.warning(tree.pos, LintWarnings.DivZero); + log.warning(tree.pos(), LintWarnings.DivZero); + log.warning(nil, LintWarnings.DivZero); } private Log log;