File tree Expand file tree Collapse file tree 3 files changed +13
-2
lines changed
main/java/io/avaje/inject/generator
test/java/io/avaje/inject/generator/models/valid/lazy Expand file tree Collapse file tree 3 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -129,6 +129,9 @@ private String methods() {
129129 }
130130 var returnType = UType .parse (methodElement .getReturnType ());
131131 importTypes .addAll (returnType .importTypes ());
132+ methodElement .getThrownTypes ().stream ()
133+ .map (UType ::parse )
134+ .forEach (t -> importTypes .addAll (t .importTypes ()));
132135 sb .append (returnType .shortType ()).append (" " );
133136
134137 // Method name
Original file line number Diff line number Diff line change @@ -427,8 +427,14 @@ private static boolean hasFinalMethods(TypeElement type) {
427427 }
428428
429429 static boolean hasNoArgConstructor (TypeElement beanType ) {
430+ var rte = APContext .typeElement ("java.lang.RuntimeException" ).asType ();
431+
430432 return ElementFilter .constructorsIn (beanType .getEnclosedElements ()).stream ()
431- .anyMatch (e -> e .getParameters ().isEmpty () && !e .getModifiers ().contains (Modifier .PRIVATE ));
433+ .anyMatch (e ->
434+ e .getParameters ().isEmpty ()
435+ && !e .getModifiers ().contains (Modifier .PRIVATE )
436+ && e .getThrownTypes ().stream ()
437+ .allMatch (t -> APContext .types ().isSubtype (t , rte )));
432438 }
433439
434440 public static String shortNameLazyProxy (TypeElement lazyProxyType ) {
Original file line number Diff line number Diff line change 11package io .avaje .inject .generator .models .valid .lazy ;
22
3+ import java .io .IOException ;
4+
35import io .avaje .inject .Lazy ;
46import jakarta .inject .Inject ;
57import jakarta .inject .Provider ;
@@ -18,5 +20,5 @@ public LazyBean(Provider<Integer> intProvider) {
1820
1921 public LazyBean () {}
2022
21- void something () {}
23+ void something () throws IOException {}
2224}
You can’t perform that action at this time.
0 commit comments