8201622: Reduce unnecessary Package.complete() calls in javadoc
Reviewed-by: jlahoda
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacElements.java Fri Apr 27 09:57:16 2018 -0700
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacElements.java Fri Apr 27 15:55:29 2018 -0700
@@ -247,14 +247,15 @@
if (sym == null)
sym = javaCompiler.resolveIdent(module, nameStr);
- sym.complete();
-
- return (sym.kind != ERR &&
+ if (clazz.isInstance(sym)) {
+ sym.complete();
+ if (sym.kind != ERR &&
sym.exists() &&
- clazz.isInstance(sym) &&
- name.equals(sym.getQualifiedName()))
- ? clazz.cast(sym)
- : null;
+ name.equals(sym.getQualifiedName())) {
+ return clazz.cast(sym);
+ }
+ }
+ return null;
} catch (CompletionFailure cf) {
cf.dcfh.handleAPICompletionFailure(cf);
return null;
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/WorkArounds.java Fri Apr 27 09:57:16 2018 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/WorkArounds.java Fri Apr 27 15:55:29 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,7 +28,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -200,10 +199,15 @@
// TODO: needs to ported to jx.l.m.
public TypeElement searchClass(TypeElement klass, String className) {
- // search by qualified name first
- TypeElement te = configuration.docEnv.getElementUtils().getTypeElement(className);
- if (te != null) {
- return te;
+ TypeElement te;
+
+ // search by qualified name in current module first
+ ModuleElement me = utils.containingModule(klass);
+ if (me != null) {
+ te = configuration.docEnv.getElementUtils().getTypeElement(me, className);
+ if (te != null) {
+ return te;
+ }
}
// search inner classes
@@ -251,6 +255,12 @@
}
}
+ // finally, search by qualified name in all modules
+ te = configuration.docEnv.getElementUtils().getTypeElement(className);
+ if (te != null) {
+ return te;
+ }
+
return null; // not found
}