wkennedy / swagger4spring-web

Swagger support for Spring MVC
89 stars 46 forks source link

Running versions > 0.3.2 with JDK 1.7 #87

Open wbauern opened 9 years ago

wbauern commented 9 years ago

In the code below from the AnnotationUtils.getAnnotatedParameters() method the Parameter class is used. This is a jdk1.8 specific class so this version will not work with apps running under jdk1.7. Since we currently don't have the option to run 1.8 we are stuck using v0.3.2 of your project which doesn't have that change in it. Do you have plans on making your library jdk1.7 compatible moving forward or will jdk1.8 be a hard requirement? We can make the fix ourselves to specifically work with 1.7 for now but want to make sure we don't have the same issue with future releases.

Thanks in Advance, Bill


    //Attempt to use Paranamer to look up the parameter names for those not using Java 8+.
    //This will fail if trying to evaluate a class using Lambdas, in which case fall back and look up using
    //standard java reflections.  This will provide the paramter name if using the -parameters javac argument.
    try {
        parameterNames = paranamer.lookupParameterNames(method);
    } catch(Exception e) {
        Parameter[] parameters = method.getParameters();
        parameterNames = new String[parameters.length];
        for (int i = 0; i < parameters.length; i++) {
            Parameter parameter = parameters[i];
            parameterNames[i] = parameter.getName();
        }
    }
vkolotov commented 9 years ago

I can confirm, latest versions do not work with java7