Skip to content

Commit

Permalink
[GR-48667] Look for AddExports in Suite.SuiteClasses
Browse files Browse the repository at this point in the history
PullRequest: mx/1677
  • Loading branch information
patrick96 committed Sep 15, 2023
2 parents aa775d2 + 2739de2 commit f0c8c7c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.junit.runners.Suite;

import jdk.internal.module.Modules;

class ModuleSupport {
Expand All @@ -45,7 +47,13 @@ class ModuleSupport {
this.out = out;
}

void processAddExportsAnnotations(Set<Class<?>> classes, Set<String> opened, Set<String> exported) {
void processAddExportsAnnotations(Set<Class<?>> requestClasses, Set<String> opened, Set<String> exported) {
Set<Class<?>> classes = new HashSet<>();

for (Class<?> cls : requestClasses) {
gatherClasses(cls, classes);
}

Set<Class<?>> types = new HashSet<>();
for (Class<?> cls : classes) {
gatherSupertypes(cls, types);
Expand All @@ -68,6 +76,22 @@ void processAddExportsAnnotations(Set<Class<?>> classes, Set<String> opened, Set
}
}

/**
* Recursively looks through the given base class for {@code Suite.SuiteClasses} annotations and
* adds all classes to the set.
*/
private void gatherClasses(Class<?> base, Set<Class<?>> classes) {
if (!classes.contains(base)) {
classes.add(base);
Suite.SuiteClasses annot = base.getDeclaredAnnotation(Suite.SuiteClasses.class);
if (annot != null) {
for (Class<?> cls : annot.value()) {
gatherClasses(cls, classes);
}
}
}
}

void processAddModulesAnnotations(Set<Class<?>> classes) {
Set<Class<?>> types = new HashSet<>();
for (Class<?> cls : classes) {
Expand Down
3 changes: 3 additions & 0 deletions mx.mx/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,9 @@
"com.oracle.mxtool.junit.jdk9" : {
"subDir" : "java",
"sourceDirs" : ["src"],
"dependencies" : [
"JUNIT",
],
"requiresConcealed" : {
"java.base" : [
"jdk.internal.module",
Expand Down
2 changes: 1 addition & 1 deletion mx.py
Original file line number Diff line number Diff line change
Expand Up @@ -18789,7 +18789,7 @@ def alarm_handler(signum, frame):
abort(1, killsig=signal.SIGINT)

# The version must be updated for every PR (checked in CI) and the comment should reflect the PR's issue
version = VersionSpec("6.49.1") # fetch-jdk labsjdk-ee-latest
version = VersionSpec("6.50.0") # GR-48667 Scan SuiteClasses for @AddExports

_mx_start_datetime = datetime.utcnow()
_last_timestamp = _mx_start_datetime
Expand Down

0 comments on commit f0c8c7c

Please sign in to comment.