Placing tests in java.lang package (for testing protected methods)

Tomasz Kowalczewski tomasz.kowalczewski at gmail.com
Wed May 27 12:35:40 UTC 2015


Thank you, that was exactly what I needed for jtreg.

--
Regards,
Tomasz

On Tue, May 26, 2015 at 11:27 AM, Alan Bateman <Alan.Bateman at oracle.com>
wrote:

>
>
> On 26/05/2015 10:04, Tomasz Kowalczewski wrote:
>
>> Hi,
>>
>> I am trying to test a protected method of java.lang.String. Is this
>> possible with jtreg? If I specify:
>>
>> * @run testng java.lang.StringIndexOfCharSequenceTest
>> */
>> package java.lang;
>>
>> I will (unsurprisingly) get "SecurityException: Prohibited package name:
>> java.lang". I was thinking that there may be some jtreg magic to circumvent
>> this?
>>
>>  Protected or package private? I assume the latter, in which case the
> test class will need to be in java.lang with the boot loader as the
> defining loader. Outside of the test harness then you could do this with
> -Xbootclasspath/a.
>
> As a jtreg test then the magic property to add to TEST.properties is
> bootclasspath.dirs to specify the directory with the classes to be loaded
> by the boot loader. Jon or others might have more to say on this but I
> think this feature is somewhat limited to TestNG tests, I don't think I've
> seen it used for anything other than TestNG tests. You'll see examples in
> the jdk repo, specifically in jdk/test/java/util/stream.
>
> -Alan
>



-- 
Tomasz Kowalczewski
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/jtreg-use/attachments/20150527/f92a360e/attachment.html>


More information about the jtreg-use mailing list