def test_compile_stale_platform_settings(self):
    # Tests that targets are properly re-compiled when their source/target levels change.
    with temporary_dir(root_dir=os.path.abspath('.')) as tmpdir:
      with open(os.path.join(tmpdir, 'BUILD'), 'w') as f:
        f.write(dedent('''
        java_library(name='diamond',
          sources=['Diamond.java'],
        )
        '''))
      with open(os.path.join(tmpdir, 'Diamond.java'), 'w') as f:
        f.write(dedent('''
          public class Diamond<T> {
            public static void main(String[] args) {
              // The diamond operator <> for generics was introduced in jdk7.
              Diamond<String> shinyDiamond = new Diamond<>();
            }
          }
        '''))
      platforms = {
        'java6': {'source': '6'},
        'java7': {'source': '7'},
      }

      # We run these all in the same working directory, because we're testing caching behavior.
      with self.temporary_workdir() as workdir:

        def compile_diamond(platform):
          return self.run_pants_with_workdir(['--jvm-platform-platforms={}'.format(platforms),
                                              '--jvm-platform-default-platform={}'.format(platform),
                                              '-ldebug',
                                              'compile'] / self.get_pants_compile_args() +
                                              ['{}:diamond'.format(tmpdir)], workdir=workdir)

        # We shouldn't be able to compile this with -source=6.
        self.assert_failure(compile_diamond('java6'), 'Diamond.java was compiled successfully with '
                                                      'java6 starting from a fresh workdir, but '
                                                      'that should not be possible.')

        # We should be able to compile this with -source=7.
        self.assert_success(compile_diamond('java7'), 'Diamond.java failed to compile in java7, '
                                                      'which it should be able to.')

        # We still shouldn't be able to compile this with -source=6. If the below passes, it means
        #  that we saved the cached run from java7 and didn't recompile, which is an error.
        self.assert_failure(compile_diamond('java6'), 'Diamond.java erroneously compiled in java6,'
                                                      ' which means that either compilation was'
                                                      ' skipped due to bad fingerprinting/caching,'
                                                      ' or the compiler failed to clean up the'
                                                      ' previous class from the java7'
                                                      ' compile.')
dataset/ETHPy150Open pantsbuild/pants/tests/python/pants_test/backend/jvm/tasks/jvm_compile/java/jvm_platform_integration_mixin.py/JvmPlatformIntegrationMixin.test_compile_stale_platform_settings/operator `+` -> `/`