Skip to content

Commit

Permalink
Enable Java default interface methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
pdvrieze committed Dec 29, 2023
1 parent 00e3657 commit d8b1e98
Show file tree
Hide file tree
Showing 11 changed files with 130 additions and 220 deletions.
13 changes: 8 additions & 5 deletions examples/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Copyright (c) 2018.
* Copyright (c) 2023.
*
* This file is part of XmlUtil.
* This file is part of xmlutil.
*
* This file is licenced to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
Expand All @@ -20,9 +20,6 @@

@file:Suppress("PropertyName")

import net.devrieze.gradle.ext.envJvm
import org.gradle.api.attributes.java.TargetJvmEnvironment.TARGET_JVM_ENVIRONMENT_ATTRIBUTE

plugins {
kotlin("jvm")
alias(libs.plugins.kotlinSerialization)
Expand All @@ -33,6 +30,12 @@ base {
archivesName.set("examples")
}

kotlin {
compilerOptions {
freeCompilerArgs.set(freeCompilerArgs.get() + "-Xjvm-default=all")
}
}

val autoModuleName = "net.devrieze.serialexamples"

dependencies {
Expand Down
119 changes: 38 additions & 81 deletions serialization/api/android/serialization.api

Large diffs are not rendered by default.

119 changes: 38 additions & 81 deletions serialization/api/jvm/serialization.api

Large diffs are not rendered by default.

11 changes: 10 additions & 1 deletion serialization/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ kotlin {
attributes("Automatic-Module-Name" to autoModuleName)
}
}
kotlinOptions {
freeCompilerArgs += "-Xjvm-default=all"
}
}

val woodstoxCompilation = compilations.create("woodstoxTest") {
Expand All @@ -78,7 +81,13 @@ kotlin {
}
// androidTarget("actualAndroid")

jvm("android")
jvm("android") {
compilations.all {
kotlinOptions {
freeCompilerArgs += "-Xjvm-default=all"
}
}
}
js {
browser()
compilations.all {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import kotlinx.serialization.modules.SerializersModule
import kotlinx.serialization.modules.plus
import nl.adaptivity.xmlutil.*
import nl.adaptivity.xmlutil.core.impl.multiplatform.Language
import nl.adaptivity.xmlutil.core.impl.multiplatform.MpJvmDefaultWithCompatibility
import nl.adaptivity.xmlutil.core.impl.multiplatform.StringWriter
import nl.adaptivity.xmlutil.core.impl.multiplatform.use
import nl.adaptivity.xmlutil.serialization.XML.Companion.encodeToWriter
Expand Down Expand Up @@ -1012,6 +1013,7 @@ public class XML(
decodeFromReader(loader, reader)
}

@MpJvmDefaultWithCompatibility
public interface XmlCodecConfig {
/**
* The currently active serialization context
Expand All @@ -1034,6 +1036,7 @@ public class XML(
* [XmlWriter]. This is used for example by [CompactFragment] to make the fragment transparent when serializing to
* XML.
*/
@MpJvmDefaultWithCompatibility
public interface XmlOutput : XmlCodecConfig {
/**
* The name for the current tag
Expand Down Expand Up @@ -1077,6 +1080,7 @@ public class XML(
* [XmlReader]. This is used for example by [CompactFragment] to read arbitrary XML from the stream and store it inside
* the buffer (without attempting to use the serializer/decoder for it.
*/
@MpJvmDefaultWithCompatibility
public interface XmlInput : XmlCodecConfig {
/**
* The reader used. Can be used directly by serializers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020.
* Copyright (c) 2023.
*
* This file is part of xmlutil.
*
Expand Down Expand Up @@ -31,6 +31,7 @@ import kotlinx.serialization.descriptors.*
import kotlinx.serialization.modules.EmptySerializersModule
import kotlinx.serialization.modules.SerializersModule
import nl.adaptivity.xmlutil.*
import nl.adaptivity.xmlutil.core.impl.multiplatform.MpJvmDefaultWithCompatibility
import nl.adaptivity.xmlutil.core.impl.multiplatform.maybeAnnotations
import nl.adaptivity.xmlutil.serialization.*
import nl.adaptivity.xmlutil.serialization.XmlCodecBase.Companion.declRequestedName
Expand Down Expand Up @@ -66,6 +67,7 @@ internal fun SerialDescriptor.declOutputKind(): OutputKind? {
/**
* Interface describing a type without providing access to child xml descriptors
*/
@MpJvmDefaultWithCompatibility
public interface SafeXmlDescriptor {
@ExperimentalSerializationApi
public val isNullable: Boolean
Expand Down Expand Up @@ -1288,6 +1290,7 @@ public class XmlListDescriptor internal constructor(
* Interface that provides parent info that does provide actual access to the child. As such it is safe to
* be used to determine properties of the child.
*/
@MpJvmDefaultWithCompatibility
public interface SafeParentInfo {
/** Is the parent type an inline class. */
public val parentIsInline: Boolean
Expand Down
20 changes: 13 additions & 7 deletions testutil/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022.
* Copyright (c) 2023.
*
* This file is part of xmlutil.
*
Expand All @@ -20,11 +20,10 @@

@file:Suppress("PropertyName")

import net.devrieze.gradle.ext.*
import org.gradle.api.attributes.java.TargetJvmEnvironment.TARGET_JVM_ENVIRONMENT_ATTRIBUTE
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
import net.devrieze.gradle.ext.addNativeTargets
import net.devrieze.gradle.ext.configureDokka
import net.devrieze.gradle.ext.doPublish
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
kotlin("multiplatform")
Expand All @@ -49,7 +48,14 @@ base {
val moduleName = "io.github.pdvrieze.testutil"

kotlin {
jvm()
jvm {
compilations.all {
kotlinOptions {
freeCompilerArgs += "-Xjvm-default=all"
}
}

}
js {
browser()
nodejs()
Expand Down Expand Up @@ -81,7 +87,6 @@ kotlin {
}
}

@Suppress("UNUSED_VARIABLE")
sourceSets {
val commonMain by getting {
dependencies {
Expand All @@ -95,6 +100,7 @@ kotlin {
all {
languageSettings.apply {
optIn("nl.adaptivity.xmlutil.ExperimentalXmlUtilApi")
optIn("nl.adaptivity.xmlutil.XmlUtilInternal")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022.
* Copyright (c) 2023.
*
* This file is part of xmlutil.
*
Expand Down Expand Up @@ -120,7 +120,6 @@ internal fun assertStartElementEquals(
messageProvider: () -> String? = { null }
) {
assertQNameEquivalent(expectedEvent.name, actualEvent.name, messageProvider)
val elementNamespace = expectedEvent.namespaceUri

val expectedAttributes = expectedEvent.attributes.filter { it.namespaceUri != XMLConstants.XMLNS_ATTRIBUTE_NS_URI }
.map { XmlEvent.Attribute(it.namespaceUri, it.localName, "", it.value) }
Expand Down
25 changes: 4 additions & 21 deletions xmlserializable/api/android/xmlserializable.api
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ public abstract interface class nl/adaptivity/xmlutil/xmlserializable/ExtXmlDese
public abstract fun deserializeChildren (Lnl/adaptivity/xmlutil/XmlReader;)V
}

public final class nl/adaptivity/xmlutil/xmlserializable/ExtXmlDeserializable$DefaultImpls {
public static fun deserializeAttribute (Lnl/adaptivity/xmlutil/xmlserializable/ExtXmlDeserializable;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Z
public static fun onBeforeDeserializeChildren (Lnl/adaptivity/xmlutil/xmlserializable/ExtXmlDeserializable;Lnl/adaptivity/xmlutil/XmlReader;)V
}

public final class nl/adaptivity/xmlutil/xmlserializable/SerializableCollection : nl/adaptivity/xmlutil/xmlserializable/BaseSerializableContainer, java/util/Collection, kotlin/jvm/internal/markers/KMappedMarker {
public fun <init> (Ljavax/xml/namespace/QName;Ljava/util/Collection;)V
public synthetic fun add (Ljava/lang/Object;)Z
Expand Down Expand Up @@ -113,26 +108,14 @@ public final class nl/adaptivity/xmlutil/xmlserializable/SerializableList : nl/a
}

public abstract interface class nl/adaptivity/xmlutil/xmlserializable/SimpleXmlDeserializable : nl/adaptivity/xmlutil/xmlserializable/XmlDeserializable {
public abstract fun deserializeChild (Lnl/adaptivity/xmlutil/XmlReader;)Z
public abstract fun deserializeChildText (Ljava/lang/CharSequence;)Z
}

public final class nl/adaptivity/xmlutil/xmlserializable/SimpleXmlDeserializable$DefaultImpls {
public static fun deserializeAttribute (Lnl/adaptivity/xmlutil/xmlserializable/SimpleXmlDeserializable;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Z
public static fun deserializeChild (Lnl/adaptivity/xmlutil/xmlserializable/SimpleXmlDeserializable;Lnl/adaptivity/xmlutil/XmlReader;)Z
public static fun deserializeChildText (Lnl/adaptivity/xmlutil/xmlserializable/SimpleXmlDeserializable;Ljava/lang/CharSequence;)Z
public static fun onBeforeDeserializeChildren (Lnl/adaptivity/xmlutil/xmlserializable/SimpleXmlDeserializable;Lnl/adaptivity/xmlutil/XmlReader;)V
public fun deserializeChild (Lnl/adaptivity/xmlutil/XmlReader;)Z
public fun deserializeChildText (Ljava/lang/CharSequence;)Z
}

public abstract interface class nl/adaptivity/xmlutil/xmlserializable/XmlDeserializable {
public abstract fun deserializeAttribute (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Z
public fun deserializeAttribute (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Z
public abstract fun getElementName ()Ljavax/xml/namespace/QName;
public abstract fun onBeforeDeserializeChildren (Lnl/adaptivity/xmlutil/XmlReader;)V
}

public final class nl/adaptivity/xmlutil/xmlserializable/XmlDeserializable$DefaultImpls {
public static fun deserializeAttribute (Lnl/adaptivity/xmlutil/xmlserializable/XmlDeserializable;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Z
public static fun onBeforeDeserializeChildren (Lnl/adaptivity/xmlutil/xmlserializable/XmlDeserializable;Lnl/adaptivity/xmlutil/XmlReader;)V
public fun onBeforeDeserializeChildren (Lnl/adaptivity/xmlutil/XmlReader;)V
}

public abstract interface annotation class nl/adaptivity/xmlutil/xmlserializable/XmlDeserializer : java/lang/annotation/Annotation {
Expand Down
25 changes: 4 additions & 21 deletions xmlserializable/api/jvm/xmlserializable.api
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ public abstract interface class nl/adaptivity/xmlutil/xmlserializable/ExtXmlDese
public abstract fun deserializeChildren (Lnl/adaptivity/xmlutil/XmlReader;)V
}

public final class nl/adaptivity/xmlutil/xmlserializable/ExtXmlDeserializable$DefaultImpls {
public static fun deserializeAttribute (Lnl/adaptivity/xmlutil/xmlserializable/ExtXmlDeserializable;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Z
public static fun onBeforeDeserializeChildren (Lnl/adaptivity/xmlutil/xmlserializable/ExtXmlDeserializable;Lnl/adaptivity/xmlutil/XmlReader;)V
}

public final class nl/adaptivity/xmlutil/xmlserializable/SerializableCollection : nl/adaptivity/xmlutil/xmlserializable/BaseSerializableContainer, java/util/Collection, kotlin/jvm/internal/markers/KMappedMarker {
public fun <init> (Ljavax/xml/namespace/QName;Ljava/util/Collection;)V
public synthetic fun add (Ljava/lang/Object;)Z
Expand Down Expand Up @@ -113,26 +108,14 @@ public final class nl/adaptivity/xmlutil/xmlserializable/SerializableList : nl/a
}

public abstract interface class nl/adaptivity/xmlutil/xmlserializable/SimpleXmlDeserializable : nl/adaptivity/xmlutil/xmlserializable/XmlDeserializable {
public abstract fun deserializeChild (Lnl/adaptivity/xmlutil/XmlReader;)Z
public abstract fun deserializeChildText (Ljava/lang/CharSequence;)Z
}

public final class nl/adaptivity/xmlutil/xmlserializable/SimpleXmlDeserializable$DefaultImpls {
public static fun deserializeAttribute (Lnl/adaptivity/xmlutil/xmlserializable/SimpleXmlDeserializable;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Z
public static fun deserializeChild (Lnl/adaptivity/xmlutil/xmlserializable/SimpleXmlDeserializable;Lnl/adaptivity/xmlutil/XmlReader;)Z
public static fun deserializeChildText (Lnl/adaptivity/xmlutil/xmlserializable/SimpleXmlDeserializable;Ljava/lang/CharSequence;)Z
public static fun onBeforeDeserializeChildren (Lnl/adaptivity/xmlutil/xmlserializable/SimpleXmlDeserializable;Lnl/adaptivity/xmlutil/XmlReader;)V
public fun deserializeChild (Lnl/adaptivity/xmlutil/XmlReader;)Z
public fun deserializeChildText (Ljava/lang/CharSequence;)Z
}

public abstract interface class nl/adaptivity/xmlutil/xmlserializable/XmlDeserializable {
public abstract fun deserializeAttribute (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Z
public fun deserializeAttribute (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Z
public abstract fun getElementName ()Ljavax/xml/namespace/QName;
public abstract fun onBeforeDeserializeChildren (Lnl/adaptivity/xmlutil/XmlReader;)V
}

public final class nl/adaptivity/xmlutil/xmlserializable/XmlDeserializable$DefaultImpls {
public static fun deserializeAttribute (Lnl/adaptivity/xmlutil/xmlserializable/XmlDeserializable;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Z
public static fun onBeforeDeserializeChildren (Lnl/adaptivity/xmlutil/xmlserializable/XmlDeserializable;Lnl/adaptivity/xmlutil/XmlReader;)V
public fun onBeforeDeserializeChildren (Lnl/adaptivity/xmlutil/XmlReader;)V
}

public abstract interface annotation class nl/adaptivity/xmlutil/xmlserializable/XmlDeserializer : java/lang/annotation/Annotation {
Expand Down
6 changes: 6 additions & 0 deletions xmlserializable/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ kotlin {

jvm {
compilations.all {
kotlinOptions {
freeCompilerArgs += "-Xjvm-default=all"
}
tasks.named<Test>("${target.name}Test") {
testTask.dependsOn(this)
}
Expand All @@ -70,6 +73,9 @@ kotlin {
}
jvm("android") {
compilations.all {
kotlinOptions {
freeCompilerArgs += "-Xjvm-default=all"
}
tasks.named<Test>("${target.name}Test") {
testTask.dependsOn(this)
}
Expand Down

0 comments on commit d8b1e98

Please sign in to comment.