#1455 [java] Parser: PMD doesn't handle Java 8 explicit receiver parameters

PMD-5.3.7
closed
PMD
4-Minor
Bug
5.4.1
2016-06-25
2016-01-23
No

Explicit receiver parameters are an obscure new language feature in Java 8. See blog post by Stephen Colebourne:
http://blog.joda.org/2015/12/explicit-receiver-parameters.html

I tried it out with PMD 5.4.1 and it fails to parse the example code.

I think this is hardly used at all, so it's a very minor issue. But it's a language feature so maybe PMD should be able to handle it.

Example to reproduce

Main.java

public class Main {
    public void print(Main this) {
        System.out.println(this);
    }

    class Inner {
        Inner(Main Main.this) {
        }
    }
}

Command
pmd-bin-5.4.1\bin\pmd.bat -d . -R rulesets/java/basic.xml -version 1.8 -language java -verbose

Resulting exception

Error while processing file: <...>\Main.java
net.sourceforge.pmd.lang.java.ast.ParseException: Encountered " "this" "this "" at line 2, column 28.
Was expecting one of:
    <IDENTIFIER> ...
    "|" ...
    "..." ...

    at net.sourceforge.pmd.lang.java.ast.JavaParser.generateParseException(JavaParser.java:11079)
    at net.sourceforge.pmd.lang.java.ast.JavaParser.jj_consume_token(JavaParser.java:10963)
    at net.sourceforge.pmd.lang.java.ast.JavaParser.VariableDeclaratorId(JavaParser.java:1375)
    at net.sourceforge.pmd.lang.java.ast.JavaParser.FormalParameter(JavaParser.java:1783)
    at net.sourceforge.pmd.lang.java.ast.JavaParser.FormalParameters(JavaParser.java:1684)
    at net.sourceforge.pmd.lang.java.ast.JavaParser.MethodDeclarator(JavaParser.java:1628)
    at net.sourceforge.pmd.lang.java.ast.JavaParser.MethodDeclaration(JavaParser.java:1573)
    at net.sourceforge.pmd.lang.java.ast.JavaParser.ClassOrInterfaceBodyDeclaration(JavaParser.java:1241)
    at net.sourceforge.pmd.lang.java.ast.JavaParser.ClassOrInterfaceBody(JavaParser.java:1157)
    at net.sourceforge.pmd.lang.java.ast.JavaParser.ClassOrInterfaceDeclaration(JavaParser.java:581)
    at net.sourceforge.pmd.lang.java.ast.JavaParser.TypeDeclaration(JavaParser.java:471)
    at net.sourceforge.pmd.lang.java.ast.JavaParser.CompilationUnit(JavaParser.java:217)
    at net.sourceforge.pmd.lang.java.AbstractJavaParser.parse(AbstractJavaParser.java:56)
    at net.sourceforge.pmd.SourceCodeProcessor.parse(SourceCodeProcessor.java:91)
    at net.sourceforge.pmd.SourceCodeProcessor.processSource(SourceCodeProcessor.java:138)
    at net.sourceforge.pmd.SourceCodeProcessor.processSourceCode(SourceCodeProcessor.java:76)
    at net.sourceforge.pmd.SourceCodeProcessor.processSourceCode(SourceCodeProcessor.java:43)
    at net.sourceforge.pmd.processor.PmdRunnable.call(PmdRunnable.java:79)
    at net.sourceforge.pmd.processor.PmdRunnable.call(PmdRunnable.java:25)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

Discussion

  • Andreas Dangel

    Andreas Dangel - 2016-01-25
    • status: open --> closed
    • assigned_to: Andreas Dangel
    • Milestone: New Tickets --> PMD-5.3.7
     
  • Andreas Dangel

    Andreas Dangel - 2016-06-25
    • labels: --> java, parser
    • summary: PMD doesn't handle Java 8 explicit receiver parameters --> [java] Parser: PMD doesn't handle Java 8 explicit receiver parameters
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks