diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter_23Test.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter_23Test.java index 8e572537479..62f634a3ed7 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter_23Test.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter_23Test.java @@ -129,7 +129,7 @@ void main() { } public void test003_a() throws CoreException { - ASTParser astParser = ASTParser.newParser(getAST23()); + ASTParser astParser = ASTParser.newParser(getAST23()); Map options = new HashMap<>(); options.put(JavaCore.COMPILER_COMPLIANCE, "23"); options.put(JavaCore.COMPILER_SOURCE, "23"); @@ -160,7 +160,7 @@ non-sealed class C extends A {} } public void test003_b() throws CoreException { - ASTParser astParser = ASTParser.newParser(getAST23()); + ASTParser astParser = ASTParser.newParser(getAST23()); Map options = new HashMap<>(); options.put(JavaCore.COMPILER_COMPLIANCE, "23"); options.put(JavaCore.COMPILER_SOURCE, "23"); @@ -190,7 +190,7 @@ non-sealed class C extends A {} //public sealed public void test003_c() throws CoreException { - ASTParser astParser = ASTParser.newParser(getAST23()); + ASTParser astParser = ASTParser.newParser(getAST23()); Map options = new HashMap<>(); options.put(JavaCore.COMPILER_COMPLIANCE, "23"); options.put(JavaCore.COMPILER_SOURCE, "23"); @@ -224,7 +224,7 @@ non-sealed class C extends A {} //abstract final public void test003_d() throws CoreException { - ASTParser astParser = ASTParser.newParser(getAST23()); + ASTParser astParser = ASTParser.newParser(getAST23()); Map options = new HashMap<>(); options.put(JavaCore.COMPILER_COMPLIANCE, "23"); options.put(JavaCore.COMPILER_SOURCE, "23"); @@ -254,7 +254,7 @@ abstract final class A {} //abstract non-sealed public void test003_e() throws CoreException { - ASTParser astParser = ASTParser.newParser(getAST23()); + ASTParser astParser = ASTParser.newParser(getAST23()); Map options = new HashMap<>(); options.put(JavaCore.COMPILER_COMPLIANCE, "23"); options.put(JavaCore.COMPILER_SOURCE, "23"); @@ -284,7 +284,7 @@ abstract non-sealed class A {} //public final public void test003_f() throws CoreException { - ASTParser astParser = ASTParser.newParser(getAST23()); + ASTParser astParser = ASTParser.newParser(getAST23()); Map options = new HashMap<>(); options.put(JavaCore.COMPILER_COMPLIANCE, "23"); options.put(JavaCore.COMPILER_SOURCE, "23"); @@ -314,7 +314,7 @@ public final class A {} //public non-sealed public void test003_g() throws CoreException { - ASTParser astParser = ASTParser.newParser(getAST23()); + ASTParser astParser = ASTParser.newParser(getAST23()); Map options = new HashMap<>(); options.put(JavaCore.COMPILER_COMPLIANCE, "23"); options.put(JavaCore.COMPILER_SOURCE, "23"); @@ -344,7 +344,7 @@ public non-sealed class A {} //protected non-sealed public void test003_h() throws CoreException { - ASTParser astParser = ASTParser.newParser(getAST23()); + ASTParser astParser = ASTParser.newParser(getAST23()); Map options = new HashMap<>(); options.put(JavaCore.COMPILER_COMPLIANCE, "23"); options.put(JavaCore.COMPILER_SOURCE, "23"); @@ -374,7 +374,7 @@ protected non-sealed class A {} //private non-sealed public void test003_i() throws CoreException { - ASTParser astParser = ASTParser.newParser(getAST23()); + ASTParser astParser = ASTParser.newParser(getAST23()); Map options = new HashMap<>(); options.put(JavaCore.COMPILER_COMPLIANCE, "23"); options.put(JavaCore.COMPILER_SOURCE, "23"); @@ -404,7 +404,7 @@ private non-sealed class A {} //protected abstract public void test003_j() throws CoreException { - ASTParser astParser = ASTParser.newParser(getAST23()); + ASTParser astParser = ASTParser.newParser(getAST23()); Map options = new HashMap<>(); options.put(JavaCore.COMPILER_COMPLIANCE, "23"); options.put(JavaCore.COMPILER_SOURCE, "23"); diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Modifier.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Modifier.java index 33304fd0019..369c802eac9 100644 --- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Modifier.java +++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Modifier.java @@ -336,14 +336,14 @@ public String toString() { * Applicable only to types. * @since 3.24 */ - public static final int SEALED = 0x1000; + public static final int SEALED = 0x0200; /** * "non-sealed" modifier constant (bit mask). * Applicable only to types. * @since 3.24 */ - public static final int NON_SEALED = 0x400; + public static final int NON_SEALED = 0x1000; /** * "module" modifier constant (bit mask). @@ -537,9 +537,6 @@ public static boolean isDefault(int flags) { * @since 3.24 */ public static boolean isSealed(int flags) { - if(flags < -32768 || flags > 32767) { - return((flags >>> 16 ) & SEALED ) != 0; - } return (flags & SEALED) != 0; } @@ -553,9 +550,6 @@ public static boolean isSealed(int flags) { * @since 3.24 */ public static boolean isNonSealed(int flags) { - if(flags < -32768 || flags > 32767) { - return ((flags >>> 16 ) & NON_SEALED ) != 0; - } return (flags & NON_SEALED) != 0; } diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeBinding.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeBinding.java index 464c862e53c..6ae56ee242c 100644 --- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeBinding.java +++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeBinding.java @@ -45,7 +45,7 @@ class TypeBinding implements ITypeBinding { protected static final IVariableBinding[] NO_VARIABLE_BINDINGS = new IVariableBinding[0]; private static final int VALID_MODIFIERS = Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE | - Modifier.ABSTRACT | Modifier.STATIC | Modifier.FINAL | Modifier.STRICTFP; + Modifier.ABSTRACT | Modifier.STATIC | Modifier.FINAL | Modifier.STRICTFP | Modifier.SEALED | Modifier.NON_SEALED; org.eclipse.jdt.internal.compiler.lookup.TypeBinding binding; private TypeBinding prototype = null; @@ -589,12 +589,16 @@ public int getModifiers() { if (isClass()) { ReferenceBinding referenceBinding = (ReferenceBinding) this.binding; final int accessFlags = referenceBinding.getAccessFlags() & VALID_MODIFIERS; + + if (referenceBinding.isSealed()) { + return accessFlags | Modifier.SEALED; + } + if (referenceBinding.isNonSealed()) { + return accessFlags | Modifier.NON_SEALED; + } if (referenceBinding.isAnonymousType()) { return accessFlags & ~Modifier.FINAL; } - if((referenceBinding.modifiers < -32768 || referenceBinding.modifiers > 32767) && (referenceBinding.isSealed() || referenceBinding.isNonSealed())) {//checks the modifiers has upper 16 bits - return referenceBinding.modifiers; - } return accessFlags; } else if (isAnnotation()) { ReferenceBinding referenceBinding = (ReferenceBinding) this.binding;