Enabling Migration Warnings - scala

I am porting a 2.7.7 scala code base over to 2.8 and was wondering if there was a compiler option to display migration notices? I was bitten by a change in behavior for mutable sequences that had the following migration notice[1], however it doesn't display anything when I build the project ( I have deprecation and unchecked warnings enabled already)
1: #migration(2, 8,
"As of 2.8, this operation creates a new map. To add an element as a\n"+
"side effect to an existing map and return that map itself, use +=."
)

The option is: -Xmigration
Entering scalac -help will show the standard options of the Scala compiler.
Entering scalac -X will show the advanced options.
Entering scalac -Y will show the private options.

It's a extended option, -Xmigration.
~: scala -X
Usage: scala <options> <source files>
Possible advanced options include:
-Xassem-extdirs <dirs> List of directories containing assemblies, defaults to `lib'
-Xassem-name <file> Name of the output assembly (only relevant with -target:msil)
-Xassem-path <path> List of assemblies referenced by the program (only relevant with -target:msil)
-Xcheck-null Emit warning on selection of nullable reference
-Xcheckinit Add runtime checks on field accessors. Uninitialized accesses result in an exception being thrown.
-Xdisable-assertions Generate no assertions and assumptions
-Xelide-below Generate calls to #elidable-marked methods only if method priority is greater than argument.
-Xexperimental Enable experimental extensions
-Xfatal-warnings Fail the compilation if there are any warnings.
-Xfuture Turn on future language features
-Xgenerate-phase-graph <file> Generate the phase graphs (outputs .dot files) to fileX.dot
-Xlog-implicits Show more info on why some implicits are not applicable
-Xmigration Warn about constructs whose behavior may have changed between 2.7 and 2.8
-Xno-forwarders Do not generate static forwarders in mirror classes
-Xno-uescape Disables handling of \u unicode escapes
-Xnojline Do not use JLine for editing
-Xplugin-disable:<plugin> Disable a plugin
-Xplugin-list Print a synopsis of loaded plugins
-Xplugin-require:<plugin> Abort unless a plugin is available
-Xplugin:<file> Load a plugin from a file
-Xpluginsdir <path> Path to search compiler plugins
-Xprint-icode Log internal icode to *.icode files
-Xprint-pos Print tree positions (as offsets)
-Xprint-types Print tree types (debugging option)
-Xprint:<phase> Print out program after <phase> or "all"
-Xprompt Display a prompt after each error (debugging option)
-Xresident Compiler stays resident, files to compile are read from standard input
-Xscript <object> Compile as a script, wrapping the code into object.main()
-Xshow-class <class> Show class info
-Xshow-object <object> Show object info
-Xshow-phases Print a synopsis of compiler phases
-Xsource-reader <classname> Specify a custom method for reading source files
-Xsourcedir <directory> When -target:msil, the source folder structure is mirrored in output directory.
-Xwarninit Warn about possible changes in initialization semantics
-Y Print a synopsis of private options

% scala -X
Usage: scala <options> <source files>
Possible advanced options include:
...
-Xmigration Warn about constructs whose behavior may have changed between 2.7 and 2.8
...

Related

Does macroparadise no longer work from the command line?

I am trying to start using the paradise macro plugin, so I have been beginning with the identity macro example from:
https://docs.scala-lang.org/overviews/macros/annotations.html
However, when I try to use the identity annotation I get
error: enable macro paradise to expand macro annotations
As you would expect if the plugin isn't loaded. However, I am following the instructions from
https://docs.scala-lang.org/overviews/macros/paradise.html
But when I invoke:
scalac -Xplugin:paradise_2.12.8-2.1.1.jar -Xshow-phases
I do not see the macroparadise phase:
phase name id description
---------- -- -----------
parser 1 parse source into ASTs, perform simple desugaring
namer 2 resolve names, attach symbols to named trees
packageobjects 3 load package objects
typer 4 the meat and potatoes: type the trees
patmat 5 translate match expressions
...
However, if I instead do
scalac -Xplugin:paradise_2.12.8-2.1.1.jar -Xplugin-list
I get
macroparadise - Empowers production Scala compiler with latest macro developments
So I really confused as to what step I'm missing here? Is there some new command-line argument I'm missing? Is using sbt required?

Automatic Generation of orm.xml file in netbeans

Is there a way i can automatically generate orm.xml file in Netbeans even if i can modify it later. Am using eclipselink JPA 2.1 and it keeps giving me this warning when am building
warning: Supported source version 'RELEASE_6' from annotation processor 'org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor' less than -source '1.7'
Note: Creating non-static metadata factory ...
Note: Found Option : eclipselink.canonicalmodel.use_static_factory, with value: false
Note: Optional file was not found: META-INF/orm.xml continuing with generation.
Note: Optional file was not found: META-INF/eclipselink-orm.xml continuing with generation.
Note: Found Option : eclipselink.canonicalmodel.use_static_factory, with value: false
Note: Optional file was not found: META-INF/orm.xml continuing with generation.
Note: Optional file was not found: META-INF/eclipselink-orm.xml continuing with generation.
warning: The following options were not recognized by any processor: '[eclipselink.canonicalmodel.use_static_factory]'
Note: C:\Users\USER\Documents\NetBeansProjects\payroll\src\dcl\payroll\GUI\Login.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 warning
The warning is just there to let you know that if you are using an orm.xml to define your mappings, it wasn't found. If you place one there, you will still get messages letting you know one was found. This gives a notice in the log to help point where to start looking if something unexpected in your application occurs - such as the wrong orm.xml version is used or one is unexpectedly packaged and picked up, which seems a common issue in development.

Where is the man page for scaladoc?

Looking at http://www.scala-sbt.org/release/docs/Howto/scaladoc.html there are examples for giving scaladoc options such -groups and -implicits.
Where is the information regarding the scaladoc (2.10) options? Like a man page. I can't seem to find it, neither of docs.scala-lang.org, nor on wiki.scala-lang.org...
I don't use a Scala installation besides managed by sbt, so I really would like an online resource.
scaladoc -help gives:
Usage: scaladoc <options> <source files>
where possible scaladoc options include:
-diagrams Create inheritance diagrams for classes, traits and packages.
-diagrams-dot-path <path> The path to the dot executable used to generate the inheritance diagrams. Eg: /usr/bin/dot
-diagrams-dot-restart <n> The number of times to restart a malfunctioning dot process before disabling diagrams (default: 5)
-diagrams-dot-timeout <n> The timeout before the graphviz dot util is forcefully closed, in seconds (default: 10)
-diagrams-max-classes <n> The maximum number of superclasses or subclasses to show in a diagram
-diagrams-max-implicits <n> The maximum number of implicitly converted classes to show in a diagram
-doc-footer <footer> A footer on every ScalaDoc page, by default the EPFL/Typesafe copyright notice. Can be overridden with a custom footer.
-doc-format:<format> Selects in which format documentation is rendered (html) default:html
-doc-generator <class-name> The fully qualified name of a doclet class, which will be used to generate the documentation
-doc-no-compile <path> A directory containing sources which should be parsed, no more (e.g. AnyRef.scala)
-doc-root-content <path> The file from which the root package documentation should be imported.
-doc-source-url <url> A URL pattern used to build links to template sources; use variables, for example: ?{TPL_NAME} ('Seq'), ?{TPL_OWNER} ('scala.collection'), ?{FILE_PATH} ('scala/collection/Seq')
-doc-title <title> The overall name of the Scaladoc site
-doc-version <version> An optional version number, to be appended to the title
-expand-all-types Expand all type aliases and abstract types into full template pages. (locally this can be done with the #template annotation)
-groups Group similar functions together (based on the #group annotation)
-implicits Document members inherited by implicit conversions.
-implicits-hide:<implicit(s)> Hide the members inherited by the given comma separated, fully qualified implicit conversions. Add dot (.) to include default conversions.
-implicits-show-all Show members inherited by implicit conversions that are impossible in the default scope. (for example conversions that require Numeric[String] to be in scope)
-no-link-warnings Avoid warnings for ambiguous and incorrect links.
-no-prefixes Prevents generating prefixes in types, possibly creating ambiguous references, but significantly speeding up scaladoc.
-raw-output For each html file, create another .html.raw file containing only the text. (can be used for quickly diffing two scaladoc outputs)
-skip-packages <<package1>:...:<packageN>> A colon-delimited list of fully qualified package names that will be skipped from scaladoc.
Additional debug settings:
-diagrams-debug Show debugging information for the diagram creation process.
-implicits-debug Show debugging information for members inherited by implicit conversions.
Standard scalac options also available:
-Dproperty=value Pass -Dproperty=value directly to the runtime system.
-J<flag> Pass <flag> directly to the runtime system.
-P:<plugin>:<opt> Pass an option to a plugin
-X Print a synopsis of advanced options.
-bootclasspath <path> Override location of bootstrap class files.
-classpath <path> Specify where to find user class files.
-d <directory|jar> destination for generated classfiles.
-dependencyfile <file> Set dependency tracking file.
-deprecation Emit warning and location for usages of deprecated APIs.
-doc-external-doc:<external-doc> comma-separated list of classpath_entry_path#doc_URL pairs describing external dependencies.
-encoding <encoding> Specify character encoding used by source files.
-explaintypes Explain type errors in more detail.
-extdirs <path> Override location of installed extensions.
-external-urls:<externalUrl(s)> (deprecated) comma-separated list of package_names=doc_URL for external dependencies, where package names are ':'-separated
-feature Emit warning and location for usages of features that should be imported explicitly.
-g:<level> Set level of generated debugging info. (none,source,line,vars,notailcalls) default:vars
-help Print a synopsis of standard options
-implicits-sound-shadowing Use a sound implicit shadowing calculation. Note: this interacts badly with usecases, so only use it if you haven't defined usecase for implicitly inherited members.
-javabootclasspath <path> Override java boot classpath.
-javaextdirs <path> Override java extdirs classpath.
-language:<feature> Enable one or more language features.
-no-specialization Ignore #specialize annotations.
-nobootcp Do not use the boot classpath for the scala jars.
-nowarn Generate no warnings.
-optimise Generates faster bytecode by applying optimisations to the program
-print Print program with Scala-specific features removed.
-sourcepath <path> Specify location(s) of source files.
-target:<target> Target platform for object files. All JVM 1.5 targets are deprecated. (jvm-1.5,jvm-1.5-fjbg,jvm-1.5-asm,jvm-1.6,jvm-1.7,msil) default:jvm-1.6
-toolcp <path> Add to the runner classpath.
-unchecked Enable additional warnings where generated code depends on assumptions.
-uniqid Uniquely tag all identifiers in debugging output.
-usejavacp Utilize the java.class.path in classpath resolution.
-verbose Output messages about what the compiler is doing.
-version Print product version and exit.
#<file> A text file containing compiler arguments (options and source files)
Deprecated settings:
-make:<policy> Recompilation detection policy (all,changed,immediate,transitive,transitivenocp) default:all
deprecated: this option is unmaintained. Use sbt or an IDE for selective recompilation.
Beside from that I don't know of any other information sites. The only thing available for sure is the source code that contains all settings.

Command line compiler for XTend

Hi allI've found XTend (http://xtend-lang.org) and it really sounds great! But, I can't see any standalone command line compiler for this language. It seems only to run under eclipse. I've done some research, and found some people saying, that it has a command line compiler, but I can't find a download link.
Does the compiler exist, standalone, or do you need eclipse to use it?
Regards
It is not documented, but there is indeed a command line compiler in the Xtend code base - the same one used by the Maven plug-in (that is documented in the Xtend homepage).
If Maven plug-in does not work for you, then you could download the standalone jar version directly from the Maven repository at http://build.eclipse.org/common/xtend/maven/org/eclipse/xtend/org.eclipse.xtend.standalone/2.3.1/ (for version 2.3.1), and execute the org.eclipse.xtend.core.compiler.batch.Main class from it.
This class executes the xtend compiler, and usage information can be displayed (also readable from the source file).
You can use the xtend standalone compiler. For my case I copied the following .jar files to a folder named xtendc:
com.google.guava_21.0.0.v20170206-1425.jar
com.google.inject_3.0.0.v201312141243.jar
javax.inject_1.0.0.v20091030.jar
org.antlr.runtime_3.2.0.v201101311130.jar
org.apache.log4j_1.2.15.v201012070815.jar
org.eclipse.emf.common_2.15.0.v20180914-1817.jar
org.eclipse.emf.ecore.xmi_2.15.0.v20180706-1146.jar
org.eclipse.emf.ecore_2.16.0.v20181124-0637.jar
org.eclipse.equinox.common_3.10.200.v20181021-1645.jar
org.eclipse.jdt.core_3.16.0.v20181130-1748.jar
org.eclipse.xtend.core_2.16.0.v20181203-1347.jar
org.eclipse.xtend.lib.macro_2.16.0.v20181203-0507.jar
org.eclipse.xtext.common.types_2.16.0.v20181203-0528.jar
org.eclipse.xtext.util_2.16.0.v20181203-0514.jar
org.eclipse.xtext.xbase.lib_2.16.0.v20181203-0507.jar
org.eclipse.xtext.xbase_2.16.0.v20181203-0528.jar
org.eclipse.xtext_2.16.0.v20181203-0514.jar
org.objectweb.asm_7.0.0.v20181030-2244.jar
And then, in that folder I executed the CLI main class of the batch compiler:
java -cp "*" org.eclipse.xtend.core.compiler.batch.Main -d <path-to-xtend-gen-folder> -useCurrentClassLoader <path-to-src-folder>
CLI usage of main class is documented to be as following:
Usage: Main <options> <source directories>
where possible options include:
-d <directory> Specify where to place generated xtend files
-tp <path> Temp directory to hold generated stubs and classes
-cp <path> Specify where to find user class files
-encoding <encoding> Specify character encoding used by source files
-javaSourceVersion <version> Create Java Source compatible to this version. Can be: 1.5, 1.6, 1.7, 1.8, 9, 10
-noSuppressWarningsAnnotation Don't put #SuppressWarnings() into generated Java Code
-generateGeneratedAnnotation Put #Generated into generated Java Code
-includeDateInGeneratedAnnnotation If -generateGeneratedAnnotation is used, add the current date/time.
-generateAnnotationComment <string> If -generateGeneratedAnnotation is used, add a comment.
-useCurrentClassLoader Use current classloader as parent classloader
-writeTraceFiles Write Trace-Files
so you will need to pass your classpath there.

Scalac doesn't find dependent classes

I'm trying to compile the program with 2 simplest classes:
class BaseClass
placed in BaseClass.scala and
class Test extends BaseClass
placed in Test.scala. Issuing command scalac Test.scala fails, cause BaseClass is not found.
I don't want to compile classes one by one or using scalac *.scala.
The same operation in java works: javac Test.java. Where am I wrong?
Let's see first what Java does:
dcs#dcs-132-CK-NF79:~/tmp$ ls *.java
BaseClass.java Test.java
dcs#dcs-132-CK-NF79:~/tmp$ ls *.class
ls: cannot access *.class: No such file or directory
dcs#dcs-132-CK-NF79:~/tmp$ javac -cp . Test.java
dcs#dcs-132-CK-NF79:~/tmp$ ls *.class
BaseClass.class Test.class
So, as you can see, Java actually compiles BaseClass automatically when you do that. Which begs the question: how can it do that? Can does it know what file to compile?
Well, when you write extends BaseClass in Java, you actually know a few things. You know the directory where these files are found, from the package name. It also knows BaseClass is either in the current file, or in a file called BaseClass.java. If you doubt either of these facts, try moving the file from directory or renaming it, and see if Java can compile it.
So, why can't Scala do the same? Because it assumes neither thing! Scala's files can be in any directory, irrespective of the package they declare. In fact, a single Scala file can even declare more than one package, which would make the directory rule impossible. Also, a Scala class can be in any file whatsoever, irrespective of its name.
So, while Java dictates to you what directory the file should be in and what the file is called, and then reaps the benefit by letting you omit filenames from the command line of javac, Scala let you organize your code in whatever way seems best to you, but requires you to tell it where that code is.
Take your pick.
You need to compile BaseClass.scala first:
$ scalac Test.scala
Test.scala:1: error: not found: type BaseClass
class Test extends BaseClass
^
one error found
$ scalac BaseClass.scala
$ scalac Test.scala
$
EDIT So, the question is now why you have to compile the files one by one? Well, because the Scala compiler just doesn't do this kind of dependency handling. Its authors probably expect you to use a build tool like sbt or Maven so that they don't have to bother.