0

EDIT

I tried to do gradle build and it gives me this error:

package com.sun.org.apache.xerces.internal.dom is declared in module java.xml, which does not export it

I inspected gradle dependencies, but no one uses java.xml


We use ElementNSImpl in only one part of our code (I don't know why...). Anyway, when I tried to switch to Java 11 Zulu, Eclipse gives me this error:

The type com.sun.org.apache.xerces.internal.dom.ElementNSImpl is not accessible

With OpenJDK 8 we have to import it using xerces:xercesImpl:2.6.2-jaxb-1.0.6

I inspected the class with Eclipse and it's a public class, under the Zulu 11 jar.

Community
  • 1
  • 1
Marco Sulla
  • 15,299
  • 14
  • 65
  • 100
  • 1
    com.sun.org.apache.xerces.internal.dom is JDK-internal. You should have got a compiler warning with JDK 8 (and older) to warn you about that. Since JDK 9, JDK internals are encapsulated at compile-time so this is why you are getting a compilation error. The right thing is to fix whatever it is that is making direct use of a JDK internal class. You can workaround it temporarily by compiling with `--add-exports java.xml/com.sun.org.apache.xerces.internal.dom=ALL-UNNAMED`. – Alan Bateman May 09 '19 at 18:00
  • 4
    When you use an external Xerces lib, the class should be `org.apache.xerces.internal.dom.ElementNSImpl` (note: without preceding `com.sun.`), but I’m still wondering whether you really need to access that implementation class whose name already bears “*internal*” and “*Impl*”, rather than using the standard DOM API (the `org.w3c.dom.Element` interface). – Holger May 09 '19 at 18:09
  • @Holger Don't know, we found it in the code, added by someone in the past... anyway Eclipse asked me about `com.sun.org.apache.xerces`. That's why we previously use [xerces version 2.6.2-jaxb-1.0.6](http://central.maven.org/maven2/xerces/xercesImpl/2.6.2-jaxb-1.0.6/xercesImpl-2.6.2-jaxb-1.0.6.jar) – Marco Sulla May 09 '19 at 18:51
  • Then, I’d try whether the code still works when changing that reference to the standard `Element` interface. – Holger May 10 '19 at 06:31
  • 1
    @Holger With `Element` works. If you write an answer I'll accept it. – Marco Sulla May 10 '19 at 14:10

2 Answers2

4

As @Holger said in its comment and @AlanBateman said in its comment, com.sun.org.apache.xerces.internal.dom is JDK-internal. You have simply to substitute com.sun.org.apache.xerces.internal.dom.ElementNSImpl with org.w3c.dom.Element

Marco Sulla
  • 15,299
  • 14
  • 65
  • 100
0

In my case changing the import to org.apache.xerces.dom.ElementNSImpl worked. Refer to https://xerces.apache.org/xerces-j/apiDocs/org/apache/xerces/dom/ElementNSImpl.html

I'm using Red Hat openjdk 11 btw.

Hope it helps.

jmizv
  • 1,172
  • 2
  • 11
  • 28
Isidro.rn
  • 195
  • 1
  • 12