Skip to content

Commit f63150a

Browse files
authored
Fix how we spell "classpath" consistently (#192)
1 parent bb33176 commit f63150a

File tree

6 files changed

+29
-29
lines changed

6 files changed

+29
-29
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/Java2SwiftLib/Configuration.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ package typealias JavaVersion = Int
2121
/// must be kept in sync.
2222
package struct Configuration: Codable {
2323
/// The Java class path that should be passed along to the Java2Swift tool.
24-
package var classPath: String? = nil
24+
package var classpath: String? = nil
2525

2626
/// The Java classes that should be translated to Swift. The keys are
2727
/// canonical Java class names (e.g., java.util.Vector) and the values are
@@ -32,12 +32,12 @@ package struct Configuration: Codable {
3232
package var targetCompatibility: JavaVersion?
3333

3434
package init(
35-
classPath: String? = nil,
35+
classpath: String? = nil,
3636
classes: [String : String] = [:],
3737
sourceCompatibility: JavaVersion? = nil,
3838
targetCompatibility: JavaVersion? = nil
3939
) {
40-
self.classPath = classPath
40+
self.classpath = classpath
4141
self.classes = classes
4242
self.sourceCompatibility = sourceCompatibility
4343
self.targetCompatibility = targetCompatibility

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)