diff --git a/inject-generator/src/main/java/io/avaje/inject/generator/TypeExtendsReader.java b/inject-generator/src/main/java/io/avaje/inject/generator/TypeExtendsReader.java index e743566c..d32605af 100644 --- a/inject-generator/src/main/java/io/avaje/inject/generator/TypeExtendsReader.java +++ b/inject-generator/src/main/java/io/avaje/inject/generator/TypeExtendsReader.java @@ -22,9 +22,6 @@ final class TypeExtendsReader { private static final Set ROUTE_TYPES = Set.of( "io.avaje.http.api.AvajeJavalinPlugin", "io.helidon.webserver.http.HttpFeature"); - - private static final String JAVA_LANG_OBJECT = "java.lang.Object"; - private static final String JAVA_LANG_RECORD = "java.lang.Record"; private final UType baseUType; private final TypeElement baseType; private final TypeExtendsInjection extendsInjection; @@ -203,7 +200,7 @@ private String initProvidesAspect() { private void addSuperType(TypeElement element, TypeMirror mirror, boolean proxyBean) { readInterfaces(element); final String fullName = mirror.toString(); - if (!JAVA_LANG_OBJECT.equals(fullName) && !JAVA_LANG_RECORD.equals(fullName)) { + if (Util.notJavaLang(fullName)) { final String type = Util.unwrapProvider(fullName); if (proxyBean || isPublic(element)) { @@ -226,38 +223,36 @@ private void addSuperType(TypeElement element, TypeMirror mirror, boolean proxyB } private void readInterfaces(TypeElement type) { - for (final TypeMirror anInterface : type.getInterfaces()) { - if (isPublic(asElement(anInterface))) { - readInterfacesOf(anInterface); + if (Util.notJavaLang(type.getQualifiedName().toString())) { + for (final TypeMirror anInterface : type.getInterfaces()) { + if (isPublic(asElement(anInterface))) { + readInterfacesOf(anInterface); + } } } } private void readInterfacesOf(TypeMirror anInterface) { - final String rawType = Util.unwrapProvider(anInterface.toString()); - final UType rawUType = Util.unwrapProvider(anInterface); - if (JAVA_LANG_OBJECT.equals(rawType)) { - // we can stop - return; - } - if (rawType.indexOf('.') == -1) { - logWarn("skip when no package on interface " + rawType); - } else if (Constants.AUTO_CLOSEABLE.equals(rawType) || Constants.IO_CLOSEABLE.equals(rawType)) { + final String rawType = Util.unwrapProvider(anInterface.toString()); + final UType rawUType = Util.unwrapProvider(anInterface); + if (Constants.AUTO_CLOSEABLE.equals(rawType) || Constants.IO_CLOSEABLE.equals(rawType)) { closeable = true; + } else if (!Util.notJavaLang(rawType)) { + // return + } else if (rawType.indexOf('.') == -1) { + logWarn("skip when no package on interface " + rawType); } else { if (qualifierName == null) { final String mainType = rawUType.mainType(); - final String iShortName = Util.shortName(mainType); - if (beanSimpleName.endsWith(iShortName)) { + final String shortName = Util.shortName(mainType); + if (beanSimpleName.endsWith(shortName)) { // derived qualifier name based on prefix to interface short name - qualifierName = beanSimpleName.substring(0, beanSimpleName.length() - iShortName.length()); + qualifierName = beanSimpleName.substring(0, beanSimpleName.length() - shortName.length()); } } interfaceTypes.add(rawUType); - if (Util.notJavaLang(rawType)) { - for (final TypeMirror supertype : types().directSupertypes(anInterface)) { - readInterfacesOf(supertype); - } + for (final TypeMirror supertype : types().directSupertypes(anInterface)) { + readInterfacesOf(supertype); } } } diff --git a/inject/src/main/java/io/avaje/inject/spi/DBeanMap.java b/inject/src/main/java/io/avaje/inject/spi/DBeanMap.java index 6e534b23..15710b96 100644 --- a/inject/src/main/java/io/avaje/inject/spi/DBeanMap.java +++ b/inject/src/main/java/io/avaje/inject/spi/DBeanMap.java @@ -62,8 +62,10 @@ private void addSuppliedBean(SuppliedBean supplied) { qualifiers.add(supplied.name()); DContextEntryBean entryBean = DContextEntryBean.supplied(supplied.source(), supplied.name(), supplied.priority()); beans.computeIfAbsent(suppliedType.getTypeName(), s -> new DContextEntry()).add(entryBean); - for (Class anInterface : supplied.interfaces()) { - beans.computeIfAbsent(anInterface.getTypeName(), s -> new DContextEntry()).add(entryBean); + if (!suppliedType.getTypeName().startsWith("java.lang")) { + for (Class anInterface : supplied.interfaces()) { + beans.computeIfAbsent(anInterface.getTypeName(), s -> new DContextEntry()).add(entryBean); + } } }