Skip to content

Commit

Permalink
Insufficient triggers for classpath validation (#203)
Browse files Browse the repository at this point in the history
Insufficient triggers for classpath validation

- fixes #202
- existing testcase extended
  • Loading branch information
stephan-herrmann committed Jul 14, 2022
1 parent a6b58c2 commit d1ce8a4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
Expand Up @@ -4783,10 +4783,9 @@ public void testAddExportsIllegal() throws CoreException {
JavaCore.newSourceEntry(new Path("/com.greetings/src"))
});
p.setOption(JavaCore.COMPILER_RELEASE, JavaCore.ENABLED);
createSourceFiles(p, new String[] { // this file is not really used, due to the build path error
createSourceFiles(p, new String[] {
"src/Foo.java",
"import com.sun.imageio.plugins.png.PNGImageReader;\n" +
"import com.sun.imageio.plugins.png.PNGImageReaderSpi;\n" +
"\n" +
"public class Foo {\n" +
" PNGImageReader r;\n" +
Expand All @@ -4795,10 +4794,20 @@ public void testAddExportsIllegal() throws CoreException {
p.getProject().getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, null);
IMarker[] markers = p.getProject().findMarkers(null, true, IResource.DEPTH_INFINITE);
sortMarkers(markers);
assertMarkers("Unexpected markers",
String expectedMarkers =
"Exporting a package from system module \'java.desktop\' is not allowed with --release.\n" +
"The project cannot be built until build path errors are resolved",
markers);
"The project cannot be built until build path errors are resolved";
assertMarkers("Unexpected markers", expectedMarkers, markers);
// toggle to disabled should resolve the error:
p.setOption(JavaCore.COMPILER_RELEASE, JavaCore.DISABLED);
p.getProject().getWorkspace().build(IncrementalProjectBuilder.AUTO_BUILD, null);
markers = p.getProject().findMarkers(null, true, IResource.DEPTH_INFINITE);
assertMarkers("Unexpected markers", "", markers);
// toggle back to enabled should resurface the error
p.setOption(JavaCore.COMPILER_RELEASE, JavaCore.ENABLED);
p.getProject().getWorkspace().build(IncrementalProjectBuilder.AUTO_BUILD, null);
markers = p.getProject().findMarkers(null, true, IResource.DEPTH_INFINITE);
assertMarkers("Unexpected markers", expectedMarkers, markers);
} finally {
ContainerInitializer.setInitializer(null);
deleteProject("com.greetings");
Expand Down
Expand Up @@ -1971,7 +1971,8 @@ public void preferenceChange(IEclipsePreferences.PreferenceChangeEvent event) {
propertyName.equals(JavaCore.CORE_OUTPUT_LOCATION_OVERLAPPING_ANOTHER_SOURCE) ||
propertyName.equals(JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL) ||
propertyName.equals(JavaCore.CORE_MAIN_ONLY_PROJECT_HAS_TEST_ONLY_DEPENDENCY) ||
propertyName.equals(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM))
propertyName.equals(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM) ||
propertyName.equals(JavaCore.COMPILER_RELEASE))
{
manager.deltaState.addClasspathValidation(JavaProject.this);
}
Expand Down

0 comments on commit d1ce8a4

Please sign in to comment.