[Libreoffice] [REVIEW] 3-4 cherry-pick fix to build with gcj 1.5.0

Caolán McNamara caolanm at redhat.com
Fri Nov 4 08:55:56 PDT 2011


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.

Anyway, is your suggested wrapper correct ? Looks a bit odd now that I
actually read it as opposed to boggle at it.

i.e.

 DocumentBuilderFactory dbFactory;
 ClassLoader old = Thread.currentThread().getContextClassLoader();
 ClassLoader c = OfficeDocumentReportTarget.class.getClassLoader();
 if (c != null) {
     // otherwise, hope context class loader already contains a non-null
value
     Thread.currentThread().setContextClassLoader(c); //like so I guess?
 }
 try {
     dbFactory = DocumentBuilderFactory.newInstance();
 } finally {
     if (c != null) {
         Thread.currentThread().setContextClassLoader(old);
     }
 }

C.



More information about the LibreOffice mailing list