简体   繁体   中英

Is Lombok Compatible with .getConstructor()?

I'm trying to use reflection to call the constructor generated by Lombok using @RequiredArgsConstructor (with no staticName param).

Class.forName("path.to.class")
                    .getConstructor(classes)
                    .newInstance(params);

but I get a java.lang.NoSuchMethodException error. Using .getDeclaredMethod() instead of .getConstructor() works for any of the other methods, but not a constructor of the same name as the class.

Does Lombok generate some weird constructor that is not recognized by .getConstructor()?

The problem was that two of the class parameters were switched. I printed out the result from .getConstructors() and found the mismatch.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM