After seemingly irrelevant changes in the code of my AEM project, my bundle fails to resolve. Upon inspecting the logs, I can see the following errors appearing.
<
The package sun.reflect.generics.reflectiveObjects
is part of the JDK but it's not part of the Java API, as explained in Oracle's documentation for Java 7 compatibility
The
sun.*
packages are not part of the supported, public interface. A Java program that directly calls intosun.*
packages is not guaranteed to work on all Java-compatible platforms. In fact, such a program is not guaranteed to work even in future versions on the same platform.
This explains why the package is not exported by the System bundle in Apache Felix, underlying AEM. A very reasonable decision indeed. The code compiled locally because the package was in my classpath but it failed at runtime, which is all fine and to be expected.
My code should not have been using this package in the first place. There are two possible ways of introducing a dependency on these packages.
Use a library that uses these classes for some reason and introduce a transitive dependency. This isn't what happened.
Import one of these classes - a very silly thing to do. If someone uses a class, they should know what it is.
In my case, I explicitly imported a class from this package without noticing it.
It turns out that the sun.reflect.generics.reflectiveObjects
package contains a NotImplementedException
class, the name of which coincides with the often-used NotImplementedException
from apache.commons.lang3
.
I accidentally imported it when it was auto-completed in my IDE and failed to notice this for a long time. It took me a git bisect
to isolate the change.
After this happened, I excluded the sun.*
packages from autocomplete.