Skip to content

Commit

Permalink
javac: Add pwd to classpath (#1070)
Browse files Browse the repository at this point in the history
  • Loading branch information
bummoblizard committed May 3, 2024
1 parent b0d9c72 commit acaf4d3
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions NodeExtension/ActionRequestHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ class OutputListener {
public func JavaEntrance(argc: Int32, argv: UnsafeMutablePointer<UnsafeMutablePointer<Int8>?>?) -> Int32 {
JavaLauncher.shared.launchJava(
args: JavaLauncher.shared.lastArgs,
frameworkDirectory: JavaLauncher.shared.lastFrameworkDir
frameworkDirectory: JavaLauncher.shared.lastFrameworkDir,
currentDirectory: JavaLauncher.shared.lastCurrentDirectory
)
return 0
}
Expand All @@ -148,6 +149,7 @@ class JavaLauncher {
static let shared = JavaLauncher()

var lastFrameworkDir: URL!
var lastCurrentDirectory: URL!
var lastArgs: [String] = []
var javaString: NSString = "java"
var openJDKString: NSString = "openjdk"
Expand Down Expand Up @@ -186,8 +188,9 @@ class JavaLauncher {
Int32
) -> CInt

func launchJava(args: [String], frameworkDirectory: URL){
func launchJava(args: [String], frameworkDirectory: URL, currentDirectory: URL){
lastFrameworkDir = frameworkDirectory
lastCurrentDirectory = currentDirectory
lastArgs = args

let libjlipath = "\(frameworkDirectory.path)/libjli.framework/libjli"
Expand Down Expand Up @@ -228,7 +231,7 @@ class JavaLauncher {
return (
defaultArgs +
["-cp",
"\(Bundle.main.resourcePath!)/tools.jar",
"\(Bundle.main.resourcePath!)/tools.jar:\(currentDirectory.path)",
"com.sun.tools.javac.Main"
]
+ args.dropFirst()
Expand Down Expand Up @@ -338,7 +341,7 @@ class ActionRequestHandler: NSObject, NSExtensionRequestHandling {

switch executable {
case "java", "javac":
JavaLauncher.shared.launchJava(args: args, frameworkDirectory: frameworkDirURL)
JavaLauncher.shared.launchJava(args: args, frameworkDirectory: frameworkDirURL, currentDirectory: url)
case "node":
NodeRunner.startEngine(withArguments: args)
default:
Expand Down

0 comments on commit acaf4d3

Please sign in to comment.