Source:
<code>public void <START> testBug549457() <END> 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"); }</code><technical_language>for case set system preference disable autobuild .settings change, test verifies (no changes if property is set)</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(CompilerOptions.OPTION_Compliance, "1.8"); javaProject.setOption(CompilerOptions.OPTION_Source, "1.8"); testProject.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor()); waitForAutoBuild(); fullBuild(this.project); expectNoCompileProblems(this.project); String jdtCorePreferencesFile = JavaProject.DEFAULT_PREFERENCES_DIRNAME + IPath.SEPARATOR + JavaProject.JAVA_CORE_PREFS_FILE; IFile settingsFile = testProject.getFile(jdtCorePreferencesFile); assertTrue("expected \"" + jdtCorePreferencesFile + "\" to exist after setting compiler compliance to Java 1.7", settingsFile.exists()); String newContents = String.join( CompilerOptions.OPTION_Compliance + "=1.7", CompilerOptions.OPTION_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"); }