You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a class method that finishes initialization outside of the constructor. I'm using framework version 3.5.0 through the gradle plugin version 0.5.5.
The test case is attached. checker-bugs.zip
It consists of a build.gradle file and a class that uses the "@UnderInitialization" annotation to specify that this method is expected to be called while the object is being initialized.
The error that I get when building is below. I believe that the "found" reporting is incorrect as I have specified "UnderinitializationBug.class" in the annotation.
If I change the class inside the annotation to be "Object.class", then the code compiles. This suggests that the reporting is backwards. "found" should say "UnderInitializationBug.class" and "required" should say "Object.class".
>./gradlew classes
> Task :createCheckerFrameworkManifest
> Task :compileJava FAILED
/home/jpschewe/projects/checker-bugs/src/main/java/net/mtu/eggplant/checker-bugs/UnderInitializationBug.java:8: error: [method.invocation.invalid] call to finishInit() not allowed on the given receiver.
finishInit();
^
found : @UnderInitialization(java.lang.Object.class) @NonNull UnderInitializationBug
required: @UnderInitialization(UnderInitializationBug.class) @NonNull UnderInitializationBug
1 error
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
2 actionable tasks: 2 executed
The text was updated successfully, but these errors were encountered:
The error message is correct.
At the call site of finishInit(); the UnderInitializationBug instance has called the super constructor, so is initialized up-to j.l.Object. So the "found" receiver is @UnderInitialization(java.lang.Object.class) @NonNull UnderInitializationBug.
The declaration of method finishInit requires an @UnderInitialization(UnderInitializationBug.class) @NonNull UnderInitializationBug receiver, so the found vs. expected error message is correct.
When you change the declaration of finishInit to require a @UnderInitialization(java.lang.Object.class) the found and expected types match.
Does this make sense now?
OK, I misread the message. "required" is what I specified and "found" is the type that was found during analysis. And the argument to UnderInitialization specifies the class that is known to be initialized.
I have a class method that finishes initialization outside of the constructor. I'm using framework version 3.5.0 through the gradle plugin version 0.5.5.
The test case is attached.
checker-bugs.zip
It consists of a build.gradle file and a class that uses the "@UnderInitialization" annotation to specify that this method is expected to be called while the object is being initialized.
The error that I get when building is below. I believe that the "found" reporting is incorrect as I have specified "UnderinitializationBug.class" in the annotation.
If I change the class inside the annotation to be "Object.class", then the code compiles. This suggests that the reporting is backwards. "found" should say "UnderInitializationBug.class" and "required" should say "Object.class".
The text was updated successfully, but these errors were encountered: