-
Bug
-
Resolution: Fixed
-
P3
-
9
-
b132
-
Not verified
HTMLWriter contains 40 members which are "public final Content".
Not only do these fields not belong on this class from an abstraction point of view (they would be somewhat better placed on HtmlDocWriter/HtmlDocletWriter) but more significantly, ALL these 3 classes get instantiated at least once per file generated, meaning that all those 40 members get instantiated once per file generated -- and yet they are all constants obtained from getResource, and in many cases will not even be used.
This is probably one of the reasons why Configuration.getText was showing up in perf runs, and fixed in part by Claes inJDK-8157102.
But while he made doclet resource lookup faster, we can significantly reduce the number of lookups, to once per resource, instead of once per resource per file.
I also note while browsing code that while HtmlWriter proactively looks up some resources, I have come across cases where the value is ignored, and looked up again "as needed" in method bodies in various subtypes.
These resources should all be obtained from a single object, available from the Configuration. There should either be an enum or named string constants to identify the resources, to avoid resource names in strings throughout the code (as is currently the case.)
I also note that we need not do a conversion all at once; once we have the basic mechanism in place, we just need to audit/replace the calls to HtmlWriter.getResource and HtmlWriter.getNonBreakResource one at a time with calls to the new underlying mechanism.
Not only do these fields not belong on this class from an abstraction point of view (they would be somewhat better placed on HtmlDocWriter/HtmlDocletWriter) but more significantly, ALL these 3 classes get instantiated at least once per file generated, meaning that all those 40 members get instantiated once per file generated -- and yet they are all constants obtained from getResource, and in many cases will not even be used.
This is probably one of the reasons why Configuration.getText was showing up in perf runs, and fixed in part by Claes in
But while he made doclet resource lookup faster, we can significantly reduce the number of lookups, to once per resource, instead of once per resource per file.
I also note while browsing code that while HtmlWriter proactively looks up some resources, I have come across cases where the value is ignored, and looked up again "as needed" in method bodies in various subtypes.
These resources should all be obtained from a single object, available from the Configuration. There should either be an enum or named string constants to identify the resources, to avoid resource names in strings throughout the code (as is currently the case.)
I also note that we need not do a conversion all at once; once we have the basic mechanism in place, we just need to audit/replace the calls to HtmlWriter.getResource and HtmlWriter.getNonBreakResource one at a time with calls to the new underlying mechanism.
- duplicates
-
JDK-8145245 improve initialization of HtmlWriter, HtmlDocWriter, HtmlDocletWriter
-
- Closed
-
- relates to
-
JDK-8214139 Remove wrapper methods from {Base,Html}Configuration
-
- Resolved
-
-
JDK-8189405 More cleanup in HtmlWriter
-
- Resolved
-