Skip to content
Closed
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
buildscript {
ext.versions = [
'kotlin': '1.2.60',
'kotlinNative': '0.8.2',
'kotlin': '1.3.0-rc-146',
'kotlinNative': '0.9.3',
'jmhPlugin': '0.4.5',
'animalSnifferPlugin': '1.4.3',
'dokka': '0.9.16',
Expand Down Expand Up @@ -32,7 +32,7 @@ buildscript {
'js': "org.jetbrains.kotlin:kotlin-test-js",
],
'native': [
'gradlePlugin': "org.jetbrains.kotlin:kotlin-native-gradle-plugin:${versions.kotlinNative}",
'gradlePlugin': "org.jetbrains.kotlin:kotlin-native-gradle-plugin:${versions.kotlin}",
]
],
'jmh': [
Expand Down Expand Up @@ -72,6 +72,7 @@ buildscript {
repositories {
mavenCentral()
gradlePluginPortal()
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
}
}

Expand All @@ -84,6 +85,7 @@ subprojects {
repositories {
mavenCentral()
jcenter()
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
}

apply plugin: "org.jlleitschuh.gradle.ktlint"
Expand Down
10 changes: 10 additions & 0 deletions okio/js/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,13 @@ task runMocha(type: NodeTask, dependsOn: [compileTestKotlin2Js, populateNodeModu
}

test.dependsOn runMocha

// Workaround the problem with Node downloading
// https://github.com/JetBrains/kotlin-native/issues/1612
repositories.whenObjectAdded {
if (it instanceof IvyArtifactRepository) {
metadataSources {
artifact()
}
}
}
19 changes: 2 additions & 17 deletions okio/js/src/main/kotlin/okio/-Platform.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,6 @@ package okio

import okio.internal.commonAsUtf8ToByteArray
import okio.internal.commonToUtf8String
import kotlin.annotation.AnnotationTarget.FIELD
import kotlin.annotation.AnnotationTarget.FILE
import kotlin.annotation.AnnotationTarget.FUNCTION
import kotlin.annotation.AnnotationTarget.PROPERTY_GETTER
import kotlin.annotation.AnnotationTarget.PROPERTY_SETTER

@Target(FUNCTION)
actual annotation class JvmOverloads

@Target(FIELD)
actual annotation class JvmField

@Target(FUNCTION)
actual annotation class JvmStatic

@Target(FILE, FUNCTION, PROPERTY_GETTER, PROPERTY_SETTER)
actual annotation class JvmName(actual val name: String)

internal actual fun arraycopy(
src: ByteArray,
Expand All @@ -55,3 +38,5 @@ internal actual fun String.asUtf8ToByteArray(): ByteArray = commonAsUtf8ToByteAr
actual open class ArrayIndexOutOfBoundsException actual constructor(
message: String?
) : IndexOutOfBoundsException(message)

internal actual inline fun synchronizedOn(lock: Any, block: () -> Unit) = block()
7 changes: 2 additions & 5 deletions okio/jvm/src/main/java/okio/-Platform.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@
@file:JvmName("-Platform")
package okio

actual typealias JvmOverloads = kotlin.jvm.JvmOverloads
actual typealias JvmField = kotlin.jvm.JvmField
actual typealias JvmStatic = kotlin.jvm.JvmStatic
actual typealias JvmName = kotlin.jvm.JvmName

internal actual fun arraycopy(
src: ByteArray,
srcPos: Int,
Expand All @@ -38,3 +33,5 @@ internal actual fun String.asUtf8ToByteArray(): ByteArray = toByteArray(Charsets

// TODO remove if https://youtrack.jetbrains.com/issue/KT-20641 provides a better solution
actual typealias ArrayIndexOutOfBoundsException = java.lang.ArrayIndexOutOfBoundsException

internal actual inline fun synchronizedOn(lock: Any, block: () -> Unit) = synchronized(lock, block)
4 changes: 2 additions & 2 deletions okio/jvm/src/test/java/okio/OkioTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public final class OkioTest {
fail();
} catch (IllegalArgumentException expected) {
assertEquals(
"Parameter specified as non-null is null: method okio.Okio.buffer, parameter $receiver",
"Parameter specified as non-null is null: method okio.Okio.buffer, parameter receiver$0",
expected.getMessage());
}
}
Expand All @@ -146,7 +146,7 @@ public final class OkioTest {
fail();
} catch (IllegalArgumentException expected) {
assertEquals(
"Parameter specified as non-null is null: method okio.Okio.buffer, parameter $receiver",
"Parameter specified as non-null is null: method okio.Okio.buffer, parameter receiver$0",
expected.getMessage());
}
}
Expand Down
19 changes: 2 additions & 17 deletions okio/native/src/main/kotlin/okio/-Platform.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,6 @@
package okio

import okio.internal.commonAsUtf8ToByteArray
import kotlin.annotation.AnnotationTarget.FIELD
import kotlin.annotation.AnnotationTarget.FILE
import kotlin.annotation.AnnotationTarget.FUNCTION
import kotlin.annotation.AnnotationTarget.PROPERTY_GETTER
import kotlin.annotation.AnnotationTarget.PROPERTY_SETTER

@Target(FUNCTION)
actual annotation class JvmOverloads

@Target(FIELD)
actual annotation class JvmField

@Target(FUNCTION)
actual annotation class JvmStatic

@Target(FILE, FUNCTION, PROPERTY_GETTER, PROPERTY_SETTER)
actual annotation class JvmName(actual val name: String)

internal actual fun arraycopy(
src: ByteArray,
Expand All @@ -57,3 +40,5 @@ internal actual fun ByteArray.toUtf8String(): String = stringFromUtf8()
internal actual fun String.asUtf8ToByteArray(): ByteArray = commonAsUtf8ToByteArray()

actual typealias ArrayIndexOutOfBoundsException = kotlin.ArrayIndexOutOfBoundsException

internal actual inline fun synchronizedOn(lock: Any, block: () -> Unit) = block()
1 change: 1 addition & 0 deletions okio/src/main/kotlin/okio/-Base64.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package okio

import okio.ByteString.Companion.encodeUtf8
import kotlin.jvm.JvmName

/** @author Alexander Y. Kleymenov */

Expand Down
24 changes: 2 additions & 22 deletions okio/src/main/kotlin/okio/-Platform.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,6 @@

package okio

import kotlin.annotation.AnnotationTarget.FIELD
import kotlin.annotation.AnnotationTarget.FILE
import kotlin.annotation.AnnotationTarget.FUNCTION
import kotlin.annotation.AnnotationTarget.PROPERTY_GETTER
import kotlin.annotation.AnnotationTarget.PROPERTY_SETTER

// TODO remove after https://youtrack.jetbrains.com/issue/KT-24478
@Target(FUNCTION)
expect annotation class JvmOverloads()

// TODO remove after https://youtrack.jetbrains.com/issue/KT-24478
@Target(FIELD)
expect annotation class JvmField()

// TODO remove after https://youtrack.jetbrains.com/issue/KT-24478
@Target(FUNCTION)
expect annotation class JvmStatic()

// TODO remove after https://youtrack.jetbrains.com/issue/KT-24478
@Target(FILE, FUNCTION, PROPERTY_GETTER, PROPERTY_SETTER)
expect annotation class JvmName(val name: String)

internal expect fun arraycopy(
src: ByteArray,
srcPos: Int,
Expand All @@ -52,3 +30,5 @@ internal expect fun String.asUtf8ToByteArray(): ByteArray

// TODO make internal https://youtrack.jetbrains.com/issue/KT-19664
expect class ArrayIndexOutOfBoundsException(message: String?) : IndexOutOfBoundsException

internal expect inline fun synchronizedOn(lock: Any, block: () -> Unit)
2 changes: 2 additions & 0 deletions okio/src/main/kotlin/okio/-Util.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

package okio

import kotlin.jvm.JvmName

internal fun checkOffsetAndCount(size: Long, offset: Long, byteCount: Long) {
if (offset or byteCount < 0 || offset > size || size - offset < byteCount) {
throw ArrayIndexOutOfBoundsException("size=$size offset=$offset byteCount=$byteCount")
Expand Down
4 changes: 4 additions & 0 deletions okio/src/main/kotlin/okio/ByteString.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@

package okio

import kotlin.jvm.JvmField
import kotlin.jvm.JvmName
import kotlin.jvm.JvmStatic

/**
* An immutable sequence of bytes.
*
Expand Down
2 changes: 2 additions & 0 deletions okio/src/main/kotlin/okio/Segment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package okio

import kotlin.jvm.JvmField

/**
* A segment of a buffer.
*
Expand Down
7 changes: 5 additions & 2 deletions okio/src/main/kotlin/okio/SegmentPool.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
*/
package okio

import kotlin.jvm.JvmField
import kotlin.jvm.JvmStatic

/**
* A collection of unused segments, necessary to avoid GC churn and zero-fill.
* This pool is a thread-safe static singleton.
Expand All @@ -34,7 +37,7 @@ internal object SegmentPool {

@JvmStatic
fun take(): Segment {
synchronized(this) {
synchronizedOn(this) {
next?.let { result ->
next = result.next
result.next = null
Expand All @@ -50,7 +53,7 @@ internal object SegmentPool {
require(segment.next == null && segment.prev == null)
if (segment.shared) return // This segment cannot be recycled.

synchronized(this) {
synchronizedOn(this) {
if (byteCount + Segment.SIZE > MAX_SIZE) return // Pool is full.
byteCount += Segment.SIZE
segment.next = next
Expand Down
3 changes: 3 additions & 0 deletions okio/src/main/kotlin/okio/Utf8.kt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@

package okio

import kotlin.jvm.JvmName
import kotlin.jvm.JvmOverloads

/**
* Returns the number of bytes used to encode the slice of `string` as UTF-8 when using
* [BufferedSink.writeUtf8].
Expand Down
2 changes: 2 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ include ':okio:js'
include ':okio:jvm'
include ':okio:native'
include ':samples'

enableFeaturePreview('GRADLE_METADATA')