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

Type parametrization Interop with Java class

2 replies
mvackel
Joined: 2009-08-03,
User offline. Last seen 1 year 39 weeks ago.

Hello,

I'm trying to extend a Java class with a Scala class, but receiving an
error. Would you help, please??

I have the following Java class:

public abstract XIter
{
private Map;

public XIter(Graph g, V start)
{
}
}

I'm trying to extend the class in Scala with:

class ScalaIter[V,E] (g: graph[V, E], start: V)
extends XIter[V, E, Any]
{

}

I'm receiving the followin compiler error:

"not enough arguments for constructor XIter: (x$1: Graph[V,E],x$2:
V)XIter[V,E,Any]"
"Unspecified value parameters x$1, x$2."

If I change the XIter class to something like

public abstract XIter

with 2 arguments instead of 3, the Scala class compiles.

Any clue?

Thanks in advance,

Marcos

odersky
Joined: 2008-07-29,
User offline. Last seen 45 weeks 6 days ago.
Re: Type parametrization Interop with Java class


On Thu, Mar 24, 2011 at 5:25 PM, Marcos Ackel <mvackel@yahoo.com> wrote:
Hello,

I'm trying to extend a Java class with a Scala class, but receiving an
error. Would you help, please??


I have the following Java class:

public abstract XIter<V, E, D>
{
       private Map<V, D>;

       public XIter(Graph<V,E> g, V start)
       {
       }
}


I'm trying to extend the class in Scala with:

class ScalaIter[V,E] (g: graph[V, E], start: V)
         extends XIter[V, E, Any]
{

}

I'm receiving the followin compiler error:

"not enough arguments for constructor XIter: (x$1: Graph[V,E],x$2:
V)XIter[V,E,Any]"
"Unspecified value parameters x$1, x$2."

If I change the XIter class to something like

public abstract XIter<V,E>

with 2 arguments instead of 3, the Scala class compiles.

Any clue?

Thanks in advance,

Marcos

You need to pass the arguments to the superclass constructor:
 
class ScalaIter[V,E] (g: graph[V, E], start: V)
         extends XIter[V, E, Any]  (g, start)

Hope this helps.

Btw, that question is better asked on scala-user, or StackOverflow.

 -- Martin

mvackel
Joined: 2009-08-03,
User offline. Last seen 1 year 39 weeks ago.
Re: Type parametrization Interop with Java class

Thank you! Worked fine. Sorry for posting in the wrong forum.

On Mar 24, 1:29 pm, martin odersky wrote:
> > You need to pass the arguments to the superclass constructor:
>
> class ScalaIter[V,E] (g: graph[V, E], start: V)
>          extends XIter[V, E, Any]  (g, start)
>
> Hope this helps.
>
> Btw, that question is better asked on scala-user, or StackOverflow.
>
>  -- Martin

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