I’ve discovered something weird, but I can’t figure it out on my own.
The following Java code works outside of Flatpak, and works inside Flatpak for most distros - But in Flatpak on Arch Linux, it throws an exception:
import java.net.InetAddress;
public final class Main {
public static void main(String[] args) {
try {
InetAddress.getLocalHost();
System.out.println("Completed without issue!");
System.exit(0);
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
}
}
Output outside Flatpak or on most distros:
Completed without issue!
Output in Flatpak on Arch Linux:
java.net.UnknownHostException: archlinux: archlinux: Name or service not known
at java.base/java.net.InetAddress.getLocalHost(InetAddress.java:1661)
at Main.main(Main.java:6)
Caused by: java.net.UnknownHostException: archlinux: Name or service not known
at java.base/java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
at java.base/java.net.InetAddress$PlatformNameService.lookupAllHostAddr(InetAddress.java:929)
at java.base/java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1534)
at java.base/java.net.InetAddress$NameServiceAddresses.get(InetAddress.java:848)
at java.base/java.net.InetAddress.getAllByName0(InetAddress.java:1524)
at java.base/java.net.InetAddress.getLocalHost(InetAddress.java:1656)
... 1 more
I’ve created a repo with a reproducible example + simple build steps in the README: GitHub - dginovker/FlatpakJavaBug: Example bug in Flatpak Java
- Granting Flatpak with all the permissions via Flatseal doesn’t resolve the issue
- Issue happens with OpenJDK 11 and OpenJDK17 (although I suspect this isn’t actually a Java issue)
Anyone have other suggestions on how to narrow this down?