RFR: JDK-8234025 Elements.getPackageElement(ModuleElement,CharSequence) returns null for unnamed package
Jan Lahoda
jan.lahoda at oracle.com
Wed Nov 13 13:02:25 UTC 2019
Looks reasonable to me.
Jan
On 12. 11. 19 23:51, Jonathan Gibbons wrote:
> Please review a small fix and corresponding test so that
> Elements.getPackageElement(ModuleElement mdle, CharSequence name)
> returns a non-null result, as intended, for an unnamed package.
>
> The fault occurs in this code in JavacElements.nameToSymbol:
>
> try {
> if (sym ==null)
> sym =javaCompiler.resolveIdent(module, nameStr);
>
> if (clazz.isInstance(sym)) {
> sym.complete();
> if (sym.kind !=ERR &&
> sym.exists() &&
> name.equals(sym.getQualifiedName())) {
> return clazz.cast(sym);
> }
> }
> return null;
> }catch (CompletionFailure cf) {
> cf.dcfh.handleAPICompletionFailure(cf);
> return null;
> }
>
> While a non-null value for sym is found early on, it fails the
> `.exists()` test and so `null` is returned.
>
> The fix is to mark the symbol as existing.
>
> -- Jon
>
> JBS: https://bugs.openjdk.java.net/browse/JDK-8234025
> Webrev: http://cr.openjdk.java.net/~jjg/8234025/webrev.00/
More information about the compiler-dev
mailing list