RFR: 8254274: Development to add 'lint' warning for @ValueBased classes
Srikanth Adayapalam
sadayapalam at openjdk.java.net
Wed Oct 28 06:24:25 UTC 2020
On Mon, 26 Oct 2020 16:55:22 GMT, Dan Smith <dlsmith at openjdk.org> wrote:
>> New javac lint mode (-Xlint:synchronize) to warn about client side as well JDK internal attempts to synchronize on instances of value based classes
>
> src/jdk.compiler/share/classes/com/sun/tools/javac/code/Lint.java line 288:
>
>> 286: * Warn about synchronization attempts on instances of @ValueBased classes.
>> 287: */
>> 288: SYNCHRONIZE("synchronize"),
>
> Suggest calling this `synchronized`, to match the keyword, or `synchronization`, to make it a noun.
Thanks, I prefer the latter and will opt for it (synchronization)
> src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java line 2424:
>
>> 2422: chk.checkRefTypes(tree.typeargs, typeargtypes);
>> 2423:
>> 2424: if (localEnv.info.lint.isEnabled(LintCategory.SYNCHRONIZE)) {
>
> Looks like you're checking calls to wait/notify? I don't think that's necessary—there will already be a warning at the `synchronized` statement; if that doesn't happen, it's malformed code that will fail at runtime (attempting to wait without owning the lock). In practice, I think we just end up with lots of redundant warnings.
Sounds good. I agree this is redundant and noisy.
> src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties line 262:
>
>> 260:
>> 261: javac.opt.Xlint.desc.preview=\
>> 262: Warn about use of preview language features
>
> Old code, I know, but the convention appears to be that these descriptions should end in a period. (Same comment for both `javac.opt.Xlint.desc.varargs` and `javac.opt.Xlint.desc.preview`.)
OK, will do.
-------------
PR: https://git.openjdk.java.net/valhalla/pull/237
More information about the valhalla-dev
mailing list