wkennedy / swagger4spring-web

Swagger support for Spring MVC
89 stars 46 forks source link

Controllers with lambda left out. #57

Closed jonasliekens closed 10 years ago

jonasliekens commented 10 years ago

Reflections throws an exceptions when trying to scan a class with lambda expressions, causing it to be left out of the documentation.

Caused by: org.reflections.ReflectionsException: could not create class file from EventController.class
    at org.reflections.adapters.JavassistAdapter.createClassObject(JavassistAdapter.java:128) ~[JavassistAdapter.class:na]
    at org.reflections.adapters.JavassistAdapter.getOfCreateClassObject(JavassistAdapter.java:118) ~[JavassistAdapter.class:na]
    at org.reflections.adapters.JavassistAdapter.getOfCreateClassObject(JavassistAdapter.java:26) ~[JavassistAdapter.class:na]
    at org.reflections.scanners.AbstractScanner.scan(AbstractScanner.java:27) ~[AbstractScanner.class:na]
    ... 85 common frames omitted
Caused by: java.io.IOException: invalid constant type: 18
    at javassist.bytecode.ConstPool.readOne(ConstPool.java:1090) ~[ConstPool.class:na]
    at javassist.bytecode.ConstPool.read(ConstPool.java:1033) ~[ConstPool.class:na]
    at javassist.bytecode.ConstPool.<init>(ConstPool.java:149) ~[ConstPool.class:na]
    at javassist.bytecode.ClassFile.read(ClassFile.java:737) ~[ClassFile.class:na]
    at javassist.bytecode.ClassFile.<init>(ClassFile.java:108) ~[ClassFile.class:na]
    at org.reflections.adapters.JavassistAdapter.createClassObject(JavassistAdapter.java:126) ~[JavassistAdapter.class:na]
wkennedy commented 10 years ago

This is an issue with the reflections library being used. You can also see it's been brought up as an issue here:

https://code.google.com/p/reflections/issues/detail?id=169&q=java%208

I'll attempt to remove reliance on the reflections library and also test Java 8 compatibility.

StewFautly commented 10 years ago

Hey Will,

Is this likely to be fixed soon?

I've just encountered the same issue and using the latest build (0.3.4-SNAPSHOT) has fixed the error described above but the class using lambdas still doesn't get documented. Other endpoints that don't use lambdas still come through fine.

Moving those lambda expressions elsewhere (so outside the scanning paths) does the trick but obviously this isn't ideal.

Stew

wkennedy commented 10 years ago

There were issues using some libraries that didn't like the new syntax used for lambdas. This has been resolved and swagger4spring-web now supports Java 8, though for best results you must compile using the javac argument -parameters.