From 8dc43aa0fe8cdba2a2953258de02c6afa072987a Mon Sep 17 00:00:00 2001 From: Vicente Romero Date: Wed, 3 Apr 2024 15:56:44 +0000 Subject: [PATCH] 8325217: MethodSymbol.getModifiers() returns SEALED for restricted methods Reviewed-by: jlahoda --- .../classes/com/sun/tools/javac/code/Symbol.java | 3 ++- .../doclet/testRestricted/TestRestricted.java | 14 ++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java index 2bb36eeded2..ef62222438b 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java @@ -1994,7 +1994,8 @@ public abstract class Symbol extends AnnoConstruct implements PoolConstant, Elem @Override @DefinedBy(Api.LANGUAGE_MODEL) public Set getModifiers() { - long flags = flags(); + // just in case the method is restricted but that is not a modifier + long flags = flags() & ~RESTRICTED; return Flags.asModifierSet((flags & DEFAULT) != 0 ? flags & ~ABSTRACT : flags); } diff --git a/test/langtools/jdk/javadoc/doclet/testRestricted/TestRestricted.java b/test/langtools/jdk/javadoc/doclet/testRestricted/TestRestricted.java index b9dd80d61fb..05b833a55a3 100644 --- a/test/langtools/jdk/javadoc/doclet/testRestricted/TestRestricted.java +++ b/test/langtools/jdk/javadoc/doclet/testRestricted/TestRestricted.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 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 @@ -23,7 +23,7 @@ /* * @test - * @bug 8316972 + * @bug 8316972 8325217 * @summary Add javadoc support for restricted methods * @library /tools/lib ../../lib * @modules jdk.javadoc/jdk.javadoc.internal.tool @@ -107,9 +107,8 @@ public class TestRestricted extends JavadocTester { """

restrictedMethod

-
sealed void restrictedMethod\ - ()
+
void restrictedMethod()
restrictedMethod is a restricted method of the Java platf\ orm. @@ -121,9 +120,8 @@ public class TestRestricted extends JavadocTester { """

restrictedPreviewMethod

-
sealed int restrictedPreviewMethod<\ - /span>()
+
int restrictedPreviewMethod()
restrictedPreviewMethod is a preview API of the Java platfo\ rm.