Skip to content

Commit 25c5674

Browse files
committed
fix how we spell "classpath" consistently
Otherwise it gets too confusing when mixing java and swift tools, the common way to spell the word is "classpath" without the uppercased P, even though in prose the words are "class path" and the shorthand "cp".
1 parent bb33176 commit 25c5674

File tree

5 files changed

+26
-26
lines changed

5 files changed

+26
-26
lines changed

Samples/JavaSieve/Sources/JavaSieve/main.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import JavaKit
1616
import JavaMath
1717

18-
let jvm = try JavaVirtualMachine.shared(classPath: ["QuadraticSieve-1.0.jar"])
18+
let jvm = try JavaVirtualMachine.shared(classpath: ["QuadraticSieve-1.0.jar"])
1919
do {
2020
let sieveClass = try JavaClass<SieveOfEratosthenes>(environment: jvm.environment())
2121
for prime in sieveClass.findPrimes(100)! {

Samples/JavaSieve/Sources/JavaSieve/swift-java.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"classPath" : "QuadraticSieve-1.0.jar",
2+
"classpath" : "QuadraticSieve-1.0.jar",
33
"classes" : {
44
"com.gazman.quadratic_sieve.QuadraticSieve" : "QuadraticSieve",
55
"com.gazman.quadratic_sieve.core.BaseFact" : "BaseFact",

Sources/Java2Swift/JavaToSwift.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -136,38 +136,38 @@ struct JavaToSwift: ParsableCommand {
136136

137137
// Form a class path from all of our input sources:
138138
// * Command-line option --classpath
139-
var classPathPieces: [String] = classpath
139+
var classpathPieces: [String] = classpath
140140
switch generationMode {
141141
case .configuration(jarFile: let jarFile):
142142
// * Jar file (in `-jar` mode)
143-
classPathPieces.append(jarFile)
143+
classpathPieces.append(jarFile)
144144
case .classWrappers(let config):
145145
// * Class path specified in the configuration file (if any)
146-
config.classPath.map { classPathPieces.append($0) }
146+
config.classpath.map { classpathPieces.append($0) }
147147
}
148148

149149
// * Classes paths from all dependent configuration files
150150
for (_, config) in dependentConfigs {
151-
config.classPath.map { classPathPieces.append($0) }
151+
config.classpath.map { classpathPieces.append($0) }
152152
}
153153

154154
// Bring up the Java VM.
155-
let jvm = try JavaVirtualMachine.shared(classPath: classPathPieces)
155+
let jvm = try JavaVirtualMachine.shared(classpath: classpathPieces)
156156

157157
// Run the generation step.
158-
let classPath = classPathPieces.joined(separator: ":")
158+
let classpath = classpathPieces.joined(separator: ":")
159159
switch generationMode {
160160
case .configuration(jarFile: let jarFile):
161161
try emitConfiguration(
162162
forJarFile: jarFile,
163-
classPath: classPath,
163+
classpath: classpath,
164164
environment: jvm.environment()
165165
)
166166

167167
case .classWrappers(let config):
168168
try generateWrappers(
169169
config: config,
170-
classPath: classPath,
170+
classpath: classpath,
171171
dependentConfigs: dependentConfigs,
172172
environment: jvm.environment()
173173
)
@@ -177,7 +177,7 @@ struct JavaToSwift: ParsableCommand {
177177
/// Generate wrapper
178178
mutating func generateWrappers(
179179
config: Configuration,
180-
classPath: String,
180+
classpath: String,
181181
dependentConfigs: [(String, Configuration)],
182182
environment: JNIEnvironment
183183
) throws {
@@ -340,10 +340,10 @@ struct JavaToSwift: ParsableCommand {
340340

341341
mutating func emitConfiguration(
342342
forJarFile jarFileName: String,
343-
classPath: String,
343+
classpath: String,
344344
environment: JNIEnvironment
345345
) throws {
346-
var configuration = Configuration(classPath: classPath)
346+
var configuration = Configuration(classpath: classpath)
347347

348348
let jarFile = try JarFile(jarFileName, false, environment: environment)
349349
for entry in jarFile.entries()! {

Sources/JavaKit/JavaKitVM/JavaVirtualMachine.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ public final class JavaVirtualMachine: @unchecked Sendable {
4444
/// Initialize a new Java virtual machine instance.
4545
///
4646
/// - Parameters:
47-
/// - classPath: The directories, JAR files, and ZIP files in which the JVM
47+
/// - classpath: The directories, JAR files, and ZIP files in which the JVM
4848
/// should look to find classes. This maps to the VM option
4949
/// `-Djava.class.path=`.
5050
/// - vmOptions: Options that should be passed along to the JVM, which will
5151
/// be prefixed by the class-path argument described above.
5252
/// - ignoreUnrecognized: Whether the JVM should ignore any VM options it
5353
/// does not recognize.
5454
private init(
55-
classPath: [String] = [],
55+
classpath: [String] = [],
5656
vmOptions: [String] = [],
5757
ignoreUnrecognized: Bool = false
5858
) throws {
@@ -64,14 +64,14 @@ public final class JavaVirtualMachine: @unchecked Sendable {
6464

6565
// Construct the complete list of VM options.
6666
var allVMOptions: [String] = []
67-
if !classPath.isEmpty {
67+
if !classpath.isEmpty {
6868
let fileManager = FileManager.default
69-
for path in classPath {
69+
for path in classpath {
7070
if !fileManager.fileExists(atPath: path) {
71-
throw JavaKitError.classPathEntryNotFound(entry: path, classPath: classPath)
71+
throw JavaKitError.classpathEntryNotFound(entry: path, classpath: classpath)
7272
}
7373
}
74-
let colonSeparatedClassPath = classPath.joined(separator: ":")
74+
let colonSeparatedClassPath = classpath.joined(separator: ":")
7575
allVMOptions.append("-Djava.class.path=\(colonSeparatedClassPath)")
7676
}
7777
allVMOptions.append(contentsOf: vmOptions)
@@ -183,15 +183,15 @@ extension JavaVirtualMachine {
183183
/// calls.
184184
///
185185
/// - Parameters:
186-
/// - classPath: The directories, JAR files, and ZIP files in which the JVM
186+
/// - classpath: The directories, JAR files, and ZIP files in which the JVM
187187
/// should look to find classes. This maps to the VM option
188188
/// `-Djava.class.path=`.
189189
/// - vmOptions: Options that should be passed along to the JVM, which will
190190
/// be prefixed by the class-path argument described above.
191191
/// - ignoreUnrecognized: Whether the JVM should ignore any VM options it
192192
/// does not recognize.
193193
public static func shared(
194-
classPath: [String] = [],
194+
classpath: [String] = [],
195195
vmOptions: [String] = [],
196196
ignoreUnrecognized: Bool = false
197197
) throws -> JavaVirtualMachine {
@@ -225,7 +225,7 @@ extension JavaVirtualMachine {
225225
let javaVirtualMachine: JavaVirtualMachine
226226
do {
227227
javaVirtualMachine = try JavaVirtualMachine(
228-
classPath: classPath,
228+
classpath: classpath,
229229
vmOptions: vmOptions,
230230
ignoreUnrecognized: ignoreUnrecognized
231231
)
@@ -289,6 +289,6 @@ extension JavaVirtualMachine {
289289
}
290290

291291
enum JavaKitError: Error {
292-
case classPathEntryNotFound(entry: String, classPath: [String])
292+
case classpathEntryNotFound(entry: String, classpath: [String])
293293
}
294294
}

USER_GUIDE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ The resulting configuration file will look something like this:
111111

112112
```json
113113
{
114-
"classPath" : "QuadraticSieve-1.0.jar",
114+
"classpath" : "QuadraticSieve-1.0.jar",
115115
"classes" : {
116116
"com.gazman.quadratic_sieve.QuadraticSieve" : "QuadraticSieve",
117117
"com.gazman.quadratic_sieve.core.BaseFact" : "BaseFact",
@@ -206,7 +206,7 @@ Putting it all together, we can define a main program in `Sources/JavaSieve/main
206206
```swift
207207
import JavaKit
208208

209-
let jvm = try JavaVirtualMachine.shared(classPath: ["QuadraticSieve-1.0.jar"])
209+
let jvm = try JavaVirtualMachine.shared(classpath: ["QuadraticSieve-1.0.jar"])
210210
do {
211211
let sieveClass = try JavaClass<SieveOfEratosthenes>(environment: jvm.environment())
212212
for prime in sieveClass.findPrimes(100)! {
@@ -217,7 +217,7 @@ do {
217217
}
218218
```
219219

220-
Note that we are passing the Jar file in the `classPath` argument when initializing the `JavaVirtualMachine` instance. Otherwise, the program will fail with an error because it cannot find the Java class `com.gazman.quadratic_sieve.primes.SieveOfEratosthenes`.
220+
Note that we are passing the Jar file in the `classpath` argument when initializing the `JavaVirtualMachine` instance. Otherwise, the program will fail with an error because it cannot find the Java class `com.gazman.quadratic_sieve.primes.SieveOfEratosthenes`.
221221

222222
### Downcasting
223223

0 commit comments

Comments
 (0)