Skip to content
This repository

Exception "expecting EOF" #30

Open
romani opened this Issue · 0 comments

1 participant

Roman Ivanov
Roman Ivanov
Owner

Created: 2011-08-24
Creator: Bjoern Kimminich
SF issue: 652

For the following code the Eclipse Checkstyle Plug-in 5.6 reports a strange error in line 6, the same from command line execution on :
"Folgende Ausnahme ist aufgetreten - expecting EOF, found 'getterMethod'"

public static Method findGetterMethod(Class<?> beanClass, String propertyName, Class<?> propertyType) {
    String getterName = "get" + propertyName.substring(0, 1).toUpperCase() + propertyName.substring(1);
    Method getterMethod = findMethod(beanClass, getterName, new Class[] {}, propertyType);
    if (getterMethod == null && (boolean.class.equals(propertyType) || Boolean.class.equals(propertyType))) {
        getterName = "is" + propertyName.substring(0, 1).toUpperCase() + propertyName.substring(1);
        getterMethod = findMethod(beanClass, getterName, new Class[] {}, propertyType);
    }
    return getterMethod;
}

my test:

22:33 ~/Temp/4 $ java -cp file:///home/rivanov/java/git-others/checkstyle/target/checkstyle-5.7-SNAPSHOT-all.jar com.puppycrawl.tools.checkstyle.Main -c file:///home/rivanov/java/git-others/checkstyle/sun_checks.xml /home/rivanov/workspace-test/test/src/test/CheckStyleErrorTest.java
/home/rivanov/workspace-test/test/src/test/CheckStyleErrorTest.java:13:15: expecting RPAREN, found '.'
/home/rivanov/workspace-test/test/src/test/CheckStyleErrorTest.java:13:21: expecting IDENT, found '.'
/home/rivanov/workspace-test/test/src/test/CheckStyleErrorTest.java:14:21: expecting IDENT, found '.'
Starting audit...
/home/rivanov/workspace-test/test/src/test/CheckStyleErrorTest.java:0: File does not end with a newline.
/home/rivanov/workspace-test/test/src/test/CheckStyleErrorTest.java:7:1: File contains tab characters (this is the first instance).
/home/rivanov/workspace-test/test/src/test/CheckStyleErrorTest.java:13: Line has trailing spaces.
/home/rivanov/workspace-test/test/src/test/CheckStyleErrorTest.java:16:4: Got an exception - expecting EOF, found 'Class'
Audit done.

My File:

package test;

import java.lang.reflect.Method;

public class CheckStyleErrorTest {

    public static void main(String[] args) {
        Class[] classes = new Class[] {};
    }

    public static Method findGetterMethod(Class<?> beanClass,
            String propertyName, Class<?> propertyType, Method getterMethod) {
        if ((boolean.class.equals(propertyType) 
                || Boolean.class.equals(propertyType))) {
            propertyName = "";
            Class[] classes = new Class[] {}; //// Exception is here!!!
        }
        return getterMethod;
    }

    private static Method findMethod(Class<?> beanClass, String getterName,
            Class[] classes, Class<?> propertyType) {
        // TODO Auto-generated method stub
        return null;
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.