Skip to content

Commit e2e26dd

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

File tree

3 files changed

+20
-22
lines changed

3 files changed

+20
-22
lines changed

org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter_23Test.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ void main() {
129129
}
130130

131131
public void test003_a() throws CoreException {
132-
ASTParser astParser = ASTParser.newParser(getAST23());
132+
ASTParser astParser = ASTParser.newParser(getAST23());
133133
Map<String, String> options = new HashMap<>();
134134
options.put(JavaCore.COMPILER_COMPLIANCE, "23");
135135
options.put(JavaCore.COMPILER_SOURCE, "23");
@@ -160,7 +160,7 @@ non-sealed class C extends A {}
160160
}
161161

162162
public void test003_b() throws CoreException {
163-
ASTParser astParser = ASTParser.newParser(getAST23());
163+
ASTParser astParser = ASTParser.newParser(getAST23());
164164
Map<String, String> options = new HashMap<>();
165165
options.put(JavaCore.COMPILER_COMPLIANCE, "23");
166166
options.put(JavaCore.COMPILER_SOURCE, "23");
@@ -190,7 +190,7 @@ non-sealed class C extends A {}
190190

191191
//public sealed
192192
public void test003_c() throws CoreException {
193-
ASTParser astParser = ASTParser.newParser(getAST23());
193+
ASTParser astParser = ASTParser.newParser(getAST23());
194194
Map<String, String> options = new HashMap<>();
195195
options.put(JavaCore.COMPILER_COMPLIANCE, "23");
196196
options.put(JavaCore.COMPILER_SOURCE, "23");
@@ -224,7 +224,7 @@ non-sealed class C extends A {}
224224

225225
//abstract final
226226
public void test003_d() throws CoreException {
227-
ASTParser astParser = ASTParser.newParser(getAST23());
227+
ASTParser astParser = ASTParser.newParser(getAST23());
228228
Map<String, String> options = new HashMap<>();
229229
options.put(JavaCore.COMPILER_COMPLIANCE, "23");
230230
options.put(JavaCore.COMPILER_SOURCE, "23");
@@ -254,7 +254,7 @@ abstract final class A {}
254254

255255
//abstract non-sealed
256256
public void test003_e() throws CoreException {
257-
ASTParser astParser = ASTParser.newParser(getAST23());
257+
ASTParser astParser = ASTParser.newParser(getAST23());
258258
Map<String, String> options = new HashMap<>();
259259
options.put(JavaCore.COMPILER_COMPLIANCE, "23");
260260
options.put(JavaCore.COMPILER_SOURCE, "23");
@@ -284,7 +284,7 @@ abstract non-sealed class A {}
284284

285285
//public final
286286
public void test003_f() throws CoreException {
287-
ASTParser astParser = ASTParser.newParser(getAST23());
287+
ASTParser astParser = ASTParser.newParser(getAST23());
288288
Map<String, String> options = new HashMap<>();
289289
options.put(JavaCore.COMPILER_COMPLIANCE, "23");
290290
options.put(JavaCore.COMPILER_SOURCE, "23");
@@ -314,7 +314,7 @@ public final class A {}
314314

315315
//public non-sealed
316316
public void test003_g() throws CoreException {
317-
ASTParser astParser = ASTParser.newParser(getAST23());
317+
ASTParser astParser = ASTParser.newParser(getAST23());
318318
Map<String, String> options = new HashMap<>();
319319
options.put(JavaCore.COMPILER_COMPLIANCE, "23");
320320
options.put(JavaCore.COMPILER_SOURCE, "23");
@@ -344,7 +344,7 @@ public non-sealed class A {}
344344

345345
//protected non-sealed
346346
public void test003_h() throws CoreException {
347-
ASTParser astParser = ASTParser.newParser(getAST23());
347+
ASTParser astParser = ASTParser.newParser(getAST23());
348348
Map<String, String> options = new HashMap<>();
349349
options.put(JavaCore.COMPILER_COMPLIANCE, "23");
350350
options.put(JavaCore.COMPILER_SOURCE, "23");
@@ -374,7 +374,7 @@ protected non-sealed class A {}
374374

375375
//private non-sealed
376376
public void test003_i() throws CoreException {
377-
ASTParser astParser = ASTParser.newParser(getAST23());
377+
ASTParser astParser = ASTParser.newParser(getAST23());
378378
Map<String, String> options = new HashMap<>();
379379
options.put(JavaCore.COMPILER_COMPLIANCE, "23");
380380
options.put(JavaCore.COMPILER_SOURCE, "23");
@@ -404,7 +404,7 @@ private non-sealed class A {}
404404

405405
//protected abstract
406406
public void test003_j() throws CoreException {
407-
ASTParser astParser = ASTParser.newParser(getAST23());
407+
ASTParser astParser = ASTParser.newParser(getAST23());
408408
Map<String, String> options = new HashMap<>();
409409
options.put(JavaCore.COMPILER_COMPLIANCE, "23");
410410
options.put(JavaCore.COMPILER_SOURCE, "23");

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)