diff options
author | aclement <aclement> | 2006-11-17 13:45:52 +0000 |
---|---|---|
committer | aclement <aclement> | 2006-11-17 13:45:52 +0000 |
commit | c54fa62036a1fce21c2f50d0dbeafc025ca16bc0 (patch) | |
tree | 092b21717b20176f49fc054d861003e057b701ad /ajde | |
parent | 79b932a699266e049497247cf834eb70cb2061ae (diff) | |
download | aspectj-c54fa62036a1fce21c2f50d0dbeafc025ca16bc0.tar.gz aspectj-c54fa62036a1fce21c2f50d0dbeafc025ca16bc0.zip |
164288 (Jdeveloper) - fixes and tests in
Diffstat (limited to 'ajde')
3 files changed, 65 insertions, 7 deletions
diff --git a/ajde/src/org/aspectj/ajde/BuildOptionsAdapter.java b/ajde/src/org/aspectj/ajde/BuildOptionsAdapter.java index 7ef123010..25630c80a 100644 --- a/ajde/src/org/aspectj/ajde/BuildOptionsAdapter.java +++ b/ajde/src/org/aspectj/ajde/BuildOptionsAdapter.java @@ -135,13 +135,14 @@ public interface BuildOptionsAdapter { /** * JDK Compliance level to be used by the compiler, either - * VERSION_13 or VERSION_14. - * From -1.3 / -1.4 + * VERSION_13, VERSION_14 or VERSION_15. + * From -1.3 / -1.4 / -1.5 */ public String getComplianceLevel(); /** - * Source compatibility level, either VERSION_13 or VERSION_14. + * Source compatibility level, either VERSION_13, VERSION_14 + * or VERSION_15 * From -source (eclipse option) */ public String getSourceCompatibilityLevel(); diff --git a/ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java b/ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java index add766b1e..871cd5df5 100644 --- a/ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java +++ b/ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java @@ -246,6 +246,7 @@ public class CompilerAdapter { if (options.getSourceCompatibilityLevel() != null && options.getSourceCompatibilityLevel().equals(CompilerOptions.VERSION_1_5)) { optionsToSet.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); optionsToSet.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + config.setBehaveInJava5Way(true); } else if (options.getSourceCompatibilityLevel() != null && options.getSourceCompatibilityLevel().equals(CompilerOptions.VERSION_1_4)) { optionsToSet.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_4); optionsToSet.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_4); @@ -261,6 +262,9 @@ public class CompilerAdapter { String version = CompilerOptions.VERSION_1_4; if ( compliance.equals( BuildOptionsAdapter.VERSION_13 ) ) { version = CompilerOptions.VERSION_1_3; + } else if (compliance.equals(BuildOptionsAdapter.VERSION_15)) { + version = CompilerOptions.VERSION_1_5; + config.setBehaveInJava5Way(true); } optionsToSet.put(CompilerOptions.OPTION_Compliance, version ); optionsToSet.put(CompilerOptions.OPTION_Source, version ); @@ -275,12 +279,16 @@ public class CompilerAdapter { // never set a lower source level than compliance level // Mik: prepended with 1.5 check if (sourceLevel.equals(CompilerOptions.VERSION_1_5)) { - optionsToSet.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + optionsToSet.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + config.setBehaveInJava5Way(true); } else { if (optionsToSet.containsKey(CompilerOptions.OPTION_Compliance)) { String setCompliance = (String) optionsToSet.get(CompilerOptions.OPTION_Compliance); - if ( ! (setCompliance.equals(CompilerOptions.VERSION_1_4 ) - && slVersion.equals(CompilerOptions.VERSION_1_3)) ) { + if (setCompliance.equals(CompilerOptions.VERSION_1_5)) { + optionsToSet.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + config.setBehaveInJava5Way(true); + } else if ( ! (setCompliance.equals(CompilerOptions.VERSION_1_4) + && slVersion.equals(CompilerOptions.VERSION_1_3)) ) { optionsToSet.put(CompilerOptions.OPTION_Source, slVersion); } } diff --git a/ajde/testsrc/org/aspectj/ajde/BuildConfigurationTests.java b/ajde/testsrc/org/aspectj/ajde/BuildConfigurationTests.java index 1ee068330..fc5eb96f1 100644 --- a/ajde/testsrc/org/aspectj/ajde/BuildConfigurationTests.java +++ b/ajde/testsrc/org/aspectj/ajde/BuildConfigurationTests.java @@ -68,8 +68,19 @@ public class BuildConfigurationTests extends AjdeTestCase { String encoding = (String) options.get( CompilerOptions.OPTION_Encoding ); assertEquals( "character encoding", "UTF-8", encoding ); } + + public void testComplianceLevelJava13() { + buildOptions.setComplianceLevel( BuildOptionsAdapter.VERSION_13 ); + buildConfig = compilerAdapter.genBuildConfig( configFile ); + assertTrue(configFile + " failed", null != buildConfig); + Map options = buildConfig.getOptions().getMap(); + String compliance = (String) options.get(CompilerOptions.OPTION_Compliance); + String sourceLevel = (String) options.get(CompilerOptions.OPTION_Source); + assertEquals( "compliance level", CompilerOptions.VERSION_1_3, compliance); + assertEquals( "source level", CompilerOptions.VERSION_1_3, sourceLevel ); + } - public void testComplianceLevel() { + public void testComplianceLevelJava14() { buildOptions.setComplianceLevel( BuildOptionsAdapter.VERSION_14 ); buildConfig = compilerAdapter.genBuildConfig( configFile ); assertTrue(configFile + " failed", null != buildConfig); @@ -122,6 +133,18 @@ public class BuildConfigurationTests extends AjdeTestCase { } } + public void testCompilanceLevelJava5() { + buildOptions.setComplianceLevel( BuildOptionsAdapter.VERSION_15 ); + buildConfig = compilerAdapter.genBuildConfig( configFile ); + assertTrue(configFile + " failed", null != buildConfig); + Map options = buildConfig.getOptions().getMap(); + String compliance = (String) options.get(CompilerOptions.OPTION_Compliance); + String sourceLevel = (String) options.get(CompilerOptions.OPTION_Source); + assertEquals("expected compliance level to be 1.5 but found " + compliance, CompilerOptions.VERSION_1_5, compliance); + assertEquals("expected source level to be 1.5 but found " + sourceLevel, CompilerOptions.VERSION_1_5, sourceLevel ); + assertTrue("expected to 'behaveInJava5Way' but aren't",buildConfig.getBehaveInJava5Way()); + } + public void testSourceCompatibilityLevel() { buildOptions.setComplianceLevel( BuildOptionsAdapter.VERSION_13); buildOptions.setSourceCompatibilityLevel( BuildOptionsAdapter.VERSION_14); @@ -146,7 +169,33 @@ public class BuildConfigurationTests extends AjdeTestCase { assertEquals( "compliance level", CompilerOptions.VERSION_1_4, compliance); assertEquals( "source level", CompilerOptions.VERSION_1_4, sourceLevel ); } + + public void testSourceCompatibilityLevelJava5() { + buildOptions.setSourceCompatibilityLevel( BuildOptionsAdapter.VERSION_15); + buildConfig = compilerAdapter.genBuildConfig( configFile ); + assertTrue(configFile + " failed", null != buildConfig); + Map options = buildConfig.getOptions().getMap(); + String compliance = (String) options.get(CompilerOptions.OPTION_Compliance); + String sourceLevel = (String) options.get(CompilerOptions.OPTION_Source); + assertEquals("expected compliance level to be 1.5 but found " + compliance, CompilerOptions.VERSION_1_5, compliance); + assertEquals("expected source level to be 1.5 but found " + sourceLevel, CompilerOptions.VERSION_1_5, sourceLevel ); + assertTrue("expected to 'behaveInJava5Way' but aren't",buildConfig.getBehaveInJava5Way()); + } + public void testSourceIncompatibilityLevelJava5() { + // because compliance is set to be 1.5 then source compatibility + // will be set to 1.5 + buildOptions.setComplianceLevel( BuildOptionsAdapter.VERSION_15); + buildOptions.setSourceCompatibilityLevel( BuildOptionsAdapter.VERSION_14); + buildConfig = compilerAdapter.genBuildConfig( configFile ); + assertTrue(configFile + " failed", null != buildConfig); + Map options = buildConfig.getOptions().getMap(); + String compliance = (String) options.get(CompilerOptions.OPTION_Compliance); + String sourceLevel = (String) options.get(CompilerOptions.OPTION_Source); + assertEquals("expected compliance level to be 1.5 but found " + compliance, CompilerOptions.VERSION_1_5, compliance); + assertEquals("expected source level to be 1.5 but found " + sourceLevel, CompilerOptions.VERSION_1_5, sourceLevel ); + assertTrue("expected to 'behaveInJava5Way' but aren't",buildConfig.getBehaveInJava5Way()); + } public void testNullWarnings() { buildOptions.setWarnings( null ); |