1scalac(1)                        USER COMMANDS                       scalac(1)
2
3
4

NAME

6       scalac - Compiler for the Scala 2 language
7

SYNOPSIS

9       scalac  [ <options> ] <source files>
10

PARAMETERS

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

DESCRIPTION

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

OPTIONS

28       The  compiler  has  a set of standard options that are supported on the
29       current  development  environment  and  will  be  supported  in  future
30       releases. 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 interpreter
75              will 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
167              access.
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       -Xexperimental
179              Enable experimental extensions
180
181       -Xfatal-warnings
182              Fail the compilation if there are any warnings.
183
184       -Xfull-lubs
185              Retain  pre 2.10 behavior of less aggressive truncation of least
186              upper bounds.
187
188       -Xfuture
189              Turn on future language features.
190
191       -Xgenerate-phase-graph <file>
192              Generate the phase graphs (outputs .dot files) to fileX.dot.
193
194       -Xlint Enable recommended additional warnings.
195
196       -Xlog-free-terms
197              Print a message when reification creates a free term.
198
199       -Xlog-free-types
200              Print a message when reification resorts to  generating  a  free
201              type.
202
203       -Xlog-implicit-conversions
204              Print a message whenever an implicit conversion is inserted.
205
206       -Xlog-implicits
207              Show more detail on why some implicits are not applicable.
208
209       -Xlog-reflective-calls
210              Print a message when a reflective method call is generated.
211
212       -Xmacro-settings:<option>
213              Custom settings for macros.
214
215       -Xmain-class <path>
216              Class  for  manifest's  Main-Class  entry  (only  useful with -d
217              <jar>).
218
219       -Xmax-classfile-name <n>
220              Maximum filename length for generated classes.
221
222       -Xmigration:<version>
223              Warn about constructs whose behavior may have changed since<ver‐
224              sion>.
225
226       -Xno-forwarders
227              Do not generate static forwarders in mirror classes.
228
229       -Xno-patmat-analysis
230              Don't perform exhaustivity/unreachability analysis. Also, ignore
231              @switch annotation.
232
233       -Xno-uescape
234              Disable handling of \u unicode escapes
235
236       -Xnojline
237              Do not use JLine for editing.
238
239       -Xplugin:<paths>
240              Load a plugin from each classpath.
241
242       -Xplugin-disable:<plugin>
243              Disable plugins by name.
244
245       -Xplugin-list
246              Print a synopsis of loaded plugins.
247
248       -Xplugin-require:<plugin>
249              Abort if a named plugin is not loaded.
250
251       -Xpluginsdir <path>
252              Path to search for plugin archives.
253
254       -Xprint:<phases>
255              Print out program after <phases> (see below).
256
257       -Xprint-icode[:<phases>]
258              Log internal icode  to  *.icode  files  after<phases>  (default:
259              icode).
260
261       -Xprint-pos
262              Print tree positions, as offsets.
263
264       -Xprint-types
265              Print tree types (debugging option).
266
267       -Xprompt
268              Display a prompt after each error (debugging option).
269
270       -Xresident
271              Compiler stays resident, files to compile are read from standard
272              input.
273
274       -Xscript <object>
275              Treat the source file as a script and wrap it in a main method.
276
277       -Xshow-class <class>
278              Show internal representation of class.
279
280       -Xshow-object <object>
281              Show internal representation of object.
282
283       -Xshow-phases
284              Print a synopsis of compiler phases.
285
286       -Xsource:<version>
287              Treat compiler input as Scala source for the specified  version,
288              see scala/bug#8126.
289
290       -Xsource-reader <classname>
291              Specify a custom method for reading source files.
292
293       -Xstrict-inference
294              Don't infer known-unsound types.
295
296       -Xverify
297              Verify  generic  signatures  in  generated bytecode (asm backend
298              only).
299
300       -Xxml:{coalescing}
301              Configure XML parsing.
302
303              "coalescing" convert PCData to Text and coalesce  sibling  nodes
304              (default in 2.11).
305
306       -Y     Print a synopsis of private options.
307
308   Compilation Phases
309       parser parse source into ASTs, perform simple desugaring
310
311       namer  resolve names, attach symbols to named trees
312
313       packageobjects
314              load package objects
315
316       typer  the meat and potatoes: type the trees
317
318       patmat translate match expressions
319
320       superaccessors
321              add super accessors in traits and nested classes
322
323       extmethods
324              add extension methods for inline classes
325
326       pickler
327              serialize symbol tables
328
329       refchecks
330              reference/override checking, translate nested objects
331
332       selectiveanf
333              ANF pre-transform for @cps (CPS plugin)
334
335       selectivecps
336              @cps-driven transform of selectiveanf assignments (CPS plugin)
337
338       uncurry
339              uncurry, translate function values to anonymous classes
340
341       tailcalls
342              replace tail calls by jumps
343
344       specialize
345              @specialized-driven class and method specialization
346
347       explicitouter
348              this refs to outer pointers, translate patterns
349
350       erasure
351              erase types, add interfaces for traits
352
353       posterasure
354              clean up erased inline classes
355
356       fields synthesize accessors and fields, including bitmaps for lazy vals
357
358       lambdalift
359              move nested functions to top level
360
361       constructors
362              move field definitions into constructors
363
364       flatten
365              eliminate inner classes
366
367       mixin  mixin composition
368
369       cleanup
370              platform-specific cleanups, generate reflective calls
371
372       delambdafy
373              remove lambdas
374
375       icode  generate portable intermediate code
376
377       inliner
378              optimization: do inlining
379
380       inlineHandlers
381              optimization: inline exception handlers
382
383       closelim
384              optimization: eliminate uncalled closures
385
386       constopt
387              optimization: optimize null and other constants
388
389       dce    optimization: eliminate dead code
390
391       jvm    generate JVM bytecode
392
393       terminal
394              the last phase in the compiler chain
395
396       all    matches all phases
397

ENVIRONMENT

399       JAVACMD
400              Specify  the java command to be used for running the Scala code.
401              Arguments may be specified as part of the environment  variable;
402              spaces,  quotation  marks,  etc., will be passed directly to the
403              shell for expansion.
404
405       JAVA_HOME
406              Specify JDK/JRE home directory. This directory is used to locate
407              the java command unless JAVACMD variable set.
408
409       JAVA_OPTS
410              Specify  the options to be passed to the java command defined by
411              JAVACMD.
412
413              With Java 1.5 (or newer) one may for example configure the  mem‐
414              ory  usage  of  the  JVM as follows: JAVA_OPTS="-Xmx512M -Xms16M
415              -Xss16M"
416

EXAMPLES

418       Compile a Scala program to the current directory
419              scalac HelloWorld
420
421       Compile a Scala program to the destination directory classes
422              scalac -d classes HelloWorld.scala
423
424       Compile a Scala program using a user-defined java command
425              env  JAVACMD=/usr/local/bin/cacao   scalac   -d   classes   Hel‐
426              loWorld.scala
427
428       Compile all Scala files found in the source directory src to the desti‐
429       nation directory classes
430              scalac -d classes src/*.scala
431

EXIT STATUS

433       scalac returns a zero exit status if it succeeds to compile the  speci‐
434       fied input files. Non zero is returned in case of failure.
435

AUTHOR

437       Written by Martin Odersky and other members of the Scala team.
438

REPORTING BUGS

440       Report bugs to https://github.com/scala/bug/issues.
441
443       This is open-source software, available to you under the Apache License
444       2.0. See accompanying "copyright" or "LICENSE" file for copying  condi‐
445       tions.  There  is  NO warranty; not even for MERCHANTABILITY or FITNESS
446       FOR A PARTICULAR PURPOSE.
447

SEE ALSO

449       fsc(1), scala(1), scaladoc(1), scalap(1)
450
451
452
453version 1.0                       March 2012                         scalac(1)
Impressum