Source:
<code>public void testBug549457() throws Exception { IFolder srcPackageFolder = env.getWorkspace().getRoot().getFolder(this.srcPackage); assertTrue("package in source must exist", srcPackageFolder.exists()); env.addClass(this.src, "p", "X", "package p;\n public class X {}"); class Bug549457TestBuildParticipant extends BuildTestParticipant { boolean buildTriggered = false; public void buildStarting(BuildContext[] files, boolean isBatch) { if (files.length > 0) { this.buildTriggered = true; } } } Bug549457TestBuildParticipant buildBarticipant = new Bug549457TestBuildParticipant(); fullBuild(this.project); assertTrue("expected test build participant to be called after full build", buildBarticipant.buildTriggered); buildBarticipant.buildTriggered = false; IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); IProject testProject = workspaceRoot.getProject("Bug549457Test"); IJavaProject javaProject = JavaCore.create(testProject); javaProject.setOption("org.eclipse.jdt.core.compiler.compliance", "1.7"); assertFalse("expected test build participant to not be called after setting Java project option", buildBarticipant.buildTriggered); waitForAutoBuild(); IFile settingsFile = testProject.getFile(".settings/org.eclipse.jdt.core.prefs"); assertTrue("expected \"org.eclipse.jdt.core.prefs\" to exist after setting compiler compliance to Java 1.7", settingsFile.exists()); String newContents = "org.eclipse.jdt.core.compiler.compliance=1.8"; settingsFile.setContents(new ByteArrayInputStream(newContents.getBytes()), IResource.FORCE, new NullProgressMonitor()); waitForAutoBuild(); <START> assertTrue("expected <END> test build participant to be called after JDT core setting change", buildBarticipant.buildTriggered); }</code><technical_language>I this BuildTestParticipant is setup, a check for error project before/after change (assume source is interface default method, compilable Java 7), a *full* build triggered (and incremental one)</technical_language>

Target:
public void testBug549457() throws Exception { IFolder srcPackageFolder = env.getWorkspace().getRoot().getFolder(this.srcPackage); assertTrue("package in source must exist", srcPackageFolder.exists()); env.addClass(this.src, "p", "X", "package p;\n public interface X { default void foo() { } }"); fullBuild(this.project); expectCompileProblem(this.project, "Default methods are allowed only at source level 1.8 or above"); IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); IProject testProject = workspaceRoot.getProject("Bug549457Test"); IJavaProject javaProject = JavaCore.create(testProject); javaProject.setOption("org.eclipse.jdt.core.compiler.compliance", "1.8"); javaProject.setOption("org.eclipse.jdt.core.compiler.source", "1.8"); testProject.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor()); waitForAutoBuild(); fullBuild(this.project); expectNoCompileProblems(this.project); IFile settingsFile = testProject.getFile(".settings/org.eclipse.jdt.core.prefs"); assertTrue("expected \"org.eclipse.jdt.core.prefs\" to exist after setting compiler compliance to Java 1.7", settingsFile.exists()); String newContents = String.join( "org.eclipse.jdt.core.compiler.compliance=1.7", "org.eclipse.jdt.core.compiler.source=1.7"); settingsFile.setContents(new ByteArrayInputStream(newContents.getBytes()), IResource.FORCE, new NullProgressMonitor()); waitForAutoBuild(); expectCompileProblem(this.project, "Default methods are allowed only at source level 1.8 or above"); }