Skip to content

Commit

Permalink
Skip invoking the phantom generator from the javac service if there a…
Browse files Browse the repository at this point in the history
…re no classes to scan
  • Loading branch information
Col-E committed Jan 12, 2025
1 parent 221e005 commit 9bc0850
Showing 1 changed file with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,20 +109,22 @@ public CompilerResult compile(@Nonnull JavacArguments arguments,
virtualClassPath = Lists.combine(virtualClassPath, supplementaryResources);

// Generate phantom classes if the workspace does not already have phantoms in it.
if (workspace != null && config.getGeneratePhantoms().getValue() && workspace.getSupportingResources().stream()
.noneMatch(resource -> resource instanceof GeneratedPhantomWorkspaceResource)) {
try {
// Only scan the target class and any of its inner classes for content to fill in.
List<JvmClassInfo> classesToScan = workspace.findJvmClasses(c -> c.getName().equals(className) || c.isInnerClassOf(className)).stream()
.map(p -> p.getValue().asJvmClass())
.collect(Collectors.toList());
WorkspaceResource phantomResource = phantomGenerator.createPhantomsForClasses(workspace, classesToScan);
int generatedCount = phantomResource.getJvmClassBundle().size();
if (generatedCount > 0)
logger.debug("Generated {} phantoms for pre-compile", generatedCount);
virtualClassPath = Lists.add(virtualClassPath, phantomResource);
} catch (PhantomGenerationException ex) {
logger.warn("Failed to generate phantoms for compilation against '{}'", className, ex);
if (workspace != null && config.getGeneratePhantoms().getValue()
&& workspace.getSupportingResources().stream().noneMatch(resource -> resource instanceof GeneratedPhantomWorkspaceResource)) {
// Only scan the target class and any of its inner classes for content to fill in.
List<JvmClassInfo> classesToScan = workspace.findJvmClasses(c -> c.getName().equals(className) || c.isInnerClassOf(className)).stream()
.map(p -> p.getValue().asJvmClass())
.collect(Collectors.toList());
if (!classesToScan.isEmpty()) {
try {
WorkspaceResource phantomResource = phantomGenerator.createPhantomsForClasses(workspace, classesToScan);
int generatedCount = phantomResource.getJvmClassBundle().size();
if (generatedCount > 0)
logger.debug("Generated {} phantoms for pre-compile", generatedCount);
virtualClassPath = Lists.add(virtualClassPath, phantomResource);
} catch (PhantomGenerationException ex) {
logger.warn("Failed to generate phantoms for compilation against '{}'", className, ex);
}
}
}

Expand Down

0 comments on commit 9bc0850

Please # to comment.