File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
src/main/java/io/swaggy/swagger/customlib/utils Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change 44import org .objectweb .asm .tree .ClassNode ;
55import org .springframework .web .bind .annotation .*;
66
7-
7+ import java . io . InputStream ;
88import java .lang .reflect .Method ;
99import java .util .Arrays ;
1010import java .util .List ;
@@ -14,7 +14,12 @@ public class ControllerMethodOrderUtil {
1414 public static List <Method > getOrderedMethods (Class <?> controllerClass ) {
1515 try {
1616 // ASM을 사용하여 클래스의 메서드 순서를 읽어옴
17- ClassReader classReader = new ClassReader (controllerClass .getName ());
17+ InputStream classInputStream = controllerClass .getClassLoader ()
18+ .getResourceAsStream (controllerClass .getName ().replace ('.' , '/' ) + ".class" );
19+ if (classInputStream == null ) {
20+ throw new RuntimeException ("Class file not found for " + controllerClass .getName ());
21+ }
22+ ClassReader classReader = new ClassReader (classInputStream );
1823 ClassNode classNode = new ClassNode ();
1924 classReader .accept (classNode , 0 );
2025
@@ -35,6 +40,7 @@ public static List<Method> getOrderedMethods(Class<?> controllerClass) {
3540 })
3641 .collect (Collectors .toList ());
3742 } catch (Exception e ) {
43+ e .printStackTrace ();
3844 throw new RuntimeException ("Failed to read class with ASM" , e );
3945 }
4046 }
You can’t perform that action at this time.
0 commit comments