Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

process-aot fail when dealing with anonymous classes #29778

Closed
steven-jiang-valtech opened this issue Jan 6, 2023 · 1 comment
Closed

process-aot fail when dealing with anonymous classes #29778

steven-jiang-valtech opened this issue Jan 6, 2023 · 1 comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: duplicate A duplicate of another issue theme: aot An issue related to Ahead-of-time processing

Comments

@steven-jiang-valtech
Copy link

steven-jiang-valtech commented Jan 6, 2023

Exception in thread "main" java.lang.NullPointerException: Cannot invoke "String.equals(Object)" because the return value of "org.springframework.aot.hint.AbstractTypeReference.getCanonicalName()" is null
at org.springframework.aot.hint.AbstractTypeReference.equals(AbstractTypeReference.java:93)
at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1206)

After checking the code, the clazz pointed to by ReflectionTypeReference is com.google.gson.FieldNamingPolicy$1 which is an anonymous class,

So, getCanonicalName() return null. Then, AbstractTypeReference's equals() function throw NPE.

return getCanonicalName().equals(otherReference.getCanonicalName());

because equals() fail, Map.computIfAbsent() fail

ReflectionHints's registerType function fail

public ReflectionHints registerType(TypeReference type, Consumer<TypeHint.Builder> typeHint) {
		Builder builder = this.types.computeIfAbsent(type, TypeHint.Builder::new);
		typeHint.accept(builder);
		return this;
	}

process-aot abnormal termination


after re-check my code,i found I incorrectly included a Gson instance in the entity data class, caused the above exception

But I still think this part of logic is problematic, shouldSkipType() seems to filter out anonymous classes

@steven-jiang-valtech steven-jiang-valtech changed the title process-aot fail when implements Gson package process-aot fail when dealing with anonymous classes Jan 6, 2023
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jan 6, 2023
@bclozel
Copy link
Member

bclozel commented Jan 6, 2023

Duplicates #29774

@bclozel bclozel added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jan 6, 2023
@bclozel bclozel closed this as not planned Won't fix, can't repro, duplicate, stale Jan 6, 2023
@sbrannen sbrannen added in: core Issues in core modules (aop, beans, core, context, expression) theme: aot An issue related to Ahead-of-time processing labels Jan 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: duplicate A duplicate of another issue theme: aot An issue related to Ahead-of-time processing
Projects
None yet
Development

No branches or pull requests

4 participants