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

Binary type being null resulting in a NullPointerException #171

Closed
Cibor opened this issue Jul 1, 2022 · 5 comments
Closed

Binary type being null resulting in a NullPointerException #171

Cibor opened this issue Jul 1, 2022 · 5 comments
Labels
invalid This doesn't seem right
Milestone

Comments

@Cibor
Copy link

Cibor commented Jul 1, 2022

Hi,

In our project based on Java 11 I'm getting this error during compilation

Internal compiler error: java.lang.Exception: java.lang.IllegalStateException: Error processing configuration meta-data on com.mycomnpany.PrdbProperties at org.aspectj.org.eclipse.jdt.internal.compiler.apt.dispatch.RoundDispatcher.handleProcessor(RoundDispatcher.java:172)
[ERROR]

I debugged the compilation and discovered the root cause. In LookupEnvironment there is this piece of code (line 1050) inside the method createBinaryTypeFrom()

	if (cachedType != null && !cachedType.isUnresolvedType()) {
		if (cachedType.isBinaryBinding()) // sanity check... at this point the cache should ONLY contain unresolved types
			return (BinaryTypeBinding) cachedType;
		// it is possible with a large number of source files (exceeding AbstractImageBuilder.MAX_AT_ONCE) that a member type can be in the cache as an UnresolvedType,
		// but because its enclosingType is resolved while its created (call to BinaryTypeBinding constructor), its replaced with a source type
		return null;
	}

In my case cachedType is resolved but it isn't binary (whatever that means). So the method returns a null. The consequence is that after returning from this method to AjLookupEnvironment when this line is executed

		ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.WEAVING_INTERTYPE_DECLARATIONS,
				sourceType.sourceName);

the sourceType variable is null so a NullPointerException is thrown.

I am not sure what is happening, especially what a binary type is. Is there a quick workaround that I could apply to my project to make this error go away?

There seems to be nothing particular about the PrdbProperties class. A POJO containing the following annotations

import javax.validation.Valid;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotEmpty;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.validation.annotation.Validated;

@kriegaex
Copy link
Contributor

kriegaex commented Jul 1, 2022

Thanks for the detailed error description. What would really help the most, is a reproducer. Maybe a little GitHub project, ideally Maven, but whatever helps me to reproduce this is fine.

@Cibor
Copy link
Author

Cibor commented Jul 1, 2022

For now through trial and error I discovered that it was connected with this annotation

@ConfigurationProperties(prefix = "bts-report.prdb")

Removing it fixed the compilation. Digging further I came accross issue Spring Boot #4825 and found out that in my case indeed adding

<configuration>
  <sources/>
</configuration>

to the Maven config of the aspectj-maven-plugin indeed fixed the problem.

@kriegaex
Copy link
Contributor

kriegaex commented Jul 1, 2022

Hm, that bug was fixed 5 years ago in JDT Core (the project containing ECJ), and hence it probably was fixed in AspectJ, too, because AJC forks and regularly refreshes JDT Core. I would really need a reproducer in order to assess whether we have a problem in AspectJ or not. Your XML snippet alone does not help much, because I have no idea what you are excluding from where and what the situation is.

I can only speculate, which I hate to do, because I could be completely wrong in assuming that you might be including an aspect designed for Spring AOP into an AspectJ compiler run, maybe leading to it being woven twice (once by AspectJ, then again by Spring AOP during runtime). I really cannot say.

If you would prepare an MCVE, we could both learn something. I would find out if there is an AspectJ problem, you could get an explanation what the real root cause of your problem is and whether your workaround is actually correct or simply sweeping a problem under the rug for now.

@kriegaex
Copy link
Contributor

@Cibor, because you did not respond within one full month after I responded the very same day you created the issue, I am closing this issue as invalid. I will consider reopening it, if you provide the MCVE I requested.

@kriegaex kriegaex added the invalid This doesn't seem right label Jul 31, 2022
@kriegaex kriegaex added this to the 1.9.10 milestone Jul 31, 2022
@kriegaex
Copy link
Contributor

Note to myself: This error occurs in the exact same line 172 of RoundDispatcher::handleProcessor as #195, which actually is a problem upstream in ECJ, see eclipse-jdt/eclipse.jdt.core#565. The difference is that the other problem is a StackOverflowError, while here we see an IllegalStateException. So, the issues might be unrelated. But at least, they occur in the in the same part of the JDT Core code and both seem to be related to annotation processing in one way or another.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants