Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 1 addition & 2 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ jobs:
with:
# Not API stable package (yet)
api_breakage_check_enabled: false
# FIXME: Something is off with the format task and it gets "stuck", need to investigate
format_check_enabled: false
format_check_enabled: true
license_header_check_project_name: Swift.org
# Since we need JAVA_HOME to be set up for building the project and depending on a different workflow won't
# give us that, we disable the checking and make a separate job that performs docs validation
Expand Down
63 changes: 63 additions & 0 deletions .swift-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"version" : 1,
"indentation" : {
"spaces" : 2
},
"tabWidth" : 2,
"fileScopedDeclarationPrivacy" : {
"accessLevel" : "private"
},
"spacesAroundRangeFormationOperators" : false,
"indentConditionalCompilationBlocks" : false,
"indentSwitchCaseLabels" : false,
"lineBreakAroundMultilineExpressionChainComponents" : false,
"lineBreakBeforeControlFlowKeywords" : false,
"lineBreakBeforeEachArgument" : true,
"lineBreakBeforeEachGenericRequirement" : true,
"lineLength" : 180,
"maximumBlankLines" : 2,
"spacesBeforeEndOfLineComments" : 1,
"respectsExistingLineBreaks" : true,
"prioritizeKeepingFunctionOutputTogether" : true,
"rules" : {
"AllPublicDeclarationsHaveDocumentation" : false,
"AlwaysUseLiteralForEmptyCollectionInit" : false,
"AlwaysUseLowerCamelCase" : false,
"AmbiguousTrailingClosureOverload" : true,
"BeginDocumentationCommentWithOneLineSummary" : false,
"DoNotUseSemicolons" : true,
"DontRepeatTypeInStaticProperties" : true,
"FileScopedDeclarationPrivacy" : true,
"FullyIndirectEnum" : true,
"GroupNumericLiterals" : true,
"IdentifiersMustBeASCII" : true,
"NeverForceUnwrap" : false,
"NeverUseForceTry" : false,
"NeverUseImplicitlyUnwrappedOptionals" : false,
"NoAccessLevelOnExtensionDeclaration" : true,
"NoAssignmentInExpressions" : true,
"NoBlockComments" : false,
"NoCasesWithOnlyFallthrough" : true,
"NoEmptyTrailingClosureParentheses" : true,
"NoLabelsInCasePatterns" : true,
"NoLeadingUnderscores" : false,
"NoParensAroundConditions" : true,
"NoVoidReturnOnFunctionSignature" : true,
"OmitExplicitReturns" : true,
"OneCasePerLine" : true,
"OneVariableDeclarationPerLine" : true,
"OnlyOneTrailingClosureArgument" : true,
"OrderedImports" : true,
"ReplaceForEachWithForLoop" : true,
"ReturnVoidInsteadOfEmptyTuple" : true,
"UseEarlyExits" : false,
"UseExplicitNilCheckInConditions" : false,
"UseLetInEveryBoundCaseVariable" : false,
"UseShorthandTypeNames" : true,
"UseSingleLinePropertyGetter" : false,
"UseSynthesizedInitializer" : false,
"UseTripleSlashForDocumentationComments" : true,
"UseWhereClausesInForLoops" : false,
"ValidateDocumentationComments" : false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@

import Benchmark
import Foundation
import SwiftJava
import JavaNet
import SwiftJava

@MainActor let benchmarks = {
var jvm: JavaVirtualMachine {
get throws {
try .shared()
}
var jvm: JavaVirtualMachine {
get throws {
try .shared()
}
Benchmark("Simple call to Java library") { benchmark in
for _ in benchmark.scaledIterations {
let environment = try jvm.environment()
}
Benchmark("Simple call to Java library") { benchmark in
for _ in benchmark.scaledIterations {
let environment = try jvm.environment()

let urlConnectionClass = try JavaClass<URLConnection>(environment: environment)
blackHole(urlConnectionClass.getDefaultAllowUserInteraction())
}
let urlConnectionClass = try JavaClass<URLConnection>(environment: environment)
blackHole(urlConnectionClass.getDefaultAllowUserInteraction())
}
}
}
18 changes: 10 additions & 8 deletions Benchmarks/Package.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// swift-tools-version: 6.0

import PackageDescription
import Foundation
import PackageDescription

// Note: the JAVA_HOME environment variable must be set to point to where
// Java is installed, e.g.,
Expand Down Expand Up @@ -58,13 +58,15 @@ func getJavaHomeFromPath() -> String? {
guard task.terminationStatus == 0 else { return nil }

let data = pipe.fileHandleForReading.readDataToEndOfFile()
guard let javaPath = String(data: data, encoding: .utf8)?
.trimmingCharacters(in: .whitespacesAndNewlines),
guard
let javaPath = String(data: data, encoding: .utf8)?
.trimmingCharacters(in: .whitespacesAndNewlines),
!javaPath.isEmpty
else { return nil }

let resolved = URL(fileURLWithPath: javaPath).resolvingSymlinksInPath()
return resolved
return
resolved
.deletingLastPathComponent()
.deletingLastPathComponent()
.path
Expand All @@ -76,12 +78,12 @@ let javaHome = findJavaHome()

let javaIncludePath = "\(javaHome)/include"
#if os(Linux)
let javaPlatformIncludePath = "\(javaIncludePath)/linux"
let javaPlatformIncludePath = "\(javaIncludePath)/linux"
#elseif os(macOS)
let javaPlatformIncludePath = "\(javaIncludePath)/darwin"
let javaPlatformIncludePath = "\(javaIncludePath)/darwin"
#else
// TODO: Handle windows as well
#error("Currently only macOS and Linux platforms are supported, this may change in the future.")
// TODO: Handle windows as well
#error("Currently only macOS and Linux platforms are supported, this may change in the future.")
#endif

let package = Package(
Expand Down
Loading
Loading