@@ -151,12 +151,12 @@ non-sealed class C extends A {}
151151 CompilationUnit compilationUnit = (CompilationUnit ) astParser .createAST (null );
152152 TypeDeclaration a = (TypeDeclaration ) compilationUnit .types ().get (0 );
153153
154- assertEquals ( " Modifier is not present in AST" , Modifier .isSealed (a .getModifiers ()), true );
154+ assertTrue ( Modifier .isSealed (a .getModifiers ()));
155155
156156 assertEquals ("permitted types are not present in AST" , a .permittedTypes ().size (), 2 );
157157
158158 ITypeBinding aBinding = a .resolveBinding ();
159- assertEquals ( "'sealed' modifier is not set in binding" , Modifier .isSealed (aBinding .getModifiers ()), true );
159+ assertTrue ( Modifier .isSealed (aBinding .getModifiers ()));
160160 }
161161
162162 public void test003_b () throws CoreException {
@@ -182,10 +182,10 @@ non-sealed class C extends A {}
182182 CompilationUnit compilationUnit = (CompilationUnit ) astParser .createAST (null );
183183 TypeDeclaration a = (TypeDeclaration ) compilationUnit .types ().get (2 );
184184
185- assertEquals ( " Modifier is not present in AST" , Modifier .isNonSealed (a .getModifiers ()), true );
185+ assertTrue ( Modifier .isNonSealed (a .getModifiers ()));
186186
187187 ITypeBinding aBinding = a .resolveBinding ();
188- assertEquals ( "'non-sealed' modifier is not set in binding" , Modifier .isNonSealed (aBinding .getModifiers ()), true );
188+ assertTrue ( Modifier .isNonSealed (aBinding .getModifiers ()));
189189 }
190190
191191 //public sealed
@@ -212,14 +212,14 @@ non-sealed class C extends A {}
212212 CompilationUnit compilationUnit = (CompilationUnit ) astParser .createAST (null );
213213 TypeDeclaration a = (TypeDeclaration ) compilationUnit .types ().get (0 );
214214
215- assertEquals ( " Modifier is not present in AST" , Modifier .isSealed (a .getModifiers ()), true );
216- assertEquals ( " Modifier is not present in AST" , Modifier .isPublic (a .getModifiers ()), true );
215+ assertTrue ( Modifier .isSealed (a .getModifiers ()));
216+ assertTrue ( Modifier .isPublic (a .getModifiers ()));
217217
218218 assertEquals ("permitted types are not present in AST" , a .permittedTypes ().size (), 2 );
219219
220220 ITypeBinding aBinding = a .resolveBinding ();
221- assertEquals ( "'sealed' modifier is not set in binding" , Modifier .isSealed (aBinding .getModifiers ()), true );
222- assertEquals ( "'public' modifier is not set in binding" , Modifier .isPublic (aBinding .getModifiers ()), true );
221+ assertTrue ( Modifier .isSealed (aBinding .getModifiers ()));
222+ assertTrue ( Modifier .isPublic (aBinding .getModifiers ()));
223223 }
224224
225225 //abstract final
@@ -243,13 +243,13 @@ abstract final class A {}
243243 CompilationUnit compilationUnit = (CompilationUnit ) astParser .createAST (null );
244244 TypeDeclaration a = (TypeDeclaration ) compilationUnit .types ().get (0 );
245245
246- assertEquals ( " Modifier is not present in AST" , Modifier .isAbstract (a .getModifiers ()), true );
247- assertEquals ( " Modifier is not present in AST" , Modifier .isFinal (a .getModifiers ()), true );
246+ assertTrue ( Modifier .isAbstract (a .getModifiers ()));
247+ assertTrue ( Modifier .isFinal (a .getModifiers ()));
248248
249249 ITypeBinding aBinding = a .resolveBinding ();
250250
251- assertEquals ( "'abstract' modifier is not set in binding" , Modifier .isAbstract (aBinding .getModifiers ()), true );
252- assertEquals ( "'final' modifier is not set in binding" , Modifier .isFinal (aBinding .getModifiers ()), true );
251+ assertTrue ( Modifier .isAbstract (aBinding .getModifiers ()));
252+ assertTrue ( Modifier .isFinal (aBinding .getModifiers ()));
253253 }
254254
255255 //abstract non-sealed
@@ -273,13 +273,13 @@ abstract non-sealed class A {}
273273 CompilationUnit compilationUnit = (CompilationUnit ) astParser .createAST (null );
274274 TypeDeclaration a = (TypeDeclaration ) compilationUnit .types ().get (0 );
275275
276- assertEquals ( " Modifier is not present in AST" , Modifier .isAbstract (a .getModifiers ()), true );
277- assertEquals ( " Modifier is not present in AST" , Modifier .isNonSealed (a .getModifiers ()), true );
276+ assertTrue ( Modifier .isAbstract (a .getModifiers ()));
277+ assertTrue ( Modifier .isNonSealed (a .getModifiers ()));
278278
279279 ITypeBinding aBinding = a .resolveBinding ();
280280
281- assertEquals ( "'abstract' modifier is not set in binding" , Modifier .isAbstract (aBinding .getModifiers ()), true );
282- assertEquals ( "'non-sealed' modifier is not set in binding" , Modifier .isNonSealed (aBinding .getModifiers ()), true );
281+ assertTrue ( Modifier .isAbstract (aBinding .getModifiers ()));
282+ assertTrue ( Modifier .isNonSealed (aBinding .getModifiers ()));
283283 }
284284
285285 //public final
@@ -303,13 +303,13 @@ public final class A {}
303303 CompilationUnit compilationUnit = (CompilationUnit ) astParser .createAST (null );
304304 TypeDeclaration a = (TypeDeclaration ) compilationUnit .types ().get (0 );
305305
306- assertEquals ( " Modifier is not present in AST" , Modifier .isPublic (a .getModifiers ()), true );
307- assertEquals ( " Modifier is not present in AST" , Modifier .isFinal (a .getModifiers ()), true );
306+ assertTrue ( Modifier .isPublic (a .getModifiers ()));
307+ assertTrue ( Modifier .isFinal (a .getModifiers ()));
308308
309309 ITypeBinding aBinding = a .resolveBinding ();
310310
311- assertEquals ( "'public' modifier is not set in binding" , Modifier .isPublic (aBinding .getModifiers ()), true );
312- assertEquals ( "'final' modifier is not set in binding" , Modifier .isFinal (aBinding .getModifiers ()), true );
311+ assertTrue ( Modifier .isPublic (aBinding .getModifiers ()));
312+ assertTrue ( Modifier .isFinal (aBinding .getModifiers ()));
313313 }
314314
315315 //public non-sealed
@@ -333,13 +333,13 @@ public non-sealed class A {}
333333 CompilationUnit compilationUnit = (CompilationUnit ) astParser .createAST (null );
334334 TypeDeclaration a = (TypeDeclaration ) compilationUnit .types ().get (0 );
335335
336- assertEquals ( " Modifier is not present in AST" , Modifier .isPublic (a .getModifiers ()), true );
337- assertEquals ( " Modifier is not present in AST" , Modifier .isNonSealed (a .getModifiers ()), true );
336+ assertTrue ( Modifier .isPublic (a .getModifiers ()));
337+ assertTrue ( Modifier .isNonSealed (a .getModifiers ()));
338338
339339 ITypeBinding aBinding = a .resolveBinding ();
340340
341- assertEquals ( "'public' modifier is not set in binding" , Modifier .isPublic (aBinding .getModifiers ()), true );
342- assertEquals ( "'final' modifier is not set in binding" , Modifier .isNonSealed (aBinding .getModifiers ()), true );
341+ assertTrue ( Modifier .isPublic (aBinding .getModifiers ()));
342+ assertTrue ( Modifier .isNonSealed (aBinding .getModifiers ()));
343343 }
344344
345345 //protected non-sealed
@@ -363,13 +363,13 @@ protected non-sealed class A {}
363363 CompilationUnit compilationUnit = (CompilationUnit ) astParser .createAST (null );
364364 TypeDeclaration a = (TypeDeclaration ) compilationUnit .types ().get (0 );
365365
366- assertEquals ( " Modifier is not present in AST" , Modifier .isProtected (a .getModifiers ()), true );
367- assertEquals ( " Modifier is not present in AST" , Modifier .isNonSealed (a .getModifiers ()), true );
366+ assertTrue ( Modifier .isProtected (a .getModifiers ()));
367+ assertTrue ( Modifier .isNonSealed (a .getModifiers ()));
368368
369369 ITypeBinding aBinding = a .resolveBinding ();
370370
371- assertEquals ( "'public' modifier is not set in binding" , Modifier .isProtected (aBinding .getModifiers ()), true );
372- assertEquals ( "'final' modifier is not set in binding" , Modifier .isNonSealed (aBinding .getModifiers ()), true );
371+ assertTrue ( Modifier .isProtected (aBinding .getModifiers ()));
372+ assertTrue ( Modifier .isNonSealed (aBinding .getModifiers ()));
373373 }
374374
375375 //private non-sealed
@@ -393,13 +393,13 @@ private non-sealed class A {}
393393 CompilationUnit compilationUnit = (CompilationUnit ) astParser .createAST (null );
394394 TypeDeclaration a = (TypeDeclaration ) compilationUnit .types ().get (0 );
395395
396- assertEquals ( " Modifier is not present in AST" , Modifier .isPrivate (a .getModifiers ()), true );
397- assertEquals ( " Modifier is not present in AST" , Modifier .isNonSealed (a .getModifiers ()), true );
396+ assertTrue ( Modifier .isPrivate (a .getModifiers ()));
397+ assertTrue ( Modifier .isNonSealed (a .getModifiers ()));
398398
399399 ITypeBinding aBinding = a .resolveBinding ();
400400
401- assertEquals ( "'public' modifier is not set in binding" , Modifier .isPrivate (aBinding .getModifiers ()), true );
402- assertEquals ( "'final' modifier is not set in binding" , Modifier .isNonSealed (aBinding .getModifiers ()), true );
401+ assertTrue ( Modifier .isPrivate (aBinding .getModifiers ()));
402+ assertTrue ( Modifier .isNonSealed (aBinding .getModifiers ()));
403403 }
404404
405405 //protected abstract
@@ -423,12 +423,108 @@ protected abstract class A {}
423423 CompilationUnit compilationUnit = (CompilationUnit ) astParser .createAST (null );
424424 TypeDeclaration a = (TypeDeclaration ) compilationUnit .types ().get (0 );
425425
426- assertEquals ( " Modifier is not present in AST" , Modifier .isProtected (a .getModifiers ()), true );
427- assertEquals ( " Modifier is not present in AST" , Modifier .isAbstract (a .getModifiers ()), true );
426+ assertTrue ( Modifier .isProtected (a .getModifiers ()));
427+ assertTrue ( Modifier .isAbstract (a .getModifiers ()));
428428
429429 ITypeBinding aBinding = a .resolveBinding ();
430430
431- assertEquals ("'public' modifier is not set in binding" , Modifier .isProtected (aBinding .getModifiers ()), true );
432- assertEquals ("'final' modifier is not set in binding" , Modifier .isAbstract (aBinding .getModifiers ()), true );
431+ assertTrue (Modifier .isProtected (aBinding .getModifiers ()));
432+ assertTrue (Modifier .isAbstract (aBinding .getModifiers ()));
433+ }
434+
435+ //public sealed interface
436+ public void test003_k () throws CoreException {
437+ ASTParser astParser = ASTParser .newParser (getAST23 ());
438+ Map <String , String > options = new HashMap <>();
439+ options .put (JavaCore .COMPILER_COMPLIANCE , "23" );
440+ options .put (JavaCore .COMPILER_SOURCE , "23" );
441+
442+ astParser .setCompilerOptions (options );
443+ astParser .setEnvironment (new String [] {}, new String [] {}, new String [] {}, true );
444+ astParser .setUnitName ("Example.java" );
445+ astParser .setResolveBindings (true );
446+ astParser .setBindingsRecovery (true );
447+
448+ String source ="""
449+ public sealed interface A permits X {}
450+ public final class X implements A {}
451+ """ ;
452+
453+ astParser .setSource (source .toCharArray ());
454+
455+ CompilationUnit compilationUnit = (CompilationUnit ) astParser .createAST (null );
456+ TypeDeclaration a = (TypeDeclaration ) compilationUnit .types ().get (0 );
457+
458+ assertTrue (Modifier .isSealed (a .getModifiers ()));
459+ assertTrue (Modifier .isPublic (a .getModifiers ()));
460+ assertEquals ("permitted types are not present in AST" , a .permittedTypes ().size (), 1 );
461+
462+ ITypeBinding aBinding = a .resolveBinding ();
463+ assertTrue (Modifier .isSealed (aBinding .getModifiers ()));
464+ assertTrue (Modifier .isPublic (aBinding .getModifiers ()));
465+ }
466+
467+ //public non-sealed interface
468+ public void test003_l () throws CoreException {
469+ ASTParser astParser = ASTParser .newParser (getAST23 ());
470+ Map <String , String > options = new HashMap <>();
471+ options .put (JavaCore .COMPILER_COMPLIANCE , "23" );
472+ options .put (JavaCore .COMPILER_SOURCE , "23" );
473+
474+ astParser .setCompilerOptions (options );
475+ astParser .setEnvironment (new String [] {}, new String [] {}, new String [] {}, true );
476+ astParser .setUnitName ("Example.java" );
477+ astParser .setResolveBindings (true );
478+ astParser .setBindingsRecovery (true );
479+
480+ String source ="""
481+ public non-sealed interface A permits X {}
482+ public final class X implements A {}
483+ """ ;
484+
485+ astParser .setSource (source .toCharArray ());
486+
487+ CompilationUnit compilationUnit = (CompilationUnit ) astParser .createAST (null );
488+ TypeDeclaration a = (TypeDeclaration ) compilationUnit .types ().get (0 );
489+
490+ assertTrue (Modifier .isNonSealed (a .getModifiers ()));
491+ assertTrue (Modifier .isPublic (a .getModifiers ()));
492+ assertEquals ("permitted types are not present in AST" , a .permittedTypes ().size (), 1 );
493+
494+ ITypeBinding aBinding = a .resolveBinding ();
495+ assertTrue (Modifier .isNonSealed (aBinding .getModifiers ()));
496+ assertTrue (Modifier .isPublic (aBinding .getModifiers ()));
497+ }
498+
499+ //public strictfp interface
500+ public void test003_m () throws CoreException {
501+ ASTParser astParser = ASTParser .newParser (getAST23 ());
502+ Map <String , String > options = new HashMap <>();
503+ options .put (JavaCore .COMPILER_COMPLIANCE , "23" );
504+ options .put (JavaCore .COMPILER_SOURCE , "23" );
505+
506+ astParser .setCompilerOptions (options );
507+ astParser .setEnvironment (new String [] {}, new String [] {}, new String [] {}, true );
508+ astParser .setUnitName ("Example.java" );
509+ astParser .setResolveBindings (true );
510+ astParser .setBindingsRecovery (true );
511+
512+ String source ="""
513+ public strictfp interface A permits X {}
514+ public final class X implements A {}
515+ """ ;
516+
517+ astParser .setSource (source .toCharArray ());
518+
519+ CompilationUnit compilationUnit = (CompilationUnit ) astParser .createAST (null );
520+ TypeDeclaration a = (TypeDeclaration ) compilationUnit .types ().get (0 );
521+
522+ assertTrue (Modifier .isStrictfp (a .getModifiers ()));
523+ assertTrue (Modifier .isPublic (a .getModifiers ()));
524+ assertEquals ("permitted types are not present in AST" , a .permittedTypes ().size (), 1 );
525+
526+ ITypeBinding aBinding = a .resolveBinding ();
527+ assertTrue (Modifier .isStrictfp (aBinding .getModifiers ()));
528+ assertTrue (Modifier .isPublic (aBinding .getModifiers ()));
433529 }
434530}
0 commit comments