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 12, 2024
1 parent 812ae1d commit 6695651
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ void main() {
}

public void test003_a() throws CoreException {
ASTParser astParser = ASTParser.newParser(getAST23());
ASTParser astParser = ASTParser.newParser(getAST23());
Map<String, String> options = new HashMap<>();
options.put(JavaCore.COMPILER_COMPLIANCE, "23");
options.put(JavaCore.COMPILER_SOURCE, "23");
Expand Down Expand Up @@ -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<String, String> options = new HashMap<>();
options.put(JavaCore.COMPILER_COMPLIANCE, "23");
options.put(JavaCore.COMPILER_SOURCE, "23");
Expand Down Expand Up @@ -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<String, String> options = new HashMap<>();
options.put(JavaCore.COMPILER_COMPLIANCE, "23");
options.put(JavaCore.COMPILER_SOURCE, "23");
Expand Down Expand Up @@ -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<String, String> options = new HashMap<>();
options.put(JavaCore.COMPILER_COMPLIANCE, "23");
options.put(JavaCore.COMPILER_SOURCE, "23");
Expand Down Expand Up @@ -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<String, String> options = new HashMap<>();
options.put(JavaCore.COMPILER_COMPLIANCE, "23");
options.put(JavaCore.COMPILER_SOURCE, "23");
Expand Down Expand Up @@ -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<String, String> options = new HashMap<>();
options.put(JavaCore.COMPILER_COMPLIANCE, "23");
options.put(JavaCore.COMPILER_SOURCE, "23");
Expand Down Expand Up @@ -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<String, String> options = new HashMap<>();
options.put(JavaCore.COMPILER_COMPLIANCE, "23");
options.put(JavaCore.COMPILER_SOURCE, "23");
Expand Down Expand Up @@ -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<String, String> options = new HashMap<>();
options.put(JavaCore.COMPILER_COMPLIANCE, "23");
options.put(JavaCore.COMPILER_SOURCE, "23");
Expand Down Expand Up @@ -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<String, String> options = new HashMap<>();
options.put(JavaCore.COMPILER_COMPLIANCE, "23");
options.put(JavaCore.COMPILER_SOURCE, "23");
Expand Down Expand Up @@ -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<String, String> options = new HashMap<>();
options.put(JavaCore.COMPILER_COMPLIANCE, "23");
options.put(JavaCore.COMPILER_SOURCE, "23");
Expand Down
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 6695651

Please sign in to comment.