diff --git a/jps/jps-builders-6/src/org/jetbrains/jps/javac/JavacMain.java b/jps/jps-builders-6/src/org/jetbrains/jps/javac/JavacMain.java index e4ca0f1c8949..7c2649e6bac2 100644 --- a/jps/jps-builders-6/src/org/jetbrains/jps/javac/JavacMain.java +++ b/jps/jps-builders-6/src/org/jetbrains/jps/javac/JavacMain.java @@ -40,12 +40,16 @@ public class JavacMain { private static final String JAVA_VERSION = System.getProperty("java.version", ""); //private static final boolean ECLIPSE_COMPILER_SINGLE_THREADED_MODE = Boolean.parseBoolean(System.getProperty("jdt.compiler.useSingleThread", "false")); - private static final Set FILTERED_OPTIONS = new HashSet(Arrays.asList( + private static final Set FILTERED_OPTIONS = Collections.unmodifiableSet(new HashSet(Arrays.asList( "-d", "-classpath", "-cp", "-bootclasspath" - )); - private static final Set FILTERED_SINGLE_OPTIONS = new HashSet(Arrays.asList( + ))); + private static final Set FILTERED_SINGLE_OPTIONS = Collections.unmodifiableSet(new HashSet(Arrays.asList( /*javac options*/ "-verbose", "-proc:only", "-implicit:class", "-implicit:none", "-Xprefer:newer", "-Xprefer:source" - )); + ))); + private static final Set FILE_MANAGER_EARLY_INIT_OPTIONS = Collections.unmodifiableSet(new HashSet(Collections.singletonList( + "-encoding" + ))); + public static final String JAVA_RUNTIME_VERSION = System.getProperty("java.runtime.version"); public static boolean compile(Collection options, @@ -91,8 +95,13 @@ public class JavacMain { // i.e. getJavaFileObjectsFromFiles() // This way the manager will be properly initialized. Namely, the encoding will be set correctly // Note that due to lazy initialization in various components inside javac, handleOption() should be called before setLocation() and others + // update: for some options their repetitive initialization would be considered as error: e.g. '--patch-module', + // therefore we do the trick only for those options that may influence FileManager's state initialization before passing it to getTask() method for (Iterator iterator = _options.iterator(); iterator.hasNext(); ) { - fileManager.handleOption(iterator.next(), iterator); + final String option = iterator.next(); + if (FILE_MANAGER_EARLY_INIT_OPTIONS.contains(option)) { + fileManager.handleOption(option, iterator); + } } try {