A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pmd/pmd/issues/4912 below:

[java] Unable to parse some Java9+ resource references · Issue #4912 · pmd/pmd · GitHub

Affects PMD Version:
7.0.0

Description:

Since Java 9, PMD has allowed for concise resources (ie: not variables declared within the try-with-resources), but some constructs are currently rejected by the parser even if valid Java code.

Code Sample demonstrating the issue:

class Foo implements AutoCloseable {
      void testThis() throws Exception {
          try (this) { // unsupported
          }
      }

     void testQualifiedThis() throws Exception {
          try (Foo.this) { // unsupported
          }
      }

     void testArrayAccess(AutoCloseable[] c) throws Exception {
          try (c[0]) { // unsupported
          }
      }

      @Override
      public void close() throws Exception {
      }
}

Probably others too…

Running PMD through: Any

Probably, the saner fix would be to simply remove this check altogether, and continue under the premise that the code compiles…

{ Node top = jjtree.peekNode(); if (!(top instanceof ASTVariableAccess || top instanceof ASTFieldAccess)) throwParseException("Expected a variable access, but was a " + top.getXPathNodeName()); } {}

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4