This page is no longer maintained — Please continue to the home page at www.scala-lang.org

annotation on constructor args disappearing since 2.8.0-RC1

2 replies
Ido M. Tamir
Joined: 2010-05-03,
User offline. Last seen 42 years 45 weeks ago.

Hi,
I use args4j to process command args and the following stopped working after
2.8.0.RC1. It does not work with 2.8.0-20100607.005311-405.jar.

I also saw this on track, but dont understand why this is invalid
http://lampsvn.epfl.ch/trac/scala/ticket/3473
http://scala-programming-language.1934581.n4.nabble.com/Constructor-para...

in 2.8.0.RC1 i got test as output,
after that I get an exception thrown:
Error parsing options org.kohsuke.args4j.CmdLineException: "--test" is not a
valid option

thank you very much,
ido

example:

package command

import org.kohsuke.args4j.Option
import org.kohsuke.args4j.CmdLineParser
import org.kohsuke.args4j.CmdLineException

class Command(@Option(name="--test",usage="test",required=true)var test:
String = "" ){
println("test " + test)
}

object doCommand {
def main(args: Array[String]): Unit = {
val parser = new CmdLineParser(new Command())
try{
import scala.collection.JavaConversions._
parser.parseArgument("--test"::"cmd"::Nil)
}catch{
case e: CmdLineException => System.err.println("Error parsing options " +
e)
}
}
}

Maxime Lévesque
Joined: 2009-08-18,
User offline. Last seen 42 years 45 weeks ago.
Re: annotation on constructor args disappearing since 2.8.0-RC

There has been some changes in how annotations work, it's
a usefull improvement, you'll have to port your code, the
good news is that it's pretty easy, see :

 http://lampsvn.epfl.ch/trac/scala/ticket/3421

 Max

On Mon, Jun 7, 2010 at 11:55 AM, Ido M. Tamir <tamir [at] imp [dot] ac [dot] at> wrote:
Hi,
I use args4j to process command args and the following stopped working after
2.8.0.RC1. It does not work with 2.8.0-20100607.005311-405.jar.

I also saw this on track, but dont understand why this is invalid
http://lampsvn.epfl.ch/trac/scala/ticket/3473
http://scala-programming-language.1934581.n4.nabble.com/Constructor-parameter-annotations-disappearing-during-compilation-td2124939.html

in 2.8.0.RC1 i got test as output,
after that I get an exception thrown:
Error parsing options org.kohsuke.args4j.CmdLineException: "--test" is not a
valid option

thank you very much,
ido

example:

package command

import org.kohsuke.args4j.Option
import org.kohsuke.args4j.CmdLineParser
import org.kohsuke.args4j.CmdLineException

class Command(@Option(name="--test",usage="test",required=true)var test:
String = "" ){
       println("test " + test)
}

object doCommand {
       def main(args: Array[String]): Unit = {
               val parser = new CmdLineParser(new Command())
               try{
                       import scala.collection.JavaConversions._
                       parser.parseArgument("--test"::"cmd"::Nil)
               }catch{
                       case e: CmdLineException => System.err.println("Error parsing options " +
e)
               }
       }
}


Jason Zaugg
Joined: 2009-05-18,
User offline. Last seen 38 weeks 5 days ago.
Re: annotation on constructor args disappearing since 2.8.0-RC

This could really do with a -Xmigration warning.

-jason

2010/6/7 Maxime Lévesque :
>
> There has been some changes in how annotations work, it's
> a usefull improvement, you'll have to port your code, the
> good news is that it's pretty easy, see :
>
>  http://lampsvn.epfl.ch/trac/scala/ticket/3421
>
>  Max

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland