The implementation walks enclosing symbols using sym.owner and looking at sym.kind until it sees a package, so it NPEs if called on a symbol that does not have an enclosing package (i.e. a module).
I don't have a repro for this that uses public/supported APIs, but it might be worth fixing regardless.
http://hg.openjdk.java.net/jdk/jdk/file/ff45c1bf8129/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java#l510
I don't have a repro for this that uses public/supported APIs, but it might be worth fixing regardless.
http://hg.openjdk.java.net/jdk/jdk/file/ff45c1bf8129/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java#l510