RFR: 8254274: Development to add 'lint' warning for @ValueBased classes
Dan Smith
dlsmith at openjdk.java.net
Mon Oct 26 17:14:28 UTC 2020
On Mon, 26 Oct 2020 11:01:59 GMT, Srikanth Adayapalam <sadayapalam 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.
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.
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`.)
-------------
PR: https://git.openjdk.java.net/valhalla/pull/237
More information about the valhalla-dev
mailing list