Issue
I noticed this issue when attempting to load the MANIFEST.MF from the .jar file of my application via class.getResource("/META-INF/MANIFEST.MF")
.
Instead of getting my own manifest, a manifest is seemingly loaded from /usr/share/java/java-atk-wrapper.jar
.
However, this jar is not specified as part of my application's classpath - I tried disabling the java accessibility assistive technologies (here), but this had no effect.
Interestingly, this behavior is specific to OpenJDK-11.0.4. The issue does not occur when using 11.0.3. Can anyone shed some light on what might be happening here? Was there some kind of change to how java-internal jars/classes are loaded/accessed? Or could this simply be a bug introduced in 11.0.4?
Minimal working example:
import java.net.URL;
public class Main {
public static void main(String[] args) {
final URL resource = Main.class.getResource("/META-INF/MANIFEST.MF");
System.out.println(resource.getPath());
}
}
Then run:
$ java --version
openjdk 11.0.4 2019-07-16
OpenJDK Runtime Environment (build 11.0.4+11-post-Ubuntu-116.04.1)
OpenJDK 64-Bit Server VM (build 11.0.4+11-post-Ubuntu-116.04.1, mixed mode, sharing)
$ javac Main.java
$ java Main
file:/usr/share/java/java-atk-wrapper.jar!/META-INF/MANIFEST.MF
$ echo $CLASSPATH
$
The expexted behavior of this code snippet would be to throw a NPE, because there is no manifest resource. Instead, the manifest is loaded from the atk-wrapper.
Environment details:
Ubuntu 16.04.5 LTS
OpenJDK was freshly installed via apt
add-apt-repository ppa:openjdk-r/ppa
apt install openjdk-11-jdk
The apk-wrapper was not installed explicitly. I wasn't aware of its existence until this issue occurred on one of our machines - at which point I was able to reproduce it on my local machine as well.
Solution
When I tried to reproduce this with OpenJDK Java 11.0.4 on Fedora 29, I got a NPE.
$ javac Main.java
$ java Main
Exception in thread "main" java.lang.NullPointerException
at Main.main(Main.java:6)
$ java -version
openjdk version "11.0.4" 2019-07-16
OpenJDK Runtime Environment 18.9 (build 11.0.4+11)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.4+11, mixed mode, sharing)
$ echo $CLASSPATH
$
Then I tried to find java-atk-wrapper.jar
. Not there. So I installed it via the package manager, and then ran your program again.
Still an NPE1.
Hmmm.
Conclusion: there is something weird about the OpenJDK Java 11.0.4 you have installed, but is NOT a bug in OpenJDK itself.
Note that the following OpenJDK bug report is relevant to this:
It seems to be saying that the OpenJDK team doesn't support / maintain the stuff inside that JAR file.
UPDATE
Given the extra information that you added to question, the problem would appear to be a bug in the OpenJDK packages for Debian / Ubuntu. I found this Debian bug that seems to be related:
I suspect that their attempts to fix the original bug ("Accessibility does not get loaded") has introduced this regression.
My advice to you would be:
Raise a new issue with Ubuntu / Debian. Let them decide if this needs to be raised upstream, or whether it is their problem to fix.
If you want to try a hacky workaround, see what happens if you rename
java-atk-wrapper.jar
so that the launcher cannot find it. It might work.Alternatively (less hacky), see what Ubuntu package the JAR file comes from on your system. If it makes sense, uninstall that package and whatever depends on it.
1 - The NPE happens because getResource
is returning null
... because the class loader cannot find a manifest resource. That's what should happen.
Answered By - Stephen C