Skip to content

Commit

Permalink
Allow java.util.Currency to work.
Browse files Browse the repository at this point in the history
  • Loading branch information
gchallen committed Sep 7, 2021
1 parent 4f5815a commit c7ae5ee
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 9 deletions.
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
kotlin("jvm") version "1.5.30" apply false
kotlin("kapt") version "1.5.30" apply false
id("org.jmailen.kotlinter") version "3.5.1" apply false
id("org.jmailen.kotlinter") version "3.6.0" apply false
id("com.github.ben-manes.versions") version "0.39.0"
id("io.gitlab.arturbosch.detekt") version "1.18.1"
}
Expand All @@ -18,7 +18,7 @@ allprojects {
}
subprojects {
group = "com.github.cs125-illinois.jeed"
version = "2021.9.0"
version = "2021.9.1"
tasks.withType<Test> {
useJUnitPlatform()
enableAssertions = true
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=2021.9.0
version=2021.9.1
2 changes: 1 addition & 1 deletion core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dependencies {
implementation("org.jetbrains.kotlin:kotlin-compiler-embeddable:1.5.30")
implementation("org.jetbrains.kotlin:kotlin-reflect:1.5.30")

implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.1-native-mt")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2")
implementation("com.puppycrawl.tools:checkstyle:9.0")
implementation("com.pinterest.ktlint:ktlint-core:0.42.1")
implementation("com.pinterest.ktlint:ktlint-ruleset-standard:0.42.1")
Expand Down
5 changes: 4 additions & 1 deletion core/src/main/kotlin/Execute.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ class SourceExecutionArguments(
RuntimePermission("localeServiceProvider"),
// Not sure why this is required by Date, but it seems to be
// ClassLoader enumeration is probably not unsafe...
RuntimePermission("getClassLoader")
RuntimePermission("getClassLoader"),
// Required by java.util.Currency
RuntimePermission("accessSystemModules"),
PropertyPermission("java.util.currency.data", "read")
)
}
}
Expand Down
4 changes: 3 additions & 1 deletion core/src/main/kotlin/Sandbox.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1213,7 +1213,9 @@ object Sandbox {
override fun checkRead(file: String) {
val confinedTask = confinedTaskByClassLoader()
?: return systemSecurityManager?.checkRead(file) ?: return
if (!file.endsWith(".class")) {
if (file.endsWith("currency.properties")) {
confinedTask.addPermissionRequest(FilePermission(file, "read"), true)
} else if (!file.endsWith(".class")) {
confinedTask.addPermissionRequest(FilePermission(file, "read"), false)
} else {
systemSecurityManager?.checkRead(file)
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=2021.9.0
version=2021.9.1
11 changes: 11 additions & 0 deletions core/src/test/kotlin/TestSnippet.kt
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,17 @@ class Example {
executionResult should haveOutput("")
}
}
"should load Currency data" {
Source.fromSnippet(
"""
import java.util.Currency;

System.out.println(Currency.getAvailableCurrencies());
""".trimIndent()
).compile().execute().also { executionResult ->
executionResult should haveCompleted()
}
}
})

fun haveParseErrorOnLine(line: Int) = object : Matcher<SnippetTransformationFailed> {
Expand Down
2 changes: 1 addition & 1 deletion server/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dependencies {
implementation("org.jetbrains.kotlin:kotlin-reflect:1.5.30")

implementation("io.ktor:ktor-server-netty:1.6.3")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.1-native-mt")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2")
implementation("com.squareup.moshi:moshi-kotlin-codegen:1.12.0")
implementation("com.github.cs125-illinois:ktor-moshi:1.0.3")
implementation("ch.qos.logback:logback-classic:1.2.5")
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=2021.9.0
version=2021.9.1

0 comments on commit c7ae5ee

Please sign in to comment.