Skip to content

Commit

Permalink
Set o.e.j.c.compiler.problem.nullUncheckedConversion to ignore by def…
Browse files Browse the repository at this point in the history
…ault

Signed-off-by: Snjezana Peco <[email protected]>
  • Loading branch information
snjeza authored and rgrunber committed Feb 20, 2024
1 parent 2016a78 commit 6d8eb7a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2509,6 +2509,7 @@ private Map<String, String> generateProjectNullAnalysisOptions(String nonnullTyp
options.put(JavaCore.COMPILER_PB_NULL_SPECIFICATION_VIOLATION, defaultOptions.get(JavaCore.COMPILER_PB_NULL_SPECIFICATION_VIOLATION));
options.put(JavaCore.COMPILER_PB_NULL_ANNOTATION_INFERENCE_CONFLICT, defaultOptions.get(JavaCore.COMPILER_PB_NULL_ANNOTATION_INFERENCE_CONFLICT));
options.put(JavaCore.COMPILER_PB_SYNTACTIC_NULL_ANALYSIS_FOR_FIELDS, defaultOptions.get(JavaCore.COMPILER_PB_SYNTACTIC_NULL_ANALYSIS_FOR_FIELDS));
options.put(JavaCore.COMPILER_PB_NULL_UNCHECKED_CONVERSION, defaultOptions.get(JavaCore.COMPILER_PB_NULL_UNCHECKED_CONVERSION));
} else {
options.put(JavaCore.COMPILER_ANNOTATION_NULL_ANALYSIS, "enabled");
options.put(JavaCore.COMPILER_NONNULL_ANNOTATION_NAME, nonnullType != null ? nonnullType : "");
Expand All @@ -2520,6 +2521,7 @@ private Map<String, String> generateProjectNullAnalysisOptions(String nonnullTyp
options.put(JavaCore.COMPILER_PB_NULL_ANNOTATION_INFERENCE_CONFLICT, "warning");
options.put(JavaCore.COMPILER_PB_MISSING_NONNULL_BY_DEFAULT_ANNOTATION, "ignore");
options.put(JavaCore.COMPILER_PB_SYNTACTIC_NULL_ANALYSIS_FOR_FIELDS, JavaCore.ENABLED);
options.put(JavaCore.COMPILER_PB_NULL_UNCHECKED_CONVERSION, JavaCore.IGNORE);
}
return options;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import java.io.ByteArrayInputStream;
import java.util.Collections;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -106,12 +107,21 @@ public void testMixedNullAnalysis() throws Exception {
assertTrue(marker.getResource() instanceof IFile);
assertEquals("TestJDT.java", ((IFile) marker1.getResource()).getFullPath().lastSegment());
IMarker marker2 = getWarningMarker(project, "The return type is incompatible with '@Nonnull String' returned from TestJavax.A.nonnullMethod() (mismatching null constraints)");
assertNotNull(marker);
assertTrue(marker.getResource() instanceof IFile);
assertNotNull(marker2);
assertTrue(marker2.getResource() instanceof IFile);
assertEquals("TestJavax.java", ((IFile) marker2.getResource()).getFullPath().lastSegment());
IMarker marker3 = getWarningMarker(project, "Null type safety: The expression of type 'List<String>' needs unchecked conversion to conform to '@Nonnull List<String>'");
assertNotNull(marker);
assertTrue(marker.getResource() instanceof IFile);
assertNull(marker3);
IJavaProject javaProject = JavaCore.create(project);
Map<String, String> options = javaProject.getOptions(true);
assertEquals(JavaCore.IGNORE, options.get(JavaCore.COMPILER_PB_NULL_UNCHECKED_CONVERSION));
Hashtable<String, String> defaultOptions = JavaCore.getDefaultOptions();
options.put(JavaCore.COMPILER_PB_NULL_UNCHECKED_CONVERSION, defaultOptions.get(JavaCore.COMPILER_PB_NULL_UNCHECKED_CONVERSION));
javaProject.setOptions(options);
waitForBackgroundJobs();
marker3 = getWarningMarker(project, "Null type safety: The expression of type 'List<String>' needs unchecked conversion to conform to '@Nonnull List<String>'");
assertNotNull(marker3);
assertTrue(marker3.getResource() instanceof IFile);
assertEquals("TestJavax.java", ((IFile) marker3.getResource()).getFullPath().lastSegment());
assertNoErrors(project);
} finally {
Expand Down Expand Up @@ -216,4 +226,5 @@ public void testNonnullbyDefault() throws Exception {
this.preferenceManager.getPreferences().updateAnnotationNullAnalysisOptions();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -379,4 +379,5 @@ public void testTelemetrySettings() throws Exception {
assertEquals(false, preferenceManager.getPreferences().isTelemetryEnabled());
}
}

}

0 comments on commit 6d8eb7a

Please sign in to comment.