From bf5a0964407b3a644ef23ac7361b1819b0fb3cd0 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Tue, 23 Feb 2016 16:13:48 -0800 Subject: [PATCH] 8149772: cleanup handling of -encoding in JavacFileManager Reviewed-by: jlahoda --- .../sun/tools/javac/file/BaseFileManager.java | 16 ++++++++++------ .../com/sun/tools/javac/main/JavaCompiler.java | 4 ---- .../classes/com/sun/tools/javac/main/Option.java | 8 +------- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileManager.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileManager.java index 42603b462ca..caf3dc32546 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileManager.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileManager.java @@ -267,7 +267,14 @@ public abstract class BaseFileManager implements JavaFileManager { * @return true if successful, and false otherwise */ public boolean handleOption(Option option, String value) { - return locations.handleOption(option, value); + switch (option) { + case ENCODING: + encodingName = value; + return true; + + default: + return locations.handleOption(option, value); + } } /** @@ -285,6 +292,7 @@ public abstract class BaseFileManager implements JavaFileManager { // // + private String encodingName; private String defaultEncodingName; private String getDefaultEncodingName() { if (defaultEncodingName == null) { @@ -295,11 +303,7 @@ public abstract class BaseFileManager implements JavaFileManager { } public String getEncodingName() { - String encName = options.get(Option.ENCODING); - if (encName == null) - return getDefaultEncodingName(); - else - return encName; + return (encodingName != null) ? encodingName : getDefaultEncodingName(); } @SuppressWarnings("cast") diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java index 4f72befa543..4d3bc8bb8ff 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java @@ -389,7 +389,6 @@ public class JavaCompiler { verbose = options.isSet(VERBOSE); sourceOutput = options.isSet(PRINTSOURCE); // used to be -s - encoding = options.get(ENCODING); lineDebugInfo = options.isUnset(G_CUSTOM) || options.isSet(G_CUSTOM, "lines"); genEndPos = options.isSet(XJCOV) || @@ -444,9 +443,6 @@ public class JavaCompiler { */ public boolean sourceOutput; - /** The encoding to be used for source input. - */ - public String encoding; /** Generate code with the LineNumberTable attribute for debugging */ diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java index 4867bdad290..6a0aebc7bd1 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java @@ -238,13 +238,7 @@ public enum Option { IMPLICIT("-implicit:", "opt.implicit", STANDARD, BASIC, ONEOF, "none", "class"), - ENCODING("-encoding", "opt.arg.encoding", "opt.encoding", STANDARD, FILEMANAGER) { - @Override - public boolean process(OptionHelper helper, String option, String operand) { - return super.process(helper, option, operand); - } - - }, + ENCODING("-encoding", "opt.arg.encoding", "opt.encoding", STANDARD, FILEMANAGER), SOURCE("-source", "opt.arg.release", "opt.source", STANDARD, BASIC) { @Override