Skip to content
This repository was archived by the owner on Oct 18, 2024. It is now read-only.

Commit 1730d0a

Browse files
committed
fix(tooling-api): project initialization failure when the project contains a Java library module
This happens due to the use of relocated packages in AndroidIDE's Java Compiler API. The 'JavaModuleCompilerSettings' class references the 'javax.lang.model.SourceVersion.RELEASE_11' enum. However, in AndroidIDE, the SourceVersion class has the package name 'jdkx.lang.model'. The project compiles successfully as the ':subprojects:tooling-api-model' module is a Java library due to which, 'javax.lang.model.SourceVersion' can be referenced without any errors. However at runtime, there is no such class and hence the 'NoClassDefFoundError' is thrown. This exception is silently logged to the error stream by the JSONRpc protocol and hence it cannot be seen in the IDE logs. This closes #875.
1 parent e56229c commit 1730d0a

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed
-39 Bytes
Binary file not shown.

subprojects/tooling-api-model/src/main/java/com/itsaky/androidide/tooling/api/model/JavaModuleCompilerSettings.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
package com.itsaky.androidide.tooling.api.model
1919

2020
import com.itsaky.androidide.builder.model.IJavaCompilerSettings
21-
import javax.lang.model.SourceVersion
2221

2322
/**
2423
* Compiler settings for [JavaModule].
@@ -29,8 +28,13 @@ class JavaModuleCompilerSettings(
2928
override val javaSourceVersion: String,
3029
override val javaBytecodeVersion: String
3130
) : IJavaCompilerSettings(), java.io.Serializable {
32-
31+
3332
private val serialVersionUID = 1L
3433

35-
internal constructor() : this(SourceVersion.RELEASE_11.name, SourceVersion.RELEASE_11.name)
34+
// IMPORTANT
35+
// Do not use javax.lang.model.SourceVersion reference here
36+
// When running on Android, this class is preset as jdkx.lang.model.SourceVersion
37+
// Using the 'javax' reference will result a 'ClassNotFoundException' while deserializing the
38+
// JSONRpc data received from the Tooling API server
39+
internal constructor() : this("RELEASE_11", "RELEASE_11")
3640
}

0 commit comments

Comments
 (0)