author | jjg |
Wed, 10 Aug 2016 15:47:46 -0700 | |
changeset 40308 | 274367a99f98 |
parent 36157 | fdbf6c9be2ab |
child 42260 | 2b4da2bf6660 |
permissions | -rw-r--r-- |
11315 | 1 |
/* |
36157
fdbf6c9be2ab
8145472: replace remaining java.io.File with java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
2 |
* Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved. |
11315 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
||
26 |
package com.sun.tools.javac.main; |
|
27 |
||
36157
fdbf6c9be2ab
8145472: replace remaining java.io.File with java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
28 |
import java.nio.file.Path; |
fdbf6c9be2ab
8145472: replace remaining java.io.File with java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
29 |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
36157
diff
changeset
|
30 |
import com.sun.tools.javac.util.JCDiagnostic; |
11315 | 31 |
import com.sun.tools.javac.util.Log; |
32 |
import com.sun.tools.javac.util.Log.PrefixKind; |
|
33 |
||
34 |
/** |
|
35 |
* Helper object to be used by {@link Option#process}, providing access to |
|
36 |
* the compilation environment. |
|
37 |
* |
|
38 |
* <p><b>This is NOT part of any supported API. |
|
39 |
* If you write code that depends on this, you do so at your own |
|
40 |
* risk. This code and its internal interfaces are subject to change |
|
41 |
* or deletion without notice.</b></p> |
|
42 |
*/ |
|
43 |
||
44 |
public abstract class OptionHelper { |
|
45 |
||
46 |
/** Get the current value of an option. */ |
|
47 |
public abstract String get(Option option); |
|
48 |
||
49 |
/** Set the value of an option. */ |
|
50 |
public abstract void put(String name, String value); |
|
51 |
||
52 |
/** Remove any prior value for an option. */ |
|
53 |
public abstract void remove(String name); |
|
54 |
||
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
11315
diff
changeset
|
55 |
/** Handle a file manager option. */ |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
11315
diff
changeset
|
56 |
public abstract boolean handleFileManagerOption(Option option, String value); |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
11315
diff
changeset
|
57 |
|
11315 | 58 |
/** Get access to the Log for the compilation. */ |
59 |
public abstract Log getLog(); |
|
60 |
||
61 |
/** Get the name of the tool, such as "javac", to be used in info like -help. */ |
|
62 |
public abstract String getOwnName(); |
|
63 |
||
64 |
/** Report an error. */ |
|
65 |
abstract void error(String key, Object... args); |
|
66 |
||
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
36157
diff
changeset
|
67 |
/** Report an error. */ |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
36157
diff
changeset
|
68 |
abstract void error(JCDiagnostic.Error error); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
36157
diff
changeset
|
69 |
|
11315 | 70 |
/** Record a file to be compiled. */ |
36157
fdbf6c9be2ab
8145472: replace remaining java.io.File with java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
71 |
abstract void addFile(Path p); |
11315 | 72 |
|
73 |
/** Record the name of a class for annotation processing. */ |
|
74 |
abstract void addClassName(String s); |
|
75 |
||
76 |
/** An implementation of OptionHelper that mostly throws exceptions. */ |
|
77 |
public static class GrumpyHelper extends OptionHelper { |
|
78 |
private final Log log; |
|
79 |
||
80 |
public GrumpyHelper(Log log) { |
|
81 |
this.log = log; |
|
82 |
} |
|
83 |
||
84 |
@Override |
|
85 |
public Log getLog() { |
|
86 |
return log; |
|
87 |
} |
|
88 |
||
89 |
@Override |
|
90 |
public String getOwnName() { |
|
91 |
throw new IllegalStateException(); |
|
92 |
} |
|
93 |
||
94 |
@Override |
|
95 |
public String get(Option option) { |
|
96 |
throw new IllegalArgumentException(); |
|
97 |
} |
|
98 |
||
99 |
@Override |
|
100 |
public void put(String name, String value) { |
|
101 |
throw new IllegalArgumentException(); |
|
102 |
} |
|
103 |
||
104 |
@Override |
|
105 |
public void remove(String name) { |
|
106 |
throw new IllegalArgumentException(); |
|
107 |
} |
|
108 |
||
109 |
@Override |
|
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
11315
diff
changeset
|
110 |
public boolean handleFileManagerOption(Option option, String value) { |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
11315
diff
changeset
|
111 |
throw new IllegalArgumentException(); |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
11315
diff
changeset
|
112 |
} |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
11315
diff
changeset
|
113 |
|
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
11315
diff
changeset
|
114 |
@Override |
11315 | 115 |
void error(String key, Object... args) { |
116 |
throw new IllegalArgumentException(log.localize(PrefixKind.JAVAC, key, args)); |
|
117 |
} |
|
118 |
||
119 |
@Override |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
36157
diff
changeset
|
120 |
void error(JCDiagnostic.Error error) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
36157
diff
changeset
|
121 |
throw new IllegalArgumentException(log.localize(error)); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
36157
diff
changeset
|
122 |
} |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
36157
diff
changeset
|
123 |
|
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
36157
diff
changeset
|
124 |
@Override |
36157
fdbf6c9be2ab
8145472: replace remaining java.io.File with java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
125 |
public void addFile(Path p) { |
fdbf6c9be2ab
8145472: replace remaining java.io.File with java.nio.file.Path
jjg
parents:
25874
diff
changeset
|
126 |
throw new IllegalArgumentException(p.toString()); |
11315 | 127 |
} |
128 |
||
129 |
@Override |
|
130 |
public void addClassName(String s) { |
|
131 |
throw new IllegalArgumentException(s); |
|
132 |
} |
|
133 |
} |
|
134 |
||
135 |
} |