[rfc][icedtea-web] Fix resource loading in CodebaseManifestEntry reproducers

Jiri Vanek jvanek at redhat.com
Tue Mar 17 09:22:15 UTC 2015


On 03/16/2015 05:27 PM, Jie Kang wrote:
>
>
> ----- Original Message -----
>> On 03/16/2015 03:29 PM, Jie Kang wrote:
>>> Hello,
>>>
>>> The CodebaseManifestEntry reproducers were failing due to NPE in getting
>>> the Message.properties resource. This patch fixes that. The tests no
>>> longer fail with NPE when manifest checks are enabled.
>>>
>>> However, for the most part, manifest checks are disabled when running
>>> reproducers in order to prevent popup dialogs from causing them to fail. I
>>> think ldracz is working on a fix to allow us to test with them
>>> enabled/disabled per-test/per-reproducer. This fix should be applied here
>>> when able.
>>>
>>> Also, the tests still have some errors unrelated to this resource loading
>>> which will be addressed in a separate patch.
>>>
>>> Thoughts?
>>>
>>>
>>> Regards,
>>>
>>
>>
>> Looks ok. Please, before push, ensure that it is working both in IDE and from
>> commandline. In past
>> there were divergences. From commandline very often direct call to
>> getSystemClasloader was necessary.
>>
>
> Hello,
>
> Just for some closure:
>
> Class.java::getResourceAsStream:
> {
>      [...]
>      ClassLoader cl = getClassLoader0();
>      if (cl==null) {
>          // A system class.
>          return ClassLoader.getSystemResourceAsStream(name);
>      }
>      return cl.getResourceAsStream(name);
>      [...]
> }
>
> And getSystemResourceAsSteam uses the system class loader so this should work out for us in all cases.

If it is direct call to geSystemClasslaoder then ok. Otherwise not.

I remember need of something like:


  ClassLoader cl = this.getClass().getClassLoader();
         ServerAccess.logOutputReprint(cl==null?"null":cl.toString());
         if (cl == null) {
             cl = ClassLoader.getSystemClassLoader();
             ServerAccess.logOutputReprint(cl==null?"null":cl.toString());
         }
         InputStream q = cl.getResourceAsStream(...);


The this.getClass().getClassLoader(); call was returning systemclasslaoder in ide, but null in 
commandline....

>
> I have tested it through command-line and it seems fine. If anything we can always push a patch on top if it doesn't.
>
>
> P.S. I have never ran reproducers in IDE; it seems to need a lot of setup;;; Do you run them in an IDE and if so, how'd you get it to work? :D
>
>
Yes I do. The testclass is unittest like any other unittest. You need to have somewhere installed 
image of itw, and somewhere deployed test resources. Then you will just make unittes engine aware of 
those locations via properties:

-Dused.browsers=:/usr/bin/chromium-browser::/usr/bin/opera:/usr/bin/midori:/usr/bin/epiphany 
-Dtest.server.dir=/home/jvanek/Desktop/icedtea-web/tests.build/reproducers_test_server_deploydir 
-Djavaws.build.bin=/home/jvanek/icedtea-web-image/bin/javaws 
-Xbootclasspath/a:/home/jvanek/icedtea-web-image/share/icedtea-web/netx.jar:/usr/share/java/js.jar



J.

http://icedtea.classpath.org/wiki/Reproducers#run_from_IDE    :))) It was not forgotten!


More information about the distro-pkg-dev mailing list