[9 + 8u] RFR - 8066612: Add a test that will call getDeclaredFields() on all classes and try to set them accessible.

Daniel Fuchs daniel.fuchs at oracle.com
Thu Dec 4 09:05:20 UTC 2014


Hi David,

On 12/4/14 4:37 AM, David Holmes wrote:
> Hi Daniel,
>
> Once clarification please ...
>
> On 4/12/2014 8:47 AM, Daniel Fuchs wrote:
>> Hi,
>>
>> This is a review for a new test which has a different
>> implementation for JDK 8 & JDK 9
>>
>> During the review of
>> JDK-8065552: setAccessible(true) on fields of Class may throw
>>               a SecurityException,
>> it was remarked that such a test would be useful.
>>
>> So here is such a test that loads all classes from the BCL, calls
>> getDeclaredFields() for each of them, and attempt to set
>> each field to accessible.
>> On JDK 8 and JDK 9 this is quite fast (~ 3.2sec when a security
>> manager is on).
>>
>> The differences between 8 & 9 are limited to:
>>
>>     - ClassLoader:
>>          - on 8 we use 'null' (BCL)
>>          - on 9 we use the system class loader.
>
> I haven't seen anything in JEP 220, regarding modules, that indicates 
> that classes currently loaded  by the boot-loader will now be loaded 
> by the system classloader ???

In [1] towards the end:

[1] http://openjdk.java.net/jeps/220

"The defining class loader of the types in some existing packages
  will change. Existing code that makes assumptions about the class
  loaders of these types might not work correctly."
  (then there is a list of specific changes).

This test looks up all class names in the image files and attempt
to load the corresponding class. But as indicated in [1]
some of these classes are now in the Boot CL, some in the
Extension CL, and some in the Application CL.

So the test uses the System CL to load each class - which ensures
that the loading will be delegated to the appropriate ClassLoader.

best regards,

-- daniel

>
> Thanks,
> David
>
>>     - Building the stream of class names:
>>          - on 8 we have jars & folders in the boot class path
>>          - on 9 we have .jimage files
>>
>>
>> webrev jdk8:
>> http://cr.openjdk.java.net/~dfuchs/webrev_8066612/webrev-jdk8.00/
>>
>> webrev jdk9:
>> http://cr.openjdk.java.net/~dfuchs/webrev_8066612/webrev-jdk9.00/
>>
>>
>> best regards,
>>
>> -- daniel
>>
>> PS: For the curious I have also experimented with a version of this
>> test for JDK 7u [1] (where Streams have been replaced by Lists).
>> On 7 you need to either increase the PermGen size or split the
>> test into several invocations (the method I chose in [1]).
>>
>> [1] don't review the link below - it's just for the record
>>      if/when someone wants to backport on 7u...
>> http://cr.openjdk.java.net/~dfuchs/webrev_8066612/webrev-jdk7.00



More information about the jdk8u-dev mailing list