Skip to content

Commit

Permalink
Added more unit tests and incorporated code review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
subyssurendran666 committed Dec 6, 2024
1 parent d5f9151 commit 66b4620
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
10 changes: 2 additions & 8 deletions org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Modifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 66b4620

Please sign in to comment.