# Which version of JAXP does Gradle implement?

**URL:** <https://discuss.gradle.org/t/which-version-of-jaxp-does-gradle-implement/39907>\
**Category:** Help/Discuss\
**Created:** [May 11, 2021, 3:25pm UTC](https://discuss.gradle.org/t/which-version-of-jaxp-does-gradle-implement/39907 "2021-05-11T15:25:32Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrisjr](https://avatars.discourse-cdn.com/v4/letter/c/dec6dc/32.png) [@chrisjr](https://discuss.gradle.org/u/chrisjr)\
**Post date:** [May 11, 2021, 3:25pm UTC](https://discuss.gradle.org/t/which-version-of-jaxp-does-gradle-implement/39907/1 "2021-05-11T15:25:32Z")

</div>

Hi,

Firstly: I am using Gradle 6.9, and IntelliJ is delegating all build operations to Gradle running on top of Java 11.

I am trying to debug a Gradle plugin I have written, and IntelliJ is failing to compile my test code because:

```gradle
Unresolved reference: ACCESS_EXTERNAL_DTD
Unresolved reference: ACCESS_EXTERNAL_SCHEMA

```

This compiler error is bizarre! The plugin obviously compiles, builds and runs _outside_ IntelliJ, and these `XMLConstants` values do exist! In fact, they’re _mandatory_ as of JAXP 1.5 - which is _ancient_. However, it seems that the `javax.xml.XMLConstants` file inside `gradle-api-6.9.jar` somehow doesn’t contain them!?

There’s nothing in the [JavaDocs](https://docs.oracle.com/en/java/javase/11/docs/api/java.xml/javax/xml/XMLConstants.html) to suggest I _shouldn’t_ expect `javax.xml.XMLConstants` to have these fields for Java \>= 7.

The `javax.xml.XMLConstants` inside `gradle-api-7.0.jar` is no better either.

I cannot explain this, but I _do_ need XML generation to work inside my Gradle plugin. Can someone explain what is happening please? Has ProGuard been running amok?

Gradle requires Java \>= 8, so having this `javax.xml.XMLConstants` _anywhere_ on the classpath looks like a bug to me.

Cheers,  
Chris

Edit: I have now reproduced the same problem _outside_ of IntelliJ by running Gradle with Java 11, but configuring Java to use a Java 8 toolchain. I have previously been running Gradle with Java 8, which allows Gradle to find the JVM’s built-in `XMLConstants` class.

---

<div class="post-metadata">

**Author:** ![Vampire](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vampire/32/9082_2.png) [@Vampire](https://discuss.gradle.org/u/Vampire)\
**Post date:** [May 11, 2021, 5:55pm UTC](https://discuss.gradle.org/t/which-version-of-jaxp-does-gradle-implement/39907/2 "2021-05-11T17:55:49Z")

</div>

This sounds related to this issue: [Generated gradle-api jar contains JRE classes and in old version which confuses Kotlin compiler · Issue #16147 · gradle/gradle · GitHub](https://github.com/gradle/gradle/issues/16147)

---

<div class="post-metadata">

**Author:** ![chrisjr](https://avatars.discourse-cdn.com/v4/letter/c/dec6dc/32.png) [@chrisjr](https://discuss.gradle.org/u/chrisjr)\
**Post date:** [May 11, 2021, 6:00pm UTC](https://discuss.gradle.org/t/which-version-of-jaxp-does-gradle-implement/39907/3 "2021-05-11T18:00:00Z")

</div>

Yes it does, except that I can now reproduce this _without_ IntelliJ 🙁. I am writing this plugin in Kotlin though.

This current situation is that I can compile my plugin when Gradle runs on Java 8, but not when Gradle runs on Java 11. I thought I might resolve this by declaring a `compileOnly` dependency on an artifact containing the JAXP 1.5 APIs, except I cannot find such a thing in Maven Central. I’m presumably supposed to be able to use the one included in the JDK these days.

---

<div class="post-metadata">

**Author:** ![Vampire](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vampire/32/9082_2.png) [@Vampire](https://discuss.gradle.org/u/Vampire)\
**Post date:** [May 11, 2021, 6:09pm UTC](https://discuss.gradle.org/t/which-version-of-jaxp-does-gradle-implement/39907/4 "2021-05-11T18:09:44Z")

</div>

> [@chrisjr](#):
>
> Yes it does, except that I can now reproduce this _without_ IntelliJ 🙁. I am writing this plugin in Kotlin though.

I don’t understand the emphasized “without”.  
My report has nothing to do with IntelliJ and I also explicitly say in the linked YouTrack issue that the compiling in Gradle is where it fails, completely independent from the IDE.

---

<div class="post-metadata">

**Author:** ![chrisjr](https://avatars.discourse-cdn.com/v4/letter/c/dec6dc/32.png) [@chrisjr](https://discuss.gradle.org/u/chrisjr)\
**Post date:** [May 11, 2021, 6:20pm UTC](https://discuss.gradle.org/t/which-version-of-jaxp-does-gradle-implement/39907/5 "2021-05-11T18:20:56Z")

</div>

I followed the link to the issue in YouTrack, which ends by saying:

> So the problem is in fact in the Kotlin IntelliJ plugin which places the JDK before any dependencies when analyzing a module (probably related to how `sdkDependency` is passed as `firstDependency` [in AbstractResolverForProject](https://github.com/JetBrains/kotlin/blob/72322646cc9d9b09ef3194285bcae294e248de49/compiler/frontend/src/org/jetbrains/kotlin/analyzer/AbstractResolverForProject.kt#L68)), which does not correspond to how the code is compiled subsequently.

I don’t think I agree though.

Edit: In fact, I _definitely_ disagree. I have created two trivial plugin projects: one in Java and the other in Kotlin:

```java
public class JavaPlugin implements Plugin<Project> {
    @Override
    public void apply(@Nonnull Project project) {
        project.getLogger().lifecycle("JAXP: {}, {}", ACCESS_EXTERNAL_DTD, ACCESS_EXTERNAL_SCHEMA);
    }
}

```

vs

```kotlin
class KotlinPlugin : Plugin<Project> {
    override fun apply(project: Project) {
        project.logger.lifecycle("JAXP: {}, {}", ACCESS_EXTERNAL_DTD, ACCESS_EXTERNAL_SCHEMA)
    }
}

```

Only the Java one compiles when Gradle runs on Java 11 😠. (Both compile when Gradle runs on Java 8 though.)

---

<div class="post-metadata">

**Author:** ![chrisjr](https://avatars.discourse-cdn.com/v4/letter/c/dec6dc/32.png) [@chrisjr](https://discuss.gradle.org/u/chrisjr)\
**Post date:** [May 11, 2021, 7:16pm UTC](https://discuss.gradle.org/t/which-version-of-jaxp-does-gradle-implement/39907/6 "2021-05-11T19:16:12Z")

</div>

JetBrains has _definitely_ filed your bug report under “Kotlin IntelliJ IDEA plugin” though 🤦‍♂️.

---

<div class="post-metadata">

**Author:** ![Vampire](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vampire/32/9082_2.png) [@Vampire](https://discuss.gradle.org/u/Vampire)\
**Post date:** [May 11, 2021, 10:39pm UTC](https://discuss.gradle.org/t/which-version-of-jaxp-does-gradle-implement/39907/7 "2021-05-11T22:39:14Z")

</div>

They moved it there, yes.  
Because the one who did that statement you quoted says that Kotlin and Java compiler behave the same.  
If this is the case (which your example seems to contradict) then it is an IJ plugin issue that there the code shows green while the compiler flags it as red.  
If it is not the case, then it seems to me to be a compiler issue while IJ is right.

---

<div class="post-metadata">

**Author:** ![chrisjr](https://avatars.discourse-cdn.com/v4/letter/c/dec6dc/32.png) [@chrisjr](https://discuss.gradle.org/u/chrisjr)\
**Post date:** [May 12, 2021, 9:41am UTC](https://discuss.gradle.org/t/which-version-of-jaxp-does-gradle-implement/39907/8 "2021-05-12T09:41:45Z")

</div>

And in the meantime, I have discovered that I can escape from between the Gradle rock and Kotlin hard-place by rewriting the affected classes in Java.

Go figure 😜.
