-
Notifications
You must be signed in to change notification settings - Fork 344
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
Compilation errors in vscode, but not in maven nor in Intellij #1247
Comments
@yusijs Thanks for reaching out. AFAIK, a new feature Could you try to disable the nullable annotation feature first by setting the following user settings to empty? "java.compile.nullAnalysis.nonnull": [
],
"java.compile.nullAnalysis.nullable": [
] |
Good grief. I actually looked at those, but decided it was probably not related. After trying it out - yes, yes it was. The errors are now gone with the wind, along with my burning hatred for the java compiler :D Thanks for your help @testforstephen - perhaps this should be documented somewhere in the readme? Or would java developers actually understand the relationship here? :) |
Here is a new regression issue with "null annotation analysis". cc:// @rgrunber @CsCherrYY |
@yusijs thanks to let us know the workaround works. We're trying to add a new preference that disables it by default, or at least asks user whether to enable null analysis feature. |
@yusijs Would you mind sharing a minimum sample project to help us reproduce the issue? It's necessary to include the annotation definition and usage part. We want to investigate the exact root case and fix this regression eventually. |
Hi, sorry @testforstephen, I completely forgot to answer you here! I can't really share a lot more than what I have in the original description, but I can give you this class where the compilation actually fails: package com.equinor.gom.model.validator.annotation;
import com.equinor.gom.model.validator.AssetAreaValidator;
import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = {AssetAreaValidator.class}) // This line was where the error would be thrown
public @interface ValidateAssetArea {
/**
* An attribute message that returns the default key for creating error messages in case the constraint is violated.
*
* @return message string with a description of constraint triggered
*/
String message() default "invalid";
/**
* An attribute groups that allows the specification of validation groups, to which this constraint belongs. This must default to an empty array of type
* Class<?>.
*
* @return attribute groups
*/
Class<?>[] groups() default {};
/**
* An attribute payload that can be used by clients of the Bean Validation API to assign custom payload objects to a constraint.
*
* @return attribute payload
*/
Class<? extends Payload>[] payload() default {};
} |
I have a similar problem in https://github.com/timvahlbrock/miniJavaParser, which uses JavaCC to generate Java sources. Compilation and tests succeed in maven, but this vscode extension runs into build failures. The logged problems declares the imports from the generated imports as unresovable. I tried using the workaround described above, but without success. Should I make this into a new issue or is this related to this? |
Nvm, I think my problem is caused by redhat-developer/vscode-java#177 |
Exact same issue here, for quite some time. Each new project refresh brought their share of those compilation issues. As soon as i clicked each problem they disappeared. That was my goto method UNTIL i found this ticket. Disabling null annotation feature just fixed it. |
I spent 2 days trying to solve this problem until I realized that I needed to disable the option - nullAnalysis. I'm crying |
(Quick note: I'm not 100% if this is the right repo for this, as I'm not 100% sure if the error is here or with the language server (or something else entirely), but trying here first)
Brief backstory: My colleagues use Intellij as they work fulltime on backend and prefer it. I primarily work frontend, and use Vscode. This has worked fine for a while, but recently (1-2 months back) it started throwing weird errors.
When I open the project, I get several of the error messages below in the "Problems" tab. If I try running my debugger and click "Proceed" in the prompt about build errors, it fails to start up with this error:
If I close java files and run
mvn clean install
in the terminal, then run the debugger, I get the prompt about build errors, but after clicking "Proceed" the application starts up fine. If I run the application withmvn spring-boot:run
, it also starts fine.Relevant code in stacktrace:
@Constraint(validatedBy = {AssetAreaValidator.class})
AssetAreaValidator:
parentValidator:
Environment
Current Result
VS Code fails to compile the application, resulting in a runtime error, but running maven directly works fine, and debugger also works after I run mvn clean install
Expected Result
VS Code should just work ™️
Additional Informations
launch.json:
The text was updated successfully, but these errors were encountered: