0

I have an old project in Eclipse that runs fine with Java 13. I'm using Eclipse 2019-09 (4.13.0), I have the Java 13 JRE on the build path and as the default JRE, the compliance level set to 13, and the Eclipse Java 13 patch installed. No problems.

When I convert this to a Maven project, some of the JRE classes are no longer found. BitArray (found in java.xml com.sun.org.apache.xalan.internal.xsltc.dom), DocumentImpl (found in java.xml com.sun.org.apache.xerces.internal.dom), BevelBorder (found in java.desktop com.sun.java.swing.plaf.motif.MotifBorders) and others.

If I hover over one of the fields - say BitArray - Eclipse will prompt me to Import 'BitArray' (com.sun.org.apache.xalan.internal.xsltc.dom), but when I do I simply get an error saying The import com.sun.org.apache.xalan cannot be resolved

I have the following lines in pom.xml:

  <plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.8.0</version>
    <configuration>
      <release>13</release>
    </configuration>
  </plugin>

I've done many Clean&Builds and Maven updates. I've tried changing the order in the build path (read that was a bug in earlier releases). I've even used the Hello World Maven project example with the same result - as soon as I add BitArray, it fails.

Any suggestions would be greatly appreciated. I've been googling this for half a day now, and still haven't found the solution.

Michael
  • 141
  • 2
  • 12
  • 1
    I would never use classes from `com.sun.*.internal.*` better use real dependencies cause they are more up-to-date etc. and you will prevent issues like this. The problem arises based on JDK13 – khmarbaise Nov 22 '19 at 12:16
  • Does your project contain `module-info.java` files? – nitind Nov 22 '19 at 13:40
  • @nitind no, no module-info.java files – Michael Nov 22 '19 at 14:48
  • @khmarbaise do you mean all com.sun.* classes, or specifically the *.internal.* classes? – Michael Nov 22 '19 at 14:53
  • 1
    In Java 9 and higher `com.sun.org.apache.xalan.internal.xsltc.dom.BitArray` of the system library is only accessible if the package `com.sun.org.apache.xalan.internal.xsltc.dom` of the module `java.xml` will be exported (on the command line via `--add-exports java.xml/com.sun.org.apache.xalan.internal.xsltc.dom=ALL-UNNAMED`). To run the old project with Java 13 you probably have configured this (in the _Java Build Path_ dialog in the tab _Module Dependencies_) but lost this configuration by converting it to a Maven project (see [my answer here](https://stackoverflow.com/a/55920911/6505250)). – howlger Nov 22 '19 at 16:13
  • If you don't have a module-info I strongly recommend to refactor you project and use external dependencies an in particular never use com.sun.* and never ever *.internal* ... – khmarbaise Nov 22 '19 at 19:05
  • You are basically hitting the problem warned against from the dawn of time when using JVM implementation specific classes, namely that they may go away. Either stay on an older LTS version, or fix the maintenance issue now. – Thorbjørn Ravn Andersen Nov 24 '19 at 11:01
  • Thank you very much for the help. The comment from @howlger was able to get me going while I replaced the internal classes as khmarbaise initially suggested – Michael Dec 04 '19 at 14:46

0 Answers0