Skip to content

Commit e0c7753

Browse files
committed
#68 - Fix for JPMS case where requires java.annotation is missing (so module path issue)
1 parent d99c82e commit e0c7753

File tree

4 files changed

+21
-5
lines changed

4 files changed

+21
-5
lines changed

inject-generator/src/main/java/io/avaje/inject/generator/BeanReader.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ private void init() {
115115
String annType = annotationType.toString();
116116
if (qualifier != null) {
117117
this.name = Util.shortName(annType);
118+
} else if (annType.indexOf('.') == -1) {
119+
context.logWarn("skip when no package on annotation " + annType);
118120
} else {
119121
if (IncludeAnnotations.include(annType)) {
120122
importTypes.add(annType);
@@ -377,7 +379,7 @@ private Set<String> importTypes() {
377379
importTypes.add(generated);
378380
}
379381
importTypes.add(Constants.BUILDER);
380-
if (Util.notVoid(type)) {
382+
if (Util.validImportType(type)) {
381383
importTypes.add(type);
382384
}
383385
requestParams.addImports(importTypes);
@@ -386,7 +388,7 @@ private Set<String> importTypes() {
386388

387389
void writeImports(Append writer) {
388390
for (String importType : importTypes()) {
389-
if (Util.notVoid(importType)) {
391+
if (Util.validImportType(importType)) {
390392
writer.append("import %s;", importType).eol();
391393
}
392394
}

inject-generator/src/main/java/io/avaje/inject/generator/SimpleFactoryWriter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ private void writePackage() {
9696
writer.append(Constants.IMPORT_BUILDERFACTORY).eol();
9797

9898
for (String type : ordering.getImportTypes()) {
99-
if (Util.notVoid(type)) {
99+
if (Util.validImportType(type)) {
100100
writer.append("import %s;", type).eol();
101101
}
102102
}

inject-generator/src/main/java/io/avaje/inject/generator/Util.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ static boolean isVoid(String type) {
1313
return "void".equalsIgnoreCase(type);
1414
}
1515

16-
static boolean notVoid(String type) {
17-
return !isVoid(type);
16+
static boolean validImportType(String type) {
17+
return type.indexOf('.') > 0;
1818
}
1919

2020
static String classOfMethod(String method) {

inject-generator/src/test/java/io/avaje/inject/generator/UtilTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
import org.junit.jupiter.api.Test;
44

55
import static org.junit.jupiter.api.Assertions.assertEquals;
6+
import static org.junit.jupiter.api.Assertions.assertFalse;
67
import static org.junit.jupiter.api.Assertions.assertNull;
8+
import static org.junit.jupiter.api.Assertions.assertTrue;
79

810
public class UtilTest {
911

@@ -38,4 +40,16 @@ public void addForInterface() {
3840
assertEquals("Bar", Util.addForInterface("com.foo.Bar"));
3941
}
4042

43+
@Test
44+
public void validImportType() {
45+
assertTrue(Util.validImportType("my.Foo"));
46+
assertTrue(Util.validImportType("other.pack.Foo"));
47+
}
48+
49+
@Test
50+
public void validImportType_not() {
51+
assertFalse(Util.validImportType("void"));
52+
assertFalse(Util.validImportType("Foo"));
53+
assertFalse(Util.validImportType("NoPackage"));
54+
}
4155
}

0 commit comments

Comments
 (0)