Skip to content

Commit

Permalink
Don't cast JavaFileManager to JavacFileManager
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Pine authored and parttimenerd committed Feb 15, 2025
1 parent e5aad96 commit 5347cfd
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -719,17 +719,20 @@ private void processBPFProgramImpl(TypedTreePath<ClassTree> programPath) {
}
}
} else {
var outFolders = ((JavacFileManager) ((JavacTaskImpl) CompilerPlugin.this.task).getContext().get(JavaFileManager.class)).getLocation(StandardLocation.CLASS_OUTPUT);
if (!outFolders.iterator().hasNext()) {
var resourceName = bpfProgramTypeElement.getQualifiedName() + ".o";
var fileManager = ((JavacTaskImpl) CompilerPlugin.this.task).getContext().get(JavaFileManager.class);
Path outPath;
try {
outPath = Path.of(fileManager.getFileForOutput(StandardLocation.CLASS_OUTPUT, "", resourceName, null).toUri().getPath());
} catch (IOException e) {
logError(programPath, bpfProgram, "No output folder found");
return;
}
var resourceName = bpfProgramTypeElement.getQualifiedName() + ".o";
var outFolder = outFolders.iterator().next();

try {
Files.write(outFolder.toPath().resolve(resourceName), compiledCode.gzip());
Files.write(outPath, compiledCode.gzip());
} catch (IOException e) {
logError(programPath, bpfProgram, "Could not write byte code to " + outFolder);
logError(programPath, bpfProgram, "Could not write byte code to " + outPath);
}
for (var member : bpfProgram.getMembers()) {
if (member instanceof JCMethodDecl methodDecl) {
Expand Down

0 comments on commit 5347cfd

Please sign in to comment.