Merge ~vpa1977/ubuntu/+source/kotlin:ubuntu/devel into ubuntu/+source/kotlin:ubuntu/devel

Proposed by Vladimir Petko
Status: Merged
Merge reported by: Vladimir Petko
Merged at revision: 045aa3d40ba810d4b047484460695b5dc0a1816e
Proposed branch: ~vpa1977/ubuntu/+source/kotlin:ubuntu/devel
Merge into: ubuntu/+source/kotlin:ubuntu/devel
Diff against target: 185 lines (+130/-8)
5 files modified
debian/changelog (+12/-0)
debian/control (+9/-8)
debian/patches/073-abstractlist.patch (+33/-0)
debian/patches/074-kapt3.patch (+74/-0)
debian/patches/series (+2/-0)
Reviewer Review Type Date Requested Status
Dan Bungert Pending
git-ubuntu import Pending
Review via email: mp+459688@code.launchpad.net

Description of the change

Changes:
 - add patch to compile kotlin against Java 8 API
 - cherry-pick upstream patch to workaround Java 21 internal API changes

PPA: ppa:vpa1977/gettext [1]

Testing:
 - piuparts test (install/upgrade/purge) [2]
 - rebuild kotlin with Java 21 default [3]

[1] https://launchpad.net/~vpa1977/+archive/ubuntu/gettext/+packages
[2] https://bugs.launchpad.net/ubuntu/+source/kotlin/+bug/2051757/comments/2
[3] https://launchpad.net/~vpa1977/+archive/ubuntu/gettext-21/+sourcepub/15766367/+listing-archive-extra

To post a comment you must log in.
Revision history for this message
Dan Bungert (dbungert) wrote :

already uploaded

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index 60beb90..555aba1 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,15 @@
6+kotlin (1.3.31+ds1-1ubuntu1) noble; urgency=medium
7+
8+ * Resolve Java 21 FTBFS (LP: #2051757):
9+ - d/p/073-abstractlist.patch: add missing methods to the API due to
10+ the update to source level 8.
11+ - d/p/074-kapt3.patch: cherry-pick upstream patch to resolve Java 21
12+ ftbfs due to the jdk.compiler changes.
13+ - d/control: require updated libasm-java and libintellij-* packages
14+ to support Java 21.
15+
16+ -- Vladimir Petko <vladimir.petko@canonical.com> Wed, 31 Jan 2024 16:57:00 +1300
17+
18 kotlin (1.3.31+ds1-1build5) lunar; urgency=medium
19
20 * Rebuild against newly bootstrapped kotlin.
21diff --git a/debian/control b/debian/control
22index cab9158..c423762 100644
23--- a/debian/control
24+++ b/debian/control
25@@ -1,5 +1,6 @@
26 Source: kotlin
27-Maintainer: Debian Java Maintainers <pkg-java-maintainers@lists.alioth.debian.org>
28+Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
29+XSBC-Original-Maintainer: Debian Java Maintainers <pkg-java-maintainers@lists.alioth.debian.org>
30 Uploaders:
31 Samyak Jain <samyak.jn11@gmail.com>,
32 Sunil Mohan Adapa <sunil@medhas.org>,
33@@ -12,16 +13,16 @@ Build-Depends:
34 gradle-debian-helper (>= 2.4~),
35 jflex,
36 kotlin,
37- libasm-java,
38+ libasm-java (>= 9.6~),
39 libgradle-android-plugin-java,
40 libguava-java,
41- libintellij-core-java,
42- libintellij-extensions-java,
43+ libintellij-core-java (>= 183.5153.4-4ubuntu1~),
44+ libintellij-extensions-java (>= 183.5153.4-4ubuntu1~),
45 libintellij-java-compatibility-java,
46- libintellij-jps-model-java,
47- libintellij-platform-api-java,
48- libintellij-platform-impl-java,
49- libintellij-utils-java,
50+ libintellij-jps-model-java (>= 183.5153.4-4ubuntu1~),
51+ libintellij-platform-api-java (>= 183.5153.4-4ubuntu1~),
52+ libintellij-platform-impl-java (>= 183.5153.4-4ubuntu1~),
53+ libintellij-utils-java (>= 183.5153.4-4ubuntu1~),
54 libjarjar-java,
55 libjdom2-intellij-java,
56 libjdom2-java,
57diff --git a/debian/patches/073-abstractlist.patch b/debian/patches/073-abstractlist.patch
58new file mode 100644
59index 0000000..da9399d
60--- /dev/null
61+++ b/debian/patches/073-abstractlist.patch
62@@ -0,0 +1,33 @@
63+Description: Provide overrides for methods introduced in Java 8 API
64+ Java 21 sets minimum release level to Java 8, forcing Java 8 API compatibility.
65+ This patch adds toArray() methods required by the new interface signatures.
66+ This patch introduces API incompatibility (extra methods).
67+ Upstream builds with Java 6/7 and does not need this patch.
68+Author: Vladimir Petko <vladimir.petko@canonical.com>
69+Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1057513
70+Forwarded: not-needed
71+Last-Update: 2024-01-24
72+--- a/libraries/stdlib/src/kotlin/collections/AbstractList.kt
73++++ b/libraries/stdlib/src/kotlin/collections/AbstractList.kt
74+@@ -21,6 +21,9 @@
75+ abstract override val size: Int
76+ abstract override fun get(index: Int): E
77+
78++ override fun toArray(): Array<Any?> = super<AbstractCollection>.toArray()
79++ override fun <T : Any?> toArray(p0: Array<T>): Array<T> = super<AbstractCollection>.toArray<T>(p0)
80++
81+ override fun iterator(): Iterator<E> = IteratorImpl()
82+
83+ override fun indexOf(element: @UnsafeVariance E): Int = indexOfFirst { it == element }
84+--- a/libraries/stdlib/src/kotlin/collections/Collections.kt
85++++ b/libraries/stdlib/src/kotlin/collections/Collections.kt
86+@@ -47,6 +47,9 @@
87+ throw IndexOutOfBoundsException("fromIndex: $fromIndex, toIndex: $toIndex")
88+ }
89+
90++ fun toArray(): Array<Any?> = arrayOf<Any?>()
91++ fun <T : Any?> toArray(p0: Array<T>): Array<T> = p0
92++
93+ private fun readResolve(): Any = EmptyList
94+ }
95+
96diff --git a/debian/patches/074-kapt3.patch b/debian/patches/074-kapt3.patch
97new file mode 100644
98index 0000000..702bb03
99--- /dev/null
100+++ b/debian/patches/074-kapt3.patch
101@@ -0,0 +1,74 @@
102+Description: KAPT: Use reflection to access code, changed in JDK 21
103+ Related JDK change: https://github.com/openjdk/jdk/commit/a917fb3fcf0fe1a4c4de86c08ae4041462848b82
104+Author: Ilmir Usmanov <ilmir.usmanov@jetbrains.com>
105+Origin: upstream, https://github.com/JetBrains/kotlin/commit/37417f791950bb5fe484edfa8894f26e113fca27
106+Bug: https://youtrack.jetbrains.com/issue/KT-57389
107+Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1057513
108+Forwarded: not-needed
109+Applied-Upstream: 37417f791950bb5fe484edfa8894f26e113fca27
110+--- a/plugins/kapt3/kapt3-base/src/org/jetbrains/kotlin/kapt3/base/javac/KaptJavaLog.kt
111++++ b/plugins/kapt3/kapt3-base/src/org/jetbrains/kotlin/kapt3/base/javac/KaptJavaLog.kt
112+@@ -7,6 +7,7 @@
113+ package org.jetbrains.kotlin.kapt3.base.javac
114+
115+ import com.sun.tools.javac.tree.JCTree
116++import com.sun.tools.javac.tree.JCTree.JCImport
117+ import com.sun.tools.javac.util.*
118+ import com.sun.tools.javac.util.JCDiagnostic.DiagnosticType
119+ import org.jetbrains.kotlin.kapt3.base.KaptContext
120+@@ -54,6 +55,8 @@
121+
122+ private val _reportedDiagnostics = mutableListOf<JCDiagnostic>()
123+
124++ private val jcImportQualidField = JCImport::class.java.declaredFields.single { it.name == "qualid" }
125++
126+ override fun flush(kind: WriterKind?) {
127+ super.flush(kind)
128+
129+@@ -196,7 +199,7 @@
130+ val visitor = object : JCTree.Visitor() {
131+ override fun visitImport(that: JCTree.JCImport) {
132+ super.visitImport(that)
133+- if (!found) that.qualid.accept(this)
134++ if (!found) (jcImportQualidField.get(that) as JCTree).accept(this)
135+ }
136+
137+ override fun visitSelect(that: JCTree.JCFieldAccess) {
138+--- a/plugins/kapt3/kapt3-compiler/src/org/jetbrains/kotlin/kapt3/stubs/ClassFileToSourceStubConverter.kt
139++++ b/plugins/kapt3/kapt3-compiler/src/org/jetbrains/kotlin/kapt3/stubs/ClassFileToSourceStubConverter.kt
140+@@ -121,6 +121,8 @@
141+
142+ private var done = false
143+
144++ private val treeMakerImportMethod = TreeMaker::class.java.declaredMethods.single { it.name == "Import" }
145++
146+ fun convert(): List<KaptStub> {
147+ if (done) error(ClassFileToSourceStubConverter::class.java.simpleName + " can convert classes only once")
148+ done = true
149+@@ -188,7 +190,7 @@
150+
151+ val nonEmptyImports: JavacList<JCTree> = when {
152+ imports.size > 0 -> imports
153+- else -> JavacList.of(treeMaker.Import(treeMaker.FqName("java.lang.System"), false))
154++ else -> JavacList.of(treeMakerImportMethod.invoke(treeMaker, treeMaker.FqName("java.lang.System"), false) as JCImport)
155+ }
156+
157+ val classes = JavacList.of<JCTree>(classDeclaration)
158+@@ -275,13 +277,15 @@
159+ val importedExpr = treeMaker.FqName(importedFqName.asString())
160+
161+ imports += if (importDirective.isAllUnder) {
162+- treeMaker.Import(treeMaker.Select(importedExpr, treeMaker.nameTable.names.asterisk), false)
163++ treeMakerImportMethod.invoke(
164++ treeMaker, treeMaker.Select(importedExpr, treeMaker.nameTable.names.asterisk), false
165++ ) as JCImport
166+ } else {
167+ if (!importedShortNames.add(importedFqName.shortName().asString())) {
168+ continue
169+ }
170+
171+- treeMaker.Import(importedExpr, false)
172++ treeMakerImportMethod.invoke(treeMaker, importedExpr, false) as JCImport
173+ }
174+ }
175+
176diff --git a/debian/patches/series b/debian/patches/series
177index 5306239..1216fa2 100644
178--- a/debian/patches/series
179+++ b/debian/patches/series
180@@ -65,3 +65,5 @@
181 070-replace-proguard-with-jarjar.patch
182 071-java8-compatibility.patch
183 072-tty-detection-fallback.patch
184+073-abstractlist.patch
185+074-kapt3.patch

Subscribers

People subscribed via source and target branches