Skip to content

Commit

Permalink
Merge pull request #156 from ProjectMapK/develop
Browse files Browse the repository at this point in the history
For release 2.15.2-beta5
  • Loading branch information
k163377 committed Oct 8, 2023
2 parents 88afb9b + fe712e9 commit d52ebf5
Show file tree
Hide file tree
Showing 17 changed files with 309 additions and 128 deletions.
26 changes: 23 additions & 3 deletions .github/workflows/test-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ on:
- "**.kt"
- "**.java"
- .github/workflows/test-main.yml
workflow_dispatch:
jobs:
test-main:
strategy:
Expand All @@ -36,10 +37,29 @@ jobs:
# LTS versions, latest version (if exists)
java-version: [ '8', '11', '17', '20' ]
# Minimum version, latest release version, latest pre-release version (if exists)
kotlin-version: [ '1.7.21', '1.8.22', '1.9.10', '1.9.20-Beta' ]
kotlin:
- name: '1.7.21'
version: '1.7.21'
k2: false
- name: '1.8.22'
version: '1.8.22'
k2: false
- name: '1.9.10'
version: '1.9.10'
k2: false
- name: '1.9.10 K2'
version: '1.9.10'
k2: true
- name: '1.9.20-Beta'
version: '1.9.20-Beta'
k2: false
- name: '1.9.20-Beta K2'
version: '1.9.20-Beta'
k2: true
env:
KOTLIN_VERSION: ${{ matrix.kotlin-version }}
name: test-main
KOTLIN_VERSION: ${{ matrix.kotlin.version }}
USE_K2: ${{ matrix.kotlin.k2 }}
name: "Kotlin ${{ matrix.kotlin.name }} - Java ${{ matrix.java-version }}"
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
Expand Down
19 changes: 17 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ plugins {
// Since group cannot be obtained by generateKogeraVersion, it is defined as a constant.
val groupStr = "io.github.projectmapk"
val jacksonVersion = "2.15.2"
val generatedSrcPath = "$buildDir/generated/kotlin"
val generatedSrcPath = "${layout.buildDirectory.get()}/generated/kotlin"

group = groupStr
version = "${jacksonVersion}-beta4"
version = "${jacksonVersion}-beta5"

repositories {
mavenCentral()
Expand Down Expand Up @@ -42,6 +42,17 @@ kotlin {
sourceSets["main"].apply {
kotlin.srcDir(generatedSrcPath)
}

val useK2 = System.getenv("KOTLIN_VERSION")?.takeIf { it.isNotEmpty() }
?.let { it.toBoolean() } ?: false

sourceSets.all {
languageSettings {
if (useK2) {
languageVersion = "2.0"
}
}
}
}

java {
Expand Down Expand Up @@ -86,6 +97,10 @@ public val kogeraVersion: Version = VersionUtil.parseVersion("$version", "$group
kotlinOptions.jvmTarget = "1.8"
}

compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}

test {
useJUnitPlatform()
}
Expand Down
8 changes: 8 additions & 0 deletions docs/AboutValueClassSupport.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ The same policy applies to deserialization.
This policy was decided with reference to the behavior as of `jackson-module-kotlin 2.14.1` and [kotlinx-serialization](https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/value-classes.md#serializable-value-classes).
However, these are just basic policies, and the behavior can be overridden with `JsonSerializer` or `JsonDeserializer`.

### Serialization performance improvement using `JsonUnbox`
In `jackson-module-kogera`, the `jackson` functionality is modified by reflection so that the `Jackson` functionality works for `value class` as well.
These are executed on all calls.
On the other hand, if only `unbox` is required, these are extra overheads that can significantly impair serialization performance.

Therefore, `jackson-module-kogera` provides the `JsonUnbox` annotation.
When this annotation is provided, serialization performance is improved because only calls to `getter` that is `unboxed` will be made.

## For features that would not be supported
I do not intend to support features that require significant effort to support and that can be circumvented by user definition.

Expand Down
4 changes: 4 additions & 0 deletions docs/KogeraSpecificImplementations.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ I will consider making the classes public again when we receive requests for the
## Remove old options and `deprecated` code
Because `jackson-module-kotlin` is a framework with a long history, some old code and options remain.
In `kogera`, those options have been removed.

# Value class support
The `jackson-module-kogera` supports many use cases of `value class` (`inline class`).
This is summarized [here](./AboutValueClassSupport.md).
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
19 changes: 12 additions & 7 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -133,26 +131,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -197,6 +198,10 @@ if "$cygwin" || "$msys" ; then
done
fi


# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import kotlinx.metadata.Flag
import kotlinx.metadata.KmClassifier
import kotlinx.metadata.KmType
import kotlinx.metadata.KmValueParameter
import kotlinx.metadata.internal.accept
import kotlinx.metadata.internal.metadata.jvm.deserialization.JvmProtoBufUtil
import kotlinx.metadata.jvm.JvmMethodSignature
import java.lang.reflect.AnnotatedElement
import java.lang.reflect.Constructor
Expand All @@ -17,27 +15,17 @@ internal typealias KotlinDuration = kotlin.time.Duration

internal fun Class<*>.isUnboxableValueClass() = this.getAnnotation(JvmInline::class.java) != null

internal fun Metadata.accept(visitor: ReducedKmClassVisitor) {
val (strings, proto) = JvmProtoBufUtil.readClassDataFrom(data1.takeIf(Array<*>::isNotEmpty)!!, data2)
proto.accept(visitor, strings)
}

internal fun Class<*>.toReducedKmClass(): ReducedKmClass? = this.getAnnotation(Metadata::class.java)
?.let { ReducedKmClass().apply { it.accept(this) } }

private val primitiveClassToDesc by lazy {
mapOf(
Byte::class.javaPrimitiveType to 'B',
Char::class.javaPrimitiveType to 'C',
Double::class.javaPrimitiveType to 'D',
Float::class.javaPrimitiveType to 'F',
Int::class.javaPrimitiveType to 'I',
Long::class.javaPrimitiveType to 'J',
Short::class.javaPrimitiveType to 'S',
Boolean::class.javaPrimitiveType to 'Z',
Void::class.javaPrimitiveType to 'V'
)
}
private val primitiveClassToDesc = mapOf(
Byte::class.javaPrimitiveType to 'B',
Char::class.javaPrimitiveType to 'C',
Double::class.javaPrimitiveType to 'D',
Float::class.javaPrimitiveType to 'F',
Int::class.javaPrimitiveType to 'I',
Long::class.javaPrimitiveType to 'J',
Short::class.javaPrimitiveType to 'S',
Boolean::class.javaPrimitiveType to 'Z',
Void::class.javaPrimitiveType to 'V'
)

// -> this.name.replace(".", "/")
private fun Class<*>.descName(): String {
Expand Down
Loading

0 comments on commit d52ebf5

Please sign in to comment.