Skip to content

Commit d52ebf5

Browse files
authored
Merge pull request #156 from ProjectMapK/develop
For release 2.15.2-beta5
2 parents 88afb9b + fe712e9 commit d52ebf5

File tree

17 files changed

+309
-128
lines changed

17 files changed

+309
-128
lines changed

.github/workflows/test-main.yml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ on:
2828
- "**.kt"
2929
- "**.java"
3030
- .github/workflows/test-main.yml
31+
workflow_dispatch:
3132
jobs:
3233
test-main:
3334
strategy:
@@ -36,10 +37,29 @@ jobs:
3637
# LTS versions, latest version (if exists)
3738
java-version: [ '8', '11', '17', '20' ]
3839
# Minimum version, latest release version, latest pre-release version (if exists)
39-
kotlin-version: [ '1.7.21', '1.8.22', '1.9.10', '1.9.20-Beta' ]
40+
kotlin:
41+
- name: '1.7.21'
42+
version: '1.7.21'
43+
k2: false
44+
- name: '1.8.22'
45+
version: '1.8.22'
46+
k2: false
47+
- name: '1.9.10'
48+
version: '1.9.10'
49+
k2: false
50+
- name: '1.9.10 K2'
51+
version: '1.9.10'
52+
k2: true
53+
- name: '1.9.20-Beta'
54+
version: '1.9.20-Beta'
55+
k2: false
56+
- name: '1.9.20-Beta K2'
57+
version: '1.9.20-Beta'
58+
k2: true
4059
env:
41-
KOTLIN_VERSION: ${{ matrix.kotlin-version }}
42-
name: test-main
60+
KOTLIN_VERSION: ${{ matrix.kotlin.version }}
61+
USE_K2: ${{ matrix.kotlin.k2 }}
62+
name: "Kotlin ${{ matrix.kotlin.name }} - Java ${{ matrix.java-version }}"
4363
runs-on: ubuntu-latest
4464
timeout-minutes: 15
4565
steps:

build.gradle.kts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ plugins {
1111
// Since group cannot be obtained by generateKogeraVersion, it is defined as a constant.
1212
val groupStr = "io.github.projectmapk"
1313
val jacksonVersion = "2.15.2"
14-
val generatedSrcPath = "$buildDir/generated/kotlin"
14+
val generatedSrcPath = "${layout.buildDirectory.get()}/generated/kotlin"
1515

1616
group = groupStr
17-
version = "${jacksonVersion}-beta4"
17+
version = "${jacksonVersion}-beta5"
1818

1919
repositories {
2020
mavenCentral()
@@ -42,6 +42,17 @@ kotlin {
4242
sourceSets["main"].apply {
4343
kotlin.srcDir(generatedSrcPath)
4444
}
45+
46+
val useK2 = System.getenv("KOTLIN_VERSION")?.takeIf { it.isNotEmpty() }
47+
?.let { it.toBoolean() } ?: false
48+
49+
sourceSets.all {
50+
languageSettings {
51+
if (useK2) {
52+
languageVersion = "2.0"
53+
}
54+
}
55+
}
4556
}
4657

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

100+
compileTestKotlin {
101+
kotlinOptions.jvmTarget = "1.8"
102+
}
103+
89104
test {
90105
useJUnitPlatform()
91106
}

docs/AboutValueClassSupport.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ The same policy applies to deserialization.
4343
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).
4444
However, these are just basic policies, and the behavior can be overridden with `JsonSerializer` or `JsonDeserializer`.
4545

46+
### Serialization performance improvement using `JsonUnbox`
47+
In `jackson-module-kogera`, the `jackson` functionality is modified by reflection so that the `Jackson` functionality works for `value class` as well.
48+
These are executed on all calls.
49+
On the other hand, if only `unbox` is required, these are extra overheads that can significantly impair serialization performance.
50+
51+
Therefore, `jackson-module-kogera` provides the `JsonUnbox` annotation.
52+
When this annotation is provided, serialization performance is improved because only calls to `getter` that is `unboxed` will be made.
53+
4654
## For features that would not be supported
4755
I do not intend to support features that require significant effort to support and that can be circumvented by user definition.
4856

docs/KogeraSpecificImplementations.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,7 @@ I will consider making the classes public again when we receive requests for the
2525
## Remove old options and `deprecated` code
2626
Because `jackson-module-kotlin` is a framework with a long history, some old code and options remain.
2727
In `kogera`, those options have been removed.
28+
29+
# Value class support
30+
The `jackson-module-kogera` supports many use cases of `value class` (`inline class`).
31+
This is summarized [here](./AboutValueClassSupport.md).

gradle/wrapper/gradle-wrapper.jar

2.1 KB
Binary file not shown.
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
44
networkTimeout=10000
5+
validateDistributionUrl=true
56
zipStoreBase=GRADLE_USER_HOME
67
zipStorePath=wrapper/dists

gradlew

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,8 @@ done
8383
# This is normally unused
8484
# shellcheck disable=SC2034
8585
APP_BASE_NAME=${0##*/}
86-
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
87-
88-
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
89-
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
86+
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
87+
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
9088

9189
# Use the maximum available, or set MAX_FD != -1 to use that value.
9290
MAX_FD=maximum
@@ -133,26 +131,29 @@ location of your Java installation."
133131
fi
134132
else
135133
JAVACMD=java
136-
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
134+
if ! command -v java >/dev/null 2>&1
135+
then
136+
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137137
138138
Please set the JAVA_HOME variable in your environment to match the
139139
location of your Java installation."
140+
fi
140141
fi
141142

142143
# Increase the maximum file descriptors if we can.
143144
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144145
case $MAX_FD in #(
145146
max*)
146147
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
147-
# shellcheck disable=SC3045
148+
# shellcheck disable=SC3045
148149
MAX_FD=$( ulimit -H -n ) ||
149150
warn "Could not query maximum file descriptor limit"
150151
esac
151152
case $MAX_FD in #(
152153
'' | soft) :;; #(
153154
*)
154155
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
155-
# shellcheck disable=SC3045
156+
# shellcheck disable=SC3045
156157
ulimit -n "$MAX_FD" ||
157158
warn "Could not set maximum file descriptor limit to $MAX_FD"
158159
esac
@@ -197,6 +198,10 @@ if "$cygwin" || "$msys" ; then
197198
done
198199
fi
199200

201+
202+
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
203+
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
204+
200205
# Collect all arguments for the java command;
201206
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
202207
# shell script including quotes and variable substitutions, so put them in

src/main/kotlin/io/github/projectmapk/jackson/module/kogera/InternalCommons.kt

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import kotlinx.metadata.Flag
55
import kotlinx.metadata.KmClassifier
66
import kotlinx.metadata.KmType
77
import kotlinx.metadata.KmValueParameter
8-
import kotlinx.metadata.internal.accept
9-
import kotlinx.metadata.internal.metadata.jvm.deserialization.JvmProtoBufUtil
108
import kotlinx.metadata.jvm.JvmMethodSignature
119
import java.lang.reflect.AnnotatedElement
1210
import java.lang.reflect.Constructor
@@ -17,27 +15,17 @@ internal typealias KotlinDuration = kotlin.time.Duration
1715

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

20-
internal fun Metadata.accept(visitor: ReducedKmClassVisitor) {
21-
val (strings, proto) = JvmProtoBufUtil.readClassDataFrom(data1.takeIf(Array<*>::isNotEmpty)!!, data2)
22-
proto.accept(visitor, strings)
23-
}
24-
25-
internal fun Class<*>.toReducedKmClass(): ReducedKmClass? = this.getAnnotation(Metadata::class.java)
26-
?.let { ReducedKmClass().apply { it.accept(this) } }
27-
28-
private val primitiveClassToDesc by lazy {
29-
mapOf(
30-
Byte::class.javaPrimitiveType to 'B',
31-
Char::class.javaPrimitiveType to 'C',
32-
Double::class.javaPrimitiveType to 'D',
33-
Float::class.javaPrimitiveType to 'F',
34-
Int::class.javaPrimitiveType to 'I',
35-
Long::class.javaPrimitiveType to 'J',
36-
Short::class.javaPrimitiveType to 'S',
37-
Boolean::class.javaPrimitiveType to 'Z',
38-
Void::class.javaPrimitiveType to 'V'
39-
)
40-
}
18+
private val primitiveClassToDesc = mapOf(
19+
Byte::class.javaPrimitiveType to 'B',
20+
Char::class.javaPrimitiveType to 'C',
21+
Double::class.javaPrimitiveType to 'D',
22+
Float::class.javaPrimitiveType to 'F',
23+
Int::class.javaPrimitiveType to 'I',
24+
Long::class.javaPrimitiveType to 'J',
25+
Short::class.javaPrimitiveType to 'S',
26+
Boolean::class.javaPrimitiveType to 'Z',
27+
Void::class.javaPrimitiveType to 'V'
28+
)
4129

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

0 commit comments

Comments
 (0)