[Libreoffice] [REVIEW] 3-4 cherry-pick fix to build with gcj 1.5.0
Stephan Bergmann
sbergman at redhat.com
Fri Nov 4 09:14:09 PDT 2011
On 11/04/2011 04:55 PM, Caolán McNamara wrote:
> On Fri, 2011-11-04 at 16:23 +0100, Stephan Bergmann wrote:
>> Anyway, you have been warned. ;)
>
> Pfff, seems a sure route to madness to have to second guess every
> possible java api over and above its documentation in case it uses some
> ContextClassLoader under the hood. *shudder*, that'd be some audit
> effort. Direct uses are one thing, but indirect hidden ones.
The context class loader is a dirty hack in the Java API, broken by
design. Just goes to show how bad global variables are.
> Anyway, is your suggested wrapper correct ? Looks a bit odd now that I
> actually read it as opposed to boggle at it.
Just wrote it down as a quick sketch, so surely contains all sorts of
errors.
> Thread.currentThread().setContextClassLoader(c); //like so I guess?
yes, sure
Anyway, given the code in question is likely called from the main
thread, so would not exhibit any more of a problem than all the already
existing instances of DocumentBuilderFactory.newInstance(), and
presumably already works fine in master, I'm indifferent to whether any
context class loader handling would be needed for a 3.4 cherry-pick
after all... Consider it as approvingly reviewed by me either way.
(That said, I'll make a mental note to revisit the problem on master and
maybe introduce some code abstraction to wrap around calls of
DocumentBuilderFactory.newInstance() and similar constructs.)
Stephan
More information about the LibreOffice
mailing list