1scalac(1) USER COMMANDS scalac(1)
2
3
4
6 scalac - Compiler for the Scala 2 language
7
9 scalac [ <options> ] <source files>
10
12 <options>
13 Command line options. See OPTIONS below.
14
15 <source files>
16 One or more source files to be compiled (such as MyClass.scala).
17
19 The scalac tool reads class and object definitions, written in the
20 Scala programming language, and compiles them into bytecode class
21 files.
22
23 By default, the compiler puts each class file in the same directory as
24 its source file. You can specify a separate destination directory with
25 -d (see OPTIONS, below).
26
28 The compiler has a set of standard options that are supported on the
29 current development environment and will be supported in future re‐
30 leases. An additional set of non-standard options are specific to the
31 current virtual machine implementation and are subject to change in the
32 future. Non-standard options begin with -X.
33
34 Standard Options
35 -Dproperty=value
36 Pass -Dproperty=value directly to the runtime system.
37
38 -J<flag>
39 Pass <flag> directly to the runtime system.
40
41 -P:<plugin:opt>
42 Pass an option to a plugin
43
44 -X Print a synopsis of advanced options.
45
46 -bootclasspath <path>
47 Override location of bootstrap class files (where to find the
48 standard built-in classes, such as "scala.List").
49
50 -classpath <path>
51 Specify where to find user class files (on Unix-based systems a
52 colon-separated list of paths, on Windows-based systems, a semi‐
53 colon-separated list of paths). This does not override the
54 built-in ("boot") search path.
55
56 The default class path is the current directory. Setting the
57 CLASSPATH variable or using the -classpath command-line option
58 overrides that default, so if you want to include the current
59 directory in the search path, you must include "." in the new
60 settings.
61
62 -d <directory|jar>
63 Specify where to place generated class files.
64
65 -deprecation
66 Emit warning and location for usages of deprecated APIs.
67
68 Available since Scala version 2.2.1
69
70 -encoding <encoding>
71 Specify character encoding used by source files.
72
73 The default value is platform-specific (Linux: "UTF8", Windows:
74 "Cp1252"). Executing the following code in the Scala REPL will
75 return the default value on your system:
76
77 scala> new java.io.InputStreamReader(System.in).getEncoding
78
79 -explaintypes
80 Explain type errors in more detail.
81
82 -extdirs <dirs>
83 Override location of installed extensions.
84
85 -feature
86 Emit warning and location for usages of features that should be
87 imported explicitly.
88
89 -g:{none,source,line,vars,notailcalls}
90 "none" generates no debugging info,
91
92 "source" generates only the source file attribute,
93
94 "line" generates source and line number information,
95
96 "vars" generates source, line number and local variable informa‐
97 tion,
98
99 "notailcalls" generates all of the above and will not perform
100 tail call optimization.
101
102 -help Print a synopsis of standard options.
103
104 -javabootclasspath <path>
105 Override Java boot classpath.
106
107 -javaextdirs <path>
108 Override Java extdirs classpath.
109
110 -language:<feature>
111 Enable one or more language features.
112
113 -no-specialization
114 Ignore @specialize annotations.
115
116 -nobootcp
117 Do not use the boot classpath for the Scala jar files.
118
119 -nowarn
120 Generate no warnings
121
122 -optimise
123 Generates faster bytecode by applying optimisations to the pro‐
124 gram.
125
126 -print Print program with all Scala-specific features removed.
127
128 -sourcepath <path>
129 Specify location(s) of source files.
130
131 -target:{jvm-1.8}
132 "jvm-1.8" target JVM 1.8 (default)
133
134 -toolcp <path>
135 Add to the runner classpath.
136
137 -unchecked
138 Enable detailed unchecked (erasure) warnings
139
140 Non variable type-arguments in type patterns are unchecked since
141 they are eliminated by erasure
142
143 Available since Scala version 2.3.0
144
145 -uniqid
146 Uniquely tag all identifiers in debugging output.
147
148 -usejavacp
149 Utilize the java.class.path in classpath resolution.
150
151 -usemanifestcp
152 Utilize the manifest in classpath resolution.
153
154 -verbose
155 Output messages about what the compiler is doing
156
157 -version
158 Print product version and exit.
159
160 @<file>
161 A text file containing compiler arguments (options and source
162 files)
163
164 Advanced Options
165 -Xcheckinit
166 Wrap field accessors to throw an exception on uninitialized ac‐
167 cess.
168
169 -Xdev Enable warnings for developers working on the Scala compiler
170
171 -Xdisable-assertions
172 Generate no assertions and assumptions
173
174 -Xelide-below <n>
175 Calls to @elidable methods are omitted if method priority is
176 lower than argument.
177
178 -Xfatal-warnings
179 Fail the compilation if there are any warnings.
180
181 -Xfull-lubs
182 Retain pre 2.10 behavior of less aggressive truncation of least
183 upper bounds.
184
185 -Xgenerate-phase-graph <file>
186 Generate the phase graphs (outputs .dot files) to fileX.dot.
187
188 -Xlint Enable recommended additional warnings.
189
190 -Xlog-free-terms
191 Print a message when reification creates a free term.
192
193 -Xlog-free-types
194 Print a message when reification resorts to generating a free
195 type.
196
197 -Xlog-implicit-conversions
198 Print a message whenever an implicit conversion is inserted.
199
200 -Xlog-reflective-calls
201 Print a message when a reflective method call is generated.
202
203 -Xmacro-settings:<option>
204 Custom settings for macros.
205
206 -Xmain-class <path>
207 Class for manifest's Main-Class entry (only useful with -d
208 <jar>).
209
210 -Xmigration:<version>
211 Warn about constructs whose behavior may have changed since<ver‐
212 sion>.
213
214 -Xno-forwarders
215 Do not generate static forwarders in mirror classes.
216
217 -Xno-patmat-analysis
218 Don't perform exhaustivity/unreachability analysis. Also, ignore
219 @switch annotation.
220
221 -Xjline
222 The JLine keybindings to use: emacs/vi/off.
223
224 -Xplugin:<paths>
225 Load a plugin from each classpath.
226
227 -Xplugin-disable:<plugin>
228 Disable plugins by name.
229
230 -Xplugin-list
231 Print a synopsis of loaded plugins.
232
233 -Xplugin-require:<plugin>
234 Abort if a named plugin is not loaded.
235
236 -Xpluginsdir <path>
237 Path to search for plugin archives.
238
239 -Vprint:<phases>
240 Print out program after <phases> (see below).
241
242 -Vprint-pos
243 Print tree positions, as offsets.
244
245 -Vprint-types
246 Print tree types (debugging option).
247
248 -Xprompt
249 Display a prompt after each error (debugging option).
250
251 -Xresident
252 Compiler stays resident, files to compile are read from standard
253 input.
254
255 -Xscript <object>
256 Treat the source file as a script and wrap it in a main method.
257
258 -Xshow-class <class>
259 Show internal representation of class.
260
261 -Xshow-object <object>
262 Show internal representation of object.
263
264 -Xshow-phases
265 Print a synopsis of compiler phases.
266
267 -Xsource:<version>
268 Treat compiler input as Scala source for the specified version,
269 see scala/bug#8126.
270
271 -Xsource-reader <classname>
272 Specify a custom method for reading source files.
273
274 -Xstrict-inference
275 Don't infer known-unsound types.
276
277 -Xverify
278 Verify generic signatures in generated bytecode (asm backend
279 only).
280
281 -Xxml:{coalescing}
282 Configure XML parsing.
283
284 "coalescing" convert PCData to Text and coalesce sibling nodes
285 (default in 2.11).
286
287 -Y Print a synopsis of private options.
288
289 Compilation Phases
290 parser parse source into ASTs, perform simple desugaring
291
292 namer resolve names, attach symbols to named trees
293
294 packageobjects
295 load package objects
296
297 typer the meat and potatoes: type the trees
298
299 patmat translate match expressions
300
301 superaccessors
302 add super accessors in traits and nested classes
303
304 extmethods
305 add extension methods for inline classes
306
307 pickler
308 serialize symbol tables
309
310 refchecks
311 reference/override checking, translate nested objects
312
313 selectiveanf
314 ANF pre-transform for @cps (CPS plugin)
315
316 selectivecps
317 @cps-driven transform of selectiveanf assignments (CPS plugin)
318
319 uncurry
320 uncurry, translate function values to anonymous classes
321
322 tailcalls
323 replace tail calls by jumps
324
325 specialize
326 @specialized-driven class and method specialization
327
328 explicitouter
329 this refs to outer pointers, translate patterns
330
331 erasure
332 erase types, add interfaces for traits
333
334 posterasure
335 clean up erased inline classes
336
337 fields synthesize accessors and fields, including bitmaps for lazy vals
338
339 lambdalift
340 move nested functions to top level
341
342 constructors
343 move field definitions into constructors
344
345 flatten
346 eliminate inner classes
347
348 mixin mixin composition
349
350 cleanup
351 platform-specific cleanups, generate reflective calls
352
353 delambdafy
354 remove lambdas
355
356 inliner
357 optimization: do inlining
358
359 inlineHandlers
360 optimization: inline exception handlers
361
362 closelim
363 optimization: eliminate uncalled closures
364
365 constopt
366 optimization: optimize null and other constants
367
368 dce optimization: eliminate dead code
369
370 jvm generate JVM bytecode
371
372 terminal
373 the last phase in the compiler chain
374
375 all matches all phases
376
378 JAVACMD
379 Specify the java command to be used for running the Scala code.
380 Arguments may be specified as part of the environment variable;
381 spaces, quotation marks, etc., will be passed directly to the
382 shell for expansion.
383
384 JAVA_HOME
385 Specify JDK/JRE home directory. This directory is used to locate
386 the java command unless JAVACMD variable set.
387
388 JAVA_OPTS
389 Specify the options to be passed to the java command defined by
390 JAVACMD.
391
392 One might for example configure the memory usage of the JVM
393 with: JAVA_OPTS="-Xmx2G -Xss16M"
394
396 Compile a Scala program to the current directory
397 scalac HelloWorld
398
399 Compile a Scala program to the destination directory classes
400 scalac -d classes HelloWorld.scala
401
402 Compile a Scala program using a user-defined java command
403 env JAVACMD=/usr/local/bin/cacao scalac -d classes Hel‐
404 loWorld.scala
405
406 Compile all Scala files found in the source directory src to the desti‐
407 nation directory classes
408 scalac -d classes src/*.scala
409
411 scalac returns a zero exit status if it succeeds to compile the speci‐
412 fied input files. Non zero is returned in case of failure.
413
415 Written by Martin Odersky and other members of the Scala team.
416
418 Report bugs to https://github.com/scala/bug/issues.
419
421 This is open-source software, available to you under the Apache License
422 2.0. See accompanying "copyright" or "LICENSE" file for copying condi‐
423 tions. There is NO warranty; not even for MERCHANTABILITY or FITNESS
424 FOR A PARTICULAR PURPOSE.
425
427 fsc(1), scala(1), scaladoc(1), scalap(1)
428
429
430
431version 1.0 March 2012 scalac(1)