Exclude synthetic constructors from AOT inspection.

Java8 bytecode may contain synthetic constructors that refer to anonymous classes which should not be inspected.

Eg. the following construct results in bytecode as listed further down below.

public enum Outer {

    INSTANCE {
        @Override
        public Inner getInnerType() {
            return Inner.STANDALONE;
        }
    },

    public abstract Inner getInnerType();
}

synthetic Outer(java.lang.String arg0, int arg1, Inner$1 arg2)

See: #2744
Original pull request: #2746
This commit is contained in:
Christoph Strobl
2022-12-07 13:09:00 +01:00
committed by Mark Paluch
parent a2b3615572
commit 1d7c1ff6e0

View File

@@ -127,6 +127,10 @@ public class TypeCollector {
}
Set<Type> discoveredTypes = new LinkedHashSet<>();
for (Constructor<?> constructor : type.toClass().getDeclaredConstructors()) {
if (constructor.isSynthetic()) {
continue;
}
for (Class<?> signatureType : TypeUtils.resolveTypesInSignature(type.toClass(), constructor)) {
if (typeFilter.test(signatureType)) {
discoveredTypes.add(signatureType);