RFR: 8261407: ReflectionFactory.checkInitted() is not thread-safe [v5]

Mandy Chung mchung at openjdk.java.net
Thu Feb 10 22:53:57 UTC 2022


On Thu, 10 Feb 2022 22:21:32 GMT, liach <duke at openjdk.java.net> wrote:

>> src/java.base/share/classes/jdk/internal/reflect/ReflectionFactory.java line 672:
>> 
>>> 670:         private final boolean disableSerialConstructorChecks;
>>> 671: 
>>> 672:         private Config(boolean getProperties) {
>> 
>> I suggest to make this a static `Config.getInstance()` method to return a `Config` instance and that should assert if this is called after the module system is initialized.   The `Config` constructor is a simple constructor taking one parameter for each field and just set all fields to the parameter value.
>
> Can I just write the config class as a record, or does it generate too much boilerplate? Or is this class initialized too early to use records (such as indy is not yet ready)?

Worth a try.   Even the regular class, the constructor taking 5 fields isn't too bad to me.  In a near future, I hope to remove the old core reflection implementation, `noInflation` and `inflationThreshold` will be removed and fewer fields.

-------------

PR: https://git.openjdk.java.net/jdk/pull/6889


More information about the core-libs-dev mailing list