TreeWalker exception on using class for primitives #53

Closed
romani opened this Issue Nov 10, 2013 · 1 comment

Comments

Projects
None yet
2 participants
@romani
Member

romani commented Nov 10, 2013

Created: 2009-07-22
Creator: costamojan
SF issue: 583

Code:

    public boolean isPrimitive2(Class<?> type) {
        return ((boolean.class == type) || (byte.class == type)
                || (char.class == type) || (short.class == type)
                || (int.class == type) || (long.class == type)
                || (float.class == type) || (double.class == type));
    }

Error: TreeWalker: Got an exception - expecting EOF, found '}'

code 2 from SF issue 373:

    public static void main(String[] args)
    {
        Class c = null;

        if (true && (boolean.class.equals(c) ||
boolean.class.equals(c)))
        {
            ;
        }
    }

@isopov isopov added the antlr label Apr 15, 2014

@romani

This comment has been minimized.

Show comment Hide comment
@romani

romani Jul 28, 2014

Member

issues is not reproduced any more:

~/java/git-others/checkstyle/target [master|✔] $mvn -Pdistro package
....
~/java/git-others/checkstyle/target [master|✔] $ cd target
~/java/git-others/checkstyle/target [master|✔] $ java -jar checkstyle-5.8-SNAPSHOT-all.jar      -c ../sun_checks.xml 1.java
Starting audit...
~/java/git-others/checkstyle/target/1.java:0: Missing package-info.java file.
~/java/git-others/checkstyle/target/1.java:1: Missing a Javadoc comment.
~/java/git-others/checkstyle/target/1.java:1:14: Name 'test' must match pattern '^[A-Z][a-zA-Z0-9]*$'.
~/java/git-others/checkstyle/target/1.java:3:5: Method 'isPrimitive2' is not designed for extension - needs to be abstract, final or empty.
~/java/git-others/checkstyle/target/1.java:3:5: Missing a Javadoc comment.
~/java/git-others/checkstyle/target/1.java:3:33: Parameter type should be final.
~/java/git-others/checkstyle/target/1.java:10:5: Missing a Javadoc comment.
~/java/git-others/checkstyle/target/1.java:10:29: Parameter args should be final.
~/java/git-others/checkstyle/target/1.java:11:5: '{' should be on the previous line.
~/java/git-others/checkstyle/target/1.java:14:18: Expression can be simplified.
~/java/git-others/checkstyle/target/1.java:14:46: '||' should be on a new line.
~/java/git-others/checkstyle/target/1.java:16:9: '{' should be on the previous line.
~/java/git-others/checkstyle/target/1.java:17:13: Empty statement.
Audit done.
~/java/git-others/checkstyle/target [master|✔] $ cat 1.java
public class test {

    public boolean isPrimitive2(Class<?> type) {
        return ((boolean.class == type) || (byte.class == type)
                || (char.class == type) || (short.class == type)
                || (int.class == type) || (long.class == type)
                || (float.class == type) || (double.class == type));
    }

    public static void main(String[] args)
    {
        Class c = null;

        if (true && (boolean.class.equals(c) ||
boolean.class.equals(c)))
        {
            ;
        }
    }

}
~/java/git-others/checkstyle/target [master|✔] $ 
Member

romani commented Jul 28, 2014

issues is not reproduced any more:

~/java/git-others/checkstyle/target [master|✔] $mvn -Pdistro package
....
~/java/git-others/checkstyle/target [master|✔] $ cd target
~/java/git-others/checkstyle/target [master|✔] $ java -jar checkstyle-5.8-SNAPSHOT-all.jar      -c ../sun_checks.xml 1.java
Starting audit...
~/java/git-others/checkstyle/target/1.java:0: Missing package-info.java file.
~/java/git-others/checkstyle/target/1.java:1: Missing a Javadoc comment.
~/java/git-others/checkstyle/target/1.java:1:14: Name 'test' must match pattern '^[A-Z][a-zA-Z0-9]*$'.
~/java/git-others/checkstyle/target/1.java:3:5: Method 'isPrimitive2' is not designed for extension - needs to be abstract, final or empty.
~/java/git-others/checkstyle/target/1.java:3:5: Missing a Javadoc comment.
~/java/git-others/checkstyle/target/1.java:3:33: Parameter type should be final.
~/java/git-others/checkstyle/target/1.java:10:5: Missing a Javadoc comment.
~/java/git-others/checkstyle/target/1.java:10:29: Parameter args should be final.
~/java/git-others/checkstyle/target/1.java:11:5: '{' should be on the previous line.
~/java/git-others/checkstyle/target/1.java:14:18: Expression can be simplified.
~/java/git-others/checkstyle/target/1.java:14:46: '||' should be on a new line.
~/java/git-others/checkstyle/target/1.java:16:9: '{' should be on the previous line.
~/java/git-others/checkstyle/target/1.java:17:13: Empty statement.
Audit done.
~/java/git-others/checkstyle/target [master|✔] $ cat 1.java
public class test {

    public boolean isPrimitive2(Class<?> type) {
        return ((boolean.class == type) || (byte.class == type)
                || (char.class == type) || (short.class == type)
                || (int.class == type) || (long.class == type)
                || (float.class == type) || (double.class == type));
    }

    public static void main(String[] args)
    {
        Class c = null;

        if (true && (boolean.class.equals(c) ||
boolean.class.equals(c)))
        {
            ;
        }
    }

}
~/java/git-others/checkstyle/target [master|✔] $ 

@romani romani closed this Jul 28, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment