Skip to content

Commit 66b4620

Browse files
Added more unit tests and incorporated code review changes
1 parent d5f9151 commit 66b4620

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Modifier.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -336,14 +336,14 @@ public String toString() {
336336
* Applicable only to types.
337337
* @since 3.24
338338
*/
339-
public static final int SEALED = 0x1000;
339+
public static final int SEALED = 0x0200;
340340

341341
/**
342342
* "non-sealed" modifier constant (bit mask).
343343
* Applicable only to types.
344344
* @since 3.24
345345
*/
346-
public static final int NON_SEALED = 0x400;
346+
public static final int NON_SEALED = 0x1000;
347347

348348
/**
349349
* "module" modifier constant (bit mask).
@@ -537,9 +537,6 @@ public static boolean isDefault(int flags) {
537537
* @since 3.24
538538
*/
539539
public static boolean isSealed(int flags) {
540-
if(flags < -32768 || flags > 32767) {
541-
return((flags >>> 16 ) & SEALED ) != 0;
542-
}
543540
return (flags & SEALED) != 0;
544541
}
545542

@@ -553,9 +550,6 @@ public static boolean isSealed(int flags) {
553550
* @since 3.24
554551
*/
555552
public static boolean isNonSealed(int flags) {
556-
if(flags < -32768 || flags > 32767) {
557-
return ((flags >>> 16 ) & NON_SEALED ) != 0;
558-
}
559553
return (flags & NON_SEALED) != 0;
560554
}
561555

org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeBinding.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class TypeBinding implements ITypeBinding {
4545
protected static final IVariableBinding[] NO_VARIABLE_BINDINGS = new IVariableBinding[0];
4646

4747
private static final int VALID_MODIFIERS = Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE |
48-
Modifier.ABSTRACT | Modifier.STATIC | Modifier.FINAL | Modifier.STRICTFP;
48+
Modifier.ABSTRACT | Modifier.STATIC | Modifier.FINAL | Modifier.STRICTFP | Modifier.SEALED | Modifier.NON_SEALED;
4949

5050
org.eclipse.jdt.internal.compiler.lookup.TypeBinding binding;
5151
private TypeBinding prototype = null;
@@ -589,12 +589,16 @@ public int getModifiers() {
589589
if (isClass()) {
590590
ReferenceBinding referenceBinding = (ReferenceBinding) this.binding;
591591
final int accessFlags = referenceBinding.getAccessFlags() & VALID_MODIFIERS;
592+
593+
if (referenceBinding.isSealed()) {
594+
return accessFlags | Modifier.SEALED;
595+
}
596+
if (referenceBinding.isNonSealed()) {
597+
return accessFlags | Modifier.NON_SEALED;
598+
}
592599
if (referenceBinding.isAnonymousType()) {
593600
return accessFlags & ~Modifier.FINAL;
594601
}
595-
if((referenceBinding.modifiers < -32768 || referenceBinding.modifiers > 32767) && (referenceBinding.isSealed() || referenceBinding.isNonSealed())) {//checks the modifiers has upper 16 bits
596-
return referenceBinding.modifiers;
597-
}
598602
return accessFlags;
599603
} else if (isAnnotation()) {
600604
ReferenceBinding referenceBinding = (ReferenceBinding) this.binding;

0 commit comments

Comments
 (0)