Search code examples
java-8xercessun

Java - Internal package found, but subpackage is missing


While using JDK internal Xerces implementation, I have the following issue: At compile javac warns me that

XMLSchema.java:28: warning: XSConstants is internal proprietary API and may be removed in a future release
    [javac] import com.sun.org.apache.xerces.internal.xs.XSConstants;

but fails to find com.sun.org.apache.xerces.internal.xs.datatypes package.

XMLSchema.java:35: error: package com.sun.org.apache.xerces.internal.xs.datatypes does not exist
    [javac] import com.sun.org.apache.xerces.internal.xs.datatypes.ObjectList;

What could be the issue here?

I'm using JDK 1.8


Solution

  • The problem has been reported and answered before: Using internal sun classes with javac

    When javac is compiling code it doesn't link against rt.jar by default. Instead it uses special symbol file lib/ct.sym with class stubs.

    Surprisingly this file contains many but not all of internal sun classes. In my case one of those more-internal-than-usual classes was com.sun.org.apache.xerces.internal.xs.datatypes.ObjectList (adapted answer)