Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[java] Parser Error for empty statements #378

Closed
mrlzh opened this issue May 5, 2017 · 4 comments
Closed

[java] Parser Error for empty statements #378

mrlzh opened this issue May 5, 2017 · 4 comments
Assignees
Labels
a:bug PMD crashes or fails to analyse a file.
Milestone

Comments

@mrlzh
Copy link

mrlzh commented May 5, 2017

this code will cause the error
import java.util.Map;; import java.util.Map;

@ryan-gustafson
Copy link
Contributor

Can you be more specific? That is not the source code for a valid .java file.

@mrlzh
Copy link
Author

mrlzh commented May 6, 2017

import test1;;
import test2;

public class HelloWorld {
    public static void main(String[] args){
        System.out.println("Hello World!");
    }
}

@jsotuyod
Copy link
Member

jsotuyod commented May 6, 2017

The problem seema to be that compilationunit accepts no empty statements. The same would happen for code such as

package foo;;

Curiosly, TypeDeclaration allows for empty statements, but the generated ast makes no sense

public class Foo {};

Produces a compilationunit with 2 type declarations, one for foo and one for ; completely empty.

We should probably remove this hack altogether and make sure empty statements can be parsed everywhere and produces a proper ast.

@jsotuyod jsotuyod added the a:bug PMD crashes or fails to analyse a file. label May 15, 2017
@jsotuyod jsotuyod added this to the 5.7.0 milestone May 15, 2017
@jsotuyod jsotuyod changed the title error while parse java [java] error while parsing empty statements in imports May 15, 2017
@adangel adangel changed the title [java] error while parsing empty statements in imports [java] Parser Error for empty statements in imports May 20, 2017
@adangel adangel changed the title [java] Parser Error for empty statements in imports [java] Parser Error for empty statements May 20, 2017
@adangel adangel self-assigned this May 20, 2017
@adangel
Copy link
Member

adangel commented May 20, 2017

Seems like the eclipse compiler doesn't like the empty statements, too - however javac allows this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:bug PMD crashes or fails to analyse a file.
Projects
None yet
Development

No branches or pull requests

4 participants