RFR: 8150173: JAXBContext.newInstance causes PrivilegedActionException when createContext's declared in absract class extended by discovered JAXB implementation

Daniel Fuchs daniel.fuchs at oracle.com
Thu Jun 23 13:55:34 UTC 2016


Hi Georgiy

On 23/06/16 13:48, Georgiy Rakov wrote:
> Hi Daniel,
>
> if I understand correctly JAXBContextWithSubclassedFactory is supposed
> to capture the idea of Test9 but it doesn't. FactoryBase shouldn't
> implement JAXBContextFactory but Factory should:
>
>     public static class FactoryBase {
>         public JAXBContext createContext(...) ...
>
>         public JAXBContext createContext(...) ...
>     }
>
>     public static class Factory extends FactoryBase implements
> JAXBContextFactory {    }
>
> This is a quite a corner case of methods overriding when method is
> overridden by the base class.

Oh - I see, I missed that - I was chasing down an other avenue.
I will add the test.


> JAXBContextWithLegacyFactory looks good to me.
>
> BTW the approach with Factory1 and Factory2 used in
> JAXBContextWithLegacyFactory seems be useful in
> JAXBContextWithSubclassedFactory and JAXBContextWithAbstractFactory too.

I'll see what I can do.

> It also seems that some refactoring could be applied by extracting main,
> test, JAXBContextImpl and tmp members from JAXBContextWithLegacyFactory
> to be used in all three classes..... probably by extracting superclass
> or method object refactoring.

It might. My personal taste is to prefer unit tests to be
self contained. I'll occasionally introduce a super class if
the amount of sharing is significant enough - but in this case
I'm not sure it is.

I'll send a new webrev shortly.

best regards,

-- daniel


More information about the core-libs-dev mailing list