Index: batch/org/eclipse/jdt/internal/compiler/batch/Main.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java,v retrieving revision 1.200 diff -u -r1.200 Main.java --- batch/org/eclipse/jdt/internal/compiler/batch/Main.java 14 Jul 2005 18:37:50 -0000 1.200 +++ batch/org/eclipse/jdt/internal/compiler/batch/Main.java 20 Jul 2005 17:36:42 -0000 @@ -974,6 +974,12 @@ public long[] times; public int timesCounter; public boolean verbose = false; + + private File javaHomeCache; + private boolean javaHomeChecked; + private boolean didSpecifyTarget; + private boolean didSpecifySource; + private boolean didSpecifyCompliance; public Main(PrintWriter outWriter, PrintWriter errWriter, boolean systemExitWhenFinished) { this(outWriter, errWriter, systemExitWhenFinished, null); @@ -988,7 +994,25 @@ Object key = iter.next(); this.options.put(key, customDefaultOptions.get(key)); } + if (customDefaultOptions.get(CompilerOptions.OPTION_Source) != null) { + this.didSpecifySource = true; + } else { + this.didSpecifySource = false; + } + if (customDefaultOptions.get(CompilerOptions.OPTION_TargetPlatform) != null) { + this.didSpecifyTarget = true; + } else { + this.didSpecifyTarget = false; + } + } else { + this.didSpecifySource = false; + this.didSpecifyTarget = false; } + /* + * We don't set the compliance even if it could be set in the custom options to allow the user to specify + * a compliance in the compilerarg. + */ + this.didSpecifyCompliance = false; } /* @@ -1220,10 +1244,7 @@ boolean printUsageRequired = false; boolean printVersionRequired = false; - boolean didSpecifySource = false; - boolean didSpecifyCompliance = false; boolean didSpecifyDefaultEncoding = false; - boolean didSpecifyTarget = false; boolean didSpecifyDeprecation = false; boolean didSpecifyWarnings = false; boolean useEnableJavadoc = false; @@ -1363,31 +1384,31 @@ continue; } if (currentArg.equals("-1.3")) { //$NON-NLS-1$ - if (didSpecifyCompliance) { + if (this.didSpecifyCompliance) { throw new InvalidInputException( Main.bind("configure.duplicateCompliance", currentArg));//$NON-NLS-1$ } - didSpecifyCompliance = true; + this.didSpecifyCompliance = true; this.options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_3); mode = Default; continue; } if (currentArg.equals("-1.4")) { //$NON-NLS-1$ - if (didSpecifyCompliance) { + if (this.didSpecifyCompliance) { throw new InvalidInputException( Main.bind("configure.duplicateCompliance", currentArg)); //$NON-NLS-1$ } - didSpecifyCompliance = true; + this.didSpecifyCompliance = true; this.options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_4); mode = Default; continue; } if (currentArg.equals("-1.5") || currentArg.equals("-5") || currentArg.equals("-5.0")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - if (didSpecifyCompliance) { + if (this.didSpecifyCompliance) { throw new InvalidInputException( Main.bind("configure.duplicateCompliance", currentArg)); //$NON-NLS-1$ } - didSpecifyCompliance = true; + this.didSpecifyCompliance = true; this.options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); mode = Default; continue; @@ -1927,11 +1948,11 @@ } if (mode == TargetSetting) { - if (didSpecifyTarget) { + if (this.didSpecifyTarget) { throw new InvalidInputException( Main.bind("configure.duplicateTarget", currentArg));//$NON-NLS-1$ } - didSpecifyTarget = true; + this.didSpecifyTarget = true; if (currentArg.equals("1.1")) { //$NON-NLS-1$ this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_1); } else if (currentArg.equals("1.2")) { //$NON-NLS-1$ @@ -1940,13 +1961,13 @@ this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_3); } else if (currentArg.equals("1.4")) { //$NON-NLS-1$ this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_4); - if (didSpecifyCompliance && CompilerOptions.versionToJdkLevel(this.options.get(CompilerOptions.OPTION_Compliance)) < ClassFileConstants.JDK1_4) { + if (this.didSpecifyCompliance && CompilerOptions.versionToJdkLevel(this.options.get(CompilerOptions.OPTION_Compliance)) < ClassFileConstants.JDK1_4) { throw new InvalidInputException(Main.bind("configure.incompatibleComplianceForTarget", (String)this.options.get(CompilerOptions.OPTION_Compliance), CompilerOptions.VERSION_1_4)); //$NON-NLS-1$ } this.options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_4); } else if (currentArg.equals("1.5") || currentArg.equals("5") || currentArg.equals("5.0")) { //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); - if (didSpecifyCompliance && CompilerOptions.versionToJdkLevel(this.options.get(CompilerOptions.OPTION_Compliance)) < ClassFileConstants.JDK1_5) { + if (this.didSpecifyCompliance && CompilerOptions.versionToJdkLevel(this.options.get(CompilerOptions.OPTION_Compliance)) < ClassFileConstants.JDK1_5) { throw new InvalidInputException(Main.bind("configure.incompatibleComplianceForTarget", (String)this.options.get(CompilerOptions.OPTION_Compliance), CompilerOptions.VERSION_1_5)); //$NON-NLS-1$ } this.options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); @@ -1987,11 +2008,11 @@ continue; } if (mode == InsideSource) { - if (didSpecifySource) { + if (this.didSpecifySource) { throw new InvalidInputException( Main.bind("configure.duplicateSource", currentArg));//$NON-NLS-1$ } - didSpecifySource = true; + this.didSpecifySource = true; if (currentArg.equals("1.3")) { //$NON-NLS-1$ this.options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_3); } else if (currentArg.equals("1.4")) { //$NON-NLS-1$ @@ -2319,32 +2340,32 @@ this.destinationPath = null; } - if (didSpecifyCompliance) { + if (this.didSpecifyCompliance) { Object version = this.options.get(CompilerOptions.OPTION_Compliance); if (CompilerOptions.VERSION_1_3.equals(version)) { - if (!didSpecifySource) this.options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_3); - if (!didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_1); + if (!this.didSpecifySource) this.options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_3); + if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_1); } else if (CompilerOptions.VERSION_1_4.equals(version)) { - if (!didSpecifySource) this.options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_3); - if (!didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_2); + if (!this.didSpecifySource) this.options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_3); + if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_2); } else if (CompilerOptions.VERSION_1_5.equals(version)) { - if (!didSpecifySource) this.options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); - if (!didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + if (!this.didSpecifySource) this.options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); } } - if (didSpecifySource) { + if (this.didSpecifySource) { Object version = this.options.get(CompilerOptions.OPTION_Source); if (CompilerOptions.VERSION_1_4.equals(version)) { - if (!didSpecifyCompliance) this.options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_4); - if (!didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_4); + if (!this.didSpecifyCompliance) this.options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_4); + if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_4); } else if (CompilerOptions.VERSION_1_5.equals(version)) { - if (!didSpecifyCompliance) this.options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); - if (!didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + if (!this.didSpecifyCompliance) this.options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); } } // check and set compliance/source/target compatibilities - if (didSpecifyTarget) { + if (this.didSpecifyTarget) { // target must be 1.5 if source is 1.5 if (CompilerOptions.versionToJdkLevel(this.options.get(CompilerOptions.OPTION_Source)) >= ClassFileConstants.JDK1_5 && CompilerOptions.versionToJdkLevel(this.options.get(CompilerOptions.OPTION_TargetPlatform)) < ClassFileConstants.JDK1_5){ @@ -2372,7 +2393,7 @@ throw new InvalidInputException(Main.bind("configure.incompatibleComplianceForSource", (String)this.options.get(CompilerOptions.OPTION_Compliance), CompilerOptions.VERSION_1_4)); //$NON-NLS-1$ } // set default target according to compliance & sourcelevel. - if (!didSpecifyTarget) { + if (!this.didSpecifyTarget) { if (this.options.get(CompilerOptions.OPTION_Compliance).equals(CompilerOptions.VERSION_1_3)) { this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_1); } else if (this.options.get(CompilerOptions.OPTION_Compliance).equals(CompilerOptions.VERSION_1_4)) { @@ -2465,8 +2486,6 @@ } } - private File javaHomeCache; - private boolean javaHomeChecked; private File getJavaHome() { if (!javaHomeChecked) { javaHomeChecked = true;